Search in sources :

Example 21 with SCIMException

use of io.jans.scim.model.exception.SCIMException in project jans by JanssenProject.

the class UserWebService method doSearch.

private Response doSearch(String filter, Integer startIndex, Integer count, String sortBy, String sortOrder, String attrsList, String excludedAttrsList, String method) {
    Response response;
    try {
        SearchRequest searchReq = new SearchRequest();
        response = prepareSearchRequest(searchReq.getSchemas(), filter, sortBy, sortOrder, startIndex, count, attrsList, excludedAttrsList, searchReq);
        if (response != null)
            return response;
        response = externalConstraintsService.applySearchCheck(searchReq, httpHeaders, uriInfo, method, userResourceType);
        if (response != null)
            return response;
        PagedResult<BaseScimResource> resources = scim2UserService.searchUsers(searchReq.getFilter(), translateSortByAttribute(UserResource.class, searchReq.getSortBy()), SortOrder.getByValue(searchReq.getSortOrder()), searchReq.getStartIndex(), searchReq.getCount(), endpointUrl, getMaxCount());
        String json = getListResponseSerialized(resources.getTotalEntriesCount(), searchReq.getStartIndex(), resources.getEntries(), searchReq.getAttributesStr(), searchReq.getExcludedAttributesStr(), searchReq.getCount() == 0);
        response = Response.ok(json).location(new URI(endpointUrl)).build();
    } catch (SCIMException e) {
        log.error(e.getMessage(), e);
        response = getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_FILTER, e.getMessage());
    } catch (Exception e) {
        log.error("Failure at searchUsers method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) SearchRequest(io.jans.scim.model.scim2.SearchRequest) SCIMException(io.jans.scim.model.exception.SCIMException) BaseScimResource(io.jans.scim.model.scim2.BaseScimResource) UserResource(io.jans.scim.model.scim2.user.UserResource) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) SCIMException(io.jans.scim.model.exception.SCIMException) DuplicateEntryException(io.jans.orm.exception.operation.DuplicateEntryException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException)

Aggregations

SCIMException (io.jans.scim.model.exception.SCIMException)21 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)13 URI (java.net.URI)12 URISyntaxException (java.net.URISyntaxException)12 Response (javax.ws.rs.core.Response)12 DuplicateEntryException (io.jans.orm.exception.operation.DuplicateEntryException)8 ProtectedApi (io.jans.scim.service.filter.ProtectedApi)8 RefAdjusted (io.jans.scim.service.scim2.interceptor.RefAdjusted)8 Consumes (javax.ws.rs.Consumes)8 DefaultValue (javax.ws.rs.DefaultValue)8 HeaderParam (javax.ws.rs.HeaderParam)8 Produces (javax.ws.rs.Produces)8 Path (javax.ws.rs.Path)6 BaseScimResource (io.jans.scim.model.scim2.BaseScimResource)5 PUT (javax.ws.rs.PUT)5 SearchRequest (io.jans.scim.model.scim2.SearchRequest)4 GluuGroup (io.jans.scim.model.GluuGroup)3 ScimCustomPerson (io.jans.scim.model.scim.ScimCustomPerson)3 Attribute (io.jans.scim.model.scim2.annotations.Attribute)3 Extension (io.jans.scim.model.scim2.extensions.Extension)3