Class ExecuteQuery<T>

java.lang.Object
com.sodius.oslc.client.requests.AbstractResourceRequest<ResponseInfoCollection<T>>
com.sodius.oslc.core.process.query.requests.ExecuteQuery<T>
Type Parameters:
T - the type of members of the ResponseInfoCollection resource
All Implemented Interfaces:
ResourceRequest<ResponseInfoCollection<T>>, Callable<ResponseInfoCollection<T>>

public class ExecuteQuery<T> extends AbstractResourceRequest<ResponseInfoCollection<T>>
Executes a GET or POST request on an OSLC query capability URL.

If the query parameters are too long for a GET request, prefer using post(OslcClient, URI, String, Class), provided the server supports such POST request.

This request returns a ResponseInfoCollection resource, which contains resources of the desired type and matching a given condition. The number of returned resources is usually limited by the server. The ResponseInfoCollection resource may contain information about a next page URI, that shall be used as is by a subsequent ExecuteQuery request to get the next set of resources. If a POST is used, the subsequent request entity must be the same as for the initial request. This process shall be repeated by the client to capture the entire set of resources, until no next page is provided by the ResponseInfoCollection resource.

For convenience, the class is able to read the response as a ResponseInfoCollection when the server actually responded with a LDP Container entity.

Since:
3.6.0
  • Method Details

    • get

      public static <T> ExecuteQuery<T> get(OslcClient client, URI uri, Class<T> type)
      Creates a query request to fetch resources from a remote server that match a given condition.

      The given URI should combine the base location of an OSLC query capability and query parameters to control the condition to filter resources. See QueryUriBuilder for building such URI.

      An Accept header is set to application/rdf+xml, as this is the most frequently used exchange format.

      Type Parameters:
      T - the type of members of the ResponseInfoCollection resource
      Parameters:
      client - the REST client used to execute a request
      uri - the URI of the query, which should include query parameters
      type - the type of resources to query
      Returns:
      a GET query request
      See Also:
    • get

      public static <T> ExecuteQuery<T> get(OslcClient client, URI uri, Class<T> type, MediaType acceptType)
      Creates a query request to fetch resources from a remote server that match a given condition.

      The given URI should combine the base location of an OSLC query capability and query parameters to control the condition to filter resources. See QueryUriBuilder for building such URI.

      Caution: the application/json media type is not supported by this request.

      Type Parameters:
      T - the type of members of the ResponseInfoCollection resource
      Parameters:
      client - the REST client used to execute a request
      uri - the URI of the query, which should include query parameters
      type - the type of resources to query
      acceptType - the Accept header value to use
      Returns:
      a GET query request
      Throws:
      IllegalArgumentException - if acceptType is application/json
      See Also:
    • post

      public static <T> ExecuteQuery<T> post(OslcClient client, URI uri, String formEntity, Class<T> type)
      Creates a query request to fetch resources from a remote server that match a given condition.

      The given URI should be the OSLC query base location. It should not contain OSLC Query parameters. Query parameters are to be encoded as a POST entity. See QueryUriBuilder.buildPostEntity() for building such content.

      An Accept header is set to application/rdf+xml, as this is the most frequently used exchange format.

      Type Parameters:
      T - the type of members of the ResponseInfoCollection resource
      Parameters:
      client - the REST client used to execute a request
      uri - the URI of the query base location
      formEntity - the OSLC query parameters encoded in a application/x-www-form-urlencoded body
      type - the type of resources to query
      Returns:
      a POST query request
      See Also:
    • post

      public static <T> ExecuteQuery<T> post(OslcClient client, URI uri, String formEntity, Class<T> type, MediaType acceptType)
      Creates a query request to fetch resources from a remote server that match a given condition.

      The given URI should be the OSLC query base location. It should not contain OSLC Query parameters. Query parameters are to be encoding as a POST entity. See QueryUriBuilder.buildPostEntity() for building such content.

      Caution: the application/json media type is not supported by this request.

      Type Parameters:
      T - the type of members of the ResponseInfoCollection resource
      Parameters:
      client - the REST client used to execute a request
      uri - the URI of the query base location
      formEntity - the OSLC query parameters encoded in a application/x-www-form-urlencoded body
      type - the type of resources to query
      acceptType - the Accept header value to use
      Returns:
      a POST query request
      Throws:
      IllegalArgumentException - if acceptType is application/json
      See Also:
    • call

      protected ClientResponse call(OslcResource resource)
      Description copied from class: AbstractResourceRequest
      Executes the request on the specified resource. Subclasses may add extra information (such as headers) on the resource before executing the request.
      Specified by:
      call in class AbstractResourceRequest<ResponseInfoCollection<T>>
      Parameters:
      resource - the resource on which to execute a request.
      Returns:
      the response of the request execution.
    • createResponse

      protected ResponseInfoCollection<T> createResponse(OslcResource resource, ClientResponse response)
      Description copied from class: AbstractResourceRequest
      Processes the response obtained when executing a request on the specified resource. Due to the contract of the ResourceRequest interface, this method is called only when the HTTP response status is 20x .
      Specified by:
      createResponse in class AbstractResourceRequest<ResponseInfoCollection<T>>
      Parameters:
      resource - the resource on which a request is executed.
      response - the response obtained.
      Returns:
      the extraction of the response content into the expected format.