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 theResponseInfoCollectionresource
- All Implemented Interfaces:
ResourceRequest<ResponseInfoCollection<T>>,Callable<ResponseInfoCollection<T>>
public class ExecuteQuery<T> extends AbstractResourceRequest<ResponseInfoCollection<T>>
Executes aGETorPOSTrequest on an OSLC query capability URL.If the query parameters are too long for a
GETrequest, prefer usingpost(OslcClient, URI, String, Class), provided the server supports suchPOSTrequest.This request returns a
ResponseInfoCollectionresource, which contains resources of the desired type and matching a given condition. The number of returned resources is usually limited by the server. TheResponseInfoCollectionresource may contain information about a next page URI, that shall be used as is by a subsequentExecuteQueryrequest to get the next set of resources. If aPOSTis 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 theResponseInfoCollectionresource.For convenience, the class is able to read the response as a
ResponseInfoCollectionwhen the server actually responded with a LDP Container entity.- Since:
- 3.6.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ClientResponsecall(OslcResource resource)Executes the request on the specified resource.protected ResponseInfoCollection<T>createResponse(OslcResource resource, ClientResponse response)Processes the response obtained when executing a request on the specified resource.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.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.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.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.-
Methods inherited from class com.sodius.oslc.client.requests.AbstractResourceRequest
call, createErrorResponse, createResourceResponse, getClient, getUri
-
-
-
-
Method Detail
-
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
QueryUriBuilderfor building such URI.An
Acceptheader is set toapplication/rdf+xml, as this is the most frequently used exchange format.- Type Parameters:
T- the type of members of theResponseInfoCollectionresource- Parameters:
client- the REST client used to execute a requesturi- the URI of the query, which should include query parameterstype- the type of resources to query- Returns:
- a
GETquery request - See Also:
QueryUriBuilder.build(URI)
-
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
QueryUriBuilderfor building such URI.Caution: the
application/jsonmedia type is not supported by this request.- Type Parameters:
T- the type of members of theResponseInfoCollectionresource- Parameters:
client- the REST client used to execute a requesturi- the URI of the query, which should include query parameterstype- the type of resources to queryacceptType- theAcceptheader value to use- Returns:
- a
GETquery request - Throws:
IllegalArgumentException- if acceptType isapplication/json- See Also:
QueryUriBuilder.build(URI)
-
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
POSTentity. SeeQueryUriBuilder.buildPostEntity()for building such content.An
Acceptheader is set toapplication/rdf+xml, as this is the most frequently used exchange format.- Type Parameters:
T- the type of members of theResponseInfoCollectionresource- Parameters:
client- the REST client used to execute a requesturi- the URI of the query base locationformEntity- the OSLC query parameters encoded in aapplication/x-www-form-urlencodedbodytype- the type of resources to query- Returns:
- a
POSTquery request - See Also:
QueryUriBuilder.buildPostEntity()
-
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
POSTentity. SeeQueryUriBuilder.buildPostEntity()for building such content.Caution: the
application/jsonmedia type is not supported by this request.- Type Parameters:
T- the type of members of theResponseInfoCollectionresource- Parameters:
client- the REST client used to execute a requesturi- the URI of the query base locationformEntity- the OSLC query parameters encoded in aapplication/x-www-form-urlencodedbodytype- the type of resources to queryacceptType- theAcceptheader value to use- Returns:
- a
POSTquery request - Throws:
IllegalArgumentException- if acceptType isapplication/json- See Also:
QueryUriBuilder.buildPostEntity()
-
call
protected ClientResponse call(OslcResource resource)
Description copied from class:AbstractResourceRequestExecutes the request on the specified resource. Subclasses may add extra information (such as headers) on the resource before executing the request.- Specified by:
callin classAbstractResourceRequest<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:AbstractResourceRequestProcesses the response obtained when executing a request on the specified resource. Due to the contract of theResourceRequestinterface, this method is called only when the HTTP response status is20x.- Specified by:
createResponsein classAbstractResourceRequest<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.
-
-