Search in sources :

Example 6 with DuplicateEntryException

use of org.gluu.persist.exception.operation.DuplicateEntryException in project oxTrust by GluuFederation.

the class GroupWebServiceDecorator method updateGroup.

public Response updateGroup(GroupResource group, String id, String attrsList, String excludedAttrsList) {
    Response response;
    try {
        // empty externalId, no place to store it in LDAP
        group.setExternalId(null);
        // Check if the ids match in case the group coming has one
        if (group.getId() != null && !group.getId().equals(id))
            throw new SCIMException("Parameter id does not match with id attribute of Group");
        response = validateExistenceOfGroup(id);
        if (response == null) {
            executeValidation(group, true);
            if (StringUtils.isNotEmpty(group.getDisplayName()))
                checkDisplayNameExistence(group.getDisplayName(), id);
            // Proceed with actual implementation of updateGroup method
            response = service.updateGroup(group, 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 updateGroup returned: {}", e.getMessage());
        response = getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_VALUE, e.getMessage());
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) SCIMException(org.gluu.oxtrust.model.exception.SCIMException) DuplicateEntryException(org.gluu.persist.exception.operation.DuplicateEntryException)

Example 7 with DuplicateEntryException

use of org.gluu.persist.exception.operation.DuplicateEntryException in project oxTrust by GluuFederation.

the class UserWebServiceDecorator method createUser.

public Response createUser(UserResource user, String attrsList, String excludedAttrsList) {
    Response response;
    try {
        executeDefaultValidation(user);
        checkUidExistence(user.getUserName());
        assignMetaInformation(user);
        ScimResourceUtil.adjustPrimarySubAttributes(user);
        // Proceed with actual implementation of createUser method
        response = service.createUser(user, 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 createUser returned: {}", e.getMessage());
        response = getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_VALUE, e.getMessage());
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) SCIMException(org.gluu.oxtrust.model.exception.SCIMException) DuplicateEntryException(org.gluu.persist.exception.operation.DuplicateEntryException)

Aggregations

DuplicateEntryException (org.gluu.persist.exception.operation.DuplicateEntryException)7 Response (javax.ws.rs.core.Response)4 SCIMException (org.gluu.oxtrust.model.exception.SCIMException)4 GluuGroup (org.gluu.oxtrust.model.GluuGroup)2 Date (java.util.Date)1 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)1