Package com.sodius.oslc.client.requests
Class UpdateResource<T extends IExtendedResource>
- java.lang.Object
-
- com.sodius.oslc.client.requests.UpdateResource<T>
-
- Type Parameters:
T
- the type of entity to send as PUT payload and to extract from the request execution.
- All Implemented Interfaces:
ResourceRequest<ResourceResponse<T>>
,Callable<ResourceResponse<T>>
public class UpdateResource<T extends IExtendedResource> extends Object implements ResourceRequest<ResourceResponse<T>>
Updates properties on an OSLC resource. Execution flow is the following:- A GET request is executed to obtain the original state of the resource.
- The consumer given in the constructor is called with the resource as argument, to change the desired properties.
- A PUT request is executed to apply the desired changes.
- If changes are requested to be verified, a comparison is made with the result of the PUT
to detect properties that were not modified by the server. The default behaviour is to not verify changes.
This involves an additional GET request if the PUT response does not contain a body.
The properties that were not modified by the server are available in
getDiscardedProperties()
.
- Since:
- 3.13.0
-
-
Constructor Summary
Constructors Constructor Description UpdateResource(OslcClient client, URI uri, Class<T> type, Consumer<T> action)
Creates a new instance to execute a PUT on the specified resource to modify its properties.UpdateResource(OslcClient client, URI uri, Class<T> type, Consumer<T> action, boolean verifyChanges, MediaType contentType)
Creates a new instance to execute a PUT on the specified resource to modify its properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceResponse<T>
call()
Executes the request and parse the response content in the specified format.Collection<URI>
getDiscardedProperties()
Returns the list of property definitions that were not updated although they were requested to.
-
-
-
Constructor Detail
-
UpdateResource
public UpdateResource(OslcClient client, URI uri, Class<T> type, Consumer<T> action)
Creates a new instance to execute a PUT on the specified resource to modify its properties.A
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.type
- the type of entity to updateaction
- a consumer performing the modifications on the resource
-
UpdateResource
public UpdateResource(OslcClient client, URI uri, Class<T> type, Consumer<T> action, boolean verifyChanges, MediaType contentType)
Creates a new instance to execute a PUT on the specified resource to modify its properties.- Parameters:
client
- the REST client used to execute a request.uri
- the URI used for the underlying request.type
- the type of entity to updateaction
- a consumer performing the modifications on the resourceverifyChanges
- a boolean to determine whether a verification of the changes is to perform. Non modified properties will be available through getDiscardedProperties()contentType
- theContent-Type
header to send.
-
-
Method Detail
-
call
public ResourceResponse<T> call()
Description copied from interface:ResourceRequest
Executes the request and parse the response content in the specified format. Throws aClientWebException
in case the HTTP response status is not20x
.- Specified by:
call
in interfaceCallable<T extends IExtendedResource>
- Specified by:
call
in interfaceResourceRequest<T extends IExtendedResource>
-
getDiscardedProperties
public Collection<URI> getDiscardedProperties()
Returns the list of property definitions that were not updated although they were requested to. Those properties were silently ignored by the remote server. Reason can be for example that they are not recognized or are read-only. The collection is empty if change verification was not requested.- Returns:
- A collection of property definitions
-
-