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;
}
Aggregations