Class PutResource<T,R>

Type Parameters:
T - the type of entity to send as PUT payload.
R - the type of response to extract from the request execution.
All Implemented Interfaces:
ResourceRequest<ResourceResponse<R>>, Callable<ResourceResponse<R>>
Direct Known Subclasses:
UpdateDataGroupPermissions, UpdateUserGroupMembers

public class PutResource<T,R> extends AbstractResourceRequest<ResourceResponse<R>>

Executes a PUT request on a OSLC resource.

An OSLC-Core-Version header is set to 2.0, as the PUT is expected to execute on an OSLC resource. Clients should subclass AbstractResourceRequest to execute a PUT on a non-OSLC resource.

Since:
1.1.0
  • Constructor Details

    • PutResource

      public PutResource(OslcClient client, URI uri, String eTag, T entity)
      Creates a new instance to execute a PUT on the specified resource. This constructor shall be used when no entity is expected in the response content.

      An Content-Type header is set to application/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.
      eTag - the ETag to send as PUT header.
      entity - the entity to send as PUT payload.
    • PutResource

      public PutResource(OslcClient client, URI uri, String eTag, T entity, MediaType contentType)
      Creates a new instance to execute a PUT 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.
      eTag - the ETag to send as PUT header.
      entity - the entity to send as PUT payload.
      contentType - the Content-Type header to send.
    • PutResource

      public PutResource(OslcClient client, URI uri, String eTag, T entity, MediaType contentType, Class<R> resultType, MediaType acceptType)
      Creates a new instance to execute a PUT 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.
      eTag - the ETag to send as PUT header.
      entity - the entity to send as PUT payload.
      contentType - the Content-Type header to send.
      resultType - the type of entity to extract from the response
      acceptType - the Accept header to send, which describes the expected response entity format.
  • Method Details

    • call

      protected ClientResponse call(OslcResource resource)
      Executes a PUT request on the resource.

      An OSLC-Core-Version header is set to 2.0, as the PUT is expected to execute on an OSLC resource. Clients should subclass AbstractResourceRequest to execute a PUT on a non-OSLC resource.

      Specified by:
      call in class AbstractResourceRequest<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 a 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.

      Specified by:
      createResponse in class AbstractResourceRequest<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.