Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.opencms.flex.cache
Class CmsFlexRequest  view CmsFlexRequest download CmsFlexRequest.java

java.lang.Object
  extended byjavax.servlet.ServletRequestWrapper
      extended byjavax.servlet.http.HttpServletRequestWrapper
          extended bycom.opencms.flex.cache.CmsFlexRequest
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

public class CmsFlexRequest
extends javax.servlet.http.HttpServletRequestWrapper

Wrapper class for a HttpServletRequest.

This class wrapps the standard HttpServletRequest so that it's output can be delivered to the CmsFlexCache.

Version:
$Revision: 1.12.2.1 $

Field Summary
static java.lang.String ATTRIBUTE_PROCESSED
          Attribute name used for checking if _flex request parameters have already been processed
private static boolean DEBUG
          Debug flag
private  boolean m_canCache
          Flag to decide if this request can be cached or not
private  CmsFlexController m_controller
          The CmsFlexController for this request
private  boolean m_doRecompile
          Flag to force a JSP recompile
private  java.util.Set m_includeCalls
          Set of all include calls (to prevent an endless inclusion loop)
private  boolean m_isOnline
          Flag to check if this request is in the online project or not
private  CmsFlexCacheKey m_key
          The CmsFlexCacheKey for this request
private  java.util.Map m_parameters
          Map of parameters from the original request
private  javax.servlet.http.HttpServletRequest m_req
          The wrapped HttpServletRequest
private  java.lang.String m_requestUri
          Stores the request URI after it was once calculated
private  java.lang.StringBuffer m_requestUrl
          Stores the request URI after it was once calculated
private  java.lang.String m_resource
          The requested resource (target resource)
 
Fields inherited from class javax.servlet.ServletRequestWrapper
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
  CmsFlexRequest(javax.servlet.http.HttpServletRequest req, CmsFlexController controller)
          Creates a new CmsFlexRequest wrapper which is most likley the "Top" request wrapper, i.e.
(package private) CmsFlexRequest(javax.servlet.http.HttpServletRequest req, CmsFlexController controller, java.lang.String resource)
          Constructs a new wrapper layer around a (already wrapped) CmsFlexRequest.
 
Method Summary
(package private)  void addInlucdeCall(java.lang.String target)
          Adds another include call to this wrapper.
 java.util.Map addParameterMap(java.util.Map map)
          Adds the specified Map to the paramters of the request.
(package private)  boolean containsIncludeCall(java.lang.String target)
          Checks if a given target is already included in a top-layer of this wrapped request.
(package private)  CmsFlexCacheKey getCmsCacheKey()
          Returns the CmsFlexCacheKey for this request, the key will be calculated if neccessary.
protected  java.util.Set getCmsIncludeCalls()
          Returns the Set of include calls which will be passed to the next wrapping layer.
 java.lang.String getElementUri()
          Returns the name of the resource currently processed.
 java.lang.String getParameter(java.lang.String name)
          Return the value of the specified request parameter, if any; otherwise, return null.
 java.util.Map getParameterMap()
          Returns a Map of the parameters of this request.
 java.util.Enumeration 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)
          Overloads the standard servlet API getRequestDispatcher() method, which is the main purpose of this wrapper implementation.
 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.
(package private)  boolean isCacheable()
          This is needed to decide if this request can be cached or not.
 boolean isDoRecompile()
          Checks if JSPs should always be recompiled.
 boolean isOnline()
          Indicates that this request belongs to an online project.
(package private)  void removeIncludeCall(java.lang.String target)
          Removes an include call from this wrapper.
 void setParameterMap(java.util.Map map)
          Sets the specified Map as paramter map of the request.
 java.lang.String toAbsolute(java.lang.String location)
          Convert (if necessary) and return the absolute URI that represents the resource referenced by this possibly relative URI for this request.
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Field Detail

m_req

private javax.servlet.http.HttpServletRequest m_req
The wrapped HttpServletRequest


m_resource

private java.lang.String m_resource
The requested resource (target resource)


m_key

private CmsFlexCacheKey m_key
The CmsFlexCacheKey for this request


m_controller

private CmsFlexController m_controller
The CmsFlexController for this request


m_canCache

private boolean m_canCache
Flag to decide if this request can be cached or not


m_isOnline

private boolean m_isOnline
Flag to check if this request is in the online project or not


m_doRecompile

private boolean m_doRecompile
Flag to force a JSP recompile


m_requestUri

private java.lang.String m_requestUri
Stores the request URI after it was once calculated


m_requestUrl

private java.lang.StringBuffer m_requestUrl
Stores the request URI after it was once calculated


m_includeCalls

private java.util.Set m_includeCalls
Set of all include calls (to prevent an endless inclusion loop)


m_parameters

private java.util.Map m_parameters
Map of parameters from the original request


ATTRIBUTE_PROCESSED

public static java.lang.String ATTRIBUTE_PROCESSED
Attribute name used for checking if _flex request parameters have already been processed


DEBUG

private static final boolean DEBUG
Debug flag

See Also:
Constant Field Values
Constructor Detail

CmsFlexRequest

public CmsFlexRequest(javax.servlet.http.HttpServletRequest req,
                      CmsFlexController controller)
Creates a new CmsFlexRequest wrapper which is most likley the "Top" request wrapper, i.e. the wrapper that is constructed around the first "real" (not wrapped) request.


CmsFlexRequest

CmsFlexRequest(javax.servlet.http.HttpServletRequest req,
               CmsFlexController controller,
               java.lang.String resource)
Constructs a new wrapper layer around a (already wrapped) CmsFlexRequest.

Method Detail

getElementUri

public java.lang.String getElementUri()
Returns the name of the resource currently processed.

This might be the name of an included resource, not neccesarily the name the resource requested by the user.


getRequestDispatcherToExternal

public CmsFlexRequestDispatcher getRequestDispatcherToExternal(java.lang.String vfs_target,
                                                               java.lang.String ext_target)
Replacement for the standard servlet API getRequestDispatcher() method.

This variation is used if an external file (probably JSP) is dispached to. This external file must have a "mirror" version, i.e. a file in the OpenCms VFS that represents the external file.


getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String target)
Overloads the standard servlet API getRequestDispatcher() method, which is the main purpose of this wrapper implementation.


getRequestURI

public java.lang.String 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 idenify the target.


getRequestURL

public java.lang.StringBuffer getRequestURL()
Wraps the request URL, overloading the standard API, the wrapped URL will always point to the currently included VFS resource.


toAbsolute

public java.lang.String toAbsolute(java.lang.String location)
Convert (if necessary) and return the absolute URI that represents the resource referenced by this possibly relative URI for this request.

Adjust for resources in the OpenCms VFS by cutting of servlet context and servlet name. If this URI is already absolute, return it unchanged. Return URI also unchanged if it is not well-formed.


getParameter

public java.lang.String getParameter(java.lang.String name)
Return the value of the specified request parameter, if any; otherwise, return null.

If there is more than one value defined, return only the first one.


getParameterMap

public java.util.Map getParameterMap()
Returns a 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.


getParameterNames

public java.util.Enumeration getParameterNames()
Return the names of all defined request parameters for this request.


getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Returns the defined values for the specified request parameter, if any; otherwise, return null.


addParameterMap

public java.util.Map addParameterMap(java.util.Map map)
Adds the specified Map to the paramters of the request.

Added parametes 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 occurences of the same value for one paramter are also possible.


setParameterMap

public void setParameterMap(java.util.Map map)
Sets the specified Map as paramter map of the request.

The map set should be immutable. This will completly replace the parameter map. Use this in combination with getParameterMap() and addParameterMap() in case you want to set the old status of the parameter map after you have modified it for a specific operation.


getCmsCacheKey

CmsFlexCacheKey getCmsCacheKey()
Returns the CmsFlexCacheKey for this request, the key will be calculated if neccessary.


isOnline

public boolean 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.

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.


isCacheable

boolean isCacheable()
This is needed to decide if this request can be cached or not.

Using the request to decide if caching is used or not makes it possible to set caching to false e.g. on a per-user or per-project basis.


isDoRecompile

public boolean 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.


addInlucdeCall

void addInlucdeCall(java.lang.String target)
Adds another include call to this wrapper.

The set of include calls is maintained to dectect an endless inclusion loop.


removeIncludeCall

void removeIncludeCall(java.lang.String target)
Removes an include call from this wrapper.

The set of include calls is maintained to dectect an endless inclusion loop.


containsIncludeCall

boolean containsIncludeCall(java.lang.String target)
Checks if a given target is already included in a top-layer of this wrapped request.

The set of include calls is maintained to dectect an endless inclusion loop.


getCmsIncludeCalls

protected java.util.Set getCmsIncludeCalls()
Returns the Set of include calls which will be passed to the next wrapping layer.

The set of include calls is maintained to dectect an endless inclusion loop.