Search in sources :

Example 1 with EmailExistsException

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);
}
Also used : MotechUser(org.motechproject.security.domain.MotechUser) EmailExistsException(org.motechproject.security.exception.EmailExistsException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

MotechUser (org.motechproject.security.domain.MotechUser)1 EmailExistsException (org.motechproject.security.exception.EmailExistsException)1 Transactional (org.springframework.transaction.annotation.Transactional)1