Search in sources :

Example 6 with DuplicateEmailException

use of org.gluu.oxtrust.exception.DuplicateEmailException in project oxTrust by GluuFederation.

the class PersonService method updatePerson.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.gluu.oxtrust.ldap.service.IPersonService#updatePerson(org.gluu.oxtrust.
	 * model.GluuCustomPerson)
	 */
@Override
public void updatePerson(GluuCustomPerson person) throws Exception {
    try {
        Date updateDate = new Date();
        person.setUpdatedAt(updateDate);
        if (person.getAttribute("oxTrustMetaLastModified") != null) {
            person.setAttribute("oxTrustMetaLastModified", Instant.ofEpochMilli(updateDate.getTime()).toString());
        }
        persistenceEntryManager.merge(person);
    } catch (Exception e) {
        if (e.getCause().getMessage().contains("unique attribute conflict was detected for attribute mail")) {
            throw new DuplicateEmailException("Email Already Registered");
        } else {
            throw new Exception("Duplicate UID value: " + person.getUid(), e);
        }
    }
}
Also used : DuplicateEmailException(org.gluu.oxtrust.exception.DuplicateEmailException) Date(java.util.Date) DuplicateEmailException(org.gluu.oxtrust.exception.DuplicateEmailException) DuplicateEntryException(org.gluu.persist.exception.operation.DuplicateEntryException)

Aggregations

DuplicateEmailException (org.gluu.oxtrust.exception.DuplicateEmailException)6 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)4 IOException (java.io.IOException)3 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 ValidatorException (javax.faces.validator.ValidatorException)2 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)2 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)2 DuplicateEntryException (org.gluu.persist.exception.operation.DuplicateEntryException)2 ParseException (java.text.ParseException)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 GluuOrganization (org.gluu.oxtrust.model.GluuOrganization)1 PasswordResetRequest (org.gluu.oxtrust.model.PasswordResetRequest)1 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)1