Class UpdateResource<T extends IExtendedResource>

  • 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:
    1. A GET request is executed to obtain the original state of the resource.
    2. The consumer given in the constructor is called with the resource as argument, to change the desired properties.
    3. A PUT request is executed to apply the desired changes.
    4. 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 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 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.
        type - the type of entity to update
        action - 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 update
        action - a consumer performing the modifications on the resource
        verifyChanges - a boolean to determine whether a verification of the changes is to perform. Non modified properties will be available through getDiscardedProperties()
        contentType - the Content-Type header to send.
    • Method Detail

      • 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