use of org.eclipse.che.core.db.jpa.IntegrityConstraintViolationException in project che-server by eclipse-che.
the class JpaFreeResourcesLimitDao method doStore.
@Transactional(rollbackOn = { RuntimeException.class, ConflictException.class })
protected void doStore(FreeResourcesLimitImpl resourcesLimit) throws ConflictException {
EntityManager manager = managerProvider.get();
try {
final FreeResourcesLimitImpl existedLimit = doGet(resourcesLimit.getAccountId());
existedLimit.setResources(resourcesLimit.getResources());
manager.flush();
} catch (NoResultException n) {
try {
manager.persist(resourcesLimit);
manager.flush();
} catch (IntegrityConstraintViolationException e) {
throw new ConflictException(format("The specified account '%s' does not exist", resourcesLimit.getAccountId()));
}
}
}
use of org.eclipse.che.core.db.jpa.IntegrityConstraintViolationException in project che-server by eclipse-che.
the class JpaUserDevfileDao method create.
@Override
public UserDevfile create(UserDevfile userDevfile) throws ConflictException, ServerException {
requireNonNull(userDevfile);
try {
Account account = accountDao.getByName(userDevfile.getNamespace());
UserDevfileImpl userDevfileImpl = new UserDevfileImpl(userDevfile, account);
doCreate(userDevfileImpl);
return userDevfileImpl;
} catch (DuplicateKeyException ex) {
throw new ConflictException(format("Devfile with name '%s' already exists in the specified account '%s'", userDevfile.getName(), userDevfile.getNamespace()));
} catch (IntegrityConstraintViolationException ex) {
throw new ConflictException("Could not create devfile with creator that refers to a non-existent user");
} catch (RuntimeException ex) {
throw new ServerException(ex.getMessage(), ex);
} catch (NotFoundException e) {
throw new ConflictException(format("Not able to create devfile in requested namespace %s bacause it is not found", userDevfile.getNamespace()));
}
}
use of org.eclipse.che.core.db.jpa.IntegrityConstraintViolationException in project devspaces-images by redhat-developer.
the class JpaUserDevfileDao method create.
@Override
public UserDevfile create(UserDevfile userDevfile) throws ConflictException, ServerException {
requireNonNull(userDevfile);
try {
Account account = accountDao.getByName(userDevfile.getNamespace());
UserDevfileImpl userDevfileImpl = new UserDevfileImpl(userDevfile, account);
doCreate(userDevfileImpl);
return userDevfileImpl;
} catch (DuplicateKeyException ex) {
throw new ConflictException(format("Devfile with name '%s' already exists in the specified account '%s'", userDevfile.getName(), userDevfile.getNamespace()));
} catch (IntegrityConstraintViolationException ex) {
throw new ConflictException("Could not create devfile with creator that refers to a non-existent user");
} catch (RuntimeException ex) {
throw new ServerException(ex.getMessage(), ex);
} catch (NotFoundException e) {
throw new ConflictException(format("Not able to create devfile in requested namespace %s bacause it is not found", userDevfile.getNamespace()));
}
}
use of org.eclipse.che.core.db.jpa.IntegrityConstraintViolationException in project devspaces-images by redhat-developer.
the class JpaFreeResourcesLimitDao method doStore.
@Transactional(rollbackOn = { RuntimeException.class, ConflictException.class })
protected void doStore(FreeResourcesLimitImpl resourcesLimit) throws ConflictException {
EntityManager manager = managerProvider.get();
try {
final FreeResourcesLimitImpl existedLimit = doGet(resourcesLimit.getAccountId());
existedLimit.setResources(resourcesLimit.getResources());
manager.flush();
} catch (NoResultException n) {
try {
manager.persist(resourcesLimit);
manager.flush();
} catch (IntegrityConstraintViolationException e) {
throw new ConflictException(format("The specified account '%s' does not exist", resourcesLimit.getAccountId()));
}
}
}
Aggregations