use of io.jans.scim.model.scim2.SearchRequest in project jans by JanssenProject.
the class ReferenceURIInterceptor method manage.
@AroundInvoke
public Object manage(InvocationContext ctx) throws Exception {
Object[] params = ctx.getParameters();
Annotation[][] annotations = ctx.getMethod().getParameterAnnotations();
for (int i = 0; i < annotations.length; i++) {
// Iterate over annotations found at every parameter
for (Annotation annotation : annotations[i]) {
if (annotation instanceof QueryParam) {
String paramName = ((QueryParam) annotation).value();
if ((paramName.equals(QUERY_PARAM_FILTER) || paramName.equals(QUERY_PARAM_ATTRIBUTES) || paramName.equals(QUERY_PARAM_EXCLUDED_ATTRS))) {
log.trace("Removing '$' char (if any) from {} param", paramName);
params[i] = dropDollar(params[i]);
}
}
}
if (params[i] != null && params[i] instanceof SearchRequest) {
log.trace("Removing '$' char (if any) from SearchRequest object");
SearchRequest sr = (SearchRequest) params[i];
sr.setAttributes(dropDollar(sr.getAttributesStr()));
sr.setExcludedAttributes(dropDollar(sr.getExcludedAttributesStr()));
sr.setFilter(dropDollar(sr.getFilter()));
}
}
log.debug("ReferenceURIInterceptor. manage exit");
return ctx.proceed();
}
use of io.jans.scim.model.scim2.SearchRequest in project jans by JanssenProject.
the class FidoDeviceWebService method doSearchDevices.
private Response doSearchDevices(String userId, 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, fidoResourceType);
if (response != null)
return response;
response = validateExistenceOfUser(userId);
if (response != null)
return response;
PagedResult<BaseScimResource> resources = searchDevices(userId, searchReq.getFilter(), translateSortByAttribute(FidoDeviceResource.class, searchReq.getSortBy()), SortOrder.getByValue(searchReq.getSortOrder()), searchReq.getStartIndex(), searchReq.getCount());
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 searchDevices method", e);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
return response;
}
use of io.jans.scim.model.scim2.SearchRequest in project jans by JanssenProject.
the class GroupWebService method doSearchGroups.
private Response doSearchGroups(String filter, Integer startIndex, Integer count, String sortBy, String sortOrder, String attrsList, String excludedAttrsList, String method, boolean fillMembersDisplay) {
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, groupResourceType);
if (response != null)
return response;
PagedResult<BaseScimResource> resources = scim2GroupService.searchGroups(searchReq.getFilter(), translateSortByAttribute(GroupResource.class, searchReq.getSortBy()), SortOrder.getByValue(searchReq.getSortOrder()), searchReq.getStartIndex(), searchReq.getCount(), endpointUrl, usersUrl, getMaxCount(), fillMembersDisplay);
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 searchGroups method", e);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
return response;
}
use of io.jans.scim.model.scim2.SearchRequest 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;
}
use of io.jans.scim.model.scim2.SearchRequest in project java-retail by googleapis.
the class SearchWithFiltering method getSearchResponse.
public static SearchResponse getSearchResponse(String defaultSearchPlacementName) throws IOException {
// TRY DIFFERENT FILTER EXPRESSIONS HERE:
String filter = "(colorFamilies: ANY(\"Black\"))";
String queryPhrase = "Tee";
int pageSize = 10;
String visitorId = UUID.randomUUID().toString();
SearchRequest searchRequest = SearchRequest.newBuilder().setPlacement(defaultSearchPlacementName).setVisitorId(visitorId).setQuery(queryPhrase).setPageSize(pageSize).setFilter(filter).build();
System.out.println("Search request: " + searchRequest);
try (SearchServiceClient client = SearchServiceClient.create()) {
SearchResponse searchResponse = client.search(searchRequest).getPage().getResponse();
System.out.println("Search response: " + searchResponse);
return searchResponse;
}
}
Aggregations