Example usage for com.fasterxml.jackson.databind ObjectReader getFactory

List of usage examples for com.fasterxml.jackson.databind ObjectReader getFactory

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind ObjectReader getFactory.

Prototype

@Override
public JsonFactory getFactory() 

Source Link

Usage

From source file:com.unboundid.scim2.server.providers.DotSearchFilter.java

/**
 * {@inheritDoc}/*from  w  w w  .j  a va2 s.c o m*/
 */
public void filter(final ContainerRequestContext requestContext) throws IOException {
    if (requestContext.getMethod().equals(HttpMethod.POST)
            && requestContext.getUriInfo().getPath().endsWith(SEARCH_WITH_POST_PATH_EXTENSION))

    {
        if (requestContext.getMediaType() == null
                || !(requestContext.getMediaType().isCompatible(ServerUtils.MEDIA_TYPE_SCIM_TYPE)
                        || requestContext.getMediaType().isCompatible(MediaType.APPLICATION_JSON_TYPE))) {
            throw new NotSupportedException();
        }

        ObjectReader reader = JsonUtils.getObjectReader().forType(SearchRequest.class);
        JsonParser p = reader.getFactory().createParser(requestContext.getEntityStream());
        if (p.nextToken() == null) {
            throw new BadRequestException(new NoContentException("Empty Entity"));
        }
        SearchRequest searchRequest = reader.readValue(p);
        UriBuilder builder = requestContext.getUriInfo().getBaseUriBuilder();
        List<PathSegment> pathSegments = requestContext.getUriInfo().getPathSegments();
        for (int i = 0; i < pathSegments.size() - 1; i++) {
            builder.path(pathSegments.get(i).getPath());
        }
        if (searchRequest.getAttributes() != null) {
            builder.queryParam(QUERY_PARAMETER_ATTRIBUTES,
                    StaticUtils.collectionToString(searchRequest.getAttributes(), ","));
        }
        if (searchRequest.getExcludedAttributes() != null) {
            builder.queryParam(QUERY_PARAMETER_EXCLUDED_ATTRIBUTES,
                    StaticUtils.collectionToString(searchRequest.getExcludedAttributes(), ","));
        }
        if (searchRequest.getFilter() != null) {
            builder.queryParam(QUERY_PARAMETER_FILTER, searchRequest.getFilter());
        }
        if (searchRequest.getSortBy() != null) {
            builder.queryParam(QUERY_PARAMETER_SORT_BY, searchRequest.getSortBy());
        }
        if (searchRequest.getSortOrder() != null) {
            builder.queryParam(QUERY_PARAMETER_SORT_ORDER, searchRequest.getSortOrder().getName());
        }
        if (searchRequest.getStartIndex() != null) {
            builder.queryParam(QUERY_PARAMETER_PAGE_START_INDEX, searchRequest.getStartIndex());
        }
        if (searchRequest.getCount() != null) {
            builder.queryParam(QUERY_PARAMETER_PAGE_SIZE, searchRequest.getCount());
        }
        requestContext.setRequestUri(builder.build());
        requestContext.setMethod(HttpMethod.GET);
    }
}