Package com.sodius.oslc.server
Class OslcRequests
java.lang.Object
com.sodius.oslc.server.OslcRequests
Provides access to various properties of servlet requests.
- Since:
- 1.13.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder of request wrapper. -
Method Summary
Modifier and TypeMethodDescriptionforwardTo(String path, HttpServletResponse response) Use a dispatcher toforwardthe request to the given path of a local resource.Returns the complete URI of the request, which combines the full request path and the query string, if any.Returns a list of enabled Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header and supported by the server.booleanisAccepted(MediaType type) Determines whether the given media type is compatible with the request Accept header.static OslcRequestsof(HttpServletRequest request) Returns an instance that wraps the specified servlet request.wrapper()Returns a builder to create a request wrapper, for overriding some properties of the underlying request.
-
Method Details
-
of
Returns an instance that wraps the specified servlet request.- Parameters:
request- a servlet request.- Returns:
- a new OslcRequests instance.
-
isAccepted
Determines whether the given media type is compatible with the request Accept header.- Parameters:
type- a media type to test.- Returns:
trueif the request Accept header is compatible with the given type or if the Accept value is empty,falseotherwise.
-
getFullUri
Returns the complete URI of the request, which combines the full request path and the query string, if any.- Returns:
- the complete URI of the request.
-
getLocales
Returns a list of enabled Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header and supported by the server.The returned list contains the locales requested by client and supported by the server, as defined by the
Options.ENABLED_LOCALESproperty. If the server doesn't support any locale requested by client, this method returns an empty list.- Returns:
- a list of preferred Locale objects for the client and enabled on server.
- See Also:
-
forwardTo
Use a dispatcher toforwardthe request to the given path of a local resource. If the path is relative, it must be relative to the current servlet.- Parameters:
path- a String specifying the pathname to the resourceresponse- the HTTP response used for the forward- Returns:
- an empty JAX-RS response with a HTTP 200 status
- Throws:
OslcWebApplicationException- if no request dispatcher can be provided by the servlet container or an error occurs during the forward- Since:
- 4.0.0
-
wrapper
Returns a builder to create a request wrapper, for overriding some properties of the underlying request. Wrapping a request may be useful for example in a filter, for removing or overriding the value of a header, so that successive filters are not aware of the original header the filter has already processed.Here's an example of builder usage:
HttpServletRequest wrapped = OslcRequests.of(request).wrapper().removeHeader(HttpHeaders.AUTHORIZATION).build();
- Returns:
- a builder to create a request wrapper
- Since:
- 1.14.0.
-