|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.flex.CmsFlexController
public class CmsFlexController
Controller for getting access to the CmsObject, should be used as a request attribute.
Field Summary | |
---|---|
static java.lang.String |
ATTRIBUTE_NAME
Constant for the controller request attribute name. |
Constructor Summary | |
---|---|
CmsFlexController(CmsObject cms,
CmsFlexController base)
Creates a new controller form the old one, exchanging just the provided OpenCms user context. |
|
CmsFlexController(CmsObject cms,
CmsResource resource,
CmsFlexCache cache,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
boolean streaming,
boolean top)
Default constructor. |
Method Summary | |
---|---|
void |
clear()
Clears all data of this controller. |
CmsFlexCache |
getCmsCache()
Returns the CmsFlexCache instance where all results from this request will be cached in. |
CmsObject |
getCmsObject()
Returns the wrapped CmsObject. |
static CmsObject |
getCmsObject(javax.servlet.ServletRequest req)
Returns the wrapped CmsObject form the provided request, or null if the
request is not running inside OpenCms. |
CmsResource |
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. |
static CmsFlexController |
getController(javax.servlet.ServletRequest req)
Returns the controller from the given request, or null if the
request is not running inside OpenCms. |
CmsFlexRequest |
getCurrentRequest()
Returns the current flex request. |
CmsFlexResponse |
getCurrentResponse()
Returns the current flex response. |
long |
getDateExpires()
Returns the combined "expires" date for all resources read during this request. |
long |
getDateLastModified()
Returns the combined "last modified" date for all resources read during this request. |
int |
getResponseStackSize()
Returns the size of the response stack. |
java.lang.Throwable |
getThrowable()
Returns an exception (Throwable) that was caught during inclusion of sub elements, or null if no exceptions where thrown in sub elements. |
static java.lang.Throwable |
getThrowable(javax.servlet.ServletRequest req)
Provides access to a root cause Exception that might have occurred in a complex include scenario. |
java.lang.String |
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. |
static java.lang.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 |
getTopRequest()
Returns the current http request. |
javax.servlet.http.HttpServletResponse |
getTopResponse()
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 |
isEmptyRequestList()
Returns true if the controller does not yet contain any requests. |
boolean |
isForwardMode()
Returns true 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 |
isStreaming()
Returns true if the generated output of the response should
be written to the stream directly. |
boolean |
isTop()
Returns true 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 |
removeController(javax.servlet.ServletRequest req)
Removes the controller attribute from a request. |
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 the Expires 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. |
java.lang.Throwable |
setThrowable(java.lang.Throwable throwable,
java.lang.String resource)
Sets an exception (Throwable) that was caught during inclusion of sub elements. |
void |
suspendFlexResponse()
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ATTRIBUTE_NAME
Constructor Detail |
---|
public CmsFlexController(CmsObject cms, CmsFlexController base)
cms
- the OpenCms user context for this controllerbase
- the base controllerpublic CmsFlexController(CmsObject cms, CmsResource resource, CmsFlexCache cache, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean streaming, boolean top)
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 responseMethod Detail |
---|
public static CmsObject getCmsObject(javax.servlet.ServletRequest req)
null
if the
request is not running inside OpenCms.
req
- the current request
public static CmsFlexController getController(javax.servlet.ServletRequest req)
null
if the
request is not running inside OpenCms.
req
- the request to get the controller from
null
if the request is not running inside OpenCmspublic static java.lang.Throwable getThrowable(javax.servlet.ServletRequest req)
req
- the current request
getThrowable()
public static java.lang.String getThrowableResourceUri(javax.servlet.ServletRequest req)
req
- the current request
null
getThrowableResourceUri()
public static boolean isCmsOnlineRequest(javax.servlet.ServletRequest req)
req
- the current request
true
if the request is running in OpenCms and the current users project is
the online project, false
otherwisepublic static boolean isCmsRequest(javax.servlet.ServletRequest req)
req
- the current request
true
if the request is running in OpenCms, false
otherwisepublic static boolean isNotModifiedSince(javax.servlet.http.HttpServletRequest req, long dateLastModified)
req
- the request to set the "If-Modified-Since" date header fromdateLastModified
- the date to compare the header with
true
if the header is set and the header date is equal to the provided datepublic static void removeController(javax.servlet.ServletRequest req)
req
- the request to remove the controller frompublic static void setController(javax.servlet.ServletRequest req, CmsFlexController controller)
req
- the request where to store the controller incontroller
- the controller to storepublic static void setDateExpiresHeader(javax.servlet.http.HttpServletResponse res, long dateExpires, long maxAge)
Expires
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 the maxAge
parameter.
If maxAge
is lower then 0, then a default max age of 86400000 msec (1 day) is used.
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)public static void setDateLastModifiedHeader(javax.servlet.http.HttpServletResponse res, long dateLastModified)
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)public void clear()
public CmsFlexCache getCmsCache()
This is public so that pages like the Flex Cache Administration page have a way to access the cache object.
public CmsObject getCmsObject()
public CmsResource getCmsResource()
public CmsFlexRequest getCurrentRequest()
public CmsFlexResponse getCurrentResponse()
public long getDateExpires()
public long getDateLastModified()
public int getResponseStackSize()
public java.lang.Throwable getThrowable()
public java.lang.String getThrowableResourceUri()
public javax.servlet.http.HttpServletRequest getTopRequest()
public javax.servlet.http.HttpServletResponse getTopResponse()
public boolean isEmptyRequestList()
true
if the controller does not yet contain any requests.
true
if the controller does not yet contain any requestspublic boolean isForwardMode()
true
if this controller is currently in "forward" mode.
true
if this controller is currently in "forward" modepublic boolean isStreaming()
true
if the generated output of the response should
be written to the stream directly.
true
if the generated output of the response should be written to the stream directlypublic boolean isTop()
true
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
.
true
if this controller was generated as top level controllerI_CmsResourceLoader.dump(CmsObject, CmsResource, String, java.util.Locale, HttpServletRequest, HttpServletResponse)
,
CmsJspActionElement.getContent(String)
public void pop()
public void push(CmsFlexRequest req, CmsFlexResponse res)
req
- the request to addres
- the response to addpublic void setForwardMode(boolean value)
value
- the forward mode to setpublic java.lang.Throwable setThrowable(java.lang.Throwable throwable, java.lang.String resource)
If another exception is already set in this controller, then the additional exception is ignored.
throwable
- the exception (Throwable) to setresource
- the URI of the VFS resource the error occurred on (might be null
if unknown)
public void suspendFlexResponse()
public void updateDates(long dateLastModified, long dateExpires)
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.
dateLastModified
- the value to update the "last modified" date withdateExpires
- the value to update the "expires" date with
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |