Beispiel #1
0
 @Transactional
 protected void doUpdate(ProfileImpl profile) throws NotFoundException {
   final EntityManager manager = managerProvider.get();
   if (manager.find(ProfileImpl.class, profile.getUserId()) == null) {
     throw new NotFoundException(
         format(
             "Couldn't update profile, because profile for user with id '%s' doesn't exist",
             profile.getUserId()));
   }
   manager.merge(profile);
 }
Beispiel #2
0
 @Override
 public void create(ProfileImpl profile) throws ServerException, ConflictException {
   requireNonNull(profile, "Required non-null profile");
   try {
     doCreate(profile);
   } catch (DuplicateKeyException x) {
     throw new ConflictException(
         format("Profile for user with id '%s' already exists", profile.getUserId()));
   } catch (IntegrityConstraintViolationException x) {
     throw new ConflictException(
         format("User with id '%s' referenced by profile doesn't exist", profile.getUserId()));
   } catch (RuntimeException x) {
     throw new ServerException(x.getLocalizedMessage(), x);
   }
 }