Package com.sodius.oslc.client.requests
Class GetResources<T>
java.lang.Object
com.sodius.oslc.client.requests.AbstractResourceRequest<ResourceResponse<Collection<T>>>
com.sodius.oslc.client.requests.GetResources<T>
- Type Parameters:
T- the type of response to extract from the request execution.
- All Implemented Interfaces:
ResourceRequest<ResourceResponse<Collection<T>>>,Callable<ResourceResponse<Collection<T>>>
Executes a GET request on an OSLC resource that contains multiple instances of the target type.
As suggested by the Collection return type, the order of resources is not preserved.
This is typically useful when requesting Container resources.
An OSLC-Core-Version header is set to 2.0, as the GET is expected to execute on an OSLC resource. Clients should subclass
AbstractResourceRequest to execute a GET on a non-OSLC resource.
- Since:
- 1.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionGetResources(OslcClient client, URI uri, Class<T> entityType) Creates a new instance to execute a GET on the specified resource.GetResources(OslcClient client, URI uri, Class<T> entityType, MediaType acceptType) Creates a new instance to execute a GET on the specified resource. -
Method Summary
Modifier and TypeMethodDescriptionprotected ClientResponsecall(OslcResource resource) Executes the request on the specified resource.protected ResourceResponse<Collection<T>> createResponse(OslcResource resource, ClientResponse response) Extracts aResourceResponseinstance from the obtained HTTP response.get()Executes the GET request and extracts the response entity directly, in case the response headers are not of any use.Methods inherited from class com.sodius.oslc.client.requests.AbstractResourceRequest
call, createErrorResponse, createResourceResponse, getClient, getUri
-
Constructor Details
-
GetResources
Creates a new instance to execute a GET on the specified resource.An
Acceptheader is set toapplication/rdf+xml, as this is the most frequently used exchange format.- Parameters:
client- the REST client used to execute a request.uri- the URI used for the underlying request.entityType- the entityType specifying the type of artifacts to extract from the request execution and to fill in the collection.
-
GetResources
Creates a new instance to execute a GET on the specified resource.- Parameters:
client- the REST client used to execute a request.uri- the URI used for the underlying request.entityType- the entityType specifying the type of artifacts to extract from the request execution and to fill in the collection.acceptType- the MediaType to use as theacceptheader
-
-
Method Details
-
call
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<ResourceResponse<Collection<T>>>- Parameters:
resource- the resource on which to execute a request.- Returns:
- the response of the request execution.
-
createResponse
protected ResourceResponse<Collection<T>> createResponse(OslcResource resource, ClientResponse response) Extracts aResourceResponseinstance from the obtained HTTP response. The response contains the response headers, from which theETagheader can be extracted in case this request is to follow by aPUT.- Specified by:
createResponsein classAbstractResourceRequest<ResourceResponse<Collection<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.
-
get
Executes the GET request and extracts the response entity directly, in case the response headers are not of any use. This method is a shorthand formyRequest.call().getEntity().- Returns:
- the entity of the response of the GET execution.
-