use of com.google.cloud.retail.v2.SearchRequest in project oxTrust by GluuFederation.
the class FidoDeviceWebServiceDecorator method searchDevices.
public Response searchDevices(String userId, String filter, Integer startIndex, Integer count, String sortBy, String sortOrder, String attrsList, String excludedAttrsList) {
SearchRequest searchReq = new SearchRequest();
Response response = prepareSearchRequest(searchReq.getSchemas(), filter, sortBy, sortOrder, startIndex, count, attrsList, excludedAttrsList, searchReq);
if (response == null) {
response = validateExistenceOfUser(userId);
if (response == null) {
response = service.searchDevices(userId, searchReq.getFilter(), searchReq.getStartIndex(), searchReq.getCount(), searchReq.getSortBy(), searchReq.getSortOrder(), searchReq.getAttributesStr(), searchReq.getExcludedAttributesStr());
}
}
return response;
}
use of com.google.cloud.retail.v2.SearchRequest in project oxTrust by GluuFederation.
the class GroupWebServiceDecorator method searchGroups.
public Response searchGroups(String filter, Integer startIndex, Integer count, String sortBy, String sortOrder, String attrsList, String excludedAttrsList) {
SearchRequest searchReq = new SearchRequest();
Response response = prepareSearchRequest(searchReq.getSchemas(), filter, sortBy, sortOrder, startIndex, count, attrsList, excludedAttrsList, searchReq);
if (response == null) {
response = service.searchGroups(searchReq.getFilter(), searchReq.getStartIndex(), searchReq.getCount(), searchReq.getSortBy(), searchReq.getSortOrder(), searchReq.getAttributesStr(), searchReq.getExcludedAttributesStr());
}
return response;
}
use of com.google.cloud.retail.v2.SearchRequest in project oxTrust by GluuFederation.
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 com.google.cloud.retail.v2.SearchRequest in project jans by JanssenProject.
the class SearchResourcesWebService method search.
@POST
@Consumes({ MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi(scopes = { "https://jans.io/scim/all-resources.search" })
@RefAdjusted
public Response search(SearchRequest searchRequest) {
SearchRequest searchReq = new SearchRequest();
Response response = prepareSearchRequest(searchRequest.getSchemas(), searchRequest.getFilter(), searchRequest.getSortBy(), searchRequest.getSortOrder(), searchRequest.getStartIndex(), searchRequest.getCount(), searchRequest.getAttributesStr(), searchRequest.getExcludedAttributesStr(), searchReq);
if (response == null) {
try {
List<JsonNode> resources = new ArrayList<>();
Pair<Integer, Integer> totals = computeResults(searchReq, resources);
ListResponseJsonSerializer custSerializer = new ListResponseJsonSerializer(resourceSerializer, searchReq.getAttributesStr(), searchReq.getExcludedAttributesStr(), searchReq.getCount() == 0);
if (resources.size() > 0)
custSerializer.setJsonResources(resources);
ObjectMapper objmapper = new ObjectMapper();
SimpleModule module = new SimpleModule("ListResponseModule", Version.unknownVersion());
module.addSerializer(ListResponse.class, custSerializer);
objmapper.registerModule(module);
// Provide to constructor original start index, and totals calculated in computeResults call
ListResponse listResponse = new ListResponse(searchReq.getStartIndex(), totals.getFirst(), totals.getSecond());
String json = objmapper.writeValueAsString(listResponse);
response = Response.ok(json).location(new URI(endpointUrl)).build();
} catch (Exception e) {
log.error("Failure at search method", e);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
}
return response;
}
use of com.google.cloud.retail.v2.SearchRequest in project jans by JanssenProject.
the class SpecialCharsTest method containabilityAll.
@SkipTest(databases = { "spanner", "couchbase" })
@Test
public void containabilityAll() {
// Builds a long "and" based clause
String filter = specialFilterLdapChars.stream().reduce("", (partial, next) -> partial + String.format(" and userName co \"%s\"", next));
SearchRequest sr = new SearchRequest();
// Drop beginning (namely " and ")
sr.setFilter(filter.substring(4));
sr.setAttributes("userName");
// Search users whose usernames contain ALL the chars
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
List<UserResource> resources = response.readEntity(ListResponse.class).getResources().stream().map(UserResource.class::cast).collect(Collectors.toList());
String userName = resources.get(0).getUserName();
assertEquals(resources.size(), 1);
assertTrue(Stream.of(SPECIAL_CHARS).allMatch(userName::contains));
}
Aggregations