public class CmsFlexRequest extends javax.servlet.http.HttpServletRequestWrapper
This class wraps the standard HttpServletRequest so that it's output can be delivered to the CmsFlexCache.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PARAMETER_FLEX
Request parameter for FlexCache commands.
|
Constructor and Description |
---|
CmsFlexRequest(javax.servlet.http.HttpServletRequest req,
CmsFlexController controller)
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.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
addAttributeMap(java.util.Map<java.lang.String,java.lang.Object> map)
Adds the specified Map to the attributes of the request,
added attributes will not overwrite existing attributes in the
request.
|
java.util.Map<java.lang.String,java.lang.String[]> |
addParameterMap(java.util.Map<java.lang.String,java.lang.String[]> map)
Adds the specified Map to the parameters of the request,
added parameters will not overwrite existing parameters in the
request.
|
void |
enableParameterEscaping()
Enables escaping for all parameters which are not in the list of exceptions.
|
java.lang.Object |
getAttribute(java.lang.String name)
Return the value of the specified request attribute, if any; otherwise,
return
null . |
java.util.Map<java.lang.String,java.lang.Object> |
getAttributeMap()
Returns a
Map of the attributes of this request. |
java.util.Enumeration<java.lang.String> |
getAttributeNames()
Return the names of all defined request attributes for this request.
|
protected java.util.List<java.lang.String> |
getCmsIncludeCalls()
Returns the List of include calls which will be passed to the next wrapping layer.
|
java.lang.String |
getElementRootPath()
Returns the full element URI site root path to the resource currently processed.
|
java.lang.String |
getElementUri()
Returns the element URI of the resource currently processed,
relative to the current site root.
|
protected CmsJspLoader |
getJspLoader()
Returns the jsp loader instance.
|
java.lang.String |
getParameter(java.lang.String name)
Return the value of the specified request parameter, if any; otherwise,
return
null . |
CmsParameterEscaper |
getParameterEscaper()
Gets the parameter escaper.
|
java.util.Map<java.lang.String,java.lang.String[]> |
getParameterMap()
Returns a
Map of the parameters of this request. |
java.util.Enumeration<java.lang.String> |
getParameterNames()
Return the names of all defined request parameters for this request.
|
java.lang.String[] |
getParameterValues(java.lang.String name)
Returns the defined values for the specified request parameter, if any;
otherwise, return
null . |
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String target)
Allows requests to be dispatched to internal VFS resources or
external JSP pages, overloads the standard servlet API
getRequestDispatcher() method. |
CmsFlexRequestDispatcher |
getRequestDispatcherToExternal(java.lang.String vfs_target,
java.lang.String ext_target)
Replacement for the standard servlet API getRequestDispatcher() method.
|
java.lang.String |
getRequestURI()
Wraps the request URI, overloading the standard API.
|
java.lang.StringBuffer |
getRequestURL()
Wraps the request URL, overloading the standard API,
the wrapped URL will always point to the currently included VFS resource.
|
java.lang.String |
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.
|
boolean |
isDoRecompile()
Checks if JSPs should always be recompiled.
|
boolean |
isOnline()
Indicates that this request belongs to an online project.
|
void |
removeAttribute(java.lang.String name) |
void |
setAttribute(java.lang.String name,
java.lang.Object value) |
void |
setAttributeMap(java.util.Map<java.lang.String,java.lang.Object> map)
Sets the specified Map as attribute map of the request.
|
void |
setParameterMap(java.util.Map<java.lang.String,java.lang.String[]> map)
Sets the specified Map as parameter map of the request.
|
java.lang.String |
toString() |
authenticate, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout
getAsyncContext, getCharacterEncoding, getContentLength, 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, startAsync
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAsyncContext, getCharacterEncoding, getContentLength, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, setCharacterEncoding, startAsync, startAsync
public static final java.lang.String PARAMETER_FLEX
public CmsFlexRequest(javax.servlet.http.HttpServletRequest req, CmsFlexController controller)
req
- the request to wrapcontroller
- the controller to usepublic java.util.Map<java.lang.String,java.lang.Object> addAttributeMap(java.util.Map<java.lang.String,java.lang.Object> map)
map
- the map to addpublic java.util.Map<java.lang.String,java.lang.String[]> addParameterMap(java.util.Map<java.lang.String,java.lang.String[]> map)
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.
map
- the map to addpublic void enableParameterEscaping()
public java.lang.Object getAttribute(java.lang.String name)
null
.getAttribute
in interface javax.servlet.ServletRequest
getAttribute
in class javax.servlet.ServletRequestWrapper
name
- the name of the desired request attributeServletRequest.getAttribute(java.lang.String)
public java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()
Map
of the attributes of this request.Map
containing attribute names as keys
and attribute values as map valuespublic java.util.Enumeration<java.lang.String> getAttributeNames()
getAttributeNames
in interface javax.servlet.ServletRequest
getAttributeNames
in class javax.servlet.ServletRequestWrapper
ServletRequest.getAttributeNames()
protected java.util.List<java.lang.String> getCmsIncludeCalls()
The set of include calls is maintained to detect an endless inclusion loop.
public java.lang.String getElementRootPath()
public java.lang.String getElementUri()
This might be the name of an included resource, not necessarily the name the resource requested by the user.
protected CmsJspLoader getJspLoader()
public java.lang.String getParameter(java.lang.String name)
null
.If there is more than one value defined, return only the first one.
getParameter
in interface javax.servlet.ServletRequest
getParameter
in class javax.servlet.ServletRequestWrapper
name
- the name of the desired request parameterServletRequest.getParameter(java.lang.String)
public CmsParameterEscaper getParameterEscaper()
public java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
Map
of 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.
getParameterMap
in interface javax.servlet.ServletRequest
getParameterMap
in class javax.servlet.ServletRequestWrapper
Map
containing parameter names as keys
and parameter values as map valuesServletRequest.getParameterMap()
public java.util.Enumeration<java.lang.String> getParameterNames()
getParameterNames
in interface javax.servlet.ServletRequest
getParameterNames
in class javax.servlet.ServletRequestWrapper
ServletRequest.getParameterNames()
public java.lang.String[] getParameterValues(java.lang.String name)
null
.getParameterValues
in interface javax.servlet.ServletRequest
getParameterValues
in class javax.servlet.ServletRequestWrapper
name
- Name of the desired request parameternull
otherwiseServletRequest.getParameterValues(java.lang.String)
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String target)
getRequestDispatcher()
method.getRequestDispatcher
in interface javax.servlet.ServletRequest
getRequestDispatcher
in class javax.servlet.ServletRequestWrapper
target
- the target for the request dispatcherpublic CmsFlexRequestDispatcher getRequestDispatcherToExternal(java.lang.String vfs_target, java.lang.String ext_target)
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.
vfs_target
- the OpenCms file that is a "mirror" version of the external fileext_target
- the external file (outside the OpenCms VFS)public java.lang.String getRequestURI()
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.
getRequestURI
in interface javax.servlet.http.HttpServletRequest
getRequestURI
in class javax.servlet.http.HttpServletRequestWrapper
HttpServletRequest.getRequestURI()
public java.lang.StringBuffer getRequestURL()
getRequestURL
in interface javax.servlet.http.HttpServletRequest
getRequestURL
in class javax.servlet.http.HttpServletRequestWrapper
HttpServletRequest.getRequestURL()
public java.lang.String getServletPath()
getServletPath
in interface javax.servlet.http.HttpServletRequest
getServletPath
in class javax.servlet.http.HttpServletRequestWrapper
HttpServletRequestWrapper.getServletPath()
public boolean isDoRecompile()
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.
public boolean isOnline()
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.
public void removeAttribute(java.lang.String name)
removeAttribute
in interface javax.servlet.ServletRequest
removeAttribute
in class javax.servlet.ServletRequestWrapper
ServletRequestWrapper.removeAttribute(java.lang.String)
public void setAttribute(java.lang.String name, java.lang.Object value)
setAttribute
in interface javax.servlet.ServletRequest
setAttribute
in class javax.servlet.ServletRequestWrapper
ServletRequestWrapper.setAttribute(java.lang.String, java.lang.Object)
public void setAttributeMap(java.util.Map<java.lang.String,java.lang.Object> map)
The map should be immutable.
This will completely replace the attribute map.
Use this in combination with getAttributeMap()
and
addAttributeMap(Map)
in case you want to set the old status
of the attribute map after you have modified it for
a specific operation.
map
- the map to setpublic void setParameterMap(java.util.Map<java.lang.String,java.lang.String[]> map)
The map should be immutable.
This will completely replace the parameter map.
Use this in combination with getParameterMap()
and
addParameterMap(Map)
in case you want to set the old status
of the parameter map after you have modified it for
a specific operation.
map
- the map to setpublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()