Class SlingHttpServletRequestWrapper
- java.lang.Object
-
- javax.servlet.ServletRequestWrapper
-
- javax.servlet.http.HttpServletRequestWrapper
-
- org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper
-
- All Implemented Interfaces:
HttpServletRequest,ServletRequest,Adaptable,SlingHttpServletRequest
- Direct Known Subclasses:
FormsHandlingRequest,RedirectRequest
public class SlingHttpServletRequestWrapper extends HttpServletRequestWrapper implements SlingHttpServletRequest
TheSlingHttpServletRequestWrapperclass is a default wrapper class around aSlingHttpServletRequestwhich 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
Constructors Constructor Description SlingHttpServletRequestWrapper(SlingHttpServletRequest wrappedRequest)Create a wrapper for the supplied wrappedRequest
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <AdapterType>
AdapterTypeadaptTo(java.lang.Class<AdapterType> type)Adapts the adaptable to another type.CookiegetCookie(java.lang.String name)Returns the named cookie from the HTTP request ornullif no such cookie exists in the request.RequestDispatchergetRequestDispatcher(java.lang.String path, RequestDispatcherOptions options)Returns aRequestDispatcherobject that acts as a wrapper for the resource located at the given path.RequestDispatchergetRequestDispatcher(Resource resource)Same asSlingHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions)but using empty options.RequestDispatchergetRequestDispatcher(Resource resource, RequestDispatcherOptions options)Returns aRequestDispatcherobject that acts as a wrapper for the resource located at the given resource.RequestParametergetRequestParameter(java.lang.String name)Returns the value of a request parameter as aRequestParameter, ornullif the parameter does not exist.java.util.List<RequestParameter>getRequestParameterList()Returns the request parameters as instances of theRequestParameterinterface in the order or the request where the query string parameters are first and the POST request parameters are second.RequestParameterMapgetRequestParameterMap()Returns aMapof the parameters of this request.RequestParameter[]getRequestParameters(java.lang.String name)Returns an array ofRequestParameterobjects containing all of the values the given request parameter has, ornullif the parameter does not exist.RequestPathInfogetRequestPathInfo()Returns theRequestPathInfopertaining to this request.RequestProgressTrackergetRequestProgressTracker()Returns theRequestProgressTrackerof this request.ResourcegetResource()Returns theResourceobject on whose behalf the servlet acts.java.util.ResourceBundlegetResourceBundle(java.lang.String baseName, java.util.Locale locale)Returns the resource bundle of the given base name for the given locale.java.util.ResourceBundlegetResourceBundle(java.util.Locale locale)Returns the resource bundle for the given locale.ResourceResolvergetResourceResolver()Returns theResourceResolverwhich resolved theresourceof this request.java.lang.StringgetResponseContentType()Returns the framework preferred content type for the response.java.util.Enumeration<java.lang.String>getResponseContentTypes()Gets a list of content types which the framework accepts for the response.SlingHttpServletRequestgetSlingRequest()Return the originalSlingHttpServletRequestobject 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.servlet.http.HttpServletRequest
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 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
-
-
-
-
Constructor Detail
-
SlingHttpServletRequestWrapper
public SlingHttpServletRequestWrapper(SlingHttpServletRequest wrappedRequest)
Create a wrapper for the supplied wrappedRequest- Parameters:
wrappedRequest- The request.
-
-
Method Detail
-
getSlingRequest
public SlingHttpServletRequest getSlingRequest()
Return the originalSlingHttpServletRequestobject wrapped by this.- Returns:
- The wrapped request.
-
getCookie
public Cookie getCookie(java.lang.String name)
Description copied from interface:SlingHttpServletRequestReturns the named cookie from the HTTP request ornullif no such cookie exists in the request.- Specified by:
getCookiein interfaceSlingHttpServletRequest- Parameters:
name- The name of the cookie to return.- Returns:
- The named cookie or
nullif no such cookie exists.
-
getRequestProgressTracker
public RequestProgressTracker getRequestProgressTracker()
Description copied from interface:SlingHttpServletRequestReturns theRequestProgressTrackerof this request.- Specified by:
getRequestProgressTrackerin interfaceSlingHttpServletRequest- Returns:
- The request progress tracker.
-
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(Resource resource)
Description copied from interface:SlingHttpServletRequestSame asSlingHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions)but using empty options.- Specified by:
getRequestDispatcherin interfaceSlingHttpServletRequest- Parameters:
resource- TheResourceinstance whose response content may be included by the returned dispatcher.- Returns:
- a
RequestDispatcherobject that acts as a wrapper for theresourceornullif an error occurs preparing the dispatcher.
-
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(Resource resource, RequestDispatcherOptions options)
Description copied from interface:SlingHttpServletRequestReturns aRequestDispatcherobject that acts as a wrapper for the resource located at the given resource. ARequestDispatcherobject can be used to include the resource in a response.Returns
nullif aRequestDispatchercannot be returned for any reason.- Specified by:
getRequestDispatcherin interfaceSlingHttpServletRequest- Parameters:
resource- TheResourceinstance whose response content may be included by the returned dispatcher.options- influence the rendering of the included Resource- Returns:
- a
RequestDispatcherobject that acts as a wrapper for theresourceornullif an error occurs preparing the dispatcher.
-
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(java.lang.String path, RequestDispatcherOptions options)
Description copied from interface:SlingHttpServletRequestReturns aRequestDispatcherobject that acts as a wrapper for the resource located at the given path. ARequestDispatcherobject can be used to include the resource in a response.Returns
nullif aRequestDispatchercannot be returned for any reason.- Specified by:
getRequestDispatcherin interfaceSlingHttpServletRequest- Parameters:
path- aStringspecifying 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
RequestDispatcherobject that acts as a wrapper for theresourceornullif an error occurs preparing the dispatcher.
-
getRequestParameter
public RequestParameter getRequestParameter(java.lang.String name)
Description copied from interface:SlingHttpServletRequestReturns the value of a request parameter as aRequestParameter, ornullif 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:
getRequestParameterin interfaceSlingHttpServletRequest- Parameters:
name- aStringspecifying the name of the parameter- Returns:
- a
RequestParameterrepresenting the single value of the parameter - See Also:
SlingHttpServletRequest.getRequestParameters(String),RequestParameterMap.getValue(String)
-
getRequestParameterMap
public RequestParameterMap getRequestParameterMap()
Description copied from interface:SlingHttpServletRequestReturns aMapof the parameters of this request.The values in the returned
Mapare from typeRequestParameterarray (RequestParameter[]).If no parameters exist this method returns an empty
Map.- Specified by:
getRequestParameterMapin interfaceSlingHttpServletRequest- Returns:
- an immutable
Mapcontaining parameter names as keys and parameter values as map values, or an emptyMapif no parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of typeRequestParameterarray (RequestParameter[]).
-
getRequestParameterList
public java.util.List<RequestParameter> getRequestParameterList()
Description copied from interface:SlingHttpServletRequestReturns the request parameters as instances of theRequestParameterinterface in the order or the request where the query string parameters are first and the POST request parameters are second.- Specified by:
getRequestParameterListin interfaceSlingHttpServletRequest- Returns:
- The list of
RequestParameterin request declaration order.
-
getRequestParameters
public RequestParameter[] getRequestParameters(java.lang.String name)
Description copied from interface:SlingHttpServletRequestReturns an array ofRequestParameterobjects containing all of the values the given request parameter has, ornullif 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:
getRequestParametersin interfaceSlingHttpServletRequest- Parameters:
name- aStringcontaining the name of the parameter the value of which is requested- Returns:
- an array of
RequestParameterobjects containing the parameter values. - See Also:
SlingHttpServletRequest.getRequestParameter(String),RequestParameterMap.getValues(String)
-
getRequestPathInfo
public RequestPathInfo getRequestPathInfo()
Description copied from interface:SlingHttpServletRequestReturns theRequestPathInfopertaining to this request.- Specified by:
getRequestPathInfoin interfaceSlingHttpServletRequest- Returns:
- the request path info.
-
getResource
public Resource getResource()
Description copied from interface:SlingHttpServletRequestReturns theResourceobject on whose behalf the servlet acts.- Specified by:
getResourcein interfaceSlingHttpServletRequest- Returns:
- The
Resourceobject of this request.
-
getResourceResolver
public ResourceResolver getResourceResolver()
Description copied from interface:SlingHttpServletRequestReturns theResourceResolverwhich resolved theresourceof this request.- Specified by:
getResourceResolverin interfaceSlingHttpServletRequest- Returns:
- The resource resolver
-
getResourceBundle
public java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
Description copied from interface:SlingHttpServletRequestReturns the resource bundle for the given locale.- Specified by:
getResourceBundlein 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
public java.util.ResourceBundle getResourceBundle(java.lang.String baseName, java.util.Locale locale)Description copied from interface:SlingHttpServletRequestReturns the resource bundle of the given base name for the given locale.- Specified by:
getResourceBundlein 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
public java.lang.String getResponseContentType()
Description copied from interface:SlingHttpServletRequestReturns 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:
getResponseContentTypein interfaceSlingHttpServletRequest- Returns:
- preferred MIME type of the response
-
getResponseContentTypes
public java.util.Enumeration<java.lang.String> getResponseContentTypes()
Description copied from interface:SlingHttpServletRequestGets 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:
getResponseContentTypesin interfaceSlingHttpServletRequest- Returns:
- ordered list of MIME types for the response
-
adaptTo
public <AdapterType> AdapterType adaptTo(java.lang.Class<AdapterType> type)
Description copied from interface:AdaptableAdapts 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
typeyields 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:
adaptToin 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.classorjava.io.File.class- Returns:
- The adapter target or
nullif the object cannot adapt to the requested type
-
-