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

Quick Search    Search Deep

com.opencms.core
Class OpenCmsHttpServlet  view OpenCmsHttpServlet download OpenCmsHttpServlet.java

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.opencms.core.OpenCmsHttpServlet
All Implemented Interfaces:
I_CmsConstants, com.opencms.boot.I_CmsLogChannels, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class OpenCmsHttpServlet
extends javax.servlet.http.HttpServlet
implements I_CmsConstants, com.opencms.boot.I_CmsLogChannels

This the main servlet of the OpenCms system.

From here, all other operations are invoked. Any incoming request is handled in multiple steps:

  1. The requesting user is authenticated and a CmsObject with the user information is created. The CmsObject is used to access all functions of OpenCms, limited by the authenticated users permissions. If the user is not identified, it is set to the default (guest) user.
  2. The requested document is loaded into OpenCms and depending on its type (and the users persmissions to display or modify it), it is send to one of the OpenCms launchers do be processed.
  3. The loaded launcher will then decide what to do with the contents of the requested document. In case of an XMLTemplate the template mechanism will be started, in case of a JSP the JSP handling mechanism is invoked, in case of an image (or other static file) this will simply be returned etc.

Version:
$Revision: 1.47 $ $Date: 2003/04/25 07:40:20 $

Field Summary
private static java.lang.String C_ERRORMSG
          Prefix for error messages for initialization errors.
(package private) static java.lang.String C_PROPERTY_REDIRECT
          The name of the redirect entry in the configuration file.
(package private) static java.lang.String C_PROPERTY_REDIRECTLOCATION
          The name of the redirect location entry in the configuration file.
private static boolean DEBUG
          Flag for debugging.
private  java.lang.String m_AuthenticationFormURI
          URI of the authentication form (read from properties).
private  java.lang.String m_clusterurl
          Storage for the clusterurl.
private  source.org.apache.java.util.Configurations m_configurations
          The configuration for the OpenCms servlet.
private  OpenCms m_opencms
          The reference to the OpenCms system.
private  CmsCoreSession m_sessionStorage
          The session storage for all active users.
private  boolean m_UseBasicAuthentication
          Flag to indicate if basic or form based authentication is used.
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
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
 
Fields inherited from interface com.opencms.boot.I_CmsLogChannels
C_FLEX_CACHE, C_FLEX_LOADER, C_LOGGING, C_MODULE_CRITICAL, C_MODULE_DEBUG, C_MODULE_INFO, C_OPENCMS_CACHE, C_OPENCMS_CRITICAL, C_OPENCMS_CRONSCHEDULER, C_OPENCMS_DEBUG, C_OPENCMS_ELEMENTCACHE, C_OPENCMS_INFO, C_OPENCMS_INIT, C_OPENCMS_POOL, C_OPENCMS_STATICEXPORT, C_OPENCMS_STREAMING, C_PREPROCESSOR_IS_LOGGING
 
Constructor Summary
OpenCmsHttpServlet()
           
 
Method Summary
private  java.lang.String createErrorBox(CmsException e, com.opencms.file.CmsObject cms)
          Generates a formated exception output.
 void destroy()
          Destroys all running threads before closing the VM.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Method invoked on each HTML GET request.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Method invoked on each HTML POST request.
private  void errorHandling(com.opencms.file.CmsObject cms, I_CmsRequest cmsReq, I_CmsResponse cmsRes, CmsException e)
          This method performs the error handling for the OpenCms.
 java.lang.String getErrormsg(java.lang.String part)
          Get the value for the property entry
 void init(javax.servlet.ServletConfig config)
          Initialization of the OpenCms servlet (overloaded Servlet API method).
private  com.opencms.file.CmsObject initUser(I_CmsRequest cmsReq, I_CmsResponse cmsRes)
          This method handled the user authentification for each request sent to the OpenCms.
private  void printCopyrightInformation()
          Prints the OpenCms copyright information to all log-files.
private  void requestAuthorization(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          This method sends a request to the client to display a login form.
private  void throwInitException(javax.servlet.ServletException cause)
          Throws a servlet exception that is also logged and written to the error output console.
private  void updateUser(com.opencms.file.CmsObject cms, I_CmsRequest cmsReq)
          Updates the the user data stored in the CmsCoreSession after the requested document is processed.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C_PROPERTY_REDIRECT

static final java.lang.String C_PROPERTY_REDIRECT
The name of the redirect entry in the configuration file.

See Also:
Constant Field Values

C_PROPERTY_REDIRECTLOCATION

static final java.lang.String C_PROPERTY_REDIRECTLOCATION
The name of the redirect location entry in the configuration file.

See Also:
Constant Field Values

m_configurations

private source.org.apache.java.util.Configurations m_configurations
The configuration for the OpenCms servlet.


m_sessionStorage

private CmsCoreSession m_sessionStorage
The session storage for all active users.


m_opencms

private OpenCms m_opencms
The reference to the OpenCms system.


m_clusterurl

private java.lang.String m_clusterurl
Storage for the clusterurl.


m_UseBasicAuthentication

private boolean m_UseBasicAuthentication
Flag to indicate if basic or form based authentication is used.


m_AuthenticationFormURI

private java.lang.String m_AuthenticationFormURI
URI of the authentication form (read from properties).


DEBUG

private static final boolean DEBUG
Flag for debugging.

See Also:
Constant Field Values

C_ERRORMSG

private static final java.lang.String C_ERRORMSG
Prefix for error messages for initialization errors.

See Also:
Constant Field Values
Constructor Detail

OpenCmsHttpServlet

public OpenCmsHttpServlet()
Method Detail

printCopyrightInformation

private void printCopyrightInformation()
Prints the OpenCms copyright information to all log-files.


throwInitException

private void throwInitException(javax.servlet.ServletException cause)
                         throws javax.servlet.ServletException
Throws a servlet exception that is also logged and written to the error output console.


init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialization of the OpenCms servlet (overloaded Servlet API method).

The connection information for the database is read from the opencms.properties configuration file and all resource brokers are initialized via the initalizer, which usually will be an instance of a OpenCms class.

Specified by:
init in interface javax.servlet.Servlet

destroy

public void destroy()
Destroys all running threads before closing the VM.

Specified by:
destroy in interface javax.servlet.Servlet

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  java.io.IOException
Method invoked on each HTML GET request.

(Overloaded Servlet API method, requesting a document). Reads the URI received from the client and invokes the appropiate action.


doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   java.io.IOException
Method invoked on each HTML POST request.

(Overloaded Servlet API method, posting a document) The OpenCmsMultipartRequest is invoked to upload a new document into OpenCms.


createErrorBox

private java.lang.String createErrorBox(CmsException e,
                                        com.opencms.file.CmsObject cms)
Generates a formated exception output.
Because the exception could be thrown while accessing the system files, the complete HTML code must be added here!


errorHandling

private void errorHandling(com.opencms.file.CmsObject cms,
                           I_CmsRequest cmsReq,
                           I_CmsResponse cmsRes,
                           CmsException e)
This method performs the error handling for the OpenCms. All CmsExetions throns in the OpenCms are forwared to this method and are processed here.


initUser

private com.opencms.file.CmsObject initUser(I_CmsRequest cmsReq,
                                            I_CmsResponse cmsRes)
                                     throws java.io.IOException
This method handled the user authentification for each request sent to the OpenCms.

User authentification is done in three steps:

  • Session Authentification: OpenCms stores all active sessions of authentificated users in an internal storage. During the session authetification phase, it is checked if the session of the active user is stored there.
  • HTTP Autheification: If session authentification fails, it is checked if the current user has loged in using HTTP authentification. If this check is positive, the user account is checked.
  • Default user: When both authentification methods fail, the current user is set to the default (guest) user.


requestAuthorization

private void requestAuthorization(javax.servlet.http.HttpServletRequest req,
                                  javax.servlet.http.HttpServletResponse res)
                           throws java.io.IOException
This method sends a request to the client to display a login form. It is needed for HTTP-Authentification.


updateUser

private void updateUser(com.opencms.file.CmsObject cms,
                        I_CmsRequest cmsReq)
                 throws java.io.IOException
Updates the the user data stored in the CmsCoreSession after the requested document is processed.

This is required if the user data (current group or project) was changed in the requested document.

The user data is only updated if the user was authenticated to the system.


getErrormsg

public java.lang.String getErrormsg(java.lang.String part)
Get the value for the property entry