Package com.sodius.oslc.client.requests
Class PostResource<T,R>
- java.lang.Object
-
- com.sodius.oslc.client.requests.AbstractResourceRequest<ResourceResponse<R>>
-
- com.sodius.oslc.client.requests.PostResource<T,R>
-
- Type Parameters:
T
- the type of entity to send as POST payload.R
- the type of response to extract from the request execution.
- All Implemented Interfaces:
ResourceRequest<ResourceResponse<R>>
,Callable<ResourceResponse<R>>
- Direct Known Subclasses:
CreateUserGroup
public class PostResource<T,R> extends AbstractResourceRequest<ResourceResponse<R>>
Executes a POST request on a OSLC resource.
An
OSLC-Core-Version
header is set to2.0
, as the POST is expected to execute on an OSLC resource. Clients should subclassAbstractResourceRequest
to execute a POST on a non-OSLC resource.- Since:
- 1.1.0
-
-
Constructor Summary
Constructors Constructor Description PostResource(OslcClient client, URI uri, T entity)
Creates a new instance to execute a POST on the specified resource.PostResource(OslcClient client, URI uri, T entity, MediaType contentType)
Creates a new instance to execute a POST on the specified resource.PostResource(OslcClient client, URI uri, T entity, MediaType contentType, Class<R> resultType, MediaType acceptType)
Creates a new instance to execute a POST on the specified resource and to parse the entity from the response.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ClientResponse
call(OslcResource resource)
Executes a POST request on the resource.protected ResourceResponse<R>
createResponse(OslcResource resource, ClientResponse response)
Extracts aResourceResponse
instance from the obtained HTTP response.-
Methods inherited from class com.sodius.oslc.client.requests.AbstractResourceRequest
call, createErrorResponse, createResourceResponse, getClient, getUri
-
-
-
-
Constructor Detail
-
PostResource
public PostResource(OslcClient client, URI uri, T entity)
Creates a new instance to execute a POST on the specified resource. This constructor shall be used when no entity is expected in the response content.An
Content-Type
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.entity
- the entity to send as POST payload.
-
PostResource
public PostResource(OslcClient client, URI uri, T entity, MediaType contentType)
Creates a new instance to execute a POST on the specified resource. This constructor shall be used when no entity is expected in the response content.- Parameters:
client
- the REST client used to execute a request.uri
- the URI used for the underlying request.entity
- the entity to send as POST payload.contentType
- theContent-Type
header to send.
-
PostResource
public PostResource(OslcClient client, URI uri, T entity, MediaType contentType, Class<R> resultType, MediaType acceptType)
Creates a new instance to execute a POST on the specified resource and to parse the entity from the response.- Parameters:
client
- the REST client used to execute a request.uri
- the URI used for the underlying request.entity
- the entity to send as POST payload.contentType
- theContent-Type
header to send.resultType
- the type of entity to extract from the responseacceptType
- theAccept
header to send, which describes the expected response entity format.
-
-
Method Detail
-
call
protected ClientResponse call(OslcResource resource)
Executes a POST request on the resource.An
OSLC-Core-Version
header is set to2.0
, as the POST is expected to execute on an OSLC resource. Clients should subclassAbstractResourceRequest
to execute a POST on a non-OSLC resource.- Specified by:
call
in classAbstractResourceRequest<ResourceResponse<R>>
- Parameters:
resource
- the resource on which to execute a request.- Returns:
- the response of the request execution.
-
createResponse
protected ResourceResponse<R> createResponse(OslcResource resource, ClientResponse response)
Extracts aResourceResponse
instance from the obtained HTTP response.If the specified response type is
null
orVoid.class
, this method does not try to parse the entity from the response and returns just the response headers in aResourceResponse
instance.- Specified by:
createResponse
in classAbstractResourceRequest<ResourceResponse<R>>
- 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.
-
-