use of org.gluu.persist.exception.operation.DuplicateEntryException in project oxTrust by GluuFederation.
the class UserWebServiceDecorator method updateUser.
public Response updateUser(UserResource user, String id, String attrsList, String excludedAttrsList) {
Response response;
try {
// Check if the ids match in case the user coming has one
if (user.getId() != null && !user.getId().equals(id))
throw new SCIMException("Parameter id does not match with id attribute of User");
response = validateExistenceOfUser(id);
if (response == null) {
executeValidation(user, true);
if (StringUtils.isNotEmpty(user.getUserName()))
checkUidExistence(user.getUserName(), id);
ScimResourceUtil.adjustPrimarySubAttributes(user);
// Proceed with actual implementation of updateUser method
response = service.updateUser(user, id, attrsList, excludedAttrsList);
}
} catch (DuplicateEntryException e) {
log.error(e.getMessage());
response = getErrorResponse(Response.Status.CONFLICT, ErrorScimType.UNIQUENESS, e.getMessage());
} catch (SCIMException e) {
log.error("Validation check at updateUser returned: {}", e.getMessage());
response = getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_VALUE, e.getMessage());
}
return response;
}
use of org.gluu.persist.exception.operation.DuplicateEntryException in project oxTrust by GluuFederation.
the class GroupService method addGroup.
/*
* (non-Javadoc)
*
* @see
* org.gluu.oxtrust.ldap.service.IGroupService#addGroup(org.gluu.oxtrust.model.
* GluuGroup)
*/
@Override
public void addGroup(GluuGroup group) throws Exception {
GluuGroup displayNameGroup = new GluuGroup();
displayNameGroup.setDisplayName(group.getDisplayName());
List<GluuGroup> groups = findGroups(displayNameGroup, 1);
if (groups == null || groups.size() == 0) {
persistenceEntryManager.persist(group);
} else {
throw new DuplicateEntryException("Duplicate displayName: " + group.getDisplayName());
}
}
use of org.gluu.persist.exception.operation.DuplicateEntryException in project oxTrust by GluuFederation.
the class PersonService method addPerson.
/*
* (non-Javadoc)
*
* @see
* org.gluu.oxtrust.ldap.service.IPersonService#addPerson(org.gluu.oxtrust.model
* .GluuCustomPerson)
*/
// TODO: Review this methods. We need to check if uid is unique in outside
// method
@Override
public void addPerson(GluuCustomPerson person) throws Exception {
try {
List<GluuCustomPerson> persons = getPersonsByUid(person.getUid());
if (persons == null || persons.size() == 0) {
person.setCreationDate(new Date());
persistenceEntryManager.persist(person);
} else {
throw new DuplicateEntryException("Duplicate UID value: " + person.getUid());
}
} 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());
}
}
}
use of org.gluu.persist.exception.operation.DuplicateEntryException in project oxTrust by GluuFederation.
the class GroupService method addGroup.
/* (non-Javadoc)
* @see org.gluu.oxtrust.ldap.service.IGroupService#addGroup(org.gluu.oxtrust.model.GluuGroup)
*/
@Override
public void addGroup(GluuGroup group) throws Exception {
GluuGroup displayNameGroup = new GluuGroup();
displayNameGroup.setDisplayName(group.getDisplayName());
List<GluuGroup> groups = findGroups(displayNameGroup, 1);
if (groups == null || groups.size() == 0) {
ldapEntryManager.persist(group);
} else {
throw new DuplicateEntryException("Duplicate displayName: " + group.getDisplayName());
}
}
use of org.gluu.persist.exception.operation.DuplicateEntryException in project oxTrust by GluuFederation.
the class PersonService method addPerson.
/* (non-Javadoc)
* @see org.gluu.oxtrust.ldap.service.IPersonService#addPerson(org.gluu.oxtrust.model.GluuCustomPerson)
*/
// TODO: Review this methods. We need to check if uid is unique in outside
// method
@Override
public void addPerson(GluuCustomPerson person) throws Exception {
GluuCustomPerson uidPerson = new GluuCustomPerson();
uidPerson.setUid(person.getUid());
List<GluuCustomPerson> persons = findPersons(uidPerson, 1);
if (persons == null || persons.size() == 0) {
person.setCreationDate(new Date());
ldapEntryManager.persist(person);
} else {
throw new DuplicateEntryException("Duplicate UID value: " + person.getUid());
}
}
Aggregations