|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.opencms.file.CmsRequestContext
This class provides access to the CmsRequestContext.
In the CmsRequestContext class are all methods bundled, which can inform about the
current request properties, like the url or uri of the request.
| Field Summary |
| Constructor Summary | |
CmsRequestContext()
The default constructor. |
|
| Method Summary | |
void |
addDependency(String rootName)
Adds a dependency. |
void |
addLink(String link)
Adds a link for the static export. |
CmsFolder |
currentFolder()
Returns the current folder object. |
CmsGroup |
currentGroup()
Returns the current group of the current user. |
CmsProject |
currentProject()
Returns the current project of the current user. |
CmsUser |
currentUser()
Returns the current user object. |
Vector |
getAcceptedLanguages()
Get a Vector of all accepted languages for this request. |
Object |
getAttribute(String attributeName)
Gets the value of an attribute from the OpenCms request context attribute list. |
Vector |
getDependencies()
Returns all dependencies the templatemechanism has registered. |
CmsResourceTranslator |
getDirectoryTranslator()
|
CmsElementCache |
getElementCache()
Get the CmsElementCache object. |
String |
getEncoding()
Returns the current content encoding to be used in HTTP response |
CmsResourceTranslator |
getFileTranslator()
|
String |
getFileUri()
Gets the name of the requested file without any path-information. |
String |
getFolderUri()
Gets the name of the parent folder of the requested file |
Vector |
getLinkVector()
Returns all links that the template mechanism has registered. |
I_CmsRequest |
getRequest()
Gets the current request, if availaible. |
I_CmsResponse |
getResponse()
Gets the current response, if availaible. |
I_CmsSession |
getSession(boolean value)
Gets the Session for this request. |
String |
getSiteName()
Returns the site name, e.g. |
String |
getSiteRoot()
Returns the site root, e.g. |
String |
getSiteRoot(String resourcename)
Returns the name of the current site root, e.g. |
String |
getUri()
Gets the uri for the requested resource. |
void |
initEncoding()
Detects current content encoding to be used in HTTP response based on requested resource or session state. |
boolean |
isAdmin()
Determines if the users is in the admin-group. |
boolean |
isElementCacheEnabled()
Get the current mode for element cache. |
boolean |
isEventControlled()
Check if this request context is event controlled. |
boolean |
isProjectManager()
Determines if the users current group is the projectmanager-group. |
boolean |
isStreaming()
Get the current mode for HTTP streaming. |
boolean |
isUpdateSessionEnabled()
Check if this request context will update the session. |
void |
setAttribute(String key,
Object value)
Sets an attribute in the request context. |
void |
setContextTo(String name)
Sets the name of the current site root of the virtual file system |
void |
setCurrentGroup(String groupname)
Sets the current group of the current user. |
CmsProject |
setCurrentProject(int projectId)
Sets the current project for the user. |
void |
setEncoding(String encoding)
Sets the current content encoding to be used in HTTP response |
void |
setEncoding(String encoding,
boolean storeInSession)
Sets the current content encoding to be used in HTTP response and store it in session if it is available |
void |
setEventControlled(boolean value)
Mark this request context as event controlled. |
void |
setStreaming(boolean b)
Set the current mode for HTTP streaming. |
void |
setUpdateSessionEnabled(boolean value)
Mark this request context to update the session or not. |
void |
setUri(String value)
Set the value that is returned by getUri() to the provided String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CmsRequestContext()
| Method Detail |
public void addLink(String link)
public Vector getLinkVector()
public void addDependency(String rootName)
public Vector getDependencies()
public CmsFolder currentFolder()
throws CmsException
CmsException - if operation was not successful.public CmsGroup currentGroup()
public CmsProject currentProject()
public CmsUser currentUser()
public String getFileUri()
public String getFolderUri()
public I_CmsRequest getRequest()
public I_CmsResponse getResponse()
public I_CmsSession getSession(boolean value)
This method should be used instead of the originalRequest.getSession() method.
value - indicates, if a session should be created when a session for the particular client does not already exist.
null if no session already exists and value was set to falsepublic String getUri()
For a http request, the name of the resource is extracted as follows:
http://{servername}/{servletpath}/{path to the cms resource}
In the following example:
http://my.work.server/servlet/opencms/system/def/explorer
the requested resource is /system/def/explorer.
public void setUri(String value)
This is required in a context where a cascade of included XMLTemplates are combined with JSP or other Templates that use the ResourceLoader interface. You need to fake the URI because the ElementCache always uses cms.getRequestContext().getUri() even if you called CmsXmlLauncher.generateOutput() with a differnt file name.
value - The value to set the Uri to, must be a complete OpenCms path name like /system/workplace/stlye.css
public boolean isAdmin()
throws CmsException
true if the users current group is the admin-group; false otherwise.
CmsException - if operation was not successful.
public boolean isProjectManager()
throws CmsException
All projectmanagers can create new projects, or close their own projects.
true if the users current group is the projectleader-group; false otherwise.
CmsException - if operation was not successful.
public void setCurrentGroup(String groupname)
throws CmsException
groupname - the name of the group to be set as current group.
CmsException - if operation was not successful.
public CmsProject setCurrentProject(int projectId)
throws CmsException
projectId - the id of the project to be set as current project.
CmsException - if operation was not successful.public boolean isStreaming()
true if template classes are allowed to stream the
results to the response output stream theirselves, false otherwise.
public void setStreaming(boolean b)
throws CmsException
Calling this method is only allowed, if the response output stream was not used before. Otherwise the streaming mode must not be changed.
b - true if template classes are allowed to stream the
results to the response's output stream theirselves, false otherwise.
CmsException - if the output stream was already used previously.public boolean isElementCacheEnabled()
true if element cache is active, false otherwise.public CmsElementCache getElementCache()
public Vector getAcceptedLanguages()
null if no request object is available.public String getSiteRoot(String resourcename)
resourcename -
public CmsResourceTranslator getDirectoryTranslator()
public CmsResourceTranslator getFileTranslator()
public String getSiteName()
/default
/defaultpublic String getSiteRoot()
/default/vfs
* @return the site root, e.g. /default/vfs
public void setContextTo(String name)
public void initEncoding()
public String getEncoding()
public void setEncoding(String encoding)
public void setEncoding(String encoding,
boolean storeInSession)
public void setEventControlled(boolean value)
public boolean isEventControlled()
public void setUpdateSessionEnabled(boolean value)
public boolean isUpdateSessionEnabled()
public Object getAttribute(String attributeName)
attributeName - the attribute name
null if the attribute was not found
public void setAttribute(String key,
Object value)
key - the attribute namevalue - the attribute value
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||