/**
  * Get email of user by user's id.
  *
  * @param userId user's id
  * @return an email of user by user's id
  */
 private String getEmailOfUser(long userId) {
   try {
     JCUser user = userService.get(userId);
     return user.getEmail();
   } catch (NotFoundException e) {
     return null;
   }
 }
예제 #2
0
 /** {@inheritDoc} */
 @Override
 public boolean isValid(String value, ConstraintValidatorContext context) {
   if (value == null) {
     // null emails checks are out of scope, pls use separate annotation for that
     return true;
   }
   JCUser user = userService.getCurrentUser();
   if (user.getEmail().equals(value)) {
     return true; // no changes in an email, that's ok
   } else {
     User found = userDao.getByEmail(value);
     return found == null;
   }
 }