T
- the type of entity to send as POST payload.R
- the type of response to extract from the request execution.public class PostResource<T,R> extends AbstractResourceRequest<ResourceResponse<R>>
Executes a POST request on a OSLC resource.
An OSLC-Core-Version
header is set to 2.0
, as the POST is expected to execute on an OSLC resource. Clients should
subclass AbstractResourceRequest
to execute a POST on a non-OSLC resource.
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
protected ClientResponse |
call(OslcResource resource)
Executes a POST request on the resource.
|
protected ResourceResponse<R> |
createResponse(OslcResource resource,
ClientResponse response)
Extracts a
ResourceResponse instance from the obtained HTTP response. |
call, createErrorResponse, createResourceResponse, getClient, getUri
public PostResource(OslcClient client, URI uri, T entity)
An Content-Type
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.entity
- the entity to send as POST payload.public PostResource(OslcClient client, URI uri, T entity, MediaType contentType)
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
- the Content-Type
header to send.public PostResource(OslcClient client, URI uri, T entity, MediaType contentType, Class<R> resultType, MediaType acceptType)
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
- the Content-Type
header to send.resultType
- the type of entity to extract from the responseacceptType
- the Accept
header to send, which describes the expected response entity format.protected ClientResponse call(OslcResource resource)
An OSLC-Core-Version
header is set to 2.0
, as the POST is expected to execute on an OSLC resource. Clients should
subclass AbstractResourceRequest
to execute a POST on a non-OSLC resource.
call
in class AbstractResourceRequest<ResourceResponse<R>>
resource
- the resource on which to execute a request.protected ResourceResponse<R> createResponse(OslcResource resource, ClientResponse response)
ResourceResponse
instance from the obtained HTTP response.
If the specified response type is null
or Void.class
, this method does not try to parse the entity from the response
and returns just the response headers in a ResourceResponse
instance.
createResponse
in class AbstractResourceRequest<ResourceResponse<R>>
resource
- the resource on which a request is executed.response
- the response obtained.