Class CmsFlexController
- Since:
- 6.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Information about where to redirect to. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Constant for the controller request attribute name. -
Constructor Summary
ConstructorDescriptionCmsFlexController
(CmsObject cms, CmsResource resource, CmsFlexCache cache, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean streaming, boolean top) Default constructor.CmsFlexController
(CmsObject cms, CmsFlexController base) Creates a new controller form the old one, exchanging just the provided OpenCms user context. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all data of this controller.Returns the CmsFlexCache instance where all results from this request will be cached in.Returns the wrapped CmsObject.static CmsObject
getCmsObject
(javax.servlet.ServletRequest req) Returns the wrapped CmsObject form the provided request, ornull
if the request is not running inside OpenCms.This method provides access to the top-level CmsResource of the request which is of a type that supports the FlexCache, i.e.static CmsFlexController
getController
(javax.servlet.ServletRequest req) Returns the controller from the given request, ornull
if the request is not running inside OpenCms.Returns the current flex request.Returns the current flex response.long
Returns the combined "expires" date for all resources read during this request.long
Returns the combined "last modified" date for all resources read during this request.Gets the information about where to redirect to.int
Returns the size of the response stack.Returns an exception (Throwable) that was caught during inclusion of sub elements, or null if no exceptions where thrown in sub elements.static Throwable
getThrowable
(javax.servlet.ServletRequest req) Provides access to a root cause Exception that might have occurred in a complex include scenario.Returns the URI of a VFS resource that caused the exception that was caught during inclusion of sub elements, might return null if no URI information was available for the exception.static String
getThrowableResourceUri
(javax.servlet.ServletRequest req) Provides access to URI of a VFS resource that caused an exception that might have occurred in a complex include scenario.javax.servlet.http.HttpServletRequest
Returns the current http request.javax.servlet.http.HttpServletResponse
Returns the current http response.static boolean
isCmsOnlineRequest
(javax.servlet.ServletRequest req) Checks if the provided request is running in OpenCms and the current users project is the online project.static boolean
isCmsRequest
(javax.servlet.ServletRequest req) Checks if the provided request is running in OpenCms.boolean
Returnstrue
if the controller does not yet contain any requests.boolean
Returnstrue
if this controller is currently in "forward" mode.static boolean
isNotModifiedSince
(javax.servlet.http.HttpServletRequest req, long dateLastModified) Checks if the request has the "If-Modified-Since" header set, and if so, if the header date value is equal to the provided last modification date.boolean
Returnstrue
if the generated output of the response should be written to the stream directly.boolean
isTop()
Returnstrue
if this controller was generated as top level controller.void
pop()
Removes the topmost request/response pair from the stack.void
push
(CmsFlexRequest req, CmsFlexResponse res) Adds another flex request/response pair to the stack.static void
registerUncacheableAttribute
(String attributeName) Tells the flex controller to never cache the given attribute.static void
removeController
(javax.servlet.ServletRequest req) Removes the controller attribute from a request.void
removeUncacheableAttributes
(Map<String, Object> attributeMap) Removes request attributes which shouldn't be cached in flex cache entries from a map.static void
setController
(javax.servlet.ServletRequest req, CmsFlexController controller) Stores the given controller in the given request (using a request attribute).static void
setDateExpiresHeader
(javax.servlet.http.HttpServletResponse res, long dateExpires, long maxAge) Sets theExpires
date header for a given http request.static void
setDateLastModifiedHeader
(javax.servlet.http.HttpServletResponse res, long dateLastModified) Sets the "last modified" date header for a given http request.void
setForwardMode
(boolean value) Sets the value of the "forward mode" flag.void
setRedirectInfo
(CmsFlexController.RedirectInfo redirectInfo) Sets the information about where to redirect to.setThrowable
(Throwable throwable, String resource) Sets an exception (Throwable) that was caught during inclusion of sub elements.void
Puts the response in a suspended state.void
updateDates
(long dateLastModified, long dateExpires) Updates the "last modified" date and the "expires" date for all resources read during this request with the given values.
-
Field Details
-
ATTRIBUTE_NAME
Constant for the controller request attribute name.- See Also:
-
-
Constructor Details
-
CmsFlexController
Creates a new controller form the old one, exchanging just the provided OpenCms user context.- Parameters:
cms
- the OpenCms user context for this controllerbase
- the base controller
-
CmsFlexController
public CmsFlexController(CmsObject cms, CmsResource resource, CmsFlexCache cache, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean streaming, boolean top) Default constructor.- Parameters:
cms
- the initial CmsObject to wrap in the controllerresource
- the file requestedcache
- the instance of the flex cachereq
- the current requestres
- the current responsestreaming
- indicates if the response is streamingtop
- indicates if the response is the top response
-
-
Method Details
-
getCmsObject
Returns the wrapped CmsObject form the provided request, ornull
if the request is not running inside OpenCms.- Parameters:
req
- the current request- Returns:
- the wrapped CmsObject
-
getController
Returns the controller from the given request, ornull
if the request is not running inside OpenCms.- Parameters:
req
- the request to get the controller from- Returns:
- the controller from the given request, or
null
if the request is not running inside OpenCms
-
getThrowable
Provides access to a root cause Exception that might have occurred in a complex include scenario.- Parameters:
req
- the current request- Returns:
- the root cause exception or null if no root cause exception is available
- See Also:
-
getThrowableResourceUri
Provides access to URI of a VFS resource that caused an exception that might have occurred in a complex include scenario.- Parameters:
req
- the current request- Returns:
- to URI of a VFS resource that caused an exception, or
null
- See Also:
-
isCmsOnlineRequest
Checks if the provided request is running in OpenCms and the current users project is the online project.- Parameters:
req
- the current request- Returns:
true
if the request is running in OpenCms and the current users project is the online project,false
otherwise
-
isCmsRequest
Checks if the provided request is running in OpenCms.- Parameters:
req
- the current request- Returns:
true
if the request is running in OpenCms,false
otherwise
-
isNotModifiedSince
public static boolean isNotModifiedSince(javax.servlet.http.HttpServletRequest req, long dateLastModified) Checks if the request has the "If-Modified-Since" header set, and if so, if the header date value is equal to the provided last modification date.- Parameters:
req
- the request to set the "If-Modified-Since" date header fromdateLastModified
- the date to compare the header with- Returns:
true
if the header is set and the header date is equal to the provided date
-
registerUncacheableAttribute
Tells the flex controller to never cache the given attribute.- Parameters:
attributeName
- the attribute which shouldn't be cached
-
removeController
Removes the controller attribute from a request.- Parameters:
req
- the request to remove the controller from
-
setController
Stores the given controller in the given request (using a request attribute).- Parameters:
req
- the request where to store the controller incontroller
- the controller to store
-
setDateExpiresHeader
public static void setDateExpiresHeader(javax.servlet.http.HttpServletResponse res, long dateExpires, long maxAge) Sets theExpires
date header for a given http request.Also sets the
cache-control: max-age
header to the time of the expiration. A certain upper limit is imposed on the expiration date parameter to ensure the resources are not cached to long in proxies. This can be controlled by themaxAge
parameter. IfmaxAge
is lower then 0, then a default max age of 86400000 msec (1 day) is used.- Parameters:
res
- the response to set the "Expires" date header formaxAge
- maximum amount of time in milliseconds the response remains validdateExpires
- the date to set (if this is not in the future, it is ignored)
-
setDateLastModifiedHeader
public static void setDateLastModifiedHeader(javax.servlet.http.HttpServletResponse res, long dateLastModified) Sets the "last modified" date header for a given http request.- Parameters:
res
- the response to set the "last modified" date header fordateLastModified
- the date to set (if this is lower then 0, the current time is set)
-
clear
Clears all data of this controller. -
getCmsCache
Returns the CmsFlexCache instance where all results from this request will be cached in.This is public so that pages like the Flex Cache Administration page have a way to access the cache object.
- Returns:
- the CmsFlexCache instance where all results from this request will be cached in
-
getCmsObject
Returns the wrapped CmsObject.- Returns:
- the wrapped CmsObject
-
getCmsResource
This method provides access to the top-level CmsResource of the request which is of a type that supports the FlexCache, i.e. usually the CmsFile that is identical to the file uri requested by the user, not he current included element.- Returns:
- the requested top-level CmsFile
-
getCurrentRequest
Returns the current flex request.- Returns:
- the current flex request
-
getCurrentResponse
Returns the current flex response.- Returns:
- the current flex response
-
getDateExpires
Returns the combined "expires" date for all resources read during this request.- Returns:
- the combined "expires" date for all resources read during this request
-
getDateLastModified
Returns the combined "last modified" date for all resources read during this request.- Returns:
- the combined "last modified" date for all resources read during this request
-
getRedirectInfo
Gets the information about where to redirect to.- Returns:
- the redirect information
-
getResponseStackSize
Returns the size of the response stack.- Returns:
- the size of the response stack
-
getThrowable
Returns an exception (Throwable) that was caught during inclusion of sub elements, or null if no exceptions where thrown in sub elements.- Returns:
- an exception (Throwable) that was caught during inclusion of sub elements
-
getThrowableResourceUri
Returns the URI of a VFS resource that caused the exception that was caught during inclusion of sub elements, might return null if no URI information was available for the exception.- Returns:
- the URI of a VFS resource that caused the exception that was caught during inclusion of sub elements
-
getTopRequest
Returns the current http request.- Returns:
- the current http request
-
getTopResponse
Returns the current http response.- Returns:
- the current http response
-
isEmptyRequestList
Returnstrue
if the controller does not yet contain any requests.- Returns:
true
if the controller does not yet contain any requests
-
isForwardMode
Returnstrue
if this controller is currently in "forward" mode.- Returns:
true
if this controller is currently in "forward" mode
-
isStreaming
Returnstrue
if the generated output of the response should be written to the stream directly.- Returns:
true
if the generated output of the response should be written to the stream directly
-
isTop
Returnstrue
if this controller was generated as top level controller.If a resource (e.g. a JSP) is processed and it's content is included in another resource, then this will be
false
.- Returns:
true
if this controller was generated as top level controller- See Also:
-
pop
Removes the topmost request/response pair from the stack. -
push
Adds another flex request/response pair to the stack.- Parameters:
req
- the request to addres
- the response to add
-
removeUncacheableAttributes
Removes request attributes which shouldn't be cached in flex cache entries from a map.- Parameters:
attributeMap
- the map of attributes
-
setForwardMode
Sets the value of the "forward mode" flag.- Parameters:
value
- the forward mode to set
-
setRedirectInfo
Sets the information about where to redirect to.- Parameters:
redirectInfo
- the redirect information
-
setThrowable
Sets an exception (Throwable) that was caught during inclusion of sub elements.If another exception is already set in this controller, then the additional exception is ignored.
- Parameters:
throwable
- the exception (Throwable) to setresource
- the URI of the VFS resource the error occurred on (might benull
if unknown)- Returns:
- the exception stored in the controller
-
suspendFlexResponse
Puts the response in a suspended state. -
updateDates
Updates the "last modified" date and the "expires" date for all resources read during this request with the given values.The currently stored value for "last modified" is only updated with the new value if the new value is either larger (i.e. newer) then the stored value, or if the new value is less then zero, which indicates that the "last modified" optimization can not be used because the element is dynamic.
The stored "expires" value is only updated if the new value is smaller then the stored value.
- Parameters:
dateLastModified
- the value to update the "last modified" date withdateExpires
- the value to update the "expires" date with
-