T
- the type of response to extract from the request execution.public class GetResources<T> extends AbstractResourceRequest<ResourceResponse<Collection<T>>>
Executes a GET request on an OSLC resource that contains multiple instances of the target type. To enable retrieving those multiple instances, the
target type is mapped within an EntityType. 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.
Constructor and Description |
---|
GetResources(OslcClient client,
URI uri,
EntityType<Collection<T>> entityType)
Creates a new instance to execute a GET on the specified resource.
|
GetResources(OslcClient client,
URI uri,
EntityType<Collection<T>> entityType,
MediaType acceptType)
Creates a new instance to execute a GET on the specified resource.
|
Modifier and Type | Method and Description |
---|---|
protected ClientResponse |
call(OslcResource resource)
Executes the request on the specified resource.
|
protected ResourceResponse<Collection<T>> |
createResponse(OslcResource resource,
ClientResponse response)
Extracts a
ResourceResponse instance from the obtained HTTP response. |
Collection<T> |
get()
Executes the GET request and extracts the response entity directly, in case the response headers are not of any use.
|
call, createErrorResponse, createResourceResponse, getClient, getUri
public GetResources(OslcClient client, URI uri, EntityType<Collection<T>> entityType)
An Accept
header is set to application/rdf+xml
, as this is the most frequently used exchange format.
client
- the REST client used to execute a request.uri
- the URI used for the underlying request.entityType
- the entityType specifying the Collection
of artifacts to extract from the request executionpublic GetResources(OslcClient client, URI uri, EntityType<Collection<T>> entityType, MediaType acceptType)
client
- the REST client used to execute a request.uri
- the URI used for the underlying request.entityType
- the entityType specifying the Collection of artifacts to extract from the request executionacceptType
- the MediaType to use as the accept
headerprotected ClientResponse call(OslcResource resource)
AbstractResourceRequest
call
in class AbstractResourceRequest<ResourceResponse<Collection<T>>>
resource
- the resource on which to execute a request.protected ResourceResponse<Collection<T>> createResponse(OslcResource resource, ClientResponse response)
ResourceResponse
instance from the obtained HTTP response.
The response contains the response headers, from which the ETag
header can be extracted in case this request is to follow by a
PUT
.createResponse
in class AbstractResourceRequest<ResourceResponse<Collection<T>>>
resource
- the resource on which a request is executed.response
- the response obtained.public Collection<T> get()
myRequest.call().getEntity()
.