Package com.sodius.oslc.client.requests
Class GetResource<T>
- java.lang.Object
-
- com.sodius.oslc.client.requests.AbstractResourceRequest<ResourceResponse<T>>
-
- com.sodius.oslc.client.requests.GetResource<T>
-
- Type Parameters:
T
- the type of response to extract from the request execution.
- All Implemented Interfaces:
ResourceRequest<ResourceResponse<T>>
,Callable<ResourceResponse<T>>
- Direct Known Subclasses:
GetBaseline
,GetCompact
,GetComponent
,GetConfiguration
,GetDataGroupPermissions
,GetPublisher
,GetResourceShape
,GetServiceProvider
,GetServiceProviderCatalog
,GetStream
,GetUserGroup
public class GetResource<T> extends AbstractResourceRequest<ResourceResponse<T>>
Executes a GET request on an OSLC resource.
An
OSLC-Core-Version
header is set to2.0
, as the GET is expected to execute on an OSLC resource. Clients should subclassAbstractResourceRequest
to execute a GET on a non-OSLC resource.- Since:
- 1.1.0
-
-
Constructor Summary
Constructors Constructor Description GetResource(OslcClient client, URI uri, Class<T> type)
Creates a new instance to execute a GET on the specified resource.GetResource(OslcClient client, URI uri, Class<T> type, MediaType acceptType)
Creates a new instance to execute a GET on the specified resource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ClientResponse
call(OslcResource resource)
Executes a GET request on the resource.protected ResourceResponse<T>
createResponse(OslcResource resource, ClientResponse response)
Extracts aResourceResponse
instance from the obtained HTTP response.T
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 Detail
-
GetResource
public GetResource(OslcClient client, URI uri, Class<T> type)
Creates a new instance to execute a GET on the specified resource.An
Accept
header 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.type
- the type of response to extract from the request execution
-
GetResource
public GetResource(OslcClient client, URI uri, Class<T> type, MediaType acceptType)
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.acceptType
- the value of theAccept
headers to use.type
- the type of response to extract from the request execution
-
-
Method Detail
-
call
protected ClientResponse call(OslcResource resource)
Executes a GET request on the resource.An
OSLC-Core-Version
header is set to2.0
, as the GET is expected to execute on an OSLC resource. Clients should subclassAbstractResourceRequest
to execute a GET on a non-OSLC resource.- Specified by:
call
in classAbstractResourceRequest<ResourceResponse<T>>
- Parameters:
resource
- the resource on which to execute a request.- Returns:
- the response of the request execution.
-
get
public T 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.
-
createResponse
protected ResourceResponse<T> createResponse(OslcResource resource, ClientResponse response)
Extracts aResourceResponse
instance from the obtained HTTP response. The response contains the response headers, from which theETag
header can be extracted in case this request is to follow by aPUT
.- Specified by:
createResponse
in classAbstractResourceRequest<ResourceResponse<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.
-
-