Class ActionRequestBuilder<BuilderT extends ActionRequestBuilder<BuilderT,ResultT>,ResultT>

java.lang.Object
com.sap.cloud.sdk.datamodel.odatav4.core.ActionRequestBuilder<BuilderT,ResultT>
Type Parameters:
BuilderT - The request builder type.
ResultT - The type of the result, if any.
All Implemented Interfaces:
ModificationRequestBuilder<ResultT>, RequestBuilder<ResultT>, RequestBuilderExecutable<ResultT>
Direct Known Subclasses:
CollectionValueActionRequestBuilder, SingleValueActionRequestBuilder

public abstract class ActionRequestBuilder<BuilderT extends ActionRequestBuilder<BuilderT,ResultT>,ResultT> extends Object implements ModificationRequestBuilder<ResultT>
Representation of an Action OData request as a fluent interface for further configuring the request and executing it.
  • Field Details

  • Constructor Details

    • ActionRequestBuilder

      public ActionRequestBuilder(@Nonnull String servicePath, @Nonnull String actionName)
      Instantiates this request builder using the given service path to send the requests.
      Parameters:
      servicePath - The service path to direct the requests to.
      actionName - The name of the unbound action
    • ActionRequestBuilder

      public ActionRequestBuilder(@Nonnull String servicePath, @Nonnull String actionName, @Nonnull Map<String,Object> parameters)
      Instantiates this request builder using the given service path to send the requests.
      Parameters:
      servicePath - The service path to direct the requests to.
      actionName - The name of the unbound action.
      parameters - The parameters passed to the function.
    • ActionRequestBuilder

      public ActionRequestBuilder(@Nonnull String servicePath, @Nonnull ODataResourcePath actionPath, @Nonnull Map<String,Object> parameters)
      Instantiates this request builder using the given service path to send the requests.
      Parameters:
      servicePath - The service path to direct the requests to.
      actionPath - The path to the unbound action.
      parameters - The parameters passed to the function.
  • Method Details

    • toRequest

      @Nonnull public ODataRequestAction toRequest()
      Creates an instance of ODataRequestAction based on the Entity class.

      The following settings are used:

      • the endpoint URL
      • the action name
      • the parameters if applicable as JSON string
      Specified by:
      toRequest in interface RequestBuilder<BuilderT extends ActionRequestBuilder<BuilderT,ResultT>>
      Returns:
      An initialized ODataRequestFunction.
    • withoutCsrfToken

      @Nonnull public ModificationRequestBuilder<ResultT> withoutCsrfToken()
      Deactivates 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:
      withoutCsrfToken in interface ModificationRequestBuilder<BuilderT extends ActionRequestBuilder<BuilderT,ResultT>>
      Returns:
      The same builder
    • getThis

      @Nonnull protected BuilderT getThis()
      Get the reference to this instance.
      Returns:
      The FluentHelper instance.
    • withListener

      @Nonnull public BuilderT withListener(@Nonnull ODataRequestListener listener)
      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 the execute method. 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 BuilderT withHeader(@Nonnull String key, @Nullable String value)
      Description copied from interface: RequestBuilder
      Gives 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:
      withHeader in interface RequestBuilder<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

      @Nonnull public BuilderT withHeaders(@Nonnull Map<String,String> map)
      Description copied from interface: RequestBuilder
      Gives 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:
      withHeaders in interface RequestBuilder<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 BuilderT 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 $search to 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

      @Nonnull protected String getServicePath()
    • getResourcePath

      @Nonnull protected ODataResourcePath getResourcePath()
    • getHeaders

      @Nonnull protected Map<String,Collection<String>> getHeaders()
      A map containing the headers to be used only for the actual request of this FluentHelper implementation.
    • getParametersForRequestOnly

      @Nonnull protected Map<String,String> getParametersForRequestOnly()
      A map containing the custom query parameters to be used only for the actual request of this FluentHelper implementation.
    • getListeners

      @Nonnull protected List<ODataRequestListener> getListeners()