use of org.motechproject.security.exception.EmailExistsException in project motech by motech.
the class MotechUsersDao method update.
/**
* Updates given MotechUser as long as his email is not used by another user
*
* @param motechUser to be updated
*/
@Transactional
public void update(MotechUser motechUser) {
String email = motechUser.getEmail();
MotechUser otherWithSameEmail = findUserByEmail(email);
if (null != otherWithSameEmail && !otherWithSameEmail.getUserName().equals(motechUser.getUserName())) {
throw new EmailExistsException("User with email " + email + " already exists");
}
dataService.update(motechUser);
}
Aggregations