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

Quick Search    Search Deep

com.opencms.file
Class CmsRequestContext  view CmsRequestContext download CmsRequestContext.java

java.lang.Object
  extended bycom.opencms.file.CmsRequestContext
All Implemented Interfaces:
com.opencms.core.I_CmsConstants

public class CmsRequestContext
extends java.lang.Object
implements com.opencms.core.I_CmsConstants

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.

Version:
$Revision: 1.67 $ $Date: 2003/03/07 16:15:49 $

Field Summary
private  java.util.HashMap m_attributeMap
          A map for storing (optional) request context attributes
private  CmsGroup m_currentGroup
          The current group of the user
private  CmsProject m_currentProject
          The current project
private  java.util.Vector m_dependencies
          In export mode this vector is used to store all dependencies this request may have.
private  com.opencms.flex.util.CmsResourceTranslator m_directoryTranslator
          Directroy name translator
private  com.opencms.template.cache.CmsElementCache m_elementCache
          Starting point for element cache
private  java.lang.String m_encoding
          Current encoding
private  boolean m_eventControlled
          Flag to indicate that this request is event controlled
private  com.opencms.flex.util.CmsResourceTranslator m_fileTranslator
          File name translator
private  java.util.Vector m_language
          Current languages
private  java.util.Vector m_links
          In export mode the links in pages will be stored in this vector for further processing.
private  I_CmsResourceBroker m_rb
          The rb to get access to the OpenCms
private  com.opencms.core.I_CmsRequest m_req
          The current CmsRequest
private  com.opencms.core.I_CmsResponse m_resp
          The current CmsResponse
private  java.lang.String m_siteRoot
          The name of the root, e.g.
private  boolean m_streaming
          Flag to indicate if this response is streaming or not (legacy, not used by Element or Flex cache)
private  boolean m_updateSession
          Flag to indicate that this context should not update the user session
private  java.lang.String m_uri
          The URI for getUri() in case it is "overwritten"
private  CmsUser m_user
          The current user
 
Fields inherited from interface com.opencms.core.I_CmsConstants
C_ACCESS_DEFAULT_FLAGS, C_ACCESS_GROUP, C_ACCESS_GROUP_READ, C_ACCESS_GROUP_VISIBLE, C_ACCESS_GROUP_WRITE, C_ACCESS_INTERNAL_READ, C_ACCESS_OWNER, C_ACCESS_OWNER_READ, C_ACCESS_OWNER_VISIBLE, C_ACCESS_OWNER_WRITE, C_ACCESS_PUBLIC, C_ACCESS_PUBLIC_READ, C_ACCESS_PUBLIC_VISIBLE, C_ACCESS_PUBLIC_WRITE, C_ACCESS_READ, C_ACCESS_VISIBLE, C_ACCESS_WRITE, C_ADDITIONAL_INFO_EXPLORERSETTINGS, C_ADDITIONAL_INFO_PREFERENCES, C_ADDITIONAL_INFO_STARTSETTINGS, C_ADDITIONAL_INFO_TASKSETTINGS, C_ADDITIONAL_INFO_TOWN, C_ADDITIONAL_INFO_ZIPCODE, C_AT_LEAST_ONCE, C_CLUSTERURL, C_CONFIGURATION_CACHE, C_CONFIGURATION_CLASS, C_CONFIGURATION_REGISTRY, C_CONFIGURATION_RESOURCEBROKER, C_COPYRIGHT, C_DEFAULT_SITE, C_DELETE_HISTORY, C_ENABLE_HISTORY, C_ERRPREFIX, C_ERRSPERATOR, C_EXPORT_TAG_ACCESS, C_EXPORT_TAG_ADDRESS, C_EXPORT_TAG_CREATOR, C_EXPORT_TAG_DATE, C_EXPORT_TAG_DEFAULTGROUP, C_EXPORT_TAG_DESCRIPTION, C_EXPORT_TAG_DESTINATION, C_EXPORT_TAG_EMAIL, C_EXPORT_TAG_EXPORT, C_EXPORT_TAG_FILE, C_EXPORT_TAG_FIRSTNAME, C_EXPORT_TAG_FLAGS, C_EXPORT_TAG_GROUP, C_EXPORT_TAG_GROUPDATA, C_EXPORT_TAG_GROUPNAME, C_EXPORT_TAG_INFO, C_EXPORT_TAG_LASTMODIFIED, C_EXPORT_TAG_LASTNAME, C_EXPORT_TAG_LAUNCHER_START_CLASS, C_EXPORT_TAG_MODULEXPORT, C_EXPORT_TAG_NAME, C_EXPORT_TAG_OC_VERSION, C_EXPORT_TAG_PARENTGROUP, C_EXPORT_TAG_PASSWORD, C_EXPORT_TAG_PROJECT, C_EXPORT_TAG_PROPERTIES, C_EXPORT_TAG_PROPERTY, C_EXPORT_TAG_RECOVERYPASSWORD, C_EXPORT_TAG_SECTION, C_EXPORT_TAG_SOURCE, C_EXPORT_TAG_TYPE, C_EXPORT_TAG_USER, C_EXPORT_TAG_USERDATA, C_EXPORT_TAG_USERGROUPDATA, C_EXPORT_TAG_USERGROUPS, C_EXPORT_TAG_USERINFO, C_EXPORT_TAG_VALUE, C_EXPORT_TAG_VERSION, C_EXPORT_VERSION, C_EXPORT_XMLFILENAME, C_EXPORTONLYFILES, C_EXPORTONLYUSERS, C_EXPORTPOINT, C_EXPORTPOINT_PATH, C_EXPORTUSERSFILES, C_FCONTENT, C_FELEMENT, C_FILE, C_FILECONTENT, C_FILES_IMPORTED, C_FLAG_DISABLED, C_FLAG_ENABLED, C_FLAG_GROUP_PROJECTCOWORKER, C_FLAG_GROUP_PROJECTMANAGER, C_FLAG_GROUP_ROLE, C_FOLDER, C_FOLDER_SEPARATOR, C_GROUP, C_GROUP_ADMIN, C_GROUP_GUEST, C_GROUP_PROJECTLEADER, C_GROUP_USERS, C_LINKCHECKTABLE_DATE, C_MAX_LENGTH_RESOURCE_NAME, C_MODULE_PROPERTY_ADDITIONAL_RESOURCES, C_MODULE_PROPERTY_ADDITIONAL_RESOURCES_SEPARATOR, C_MODUS_AUTO, C_MODUS_EXPORT, C_MODUS_EXTERN, C_MODUS_OFFLINE, C_MODUS_ONLINE, C_MOUNTPOINT_FILESYSTEM, C_MOUNTPOINT_MYSQL, C_NEVER, C_NO_FILES_IMPORTED, C_ORDER_AGENTUSER, C_ORDER_ENDTIME, C_ORDER_ID, C_ORDER_INITIATORUSER, C_ORDER_NAME, C_ORDER_ORIGINALUSER, C_ORDER_PERCENTAGE, C_ORDER_PRIORITY, C_ORDER_ROLE, C_ORDER_STARTTIME, C_ORDER_STATE, C_ORDER_TASKTYPE, C_ORDER_TIMEOUT, C_ORDER_WAKEUPTIME, C_PASSWORD_MINIMUMSIZE, C_PROJECT_ONLINE, C_PROJECT_ONLINE_ID, C_PROJECT_STATE_ARCHIVE, C_PROJECT_STATE_INVISIBLE, C_PROJECT_STATE_LOCKED, C_PROJECT_STATE_UNLOCKED, C_PROJECT_TYPE_INVISIBLE, C_PROJECT_TYPE_NORMAL, C_PROJECT_TYPE_TEMPORARY, C_PROPERTY_ACTIV, C_PROPERTY_CHANNELID, C_PROPERTY_CONTENT_ENCODING, C_PROPERTY_DEFAULT_FILE, C_PROPERTY_DESCRIPTION, C_PROPERTY_EXPORT, C_PROPERTY_EXPORTNAME, C_PROPERTY_KEYWORDS, C_PROPERTY_NAVPOS, C_PROPERTY_NAVTEXT, C_PROPERTY_RELATIVEROOT, C_PROPERTY_TEMPLATETYPE, C_PROPERTY_TITLE, C_PROPERTY_VISIBLE, C_PUBLISH_METHOD_LINK, C_REGISTRY_DESTINATION, C_REGISTRY_HISTORY, C_REGISTRY_KNOWNLAUNCHERS, C_REGISTRY_LAUNCHER, C_REGISTRY_SOURCE, C_REQUEST_CONSOLE, C_REQUEST_HTTP, C_RESPONSE_CONSOLE, C_RESPONSE_HTTP, C_ROOT, C_ROOT_TEMPLATE_NAME, C_ROOTNAME_COS, C_ROOTNAME_VFS, C_SESSION_ADMIN_POS, C_SESSION_BROADCASTMESSAGE, C_SESSION_CONTENT_ENCODING, C_SESSION_CURRENTGROUP, C_SESSION_DATA, C_SESSION_IS_DIRTY, C_SESSION_MESSAGEPENDING, C_SESSION_MODULE_VECTOR, C_SESSION_PROJECT, C_SESSION_THREAD_ERROR, C_SESSION_USERNAME, C_SORT_ASC, C_SORT_DESC, C_START_ACCESSFLAGS, C_START_DEFAULTGROUP, C_START_LANGUAGE, C_START_LOCKDIALOG, C_START_PROJECT, C_START_VIEW, C_STATE_CHANGED, C_STATE_DELETED, C_STATE_NEW, C_STATE_UNCHANGED, C_STATICEXPORT_PATH, C_STATICEXPORT_START, C_SYNCHRONISATION_PATH, C_SYNCHRONISATION_PROJECT, C_SYNCHRONISATION_RESOURCE, C_SYNCHRONISATION_RESOURCETAG, C_SYSTEMPROPERTY_CRONTABLE, C_SYSTEMPROPERTY_EXPORTPATH, C_SYSTEMPROPERTY_EXTENSIONS, C_SYSTEMPROPERTY_LINKCHECKTABLE, C_SYSTEMPROPERTY_MIMETYPES, C_SYSTEMPROPERTY_MOUNTPOINT, C_SYSTEMPROPERTY_RESOURCE_TYPE, C_TABLE_CHANNELID, C_TASK_FILTER, C_TASK_MESSAGES, C_TASK_MESSAGES_ACCEPTED, C_TASK_MESSAGES_COMPLETED, C_TASK_MESSAGES_FORWARDED, C_TASK_MESSAGES_MEMBERS, C_TASK_ORDER_BY_DATE, C_TASK_ORDER_BY_NAME, C_TASK_PRIORITY_HIGH, C_TASK_PRIORITY_LOW, C_TASK_PRIORITY_NORMAL, C_TASK_STATE_ENDED, C_TASK_STATE_HALTED, C_TASK_STATE_NOTENDED, C_TASK_STATE_PREPARE, C_TASK_STATE_START, C_TASK_STATE_STARTED, C_TASK_VIEW_ALL, C_TASKLOG_SYSTEM, C_TASKLOG_USER, C_TASKORDER_NONE, C_TASKORDER_STARTDATE, C_TASKORDER_TIMEOUT, C_TASKS_ACTIVE, C_TASKS_ALL, C_TASKS_DONE, C_TASKS_NEW, C_TASKS_OPEN, C_TASKSORDER_TASKNAME, C_TEMP_PREFIX, C_TFACCESS, C_TFGROUP, C_TFILEOBJ, C_TFILES, C_TFNAME, C_TFPROPERTYINFO, C_TFPROPERTYNAME, C_TFPROPERTYTYPE, C_TFPROPERTYVALUE, C_TFTYPE, C_TFTYPENAME, C_TFUSER, C_TGDESC, C_TGFLAG, C_TGNAME, C_TGPARENTGROUP, C_TGROUPOBJ, C_TGROUPS, C_TGROUPUSERS, C_TGUSER, C_TUADDINFO, C_TUDESC, C_TUDGROUP, C_TUDISABLED, C_TUEMAIL, C_TUFIRSTNAME, C_TUFLAG, C_TUGROUP, C_TUINFOKEY, C_TUINFOVALUE, C_TULOGIN, C_TUNAME, C_TUPASSWD, C_TUSERGROUPS, C_TUSEROBJ, C_TUSERS, C_TYPE_BODY_NAME, C_TYPE_COMPATIBLEPLAIN_NAME, C_TYPE_FOLDER, C_TYPE_FOLDER_NAME, C_TYPE_IMAGE_NAME, C_TYPE_LAST_INDEX, C_TYPE_PAGE_NAME, C_TYPE_PLAIN_NAME, C_UNKNOWN_ID, C_UNKNOWN_INT, C_UNKNOWN_LAUNCHER, C_UNKNOWN_LAUNCHER_ID, C_UNKNOWN_LONG, C_URL_PREFIX_EXPORT, C_URL_PREFIX_HTTP, C_URL_PREFIX_HTTPS, C_URL_PREFIX_SERVERNAME, C_USER, C_USER_ADMIN, C_USER_GUEST, C_USER_TYPE_SYSTEMANDWEBUSER, C_USER_TYPE_SYSTEMUSER, C_USER_TYPE_WEBUSER, C_WEB_APP_REPLACE_KEY, C_WEEKS_HISTORY, C_WHATEVER, C_XML_BODY_ELEMENT
 
Constructor Summary
CmsRequestContext()
          The default constructor.
 
Method Summary
 void addDependency(java.lang.String rootName)
          Adds a dependency.
 void addLink(java.lang.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.
 java.util.Vector getAcceptedLanguages()
          Get a Vector of all accepted languages for this request.
 java.lang.Object getAttribute(java.lang.String attributeName)
          Gets the value of an attribute from the OpenCms request context attribute list.
 java.util.Vector getDependencies()
          Returns all dependencies the templatemechanism has registered.
 com.opencms.flex.util.CmsResourceTranslator getDirectoryTranslator()
           
 com.opencms.template.cache.CmsElementCache getElementCache()
          Get the CmsElementCache object.
 java.lang.String getEncoding()
          Returns the current content encoding to be used in HTTP response
 com.opencms.flex.util.CmsResourceTranslator getFileTranslator()
           
 java.lang.String getFileUri()
          Gets the name of the requested file without any path-information.
 java.lang.String getFolderUri()
          Gets the name of the parent folder of the requested file
 java.util.Vector getLinkVector()
          Returns all links that the template mechanism has registered.
 com.opencms.core.I_CmsRequest getRequest()
          Gets the current request, if availaible.
 com.opencms.core.I_CmsResponse getResponse()
          Gets the current response, if availaible.
 com.opencms.core.I_CmsSession getSession(boolean value)
          Gets the Session for this request.
 java.lang.String getSiteName()
          Returns the site name, e.g.
 java.lang.String getSiteRoot()
          Returns the site root, e.g.
 java.lang.String getSiteRoot(java.lang.String resourcename)
          Returns the name of the current site root, e.g.
 java.lang.String getUri()
          Gets the uri for the requested resource.
(package private)  void init(I_CmsResourceBroker rb, com.opencms.core.I_CmsRequest req, com.opencms.core.I_CmsResponse resp, java.lang.String user, java.lang.String currentGroup, int currentProjectId, boolean streaming, com.opencms.template.cache.CmsElementCache elementCache, com.opencms.flex.util.CmsResourceTranslator directoryTranslator, com.opencms.flex.util.CmsResourceTranslator fileTranslator)
          Initializes this RequestContext.
 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(java.lang.String key, java.lang.Object value)
          Sets an attribute in the request context.
 void setContextTo(java.lang.String name)
          Sets the name of the current site root of the virtual file system
 void setCurrentGroup(java.lang.String groupname)
          Sets the current group of the current user.
 CmsProject setCurrentProject(int projectId)
          Sets the current project for the user.
 void setEncoding(java.lang.String encoding)
          Sets the current content encoding to be used in HTTP response
 void setEncoding(java.lang.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(java.lang.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
 

Field Detail

m_rb

private I_CmsResourceBroker m_rb
The rb to get access to the OpenCms


m_req

private com.opencms.core.I_CmsRequest m_req
The current CmsRequest


m_resp

private com.opencms.core.I_CmsResponse m_resp
The current CmsResponse


m_user

private CmsUser m_user
The current user


m_currentGroup

private CmsGroup m_currentGroup
The current group of the user


m_currentProject

private CmsProject m_currentProject
The current project


m_streaming

private boolean m_streaming
Flag to indicate if this response is streaming or not (legacy, not used by Element or Flex cache)


m_links

private java.util.Vector m_links
In export mode the links in pages will be stored in this vector for further processing.


m_eventControlled

private boolean m_eventControlled
Flag to indicate that this request is event controlled


m_updateSession

private boolean m_updateSession
Flag to indicate that this context should not update the user session


m_dependencies

private java.util.Vector m_dependencies
In export mode this vector is used to store all dependencies this request may have. It is saved to the database and if one of the dependencies changes the request will be exported again.


m_elementCache

private com.opencms.template.cache.CmsElementCache m_elementCache
Starting point for element cache


m_language

private java.util.Vector m_language
Current languages


m_siteRoot

private java.lang.String m_siteRoot
The name of the root, e.g. /site_a/vfs


m_encoding

private java.lang.String m_encoding
Current encoding


m_uri

private java.lang.String m_uri
The URI for getUri() in case it is "overwritten"


m_directoryTranslator

private com.opencms.flex.util.CmsResourceTranslator m_directoryTranslator
Directroy name translator


m_fileTranslator

private com.opencms.flex.util.CmsResourceTranslator m_fileTranslator
File name translator


m_attributeMap

private java.util.HashMap m_attributeMap
A map for storing (optional) request context attributes

Constructor Detail

CmsRequestContext

public CmsRequestContext()
The default constructor.

Method Detail

init

void init(I_CmsResourceBroker rb,
          com.opencms.core.I_CmsRequest req,
          com.opencms.core.I_CmsResponse resp,
          java.lang.String user,
          java.lang.String currentGroup,
          int currentProjectId,
          boolean streaming,
          com.opencms.template.cache.CmsElementCache elementCache,
          com.opencms.flex.util.CmsResourceTranslator directoryTranslator,
          com.opencms.flex.util.CmsResourceTranslator fileTranslator)
    throws com.opencms.core.CmsException
Initializes this RequestContext.


addLink

public void addLink(java.lang.String link)
Adds a link for the static export.


getLinkVector

public java.util.Vector getLinkVector()
Returns all links that the template mechanism has registered.


addDependency

public void addDependency(java.lang.String rootName)
Adds a dependency.


getDependencies

public java.util.Vector getDependencies()
Returns all dependencies the templatemechanism has registered.


currentFolder

public CmsFolder currentFolder()
                        throws com.opencms.core.CmsException
Returns the current folder object.


currentGroup

public CmsGroup currentGroup()
Returns the current group of the current user.


currentProject

public CmsProject currentProject()
Returns the current project of the current user.


currentUser

public CmsUser currentUser()
Returns the current user object.


getFileUri

public java.lang.String getFileUri()
Gets the name of the requested file without any path-information.


getFolderUri

public java.lang.String getFolderUri()
Gets the name of the parent folder of the requested file


getRequest

public com.opencms.core.I_CmsRequest getRequest()
Gets the current request, if availaible.


getResponse

public com.opencms.core.I_CmsResponse getResponse()
Gets the current response, if availaible.


getSession

public com.opencms.core.I_CmsSession getSession(boolean value)
Gets the Session for this request.

This method should be used instead of the originalRequest.getSession() method.


getUri

public java.lang.String getUri()
Gets the uri for the requested resource.

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.


setUri

public void setUri(java.lang.String value)
Set the value that is returned by getUri() to the provided String.

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.

Since:
5.0 beta 1

isAdmin

public boolean isAdmin()
                throws com.opencms.core.CmsException
Determines if the users is in the admin-group.


isProjectManager

public boolean isProjectManager()
                         throws com.opencms.core.CmsException
Determines if the users current group is the projectmanager-group.

All projectmanagers can create new projects, or close their own projects.


setCurrentGroup

public void setCurrentGroup(java.lang.String groupname)
                     throws com.opencms.core.CmsException
Sets the current group of the current user.


setCurrentProject

public CmsProject setCurrentProject(int projectId)
                             throws com.opencms.core.CmsException
Sets the current project for the user.


isStreaming

public boolean isStreaming()
Get the current mode for HTTP streaming.


setStreaming

public void setStreaming(boolean b)
                  throws com.opencms.core.CmsException
Set the current mode for HTTP streaming.

Calling this method is only allowed, if the response output stream was not used before. Otherwise the streaming mode must not be changed.


isElementCacheEnabled

public boolean isElementCacheEnabled()
Get the current mode for element cache.


getElementCache

public com.opencms.template.cache.CmsElementCache getElementCache()
Get the CmsElementCache object. This is the starting point for the element cache area.


getAcceptedLanguages

public java.util.Vector getAcceptedLanguages()
Get a Vector of all accepted languages for this request. Languages are coded in international shortcuts like "en" or "de". If the browser has sent special versions of languages (e.g. "de-ch" for Swiss-German) these extensions will be cut off.


getSiteRoot

public java.lang.String getSiteRoot(java.lang.String resourcename)
Returns the name of the current site root, e.g. /default/vfs


getDirectoryTranslator

public com.opencms.flex.util.CmsResourceTranslator getDirectoryTranslator()

getFileTranslator

public com.opencms.flex.util.CmsResourceTranslator getFileTranslator()

getSiteName

public java.lang.String getSiteName()
Returns the site name, e.g. /default


getSiteRoot

public java.lang.String getSiteRoot()
Returns the site root, e.g. /default/vfs * @return the site root, e.g. /default/vfs


setContextTo

public void setContextTo(java.lang.String name)
Sets the name of the current site root of the virtual file system


initEncoding

public void initEncoding()
Detects current content encoding to be used in HTTP response based on requested resource or session state.


getEncoding

public java.lang.String getEncoding()
Returns the current content encoding to be used in HTTP response


setEncoding

public void setEncoding(java.lang.String encoding)
Sets the current content encoding to be used in HTTP response


setEncoding

public void setEncoding(java.lang.String encoding,
                        boolean storeInSession)
Sets the current content encoding to be used in HTTP response and store it in session if it is available


setEventControlled

public void setEventControlled(boolean value)
Mark this request context as event controlled.


isEventControlled

public boolean isEventControlled()
Check if this request context is event controlled.


setUpdateSessionEnabled

public void setUpdateSessionEnabled(boolean value)
Mark this request context to update the session or not.


isUpdateSessionEnabled

public boolean isUpdateSessionEnabled()
Check if this request context will update the session.


getAttribute

public java.lang.Object getAttribute(java.lang.String attributeName)
Gets the value of an attribute from the OpenCms request context attribute list.


setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Sets an attribute in the request context.