public class LicenseFilter extends HttpFilter
When the license is not verified, the filter strategy depends on the Accept
header received:
application/rdf+xml
, application/xml
, text/xml
, application/json
,
text/turtle
), the filter chain is aborted and the response contains an OSLC Error entity.text/html
or a wildcard media type, the filter chain is processed
and an error message is added as an attribute of the request.
This enables the servlet to provide an HTML page which displays a license error message at its convenience,
using the getLicenseError(HttpServletRequest)
method.text/plain
content type.getLicenseError(HttpServletRequest)
Constructor and Description |
---|
LicenseFilter() |
Modifier and Type | Method and Description |
---|---|
protected void |
doFilter(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
Processes this filter and either executes or blocks the chain.
|
static Optional<String> |
getLicenseError(HttpServletRequest request)
Allows to request attribute containing a license error message, if any.
|
protected void |
handleLicenseException(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain,
OslcError error)
Handles the behavior of the filter when the license is not verified, depending on the received
Accept header. |
destroy, doFilter, handleOslcError, init
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException
HttpFilter
Subclasses may throw a OslcWebApplicationException
to report an OslcError
.
This filter will automatically serialize such error in the HTTP response.
doFilter
in class HttpFilter
request
- the request.response
- the response.chain
- the filter chain to process.IOException
- if an I/O error occurs.ServletException
- if the filter execution fails.public static Optional<String> getLicenseError(HttpServletRequest request)
request
- the received requestprotected void handleLicenseException(HttpServletRequest request, HttpServletResponse response, FilterChain chain, OslcError error) throws IOException, ServletException
Accept
header.request
- the received requestresponse
- the response to sendchain
- the filter chain to proceederror
- the license error received when checking licenseIOException
- exception can be thrown when writing responseServletException
- exception can be thrown when processing filter