/** * Build complete response. * * @param preResponse PreResponse object which contains result set, response context and headers * @param apiRequest ApiRequest object which contains request related information * @param containerRequestContext The container for jersey request processing objects * * @return Completely built response with headers and result set */ public javax.ws.rs.core.Response buildResponse( PreResponse preResponse, ApiRequest apiRequest, ContainerRequestContext containerRequestContext ) { ResponseBuilder rspBuilder = createResponseBuilder( preResponse.getResultSet(), preResponse.getResponseContext(), apiRequest, containerRequestContext ); @SuppressWarnings("unchecked") MultivaluedMap<String, Object> headers = (MultivaluedMap<String, Object>) preResponse .getResponseContext() .get(HEADERS.getName()); //Headers are a multivalued map, and we want to add each element of each value to the builder. headers.entrySet().stream() .forEach(entry -> entry.getValue().forEach(value -> rspBuilder.header(entry.getKey(), value))); return rspBuilder.build(); }
@SuppressWarnings("unchecked") ResponseFormatType responseFormatType = apiRequest.getFormat(); Map<String, URI> bodyLinks = (Map<String, URI>) responseContext.get( PAGINATION_LINKS_CONTEXT_KEY.getName() ); bodyLinks = Collections.emptyMap(); Pagination pagination = (Pagination) responseContext.get(PAGINATION_CONTEXT_KEY.getName()); (LinkedHashMap<String, LinkedHashSet<DimensionField>>) responseContext.get( REQUESTED_API_DIMENSION_FIELDS.getName()); (LinkedHashSet<String>) responseContext.get(API_METRIC_COLUMN_NAMES.getName()), requestedApiDimensionFields, getPartialIntervalsWithDefault(responseContext),