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 theResponseInfoCollection
resource
- All Implemented Interfaces:
ResourceRequest<ResponseInfoCollection<T>>
,Callable<ResponseInfoCollection<T>>
public class ExecuteQuery<T> extends AbstractResourceRequest<ResponseInfoCollection<T>>
Executes aGET
orPOST
request on an OSLC query capability URL.If the query parameters are too long for a
GET
request, prefer usingpost(OslcClient, URI, String, Class)
, provided the server supports suchPOST
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. TheResponseInfoCollection
resource may contain information about a next page URI, that shall be used as is by a subsequentExecuteQuery
request to get the next set of resources. If aPOST
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 theResponseInfoCollection
resource.- Since:
- 3.6.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ClientResponse
call(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
QueryUriBuilder
for building such URI.An
Accept
header is set toapplication/rdf+xml
, as this is the most frequently used exchange format.- Type Parameters:
T
- the type of members of theResponseInfoCollection
resource- 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
GET
query 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
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 theResponseInfoCollection
resource- 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
- theAccept
header value to use- Returns:
- a
GET
query 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
POST
entity. SeeQueryUriBuilder.buildPostEntity()
for building such content.An
Accept
header is set toapplication/rdf+xml
, as this is the most frequently used exchange format.- Type Parameters:
T
- the type of members of theResponseInfoCollection
resource- 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-urlencoded
bodytype
- the type of resources to query- Returns:
- a
POST
query 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
POST
entity. SeeQueryUriBuilder.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 theResponseInfoCollection
resource- 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-urlencoded
bodytype
- the type of resources to queryacceptType
- theAccept
header value to use- Returns:
- a
POST
query request - Throws:
IllegalArgumentException
- if acceptType isapplication/json
- See Also:
QueryUriBuilder.buildPostEntity()
-
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 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:AbstractResourceRequest
Processes the response obtained when executing a request on the specified resource. Due to the contract of theResourceRequest
interface, this method is called only when the HTTP response status is20x
.- Specified by:
createResponse
in 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.
-
-