Class CmsFlexRequest
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest,javax.servlet.ServletRequest
This class wraps the standard HttpServletRequest so that it's output can be delivered to the CmsFlexCache.
- Since:
- 6.0.0
-
Field Summary
FieldsFields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
ConstructorsConstructorDescriptionCmsFlexRequest(javax.servlet.http.HttpServletRequest req, CmsFlexController controller) Creates a new CmsFlexRequest wrapper which is most likely the "Top" request wrapper, i.e. -
Method Summary
Modifier and TypeMethodDescriptionaddAttributeMap(Map<String, Object> map) Adds the specified Map to the attributes of the request, added attributes will not overwrite existing attributes in the request.addParameterMap(Map<String, String[]> map) Adds the specified Map to the parameters of the request, added parameters will not overwrite existing parameters in the request.voidEnables escaping for all parameters which are not in the list of exceptions.getAttribute(String name) Return the value of the specified request attribute, if any; otherwise, returnnull.Returns aMapof the attributes of this request.Return the names of all defined request attributes for this request.Returns the List of include calls which will be passed to the next wrapping layer.Gets the set of dynamic parameters.Returns the full element URI site root path to the resource currently processed.Returns the element URI of the resource currently processed, relative to the current site root.protected CmsJspLoaderReturns the jsp loader instance.getParameter(String name) Return the value of the specified request parameter, if any; otherwise, returnnull.Gets the parameter escaper.Returns aMapof the parameters of this request.Return the names of all defined request parameters for this request.String[]getParameterValues(String name) Returns the defined values for the specified request parameter, if any; otherwise, returnnull.javax.servlet.RequestDispatchergetRequestDispatcher(String target) Allows requests to be dispatched to internal VFS resources or external JSP pages, overloads the standard servlet APIgetRequestDispatcher()method.getRequestDispatcherToExternal(String vfs_target, String ext_target) Replacement for the standard servlet API getRequestDispatcher() method.Wraps the request URI, overloading the standard API.Wraps the request URL, overloading the standard API, the wrapped URL will always point to the currently included VFS resource.This is a work around for servlet containers creating a new application dispatcher instead of using our request dispatcher, so missing RFS JSP pages are not requested to OpenCms and the dispatcher is unable to load the included/forwarded JSP file.booleanChecks if JSPs should always be recompiled.booleanisOnline()Indicates that this request belongs to an online project.voidremoveAttribute(String name) voidsetAttribute(String name, Object value) voidsetAttributeMap(Map<String, Object> map) Sets the specified Map as attribute map of the request.voidsetDynamicParameters(Set<String> dynamicParams) Sets the set of dynamic parameters.voidsetParameterMap(Map<String, String[]> map) Sets the specified Map as parameter map of the request.toString()Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgradeMethods inherited from class javax.servlet.ServletRequestWrapper
getAsyncContext, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, setCharacterEncoding, setRequest, startAsync, startAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.servlet.ServletRequest
getAsyncContext, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, setCharacterEncoding, startAsync, startAsync
-
Field Details
-
PARAMETER_FLEX
Request parameter for FlexCache commands.- See Also:
-
-
Constructor Details
-
CmsFlexRequest
Creates a new CmsFlexRequest wrapper which is most likely the "Top" request wrapper, i.e. the wrapper that is constructed around the first "real" (not wrapped) request.- Parameters:
req- the request to wrapcontroller- the controller to use
-
-
Method Details
-
addAttributeMap
Adds the specified Map to the attributes of the request, added attributes will not overwrite existing attributes in the request.- Parameters:
map- the map to add- Returns:
- the merged map of attributes
-
addParameterMap
Adds the specified Map to the parameters of the request, added parameters will not overwrite existing parameters in the request.Remember that the value for a parameter name in a HttpRequest is a String array. If a parameter name already exists in the HttpRequest, the values will be added to the existing value array. Multiple occurrences of the same value for one parameter are also possible.
- Parameters:
map- the map to add- Returns:
- the merged map of parameters
-
enableParameterEscaping
Enables escaping for all parameters which are not in the list of exceptions. -
getAttribute
Return the value of the specified request attribute, if any; otherwise, returnnull.- Specified by:
getAttributein interfacejavax.servlet.ServletRequest- Overrides:
getAttributein classjavax.servlet.ServletRequestWrapper- Parameters:
name- the name of the desired request attribute- Returns:
- the value of the specified request attribute
- See Also:
-
getAttributeMap
Returns aMapof the attributes of this request.- Returns:
- a
Mapcontaining attribute names as keys and attribute values as map values
-
getAttributeNames
Return the names of all defined request attributes for this request.- Specified by:
getAttributeNamesin interfacejavax.servlet.ServletRequest- Overrides:
getAttributeNamesin classjavax.servlet.ServletRequestWrapper- Returns:
- the names of all defined request attributes for this request
- See Also:
-
getDynamicParameters
Gets the set of dynamic parameters.Normally, when caching a JSP which includes another JSP, only the parameters given directly to the include call will be cached in the new flex cache entry's include list. But when the include call happens implicitly (e.g. for elements rendered in a cms:container tag), we can't pass it any parameters. In this case, we have to modify the parameter map of the current flex request in the JSP, and the keys for the modified parameters need to be stored in this set for the Flex cache to work correctly.
- Returns:
- the set of keys for the dynamic parameters
-
getElementRootPath
Returns the full element URI site root path to the resource currently processed.- Returns:
- the name of the resource currently processed
-
getElementUri
Returns the element URI of the resource currently processed, relative to the current site root.This might be the name of an included resource, not necessarily the name the resource requested by the user.
- Returns:
- the name of the resource currently processed
-
getParameter
Return the value of the specified request parameter, if any; otherwise, returnnull.If there is more than one value defined, return only the first one.
- Specified by:
getParameterin interfacejavax.servlet.ServletRequest- Overrides:
getParameterin classjavax.servlet.ServletRequestWrapper- Parameters:
name- the name of the desired request parameter- Returns:
- the value of the specified request parameter
- See Also:
-
getParameterEscaper
Gets the parameter escaper.- Returns:
- the parameter escaper
-
getParameterMap
Returns aMapof the parameters of this request.Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
- Specified by:
getParameterMapin interfacejavax.servlet.ServletRequest- Overrides:
getParameterMapin classjavax.servlet.ServletRequestWrapper- Returns:
- a
Mapcontaining parameter names as keys and parameter values as map values - See Also:
-
getParameterNames
Return the names of all defined request parameters for this request.- Specified by:
getParameterNamesin interfacejavax.servlet.ServletRequest- Overrides:
getParameterNamesin classjavax.servlet.ServletRequestWrapper- Returns:
- the names of all defined request parameters for this request
- See Also:
-
getParameterValues
Returns the defined values for the specified request parameter, if any; otherwise, returnnull.- Specified by:
getParameterValuesin interfacejavax.servlet.ServletRequest- Overrides:
getParameterValuesin classjavax.servlet.ServletRequestWrapper- Parameters:
name- Name of the desired request parameter- Returns:
- the defined values for the specified request parameter, if any;
nullotherwise - See Also:
-
getRequestDispatcher
Allows requests to be dispatched to internal VFS resources or external JSP pages, overloads the standard servlet APIgetRequestDispatcher()method.- Specified by:
getRequestDispatcherin interfacejavax.servlet.ServletRequest- Overrides:
getRequestDispatcherin classjavax.servlet.ServletRequestWrapper- Parameters:
target- the target for the request dispatcher- Returns:
- a special RequestDispatcher that allows access to VFS resources
-
getRequestDispatcherToExternal
public CmsFlexRequestDispatcher getRequestDispatcherToExternal(String vfs_target, String ext_target) Replacement for the standard servlet API getRequestDispatcher() method.This variation is used if an external file (probably JSP) is dispatched to. This external file must have a "mirror" version, i.e. a file in the OpenCms VFS that represents the external file.
- Parameters:
vfs_target- the OpenCms file that is a "mirror" version of the external fileext_target- the external file (outside the OpenCms VFS)- Returns:
- the constructed CmsFlexRequestDispatcher
-
getRequestURI
Wraps the request URI, overloading the standard API.This ensures that any wrapped request will use the "faked" target parameters. Remember that for the real request, a mixture of PathInfo and other request information is used to identify the target.
- Specified by:
getRequestURIin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getRequestURIin classjavax.servlet.http.HttpServletRequestWrapper- Returns:
- a faked URI that will point to the wrapped target in the VFS
- See Also:
-
getRequestURL
Wraps the request URL, overloading the standard API, the wrapped URL will always point to the currently included VFS resource.- Specified by:
getRequestURLin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getRequestURLin classjavax.servlet.http.HttpServletRequestWrapper- Returns:
- a faked URL that will point to the included target in the VFS
- See Also:
-
getServletPath
This is a work around for servlet containers creating a new application dispatcher instead of using our request dispatcher, so missing RFS JSP pages are not requested to OpenCms and the dispatcher is unable to load the included/forwarded JSP file.- Specified by:
getServletPathin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getServletPathin classjavax.servlet.http.HttpServletRequestWrapper- See Also:
-
isDoRecompile
Checks if JSPs should always be recompiled.This is useful in case directive based includes are used with <%@ include file="..." %> on a JSP. Note that this also forces the request not to be cached.
- Returns:
- true if JSPs should be recompiled, false otherwise
-
isOnline
Indicates that this request belongs to an online project.This is required to distinguish between online and offline resources in the cache. Since the resources have the same name, a suffix [online] or [offline] is added to distinguish the strings when building cache keys. Any resource from a request that isOnline() will be saved with the [online] suffix and vice versa.
Resources in the OpenCms workplace are not distinguished between online and offline but have their own suffix [workplace]. The assumption is that if you do change the workplace, this is only on true development machines so you can do the cache clearing manually if required.
The suffixes are used so that we have a simple String name for the resources in the cache. This makes it easy to use a standard HashMap for storage of the resources.
- Returns:
- true if an online resource was requested, false otherwise
-
removeAttribute
- Specified by:
removeAttributein interfacejavax.servlet.ServletRequest- Overrides:
removeAttributein classjavax.servlet.ServletRequestWrapper- See Also:
-
setAttribute
- Specified by:
setAttributein interfacejavax.servlet.ServletRequest- Overrides:
setAttributein classjavax.servlet.ServletRequestWrapper- See Also:
-
setAttributeMap
Sets the specified Map as attribute map of the request.The map should be immutable. This will completely replace the attribute map. Use this in combination with
getAttributeMap()andaddAttributeMap(Map)in case you want to set the old status of the attribute map after you have modified it for a specific operation.- Parameters:
map- the map to set
-
setDynamicParameters
Sets the set of dynamic parameters.- Parameters:
dynamicParams- the set of dynamic parameters
-
setParameterMap
Sets the specified Map as parameter map of the request.The map should be immutable. This will completely replace the parameter map. Use this in combination with
getParameterMap()andaddParameterMap(Map)in case you want to set the old status of the parameter map after you have modified it for a specific operation.- Parameters:
map- the map to set
-
toString
-
getCmsIncludeCalls
Returns the List of include calls which will be passed to the next wrapping layer.The set of include calls is maintained to detect an endless inclusion loop.
- Returns:
- the List of include calls
-
getJspLoader
Returns the jsp loader instance.- Returns:
- the jsp loader instance
-