Class ODataRequestGeneric
java.lang.Object
com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestGeneric
- All Implemented Interfaces:
ODataRequestExecutable
- Direct Known Subclasses:
ODataRequestAction
,ODataRequestBatch
,ODataRequestCreate
,ODataRequestDelete
,ODataRequestFunction
,ODataRequestRead
,ODataRequestReadByKey
,ODataRequestUpdate
Generic OData request class to provide default features for service requests.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CsrfTokenRetriever
The CSRF token retriever.protected final ODataResourcePath
TheODataResourcePath
that identifies the OData resource to operate on.protected final String
The service path of the targeted OData service. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a header to the OData HTTP request.void
addHeaderIfAbsent
(String key, String value) Add a header to the OData HTTP request, if it is not included already.void
addListener
(ODataRequestListener listener) Attach a listener to the request process.void
addQueryParameter
(String key, String value) Add a query parameter to the HTTP request.protected boolean
boolean
Get the list of headers that will be sent with this request.protected List<ODataRequestListener>
List of listeners to observe and react on OData actions.The OData protocol version of this request.Map of additional generic HTTP query parameters.Get the static request URI of the OData resource.abstract URI
getRelativeUri
(UriEncodingStrategy uriEncodingStrategy) Get the static request URI of the OData resource.Use all OData query information to construct a HTTP request query String.protected ODataResourcePath
TheODataResourcePath
that identifies the OData resource to operate on.The service path of the targeted OData service.int
hashCode()
void
setCsrfTokenRetriever
(CsrfTokenRetriever csrfTokenRetriever) The CSRF token retriever.void
Replace a header in the OData HTTP request.void
setHeader
(String key, Collection<String> values) Replace a header with multiple values in the OData HTTP request.protected io.vavr.control.Try<ODataRequestResultGeneric>
tryExecute
(Supplier<org.apache.http.HttpResponse> httpOperation, org.apache.http.client.HttpClient httpClient) Internal execute method.protected io.vavr.control.Try<ODataRequestResultGeneric>
tryExecuteWithCsrfToken
(org.apache.http.client.HttpClient httpClient, Supplier<org.apache.http.HttpResponse> httpOperation) Internal execute method.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestExecutable
execute
-
Field Details
-
servicePath
The service path of the targeted OData service. E.g.sap/opu/odata/sap/API_BUSINESS_PARTNER
-
resourcePath
TheODataResourcePath
that identifies the OData resource to operate on. E.g./BusinessPartner('123')/BusinessPartnerAddress(456)
. -
csrfTokenRetriever
The CSRF token retriever.
-
-
Method Details
-
getRelativeUri
Get the static request URI of the OData resource.- Parameters:
uriEncodingStrategy
- URI encoding strategy.- Returns:
- The String representation of the request URI.
-
getRelativeUri
Get the static request URI of the OData resource.- Returns:
- The String representation of the request URI.
-
getRequestQuery
Use all OData query information to construct a HTTP request query String.- Returns:
- The request query.
-
addListener
Attach a listener to the request process.- Parameters:
listener
- The listener to react on OData request actions.
-
setHeader
Replace a header in the OData HTTP request.- Parameters:
key
- The header name.value
- The header value.
-
setHeader
Replace a header with multiple values in the OData HTTP request.- Parameters:
key
- The header name.values
- The header values.- Since:
- 4.27.0
-
addHeader
Add a header to the OData HTTP request.- Parameters:
key
- The header name.value
- The header value.
-
addHeaderIfAbsent
Add a header to the OData HTTP request, if it is not included already.- Parameters:
key
- The header name.value
- The header value.
-
addQueryParameter
Add a query parameter to the HTTP request. The value must be encoded.- Parameters:
key
- The parameter key.value
- The encoded parameters value.
-
tryExecute
@Nonnull protected io.vavr.control.Try<ODataRequestResultGeneric> tryExecute(@Nonnull Supplier<org.apache.http.HttpResponse> httpOperation, @Nonnull org.apache.http.client.HttpClient httpClient) Internal execute method. It will perform the given httpOperation on the given request and ensure a healthy HTTP response code. Failures will always be a subtype ofODataException
- Parameters:
httpOperation
- The HTTP operation to perform, e.g.ODataHttpRequest.requestGet()
httpClient
- The HTTP client instance that is being used to perform the operation.- Returns:
- A
Try
containing either a successfulODataRequestResultGeneric
or anODataException
.
-
tryExecuteWithCsrfToken
@Nonnull protected io.vavr.control.Try<ODataRequestResultGeneric> tryExecuteWithCsrfToken(@Nonnull org.apache.http.client.HttpClient httpClient, @Nonnull Supplier<org.apache.http.HttpResponse> httpOperation) Internal execute method. It will attempt to retrieve a CSRF token before issuing the actual request viatryExecute(Supplier, HttpClient)
.CSRF token retrieval is skipped, if a token is already present. The actual request is performed regardless whether or not a CSRF token was retrieved.
- Parameters:
httpClient
- AnHttpClient
to execute the CSRF token retrieval.httpOperation
- The HTTP operation to perform, e.g.ODataHttpRequest.requestGet()
- Returns:
- A
Try
containing either a successfulODataRequestResultGeneric
or anODataException
.
-
getHeaders
Get the list of headers that will be sent with this request. To add headers, please useaddHeader
andaddHeaderIfAbsent
- Returns:
- The list of headers.
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getServicePath
The service path of the targeted OData service. E.g.sap/opu/odata/sap/API_BUSINESS_PARTNER
-
getResourcePath
TheODataResourcePath
that identifies the OData resource to operate on. E.g./BusinessPartner('123')/BusinessPartnerAddress(456)
. -
getProtocol
The OData protocol version of this request. -
getListeners
List of listeners to observe and react on OData actions. -
getQueryParameters
Map of additional generic HTTP query parameters. -
setCsrfTokenRetriever
The CSRF token retriever.
-