Class HttpRestRequest
- java.lang.Object
-
- net.webpdf.wsclient.session.connection.http.HttpRestRequest
-
public class HttpRestRequest extends Object
An instance ofHttpRestRequestmonitors and executes a webPDF wsclient request executed within aRestSessionand handles the server´s response.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull HttpRestRequestbuildRequest(@NotNull HttpMethod httpMethod, @NotNull String path)Prepare theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).@NotNull HttpRestRequestbuildRequest(@NotNull HttpMethod httpMethod, @NotNull String path, @Nullable org.apache.hc.core5.http.HttpEntity httpEntity)Prepare theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).@NotNull HttpRestRequestbuildRequest(@NotNull HttpMethod httpMethod, @NotNull String path, @Nullable org.apache.hc.core5.http.HttpEntity httpEntity, @Nullable AuthMaterial authMaterial)Prepare theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).@NotNull HttpRestRequestbuildRequest(@NotNull HttpMethod httpMethod, @NotNull URI uri)Prepare theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).@NotNull HttpRestRequestbuildRequest(@NotNull HttpMethod httpMethod, @NotNull URI uri, @Nullable org.apache.hc.core5.http.HttpEntity httpEntity)Prepare theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).@NotNull HttpRestRequestbuildRequest(@NotNull HttpMethod httpMethod, @NotNull URI uri, @Nullable org.apache.hc.core5.http.HttpEntity httpEntity, @Nullable AuthMaterial authMaterial)Prepare theHttpRestRequestto execute the selectedHttpMethodon the given (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).static @NotNull HttpRestRequestcreateRequest(@NotNull RestSession<?> session)Creates aHttpRestRequestpreparing and executing a request for a givenRestSessionto provide a matching response object.org.apache.hc.core5.http.ClassicHttpResponseexecuteRequest()Executes thisHttpRestRequest.voidexecuteRequest(@NotNull OutputStream outputStream)Executes thisHttpRestRequestand shall write the contained data transfer objectHttpEntityto the givenOutputStream.<T> TexecuteRequest(@NotNull Class<T> type)ExecutesHttpRestRequestand shall attempt to translate the response´s data transfer object (HttpEntity) to an instance of the given type.@NotNull HttpRestRequestsetAcceptHeader(@NotNull String mimeType)Selects the MIME type of the data transfer object (HttpEntity) that shall be accepted as a valid response payload for thisHttpRestRequest.@NotNull HttpRestRequestsetAdditionalHeader(String key, String value)sets an additionalHttpHeadersfor thisHttpRestRequest
-
-
-
Method Detail
-
createRequest
@NotNull public static @NotNull HttpRestRequest createRequest(@NotNull @NotNull RestSession<?> session)
Creates aHttpRestRequestpreparing and executing a request for a givenRestSessionto provide a matching response object.- Parameters:
session- theRestSessionthis Rest request is handling.- Returns:
- A
HttpRestRequestpreparing and executing a request for a givenRestSessionto provide a matching response object.
-
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 thisHttpRestRequest.- Parameters:
mimeType- The MIME type of the transfer data object that shall be accepted as a valid response payload for thisHttpRestRequest.- Returns:
- The
HttpRestRequestinstance itself.
-
setAdditionalHeader
@NotNull public @NotNull HttpRestRequest setAdditionalHeader(String key, String value)
sets an additionalHttpHeadersfor thisHttpRestRequest- Parameters:
key- TheHttpHeadersto setvalue- The value of the header- Returns:
- The
HttpRestRequestinstance itself.
-
buildRequest
@NotNull public @NotNull HttpRestRequest buildRequest(@NotNull @NotNull HttpMethod httpMethod, @NotNull @NotNull String path) throws ResultException
Prepare theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).- Parameters:
httpMethod- TheHttpMethodto execute.path- The resource path (URI) to execute the request on.- Returns:
- The
HttpRestRequestinstance itself. - Throws:
ResultException- Shall be thrown, if creating initializing theHttpRestRequestfailed 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) throws ResultException
Prepare theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).- Parameters:
httpMethod- TheHttpMethodto execute.path- The resource path (URI) to execute the request on.httpEntity- The data transfer objectHttpEntityto include in the request´s content.- Returns:
- The
HttpRestRequestinstance itself. - Throws:
ResultException- Shall be thrown, if creating initializing theHttpRestRequestfailed 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 theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).- Parameters:
httpMethod- TheHttpMethodto execute.path- The resource path (URI) to execute the request on.httpEntity- The data transfer objectHttpEntityto include in the request´s content.authMaterial- TheAuthMaterialto use for authorization.- Returns:
- The
HttpRestRequestinstance itself. - Throws:
ResultException- Shall be thrown, if creating initializing theHttpRestRequestfailed 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 theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).- Parameters:
httpMethod- TheHttpMethodto execute.uri- The resource path (URI) to execute the request on.httpEntity- The data transfer objectHttpEntityto include in the request´s content.- Returns:
- The
HttpRestRequestinstance itself. - Throws:
ResultException- Shall be thrown, if creating initializing theHttpRestRequestfailed for the given parameters.
-
buildRequest
@NotNull public @NotNull HttpRestRequest buildRequest(@NotNull @NotNull HttpMethod httpMethod, @NotNull @NotNull URI uri) throws ResultException
Prepare theHttpRestRequestto execute the selectedHttpMethodon the given resource path (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).- Parameters:
httpMethod- TheHttpMethodto execute.uri- The resource path (URI) to execute the request on.- Returns:
- The
HttpRestRequestinstance itself. - Throws:
ResultException- Shall be thrown, if creating initializing theHttpRestRequestfailed 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 theHttpRestRequestto execute the selectedHttpMethodon the given (URI) and providing the givenHttpEntityas it´s data transfer object (parameters).- Parameters:
httpMethod- TheHttpMethodto execute.uri- The resource (URI) to execute the request on.httpEntity- The data transfer objectHttpEntityto include in the request´s content.authMaterial- TheAuthMaterialto use for authorization.- Returns:
- The
HttpRestRequestinstance itself. - Throws:
ResultException- Shall be thrown, if creating initializing theHttpRestRequestfailed for the given parameters.
-
executeRequest
public void executeRequest(@NotNull @NotNull OutputStream outputStream) throws ResultExceptionExecutes thisHttpRestRequestand shall write the contained data transfer objectHttpEntityto the givenOutputStream.- Parameters:
outputStream- TheOutputStreamto write the data transfer objectHttpEntityto.- Throws:
ResultException- Shall be thrown, if writing to theOutputStreamfailed.
-
executeRequest
public org.apache.hc.core5.http.ClassicHttpResponse executeRequest() throws ResultExceptionExecutes thisHttpRestRequest.- Returns:
- The resulting
ClassicHttpResponse. - Throws:
ResultException- Shall be thrown, if writing to theOutputStreamfailed.
-
executeRequest
@Nullable public <T> T executeRequest(@NotNull @NotNull Class<T> type) throws ResultExceptionExecutes
HttpRestRequestand shall attempt to translate the response´s data transfer object (HttpEntity) to an instance of the given type.The resulting intermediate
HttpResponseshall be checked viacheckResponse(ClassicHttpResponse)}.- Parameters:
type- The type to translate the data transfer objectHttpEntityto.- Returns:
- The resulting data transfer object
HttpEntitytranslated to an instance of the given type. - Throws:
ResultException- Shall be thrown, should theHttpResponsenot be readable or should it´s validation viacheckResponse(ClassicHttpResponse)fail.
-
-