Class 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 be Comparable for 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 a Comparator and how to convert the item to a ResourceResponse.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String REMAINING  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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 using QueryResponse.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 required ResourceResponse and apply them to the given handler.
    • 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 required ResourceResponse and apply them to the given handler. This function implicitly supports paging and sorting, based on the values supplied in the QueryRequest. 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. See enableDeprecatedRemainingQueryResponse(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 using QueryResponse.getRemainingPagedResults(). Use this method to indicate the QueryResponsePresentation that it should enable this mode. For reference, CREST 3.0 resources should use QueryResponse.getTotalPagedResults() instead.
        Parameters:
        request - Non null QueryRequest to update, indicating CREST 2.0 compatibility mode.