Search in sources :

Example 36 with SearchRequest

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();
}
Also used : SearchRequest(io.jans.scim.model.scim2.SearchRequest) QueryParam(javax.ws.rs.QueryParam) Annotation(java.lang.annotation.Annotation) AroundInvoke(javax.interceptor.AroundInvoke)

Example 37 with SearchRequest

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;
}
Also used : Response(javax.ws.rs.core.Response) SearchRequest(io.jans.scim.model.scim2.SearchRequest) SCIMException(io.jans.scim.model.exception.SCIMException) FidoDeviceResource(io.jans.scim.model.scim2.fido.FidoDeviceResource) BaseScimResource(io.jans.scim.model.scim2.BaseScimResource) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) SCIMException(io.jans.scim.model.exception.SCIMException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException)

Example 38 with SearchRequest

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;
}
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) URI(java.net.URI) GroupResource(io.jans.scim.model.scim2.group.GroupResource) URISyntaxException(java.net.URISyntaxException) SCIMException(io.jans.scim.model.exception.SCIMException) DuplicateEntryException(io.jans.orm.exception.operation.DuplicateEntryException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException)

Example 39 with SearchRequest

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

Example 40 with SearchRequest

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;
    }
}
Also used : SearchServiceClient(com.google.cloud.retail.v2.SearchServiceClient) SearchRequest(com.google.cloud.retail.v2.SearchRequest) SearchResponse(com.google.cloud.retail.v2.SearchResponse)

Aggregations

Response (javax.ws.rs.core.Response)31 SearchRequest (io.jans.scim.model.scim2.SearchRequest)23 ListResponse (io.jans.scim.model.scim2.ListResponse)21 Test (org.testng.annotations.Test)15 UserResource (io.jans.scim.model.scim2.user.UserResource)13 UserBaseTest (io.jans.scim2.client.UserBaseTest)13 SearchRequest (com.google.cloud.retail.v2.SearchRequest)7 SearchResponse (com.google.cloud.retail.v2.SearchResponse)7 SearchServiceClient (com.google.cloud.retail.v2.SearchServiceClient)7 URI (java.net.URI)6 SearchRequest (org.gluu.oxtrust.model.scim2.SearchRequest)6 BaseScimResource (io.jans.scim.model.scim2.BaseScimResource)5 SkipTest (io.jans.scim2.listener.SkipTest)5 SCIMException (io.jans.scim.model.exception.SCIMException)4 URISyntaxException (java.net.URISyntaxException)4 BeforeTest (org.testng.annotations.BeforeTest)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)3 DuplicateEntryException (io.jans.orm.exception.operation.DuplicateEntryException)2 GroupResource (io.jans.scim.model.scim2.group.GroupResource)2 Annotation (java.lang.annotation.Annotation)2