Class UpdateRequestBuilder<EntityT extends VdmEntity<?>>
- Type Parameters:
EntityT- The type of the result entity.
- All Implemented Interfaces:
ModificationRequestBuilder<ModificationResponse<EntityT>>,RequestBuilder<ModificationResponse<EntityT>>,RequestBuilderExecutable<ModificationResponse<EntityT>>
executing it.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionUpdateRequestBuilder(String servicePath, EntityT entity, String entityCollection) Instantiate anUpdateRequestBuilder. -
Method Summary
Modifier and TypeMethodDescriptionThe update request will ignore any version identifier present on the entity and not send an `If-Match` header.final UpdateRequestBuilder<EntityT>excludingFields(FieldReference... fields) Allows to explicitly specify entity fields that should not be sent in an update request.execute(Destination destination) Execute the OData update request for the provided entity.protected EntityTThe entity object to be updated by calling theexecute(Destination)method.Returns a class object of the type this request builder works with.protected Map<String,Collection<String>> A map containing the headers to be used only for the actual request of this FluentHelper implementation.protected List<ODataRequestListener>A map containing the custom query parameters to be used only for the actual request of this FluentHelper implementation.protected ODataResourcePathprotected Stringprotected UpdateRequestBuilder<EntityT>getThis()Get the reference to this instance.final UpdateRequestBuilder<EntityT>includingFields(FieldReference... fields) Allows to explicitly specify entity fields that shall be sent in an update request regardless if the values of these fields have been changed.The update request will ignore any version identifier present on the entity and update the entity, regardless of any changes on the remote entity.final UpdateRequestBuilder<EntityT>Allows to control that the request to update the entity is sent with the HTTP method PATCH and its payload contains the changed fields only.final UpdateRequestBuilder<EntityT>Allows to control that the request to update the entity is sent with the HTTP method PUT and its payload contains all fields of the entity, regardless which of them have been changed.Creates an instance of theODataRequestUpdatebased on the Entity class.withHeader(String key, String value) Gives the option to specify custom HTTP headers.withHeaders(Map<String, String> map) Gives the option to specify a map of custom HTTP headers.withListener(ODataRequestListener listener) An error handling class that implements the error result handler interface can be attached to this request builder.Deactivates the CSRF token retrieval for this OData request.withQueryParameter(String key, String value) Gives the option to specify custom query parameters for the request.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sap.cloud.sdk.datamodel.odatav4.core.RequestBuilder
withHeader, withHeadersMethods inherited from interface com.sap.cloud.sdk.datamodel.odatav4.core.RequestBuilderExecutable
tryExecute
-
Field Details
-
csrfTokenRetriever
A token retriever.
-
-
Constructor Details
-
Method Details
-
getEntityClass
Returns a class object of the type this request builder works with.- Returns:
- A class object of the handled type.
-
execute
Execute the OData update request for the provided entity. Execute the OData request.- Specified by:
executein interfaceRequestBuilderExecutable<EntityT extends VdmEntity<?>>- Parameters:
destination- The destination to be used as request target.- Returns:
- The wrapped service response, exposing response headers, status code and entity references. If the HTTP response is not within healthy bounds, then one of the declared runtime exceptions will be thrown with further details.
-
toRequest
Creates an instance of theODataRequestUpdatebased on the Entity class.The following settings are used to build the Request Builder:
- the endpoint URL
- the entity collection name
- the key fields of the entity
- the entity JSON payload
- the update strategy (full update or delta)
- Specified by:
toRequestin interfaceRequestBuilder<EntityT extends VdmEntity<?>>- Returns:
- An initialized
ODataRequestUpdate. - Throws:
ODataSerializationException- If entity cannot be serialized for HTTP request.
-
includingFields
@Nonnull public final UpdateRequestBuilder<EntityT> includingFields(@Nonnull FieldReference... fields) Allows to explicitly specify entity fields that shall be sent in an update request regardless if the values of these fields have been changed. This is helpful in case the API requires to send certain fields in any case in an update request.- Parameters:
fields- The fields to be included in the update execution.- Returns:
- The same request builder which will include the specified fields in an update request.
-
excludingFields
@Nonnull public final UpdateRequestBuilder<EntityT> excludingFields(@Nonnull FieldReference... fields) Allows to explicitly specify entity fields that should not be sent in an update request. This is helpful in case some services require no read only fields to be sent for update requests. These fields are only excluded in a PUT request, they are not considered in a PATCH request.- Parameters:
fields- The fields to be excluded in the update execution.- Returns:
- The same request builder which will exclude the specified fields in an update request.
-
replacingEntity
Allows to control that the request to update the entity is sent with the HTTP method PUT and its payload contains all fields of the entity, regardless which of them have been changed.- Returns:
- The same request builder which will replace the entity in the remote system
-
modifyingEntity
Allows to control that the request to update the entity is sent with the HTTP method PATCH and its payload contains the changed fields only.- Returns:
- The same request builder which will modify the entity in the remote system.
-
disableVersionIdentifier
The update request will ignore any version identifier present on the entity and not send an `If-Match` header.Warning: This might lead to a response from the remote system that the `If-Match` header is missing.
It depends on the implementation of the remote system whether the `If-Match` header is expected.
- Returns:
- The same request builder that will not send the `If-Match` header in the update request
-
matchAnyVersionIdentifier
The update request will ignore any version identifier present on the entity and update the entity, regardless of any changes on the remote entity.Warning: Be careful with this option, as this might overwrite any changes made to the remote representation of this object.
- Returns:
- The same request builder that will ignore the version identifier of the entity to update
-
withoutCsrfToken
Description copied from interface:ModificationRequestBuilderDeactivates the CSRF token retrieval for this OData request. This is useful if the server does not support or require CSRF tokens as part of the request.- Specified by:
withoutCsrfTokenin interfaceModificationRequestBuilder<EntityT extends VdmEntity<?>>- Returns:
- The same builder
-
getEntity
The entity object to be updated by calling theexecute(Destination)method. -
getThis
Get the reference to this instance.- Returns:
- The FluentHelper instance.
-
withListener
An error handling class that implements the error result handler interface can be attached to this request builder. This allows custom logic to be called when an error occurs in theexecutemethod. If this method is not called, then an instance of ODataRequestListener is used. Only one handler can be attached at a time per request builder object, so calling this multiple times will replace the handler.- Parameters:
listener- Instance of an error handler class that implements the error result handler interface.- Returns:
- The same request builder with its error handler set to the provided object.
-
withHeader
@Nonnull public UpdateRequestBuilder<EntityT> withHeader(@Nonnull String key, @Nullable String value) Description copied from interface:RequestBuilderGives the option to specify custom HTTP headers. Multiple headers with the same key can be specified. The returned object allows to specify the requests the headers should be used in.- Specified by:
withHeaderin interfaceRequestBuilder<BuilderT extends RequestBuilder<ResultT>>- Parameters:
key- Name of the (first) desired HTTP header parameter.value- Value of the (first) desired HTTP header parameter.- Returns:
- A request builder to specify further headers and their intended usage.
-
withHeaders
Description copied from interface:RequestBuilderGives the option to specify a map of custom HTTP headers. The returned object allows to specify the requests the headers should be used in.- Specified by:
withHeadersin interfaceRequestBuilder<BuilderT extends RequestBuilder<ResultT>>- Parameters:
map- A map of HTTP header key/value pairs.- Returns:
- A request builder to specify further headers and their intended usage.
-
withQueryParameter
@Nonnull public UpdateRequestBuilder<EntityT> withQueryParameter(@Nonnull String key, @Nullable String value) Gives the option to specify custom query parameters for the request.Note: It is recommended to only use this function for query parameters which are not supported by the VDM by default. Using this function to bypass request builder method calls can lead to unsupported response handling. There is no contract on the order or priority of parameters added to the request.
Example: Use the request query option
$searchto reduce the result set, leaving only entities which match the specified search expression. This feature is supported in protocol OData v4.new DefaultBusinessPartnerService().getAllBusinessPartner().withQueryParameter("$search", "Köln OR Cologne")- Parameters:
key- Name of the query parameter.value- Value of the query parameter.- Returns:
- The same request builder.
-
getServicePath
-
getResourcePath
-
getHeaders
A map containing the headers to be used only for the actual request of this FluentHelper implementation. -
getParametersForRequestOnly
A map containing the custom query parameters to be used only for the actual request of this FluentHelper implementation. -
getListeners
-