Class OpenCmsCore
All access to this class must be done through the public static methods
of the object.
Under no circumstances should you ever try to access this class directly.OpenCms
This class is so OpenCms internal you should not even be reading this documentation ;-)
Any request to the will be forwarded to this core class.
The core will then try to map the request to a VFS (Virtual File System) URI,
that is a OpenCmsServlet in the OpenCms database.
If a resource is found, it will be read and forwarded to
to the corresponding CmsResource,
which will then generate the output for the requested resource and return it to the requesting client.I_CmsResourceLoader
There will be only one singleton instance of this object created for this core class. This means that in the default configuration, where OpenCms is accessed through a servlet context, there will be only one instance of the core in that servlet context.
- Since:
- 6.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringParameter to control whether generated links should always include the host. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddRequestHandler(I_CmsRequestHandler handler) Adds the specified request handler to the Map of OpenCms request handlers.protected CmsADEManagerGets the ADE manager, and makes sure it is initialized.protected CmsAliasManagerReturns the alias manager.protected I_CmsApiAuthorizationHandlergetApiAuthorization(String name) Gets the API authorization handler with the given name, or null if it doesn't exist.protected I_CmsAuthorizationHandlerReturns the configured authorization handler.protected CmsConfigurationManagerReturns the initialized OpenCms configuration manager.protected I_CmsCredentialsResolverGets the configured credentials resolver instance.Gets the database pool names.Returns the configured list of default directory file names.protected CmsDefaultUsersReturns the default user and group name configuration.protected CmsEventManagerReturns the OpenCms event manager.protected ScheduledThreadPoolExecutorGets the thread pool executor.protected Set<CmsExportPoint> Returns the configured export points, the returned set being an unmodifiable set.protected CmsFlexCacheGets the flex cache.protected StringGets a string containing all keys and variations currently in the flex cache, for debug purposes.protected CmsFolderSizeTrackergetFolderSizeTracker(boolean online) Gets the folder size tracker for the Online or Offline projectprotected CmsImportExportManagerReturns the initialized import/export manager, which contains information about the Cms import/export.protected static OpenCmsCoreReturns the initialized OpenCms singleton instance.protected CmsLetsEncryptConfigurationGets the LetsEncrypt configuration.protected CmsLinkManagerReturns the link manager to resolve links in <link> tags.protected CmsLocaleManagerReturns the locale manager used for obtaining the current locale.protected CmsLockManagerReturns the lock manager used for the locking mechanism.protected CmsLoginManagerReturns the login manager used to check the validity of a login.protected CmsMemoryMonitorReturns the memory monitor.protected CmsModuleManagerReturns the module manager.protected CmsOrgUnitManagerReturns the organizational unit manager.protected I_CmsPasswordHandlerReturn the password handler.static StringgetPathInfo(javax.servlet.http.HttpServletRequest req) Returns the path for the request.protected CmsPublishManagerReturns the publish manager instance.protected CmsRepositoryManagerReturns the repository manager.protected I_CmsRequestHandlergetRequestHandler(String name) Returns the handler instance for the specified name, or null if the name does not match any handler name.protected CmsResourceManagerReturns the resource manager.protected CmsRoleManagerReturns the role manager.protected intReturns the runlevel of this OpenCmsCore object instance.protected ObjectgetRuntimeProperty(Object key) Looks up a value in the runtime property Map.protected CmsScheduleManagerReturns the configured schedule manager.protected CmsSearchManagerReturns the initialized search manager, which provides indexing and searching operations.protected CmsSecurityManagerReturns the initialized OpenCms security manager.protected CmsSessionManagerReturns the session manager.protected CmsSiteManagerImplReturns the initialized site manager, which contains information about all configured sites.protected CmsSqlManagerReturns an instance of the common sql manager.protected CmsStaticExportManagerReturns the properties for the static export.protected CmsSubscriptionManagerReturns the subscription manager.protected CmsSystemInfoReturns the system information storage.protected CmsTemplateContextManagerGets the template context manager instance.protected Map<String, I_CmsTextEncryption> Gets the text encryptions.protected CmsThreadStoreReturns the OpenCms Thread store.protected CmsTwoFactorAuthenticationHandlerGets the two-factor authentication handler.protected CmsUserDataRequestManagerGets the user data request manager.protected I_CmsValidationHandlerReturns the runtime validation handler.Gets the default CmsVfsMemoryCache instance.protected I_CmsWorkflowManagerReturns the workflow manager instance.protected CmsWorkplaceAppManagerReturns the workplace app manager.protected CmsWorkplaceManagerReturns the initialized workplace manager, which contains information about the global workplace settings.protected CmsXmlContentTypeManagerReturns the XML content type manager.protected voidinitCmsContextForUI(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, CmsUIServlet servlet) Initializes the OpenCms context for Vaadin UI servlet.protected CmsObjectinitCmsObject(String user) Returns an initialized CmsObject with the user initialized as provided, with the "Online" project selected and "/" set as the current site root.protected CmsObjectinitCmsObject(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean allowPrivilegedLogin) Handles the user authentification for each request sent to OpenCms.protected CmsObjectinitCmsObject(CmsObject cms) Returns an independent copy of the provided CmsObject.protected CmsObjectinitCmsObject(CmsObject adminCms, CmsContextInfo contextInfo) Returns an initialized CmsObject with the user and context initialized as provided.protected CmsObjectinitCmsObjectFromSession(javax.servlet.http.HttpServletRequest req) Initializes a new cms object from the session data of the request.protected voidinitConfiguration(CmsParameterConfiguration configuration) Constructor to create a new OpenCms object.protected voidinitContext(javax.servlet.ServletContext context) Initialization of the OpenCms runtime environment.protected voidInitialize member variables.protected CmsResourceinitResource(CmsObject cms, String resourceName, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Reads the requested resource from the OpenCms VFS, in case a directory name is requested, the default files of the directory will be looked up and the first match is returned.protected voidinitServlet(OpenCmsServlet servlet) Initializes the system with the OpenCms servlet.protected voidinvokeBuiltinService(String remainingPath, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Handler for built-in AJAX services that don't belong anywhere else and don't deserve their own request handler.protected voidinvokeGwtService(String serviceName, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, javax.servlet.ServletConfig servletConfig) Invokes the GWT servlet from within OpenCms.protected static voidsetErrorCondition(CmsMessageContainer errorCondition) Sets the error condition.protected voidsetRuntimeProperty(Object key, Object value) This method adds an Object to the OpenCms runtime properties.protected voidshowResource(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Displays a resource from the OpenCms by writing the result to the provided Servlet response output stream.protected voidshutDown()Destroys this OpenCms instance, called if the servlet (or shell) is shut down.protected CmsObjectupdateContext(javax.servlet.http.HttpServletRequest request, CmsObject cms) This method updates the request context information.protected OpenCmsCoreupgradeRunlevel(javax.servlet.ServletContext context) Upgrades to runlevelOpenCms.RUNLEVEL_4_SERVLET_ACCESS, this is the final runlevel with an initialized database and Servlet context.protected OpenCmsCoreupgradeRunlevel(CmsParameterConfiguration configuration) Upgrades to runlevelOpenCms.RUNLEVEL_3_SHELL_ACCESS, this is shell access to the database but no Servlet context.protected voidwriteConfiguration(Class<?> clazz) Writes the XML configuration for the provided configuration class.
-
Field Details
-
PARAM_FORCE_ABSOLUTE_LINKS
Parameter to control whether generated links should always include the host.- See Also:
-
-
Method Details
-
getPathInfo
Returns the path for the request.First checks the
HttpServletRequest.getPathInfo(), then the configured request error page attribute (if set), and then if still undefined the/is returned as path info.This is only needed when the
HttpServletRequest.getPathInfo()is not really working as expected like in BEA WLS 9.x, where we have to use the 'weblogic.servlet.errorPage' request attribute.- Parameters:
req- the http request context- Returns:
- the path for the request
-
getInstance
Returns the initialized OpenCms singleton instance.- Returns:
- the initialized OpenCms singleton instance
-
setErrorCondition
Sets the error condition.- Parameters:
errorCondition- the error condition to set
-
getVfsMemoryObjectCache
Gets the default CmsVfsMemoryCache instance.- Returns:
- the default cache instance
-
addRequestHandler
Adds the specified request handler to the Map of OpenCms request handlers.- Parameters:
handler- the handler to add
-
getADEManager
Gets the ADE manager, and makes sure it is initialized.- Returns:
- the initialized ADE manager
-
getAliasManager
Returns the alias manager.- Returns:
- the alias manager
-
getApiAuthorization
Gets the API authorization handler with the given name, or null if it doesn't exist.- Parameters:
name- the name of the API authorization handler- Returns:
- the API authorization handler, or null if it wasn't found
-
getAuthorizationHandler
Returns the configured authorization handler.- Returns:
- the configured authorization handler
-
getConfigurationManager
Returns the initialized OpenCms configuration manager.- Returns:
- the initialized OpenCms configuration manager
-
getCredentialsResolver
Gets the configured credentials resolver instance.- Returns:
- the credentials resolver
-
getDbPoolNames
Gets the database pool names.- Returns:
- the configured database pool names
-
getDefaultFiles
Returns the configured list of default directory file names.- Returns:
- the configured list of default directory file names
-
getDefaultUsers
Returns the default user and group name configuration.- Returns:
- the default user and group name configuration
-
getEventManager
Returns the OpenCms event manager.- Returns:
- the OpenCms event manager
-
getExecutor
Gets the thread pool executor.- Returns:
- the thread pool executor
-
getExportPoints
Returns the configured export points, the returned set being an unmodifiable set.- Returns:
- an unmodifiable set of the configured export points
-
getFlexCache
Gets the flex cache.- Returns:
- CmsFlexCache
-
getFlexCacheKeyDump
Gets a string containing all keys and variations currently in the flex cache, for debug purposes.- Returns:
- a debug information string with the flex cache data
-
getFolderSizeTracker
Gets the folder size tracker for the Online or Offline project- Returns:
- true to get the online folder size tracker, false for the offline one
-
getImportExportManager
Returns the initialized import/export manager, which contains information about the Cms import/export.- Returns:
- the initialized import/export manager
-
getLetsEncryptConfig
Gets the LetsEncrypt configuration.- Returns:
- the LetsEncrypt configuration
-
getLinkManager
Returns the link manager to resolve links in <link> tags.- Returns:
- the link manager to resolve links in <link> tags
-
getLocaleManager
Returns the locale manager used for obtaining the current locale.- Returns:
- the locale manager
-
getLockManager
Returns the lock manager used for the locking mechanism.- Returns:
- the lock manager used for the locking mechanism
-
getLoginManager
Returns the login manager used to check the validity of a login.- Returns:
- the login manager
-
getMemoryMonitor
Returns the memory monitor.- Returns:
- the memory monitor
-
getModuleManager
Returns the module manager.- Returns:
- the module manager
-
getOrgUnitManager
Returns the organizational unit manager.- Returns:
- the organizational unit manager
-
getPasswordHandler
Return the password handler.- Returns:
- the password handler
-
getPublishManager
Returns the publish manager instance.- Returns:
- the publish manager instance
-
getRepositoryManager
Returns the repository manager.- Returns:
- the repository manager
-
getRequestHandler
Returns the handler instance for the specified name, or null if the name does not match any handler name.- Parameters:
name- the name of the handler instance to return- Returns:
- the handler instance for the specified name
-
getResourceManager
Returns the resource manager.- Returns:
- the resource manager
-
getRoleManager
Returns the role manager.- Returns:
- the role manager
-
getRunLevel
Returns the runlevel of this OpenCmsCore object instance.For a detailed description about the possible run levels, please see
OpenCms.getRunLevel().- Returns:
- the runlevel of this OpenCmsCore object instance
- See Also:
-
getRuntimeProperty
Looks up a value in the runtime property Map.- Parameters:
key- the key to look up in the runtime properties- Returns:
- the value for the key, or null if the key was not found
-
getScheduleManager
Returns the configured schedule manager.- Returns:
- the configured schedule manager
-
getSearchManager
Returns the initialized search manager, which provides indexing and searching operations.- Returns:
- the initialized search manager
-
getSecurityManager
Returns the initialized OpenCms security manager.- Returns:
- the initialized OpenCms security manager
-
getSessionManager
Returns the session manager.- Returns:
- the session manager
-
getSiteManager
Returns the initialized site manager, which contains information about all configured sites.- Returns:
- the initialized site manager
-
getSqlManager
Returns an instance of the common sql manager.- Returns:
- an instance of the common sql manager
-
getStaticExportManager
Returns the properties for the static export.- Returns:
- the properties for the static export
-
getSubscriptionManager
Returns the subscription manager.- Returns:
- the subscription manager
-
getSystemInfo
Returns the system information storage.- Returns:
- the system information storage
-
getTemplateContextManager
Gets the template context manager instance.- Returns:
- the template context manager instance
-
getTextEncryptions
Gets the text encryptions.- Returns:
- the text encryptions
-
getThreadStore
Returns the OpenCms Thread store.- Returns:
- the OpenCms Thread store
-
getTwoFactorAuthenticationHandler
Gets the two-factor authentication handler.- Returns:
- the two-factor authentication handler
-
getUserDataRequestManager
Gets the user data request manager.- Returns:
- the user data request manager
-
getValidationHandler
Returns the runtime validation handler.- Returns:
- the validation handler
-
getWorkflowManager
Returns the workflow manager instance.- Returns:
- the workflow manager
-
getWorkplaceAppManager
Returns the workplace app manager.- Returns:
- the workplace app manager
-
getWorkplaceManager
Returns the initialized workplace manager, which contains information about the global workplace settings.- Returns:
- the initialized workplace manager
-
getXmlContentTypeManager
Returns the XML content type manager.- Returns:
- the XML content type manager
-
initCmsContextForUI
protected void initCmsContextForUI(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, CmsUIServlet servlet) throws IOException, CmsException Initializes the OpenCms context for Vaadin UI servlet.- Parameters:
req- the requestres- the responseservlet- the UI servlet- Throws:
IOException- if user authentication failsCmsException- if something goes wrong
-
initCmsObject
Returns an independent copy of the provided CmsObject.This can be useful in case a permanent reference to a CmsObject is stored. Changing the request context values (for example project, siteroot) in the new CmsObject will have no side effects to the CmsObject it was copied form.
The request time (
) is set to the current time.CmsRequestContext.getRequestTime()- Parameters:
cms- the CmsObject to create a copy of- Returns:
- an independent copy of the provided CmsObject
- Throws:
CmsException- in case the initialization failed- See Also:
-
initCmsObject
protected CmsObject initCmsObject(CmsObject adminCms, CmsContextInfo contextInfo) throws CmsRoleViolationException, CmsException Returns an initialized CmsObject with the user and context initialized as provided.Note: Only if the provided
adminCmsCmsObject has admin permissions, this method allows the creation a CmsObject for any existing user. Otherwise only the default users 'Guest' and 'Export' can initialized with this method, all other user names will throw an Exception.- Parameters:
adminCms- must either be initialized with "Admin" permissions, or nullcontextInfo- the context info to create a CmsObject for- Returns:
- an initialized CmsObject with the given users permissions
- Throws:
CmsException- if an invalid user name was providedCmsRoleViolationException- if the current user does not have the role permissions to create a context for the requested user- See Also:
-
initCmsObject
protected CmsObject initCmsObject(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean allowPrivilegedLogin) throws IOException, CmsException Handles the user authentification for each request sent to OpenCms.User authentification is done in three steps:
- Session authentification: OpenCms stores information of all authentificated users in an internal storage based on the users session.
- Authorization handler authentification: If the session authentification fails, the current configured authorization handler is called.
- Default user: When both authentification methods fail, the user is set to the default (Guest) user.
- Parameters:
req- the current http requestres- the current http responseallowPrivilegedLogin-trueto allow login through authorization handlers- Returns:
- the initialized cms context
- Throws:
IOException- if user authentication failsCmsException- in case something goes wrong
-
initCmsObject
Returns an initialized CmsObject with the user initialized as provided, with the "Online" project selected and "/" set as the current site root.Note: Only the default users 'Guest' and 'Export' can initialized with this method, all other user names will throw an Exception.
- Parameters:
user- the user name to initialize, can only beCmsDefaultUsers.getUserGuest()orCmsDefaultUsers.getUserExport()- Returns:
- an initialized CmsObject with the given users permissions
- Throws:
CmsException- if an invalid user name was provided, or if something else goes wrong- See Also:
-
initCmsObjectFromSession
protected CmsObject initCmsObjectFromSession(javax.servlet.http.HttpServletRequest req) throws CmsException Initializes a new cms object from the session data of the request.If no session data is found,
nullis returned.- Parameters:
req- the request- Returns:
- the new initialized cms object
- Throws:
CmsException- if something goes wrong
-
initConfiguration
Constructor to create a new OpenCms object.It reads the configurations from the
opencms.propertiesfile in theconfig/subdirectory. With the information from this file is inits a ResourceBroker (Database access module), various caching systems and other options.This will only be done once per accessing class.
- Parameters:
configuration- the configurations from theopencms.propertiesfile- Throws:
CmsInitException- in case OpenCms can not be initialized
-
initContext
Initialization of the OpenCms runtime environment.The connection information for the database is read from the
opencms.propertiesconfiguration file and all driver manager are initialized via the initializer, which usually will be an instance of aOpenCmsclass.- Parameters:
context- configuration of OpenCms fromweb.xml- Throws:
CmsInitException- in case OpenCms can not be initialized
-
initMembers
Initialize member variables. -
initResource
protected CmsResource initResource(CmsObject cms, String resourceName, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws CmsException Reads the requested resource from the OpenCms VFS, in case a directory name is requested, the default files of the directory will be looked up and the first match is returned.The resource that is returned is always a
, even though the content will usually not be loaded in the result. Folders are never returned since the point of this method is really to load the default file if just a folder name is requested. If there is no default file in a folder, then the return value is null and no CmsException is thrown.CmsFileThe URI stored in the given OpenCms user context will be changed to the URI of the resource that was found and returned.
Implementing and configuring an
handler allows to customize the process of default resource selection.I_CmsResourceInit- Parameters:
cms- the current users OpenCms contextresourceName- the path of the requested resource in the OpenCms VFSreq- the current http requestres- the current http response- Returns:
- the requested resource read from the VFS
- Throws:
CmsException- in case the requested file does not exist or the user has insufficient access permissions- See Also:
-
initServlet
Initializes the system with the OpenCms servlet.This is the final step that is called on the servlets "init()" method. It registers the servlets request handler and also outputs the final startup message. The servlet should auto-load since the invalid input: '<load'-on-startup> parameter is set in the 'web.xml' by default.
- Parameters:
servlet- the OpenCms servlet
-
invokeBuiltinService
protected void invokeBuiltinService(String remainingPath, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException Handler for built-in AJAX services that don't belong anywhere else and don't deserve their own request handler.- Parameters:
remainingPath- the remainder of the path after /handleBuiltinServicereq- the current requestres- the current response- Throws:
javax.servlet.ServletException- if something goes wrong
-
invokeGwtService
protected void invokeGwtService(String serviceName, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, javax.servlet.ServletConfig servletConfig) Invokes the GWT servlet from within OpenCms.- Parameters:
serviceName- the GWT PRC service class namereq- the current servlet requestres- the current servlet responseservletConfig- the servlet configuration
-
setRuntimeProperty
This method adds an Object to the OpenCms runtime properties. The runtime properties can be used to store Objects that are shared in the whole system.- Parameters:
key- the key to add the Object withvalue- the value of the Object to add
-
showResource
protected void showResource(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Displays a resource from the OpenCms by writing the result to the provided Servlet response output stream.- Parameters:
req- the current servlet requestres- the current servlet response
-
shutDown
Destroys this OpenCms instance, called if the servlet (or shell) is shut down. -
updateContext
protected CmsObject updateContext(javax.servlet.http.HttpServletRequest request, CmsObject cms) throws CmsException This method updates the request context information.The update information is:
- Requested Url
- Locale
- Encoding
- Remote Address
- Request Time
- Parameters:
request- the current requestcms- the cms object to update the request context for- Returns:
- a new updated cms context
- Throws:
CmsException- if something goes wrong
-
upgradeRunlevel
protected OpenCmsCore upgradeRunlevel(CmsParameterConfiguration configuration) throws CmsInitException Upgrades to runlevelOpenCms.RUNLEVEL_3_SHELL_ACCESS, this is shell access to the database but no Servlet context.To upgrade the runlevel, the system must be in runlevel
OpenCms.RUNLEVEL_1_CORE_OBJECT, otherwise an exception is thrown.- Parameters:
configuration- the configuration- Returns:
- the initialized OpenCmsCore
- Throws:
CmsInitException- in case OpenCms can not be initialized
-
upgradeRunlevel
Upgrades to runlevelOpenCms.RUNLEVEL_4_SERVLET_ACCESS, this is the final runlevel with an initialized database and Servlet context.To upgrade the runlevel, the system must be in runlevel
OpenCms.RUNLEVEL_1_CORE_OBJECT, otherwise an exception is thrown.- Parameters:
context- the current servlet context- Returns:
- the initialized OpenCmsCore
- Throws:
CmsInitException- in case OpenCms can not be initialized
-
writeConfiguration
Writes the XML configuration for the provided configuration class.- Parameters:
clazz- the configuration class to write the XML for
-