Package org.forgerock.openam.rest.query
Class QueryResponsePresentation
- java.lang.Object
-
- org.forgerock.openam.rest.query.QueryResponsePresentation
-
public class QueryResponsePresentation extends Object
Responsible for managing the presentation detail around a CREST query and its response to the caller. Resource fields MUST beComparablefor them to be used as sorting keys. This class supports CREST query operations by providing paging and sorting of results. Sorting is always performed before paging. This implementation also defers responsibility to the caller for details about how to sort the item via aComparatorand how to convert the item to aResourceResponse.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidenableDeprecatedRemainingQueryResponse(org.forgerock.json.resource.QueryRequest request)CREST 2.0 based resources use the convention of returning the remaining count of resources to the caller usingQueryResponse.getRemainingPagedResults().static org.forgerock.util.promise.Promise<org.forgerock.json.resource.QueryResponse,org.forgerock.json.resource.ResourceException>perform(org.forgerock.json.resource.QueryResourceHandler handler, org.forgerock.json.resource.QueryRequest request, List<org.forgerock.json.resource.ResourceResponse> resources)Given a set of JsonValue results from a query, convert them to the requiredResourceResponseand apply them to the given handler.
-
-
-
Field Detail
-
REMAINING
public static final String REMAINING
- See Also:
- Constant Field Values
-
-
Method Detail
-
perform
public static org.forgerock.util.promise.Promise<org.forgerock.json.resource.QueryResponse,org.forgerock.json.resource.ResourceException> perform(org.forgerock.json.resource.QueryResourceHandler handler, org.forgerock.json.resource.QueryRequest request, List<org.forgerock.json.resource.ResourceResponse> resources)Given a set of JsonValue results from a query, convert them to the requiredResourceResponseand apply them to the given handler. This function implicitly supports paging and sorting, based on the values supplied in theQueryRequest. The QueryResponse is wrapped in the appropriate Promise for convenience. The response will indicate either the total number of results, or the remaining depending on the request. SeeenableDeprecatedRemainingQueryResponse(QueryRequest)for details.- Parameters:
handler- Non null QueryResourceHandler which will receive the results from the query.request- Non null QueryRequest required to determine how results should be processed before returning.resources- Non null, possibly empty list of ResourceResponse results from a query.- Returns:
- Non null Promise containing the QueryResponse which includes a count of the results remaining.
-
enableDeprecatedRemainingQueryResponse
public static void enableDeprecatedRemainingQueryResponse(org.forgerock.json.resource.QueryRequest request)
CREST 2.0 based resources use the convention of returning the remaining count of resources to the caller usingQueryResponse.getRemainingPagedResults(). Use this method to indicate the QueryResponsePresentation that it should enable this mode. For reference, CREST 3.0 resources should useQueryResponse.getTotalPagedResults()instead.- Parameters:
request- Non null QueryRequest to update, indicating CREST 2.0 compatibility mode.
-
-