Class HttpRestRequest


  • public class HttpRestRequest
    extends Object
    An instance of HttpRestRequest monitors and executes a webPDF wsclient request executed within a RestSession and handles the server´s response.
    • Method Detail

      • setAcceptHeader

        @NotNull
        public @NotNull HttpRestRequest setAcceptHeader​(@NotNull
                                                        @NotNull String mimeType)
        Selects the MIME type of the data transfer object (HttpEntity) that shall be accepted as a valid response payload for this HttpRestRequest.
        Parameters:
        mimeType - The MIME type of the transfer data object that shall be accepted as a valid response payload for this HttpRestRequest.
        Returns:
        The HttpRestRequest instance itself.
      • setAdditionalHeader

        @NotNull
        public @NotNull HttpRestRequest setAdditionalHeader​(String key,
                                                            String value)
        sets an additional HttpHeaders for this HttpRestRequest
        Parameters:
        key - The HttpHeaders to set
        value - The value of the header
        Returns:
        The HttpRestRequest instance itself.
      • buildRequest

        @NotNull
        public @NotNull HttpRestRequest buildRequest​(@NotNull
                                                     @NotNull HttpMethod httpMethod,
                                                     @NotNull
                                                     @NotNull String path,
                                                     @Nullable
                                                     @Nullable org.apache.hc.core5.http.HttpEntity httpEntity)
                                              throws ResultException
        Prepare the HttpRestRequest to execute the selected HttpMethod on the given resource path (URI) and providing the given HttpEntity as it´s data transfer object (parameters).
        Parameters:
        httpMethod - The HttpMethod to execute.
        path - The resource path (URI) to execute the request on.
        httpEntity - The data transfer object HttpEntity to include in the request´s content.
        Returns:
        The HttpRestRequest instance itself.
        Throws:
        ResultException - Shall be thrown, if creating initializing the HttpRestRequest failed for the given parameters.
      • buildRequest

        @NotNull
        public @NotNull HttpRestRequest buildRequest​(@NotNull
                                                     @NotNull HttpMethod httpMethod,
                                                     @NotNull
                                                     @NotNull String path,
                                                     @Nullable
                                                     @Nullable org.apache.hc.core5.http.HttpEntity httpEntity,
                                                     @Nullable
                                                     @Nullable AuthMaterial authMaterial)
                                              throws ResultException
        Prepare the HttpRestRequest to execute the selected HttpMethod on the given resource path (URI) and providing the given HttpEntity as it´s data transfer object (parameters).
        Parameters:
        httpMethod - The HttpMethod to execute.
        path - The resource path (URI) to execute the request on.
        httpEntity - The data transfer object HttpEntity to include in the request´s content.
        authMaterial - The AuthMaterial to use for authorization.
        Returns:
        The HttpRestRequest instance itself.
        Throws:
        ResultException - Shall be thrown, if creating initializing the HttpRestRequest failed for the given parameters.
      • buildRequest

        @NotNull
        public @NotNull HttpRestRequest buildRequest​(@NotNull
                                                     @NotNull HttpMethod httpMethod,
                                                     @NotNull
                                                     @NotNull URI uri,
                                                     @Nullable
                                                     @Nullable org.apache.hc.core5.http.HttpEntity httpEntity)
                                              throws ResultException
        Prepare the HttpRestRequest to execute the selected HttpMethod on the given resource path (URI) and providing the given HttpEntity as it´s data transfer object (parameters).
        Parameters:
        httpMethod - The HttpMethod to execute.
        uri - The resource path (URI) to execute the request on.
        httpEntity - The data transfer object HttpEntity to include in the request´s content.
        Returns:
        The HttpRestRequest instance itself.
        Throws:
        ResultException - Shall be thrown, if creating initializing the HttpRestRequest failed for the given parameters.
      • buildRequest

        @NotNull
        public @NotNull HttpRestRequest buildRequest​(@NotNull
                                                     @NotNull HttpMethod httpMethod,
                                                     @NotNull
                                                     @NotNull URI uri,
                                                     @Nullable
                                                     @Nullable org.apache.hc.core5.http.HttpEntity httpEntity,
                                                     @Nullable
                                                     @Nullable AuthMaterial authMaterial)
                                              throws ResultException
        Prepare the HttpRestRequest to execute the selected HttpMethod on the given (URI) and providing the given HttpEntity as it´s data transfer object (parameters).
        Parameters:
        httpMethod - The HttpMethod to execute.
        uri - The resource (URI) to execute the request on.
        httpEntity - The data transfer object HttpEntity to include in the request´s content.
        authMaterial - The AuthMaterial to use for authorization.
        Returns:
        The HttpRestRequest instance itself.
        Throws:
        ResultException - Shall be thrown, if creating initializing the HttpRestRequest failed for the given parameters.
      • executeRequest

        @Nullable
        public <T> T executeRequest​(@NotNull
                                    @NotNull Class<T> type)
                             throws ResultException

        Executes HttpRestRequest and shall attempt to translate the response´s data transfer object (HttpEntity) to an instance of the given type.

        The resulting intermediate HttpResponse shall be checked via checkResponse(ClassicHttpResponse)}.

        Parameters:
        type - The type to translate the data transfer object HttpEntity to.
        Returns:
        The resulting data transfer object HttpEntity translated to an instance of the given type.
        Throws:
        ResultException - Shall be thrown, should the HttpResponse not be readable or should it´s validation via checkResponse(ClassicHttpResponse) fail.