Package com.sodius.oslc.server.requests
Class WebAppResourceRequest<T>
java.lang.Object
com.sodius.oslc.server.requests.WebAppResourceRequest<T>
- Type Parameters:
T- the type of response to extract from the request execution.
- All Implemented Interfaces:
ResourceRequest<T>,Callable<T>
- Direct Known Subclasses:
GetProxyResource,PutProxyResource
Base class for REST requests executed from the server to another remote server.
The contract is to throw a WebApplicationException for any HTTP responses whose status is not 20x.
You may use:
call(ResourceRequest)to execute a specific requestcall(OslcClientFactory, Function)if an specific OSLC client factory must be usedcall(Supplier, Function)if the instantiation of an OSLC client must be delayedcall(HttpServletRequest, Function)if an incoming HTTP request is available and the OSLC client is to create withOAuthServer.getClientFactory(HttpServletRequest)
WebAppResourceRequest called from multiple places.
Subclasses may call a client ResourceRequest in the overridden call(OslcClient) method. Any client exception that may be
thrown will be caught and changed to a web exception.- Since:
- 1.3.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWebAppResourceRequest(HttpServletRequest request) Instantiates a new request. -
Method Summary
Modifier and TypeMethodDescriptionfinal Tcall()Executes the request and parse the response content in the specified format.protected abstract Tcall(OslcClient client) Executes the request with the specified client.static <T> Tcall(OslcClientFactory clientFactory, Function<OslcClient, T> function) Uses the given factory to obtain an OSLC client to execute the function and generate a result.static <T> Tcall(ResourceRequest<T> request) Executes the given request to provide a result.static <T> Tcall(HttpServletRequest request, Function<OslcClient, T> function) Uses the HTTP request toobtain an OSLC clientand execute the function to generate a result.static <T> Tcall(Supplier<OslcClient> clientSupplier, Function<OslcClient, T> function) Uses the given supplier to obtain an OSLC client to execute the function and generate a result.
-
Constructor Details
-
WebAppResourceRequest
Instantiates a new request.- Parameters:
request- the HTTP request used to obtain an OSLC client
-
-
Method Details
-
call
Uses the HTTP request toobtain an OSLC clientand execute the function to generate a result. The function is meant to use the provided OSLC client for executingREST requestsfrom this server to a remote server. Any client exception thrown by the function is caught by this method and changed to a web exception.- Type Parameters:
T- the type of response to extract from the request execution.- Parameters:
request- the HTTP request used to obtain an OSLC clientfunction- the function to execute with the obtained OSLC client- Returns:
- the result of the function
- Throws:
WebApplicationException- for any HTTP response whose status is not20x- Since:
- 3.4.0
-
call
Executes the given request to provide a result. Any client exception thrown by the request is caught by this method and changed to a web exception.- Type Parameters:
T- the type of response to extract from the request execution.- Parameters:
request- the request to execute- Returns:
- the result of the request
- Throws:
WebApplicationException- for any HTTP response whose status is not20x- Since:
- 4.0.0
-
call
Uses the given factory to obtain an OSLC client to execute the function and generate a result. The function is meant to use the provided OSLC client for executingREST requestsfrom this server to a remote server. Any client exception thrown by the function is caught by this method and changed to a web exception.- Type Parameters:
T- the type of response to extract from the request execution.- Parameters:
clientFactory- a factory to create an OSLC clientfunction- the function to execute with the obtained OSLC client- Returns:
- the result of the function
- Throws:
WebApplicationException- for any HTTP response whose status is not20x- Since:
- 4.0.0
-
call
Uses the given supplier to obtain an OSLC client to execute the function and generate a result. The function is meant to use the provided OSLC client for executingREST requestsfrom this server to a remote server. Any client exception thrown by the function is caught by this method and changed to a web exception.- Type Parameters:
T- the type of response to extract from the request execution.- Parameters:
clientSupplier- provides an OSLC client instancefunction- the function to execute with the obtained OSLC client- Returns:
- the result of the function
- Throws:
WebApplicationException- for any HTTP response whose status is not20x- Since:
- 4.0.0
-
call
Executes the request and parse the response content in the specified format. Throws a WebApplicationException in case the HTTP response status is not 20x. -
call
Executes the request with the specified client.Subclasses may call a
ResourceRequestor use the client to make a custom request.- Parameters:
client- the client to use to execute the request.- Returns:
- the response of the request execution.
-