Class SlingHttpServletRequestWrapper
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest
,javax.servlet.ServletRequest
,Adaptable
,SlingHttpServletRequest
- Direct Known Subclasses:
OnDemandReaderRequest
,RequestWrapper
,SlingServletRequestAdapter
SlingHttpServletRequestWrapper
class is a default wrapper
class around a SlingHttpServletRequest
which may be extended to amend
the functionality of the original request object.-
Field Summary
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
-
Constructor Summary
ConstructorDescriptionSlingHttpServletRequestWrapper
(SlingHttpServletRequest wrappedRequest) Create a wrapper for the supplied wrappedRequest -
Method Summary
Modifier and TypeMethodDescription<AdapterType>
AdapterTypeAdapts the adaptable to another type.javax.servlet.http.Cookie
Returns the named cookie from the HTTP request ornull
if no such cookie exists in the request.javax.servlet.RequestDispatcher
getRequestDispatcher
(String path, RequestDispatcherOptions options) Returns aRequestDispatcher
object that acts as a wrapper for the resource located at the given path.javax.servlet.RequestDispatcher
getRequestDispatcher
(Resource resource) Same asSlingHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions)
but using empty options.javax.servlet.RequestDispatcher
getRequestDispatcher
(Resource resource, RequestDispatcherOptions options) Returns aRequestDispatcher
object that acts as a wrapper for the resource located at the given resource.getRequestParameter
(String name) Returns the value of a request parameter as aRequestParameter
, ornull
if the parameter does not exist.Returns the request parameters as instances of theRequestParameter
interface in the order or the request where the query string parameters are first and the POST request parameters are second.Returns aMap
of the parameters of this request.getRequestParameters
(String name) Returns an array ofRequestParameter
objects containing all of the values the given request parameter has, ornull
if the parameter does not exist.Returns theRequestPathInfo
pertaining to this request.Returns theRequestProgressTracker
of this request.Returns theResource
object on whose behalf the servlet acts.getResourceBundle
(String baseName, Locale locale) Returns the resource bundle of the given base name for the given locale.getResourceBundle
(Locale locale) Returns the resource bundle for the given locale.Returns theResourceResolver
which resolved theresource
of this request.Returns the framework preferred content type for the response.Gets a list of content types which the framework accepts for the response.Return the originalSlingHttpServletRequest
object wrapped by this.Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgrade
Methods inherited from class javax.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.servlet.http.HttpServletRequest
authenticate, changeSessionId, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgrade
Methods inherited from interface javax.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
Methods inherited from interface org.apache.sling.api.SlingHttpServletRequest
getAuthType, getRemoteUser, getUserPrincipal
-
Constructor Details
-
SlingHttpServletRequestWrapper
Create a wrapper for the supplied wrappedRequest- Parameters:
wrappedRequest
- The request.
-
-
Method Details
-
getSlingRequest
Return the originalSlingHttpServletRequest
object wrapped by this.- Returns:
- The wrapped request.
-
getCookie
Description copied from interface:SlingHttpServletRequest
Returns the named cookie from the HTTP request ornull
if no such cookie exists in the request.- Specified by:
getCookie
in interfaceSlingHttpServletRequest
- Parameters:
name
- The name of the cookie to return.- Returns:
- The named cookie or
null
if no such cookie exists.
-
getRequestProgressTracker
Description copied from interface:SlingHttpServletRequest
Returns theRequestProgressTracker
of this request.- Specified by:
getRequestProgressTracker
in interfaceSlingHttpServletRequest
- Returns:
- The request progress tracker.
-
getRequestDispatcher
Description copied from interface:SlingHttpServletRequest
Same asSlingHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions)
but using empty options.- Specified by:
getRequestDispatcher
in interfaceSlingHttpServletRequest
- Parameters:
resource
- TheResource
instance whose response content may be included by the returned dispatcher.- Returns:
- a
RequestDispatcher
object that acts as a wrapper for theresource
ornull
if an error occurs preparing the dispatcher.
-
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(Resource resource, RequestDispatcherOptions options) Description copied from interface:SlingHttpServletRequest
Returns aRequestDispatcher
object that acts as a wrapper for the resource located at the given resource. ARequestDispatcher
object can be used to include the resource in a response.Returns
null
if aRequestDispatcher
cannot be returned for any reason.- Specified by:
getRequestDispatcher
in interfaceSlingHttpServletRequest
- Parameters:
resource
- TheResource
instance whose response content may be included by the returned dispatcher.options
- influence the rendering of the included Resource- Returns:
- a
RequestDispatcher
object that acts as a wrapper for theresource
ornull
if an error occurs preparing the dispatcher.
-
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(String path, RequestDispatcherOptions options) Description copied from interface:SlingHttpServletRequest
Returns aRequestDispatcher
object that acts as a wrapper for the resource located at the given path. ARequestDispatcher
object can be used to include the resource in a response.Returns
null
if aRequestDispatcher
cannot be returned for any reason.- Specified by:
getRequestDispatcher
in interfaceSlingHttpServletRequest
- Parameters:
path
- aString
specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.options
- influence the rendering of the included Resource- Returns:
- a
RequestDispatcher
object that acts as a wrapper for theresource
ornull
if an error occurs preparing the dispatcher.
-
getRequestParameter
Description copied from interface:SlingHttpServletRequest
Returns the value of a request parameter as aRequestParameter
, ornull
if the parameter does not exist.This method should only be used if the parameter has only one value. If the parameter might have more than one value, use
SlingHttpServletRequest.getRequestParameters(String)
.If this method is used with a multivalued parameter, the value returned is equal to the first value in the array returned by
getRequestParameters
.This method is a shortcut for
getRequestParameterMap().getValue(String)
.- Specified by:
getRequestParameter
in interfaceSlingHttpServletRequest
- Parameters:
name
- aString
specifying the name of the parameter- Returns:
- a
RequestParameter
representing the single value of the parameter - See Also:
-
getRequestParameterMap
Description copied from interface:SlingHttpServletRequest
Returns aMap
of the parameters of this request.The values in the returned
Map
are from typeRequestParameter
array (RequestParameter[]
).If no parameters exist this method returns an empty
Map
.- Specified by:
getRequestParameterMap
in interfaceSlingHttpServletRequest
- Returns:
- an immutable
Map
containing parameter names as keys and parameter values as map values, or an emptyMap
if no parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of typeRequestParameter
array (RequestParameter[]
).
-
getRequestParameterList
Description copied from interface:SlingHttpServletRequest
Returns the request parameters as instances of theRequestParameter
interface in the order or the request where the query string parameters are first and the POST request parameters are second.- Specified by:
getRequestParameterList
in interfaceSlingHttpServletRequest
- Returns:
- The list of
RequestParameter
in request declaration order.
-
getRequestParameters
Description copied from interface:SlingHttpServletRequest
Returns an array ofRequestParameter
objects containing all of the values the given request parameter has, ornull
if the parameter does not exist.If the parameter has a single value, the array has a length of 1.
This method is a shortcut for
getRequestParameterMap().getValues(String)
.- Specified by:
getRequestParameters
in interfaceSlingHttpServletRequest
- Parameters:
name
- aString
containing the name of the parameter the value of which is requested- Returns:
- an array of
RequestParameter
objects containing the parameter values. - See Also:
-
getRequestPathInfo
Description copied from interface:SlingHttpServletRequest
Returns theRequestPathInfo
pertaining to this request.- Specified by:
getRequestPathInfo
in interfaceSlingHttpServletRequest
- Returns:
- the request path info.
-
getResource
Description copied from interface:SlingHttpServletRequest
Returns theResource
object on whose behalf the servlet acts.- Specified by:
getResource
in interfaceSlingHttpServletRequest
- Returns:
- The
Resource
object of this request.
-
getResourceResolver
Description copied from interface:SlingHttpServletRequest
Returns theResourceResolver
which resolved theresource
of this request.- Specified by:
getResourceResolver
in interfaceSlingHttpServletRequest
- Returns:
- The resource resolver
-
getResourceBundle
Description copied from interface:SlingHttpServletRequest
Returns the resource bundle for the given locale.- Specified by:
getResourceBundle
in interfaceSlingHttpServletRequest
- Parameters:
locale
- the locale for which to retrieve the resource bundle. If this isnull
, the locale returned byServletRequest.getLocale()
is used to select the resource bundle.- Returns:
- the resource bundle for the given locale
-
getResourceBundle
Description copied from interface:SlingHttpServletRequest
Returns the resource bundle of the given base name for the given locale.- Specified by:
getResourceBundle
in interfaceSlingHttpServletRequest
- Parameters:
baseName
- The base name of the resource bundle to returned. If this parameter isnull
, the same resource bundle must be returned as if theSlingHttpServletRequest.getResourceBundle(Locale)
method is called.locale
- the locale for which to retrieve the resource bundle. If this isnull
, the locale returned byServletRequest.getLocale()
is used to select the resource bundle.- Returns:
- the resource bundle for the given locale
-
getResponseContentType
Description copied from interface:SlingHttpServletRequest
Returns the framework preferred content type for the response. The content type only includes the MIME type, not the character set.For included resources this method will returned the same string as returned by the
ServletResponse.getContentType()
without the character set.- Specified by:
getResponseContentType
in interfaceSlingHttpServletRequest
- Returns:
- preferred MIME type of the response
-
getResponseContentTypes
Description copied from interface:SlingHttpServletRequest
Gets a list of content types which the framework accepts for the response. This list is ordered with the most preferable types listed first. The content type only includes the MIME type, not the character set.For included resources this method will returned an enumeration containing a single entry which is the same string as returned by the
ServletResponse.getContentType()
without the character set.- Specified by:
getResponseContentTypes
in interfaceSlingHttpServletRequest
- Returns:
- ordered list of MIME types for the response
-
adaptTo
Description copied from interface:Adaptable
Adapts the adaptable to another type.Please note that it is explicitly left as an implementation detail whether each call to this method with the same
type
yields the same object or a new object on each call.Implementations of this method should document their adapted types as well as their behaviour with respect to returning newly created or same instances on each call.
- Specified by:
adaptTo
in interfaceAdaptable
- Type Parameters:
AdapterType
- The generic type to which this object is adapted to- Parameters:
type
- The Class object of the target type, such asjavax.jcr.Node.class
orjava.io.File.class
- Returns:
- The adapter target or
null
if the object cannot adapt to the requested type
-