|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.main.OpenCms
public final class OpenCms
The OpenCms "operating system" that provides public static methods which can be used by other classes to access basic system features of OpenCms like logging etc.
This Object provides singleton access to the initialized OpenCms runtime system. Some methods are for internal or advanced use only, but others are of also of interest for general OpenCms development.
For example, to generate a new instance of
class in your application,
use CmsObject
. The argument String should be
the name of the guest user, usually "Guest" and more formally obtained by initCmsObject(String)
.
This will give you an initialized context with guest user permissions.
Then use CmsDefaultUsers.getUserGuest()
to log in the user you want.
Obviously you need the password for the new user.CmsObject.loginUser(String, String)
Using
you can obtain the initialized getSiteManager()
which provides information about the sites configured in the running OpenCms instance.CmsSiteManagerImpl
The
instance returned by CmsDefaultUsers
provides information about the names of the OpenCms default users.getDefaultUsers()
Other objects of note that can be obtained by this class include the
or the CmsModuleManager
.CmsScheduleManager
When using the instances returned by this object, keep in mind that applying changes to these may alter the basic OpenCms system configuration, which in turn may affect the systems performance or stability.
Field Summary | |
---|---|
static int |
RUNLEVEL_0_OFFLINE
Runlevel 0: System is offline. |
static int |
RUNLEVEL_1_CORE_OBJECT
Runlevel 1: Core object created, no database (some test cases run in this level). |
static int |
RUNLEVEL_2_INITIALIZING
Runlevel 2: Initializing the system, required since this may take some seconds because of database connections. |
static int |
RUNLEVEL_3_SHELL_ACCESS
Runlevel 3: Shell access to the database possible, but no servlet context available. |
static int |
RUNLEVEL_4_SERVLET_ACCESS
Runlevel 4: Final runlevel where database and servlet are initialized. |
Method Summary | |
---|---|
static void |
addCmsEventListener(I_CmsEventListener listener)
Add a cms event listener that listens to all events. |
static void |
addCmsEventListener(I_CmsEventListener listener,
int[] eventTypes)
Add a cms event listener that listens only to particular events. |
static void |
fireCmsEvent(CmsEvent event)
Notify all event listeners that a particular event has occurred. |
static void |
fireCmsEvent(int type,
java.util.Map data)
Notify all event listeners that a particular event has occurred. |
static I_CmsAuthorizationHandler |
getAuthorizationHandler()
Returns the configured authorization handler. |
static java.util.List |
getDefaultFiles()
Returns the configured list of default directory file names (instances of ). |
static CmsDefaultUsers |
getDefaultUsers()
Returns the default user and group name configuration. |
static CmsEventManager |
getEventManager()
Returns the event manger that handles all OpenCms events. |
static java.util.Set |
getExportPoints()
Returns the configured export points, the returned set being an unmodifiable set. |
static CmsImportExportManager |
getImportExportManager()
Returns the initialized import/export manager, which contains information about how to handle imported resources. |
static CmsLinkManager |
getLinkManager()
Returns the link manager to resolve links in <link> tags. |
static CmsLocaleManager |
getLocaleManager()
Returns the locale manager used for obtaining the current locale. |
static org.apache.commons.logging.Log |
getLog(java.lang.Object obj)
Returns the log for the selected object. |
static CmsLoginManager |
getLoginManager()
Returns the login manager used to check if a login is possible. |
static CmsMemoryMonitor |
getMemoryMonitor()
Returns the memory monitor. |
static CmsModuleManager |
getModuleManager()
Returns the module manager. |
static CmsOrgUnitManager |
getOrgUnitManager()
Returns the organizational unit manager. |
static I_CmsPasswordHandler |
getPasswordHandler()
Returns the password handler. |
static CmsPublishManager |
getPublishManager()
Returns the core publish manager class. |
static CmsRepositoryManager |
getRepositoryManager()
Returns the repository manager. |
static CmsResourceManager |
getResourceManager()
Returns the resource manager. |
static CmsRoleManager |
getRoleManager()
Returns the role manager. |
static int |
getRunLevel()
Returns the current OpenCms run level. |
static java.lang.Object |
getRuntimeProperty(java.lang.Object key)
Looks up a value in the runtime property Map. |
static CmsScheduleManager |
getScheduleManager()
Returns the configured schedule manager. |
static CmsSearchManager |
getSearchManager()
Returns the initialized search manager, which provides indexing and searching operations. |
static CmsSessionManager |
getSessionManager()
Returns the session manager that keeps track of the active users. |
static CmsSiteManagerImpl |
getSiteManager()
Returns the initialized site manager, which contains information about all configured sites. |
static CmsSqlManager |
getSqlManager()
Returns an instance of the common sql manager. |
static CmsStaticExportManager |
getStaticExportManager()
Returns the properties for the static export. |
static CmsSystemInfo |
getSystemInfo()
Returns the system information storage. |
static java.util.List |
getSystemRoles()
Returns the list of system defined roles (instances of ). |
static CmsThreadStore |
getThreadStore()
Returns the OpenCms Thread store. |
static I_CmsValidationHandler |
getValidationHandler()
Returns the runtime validation handler. |
static CmsWorkplaceManager |
getWorkplaceManager()
Returns the initialized workplace manager, which contains information about the global workplace settings. |
static CmsXmlContentTypeManager |
getXmlContentTypeManager()
Returns the XML content type manager. |
static CmsObject |
initCmsObject(CmsObject cms)
Returns an independent copy of the provided CmsObject. |
static CmsObject |
initCmsObject(CmsObject adminCms,
CmsContextInfo contextInfo)
Returns an initialized CmsObject with the user and context initialized as provided. |
static CmsObject |
initCmsObject(java.lang.String user)
Returns an initialized CmsObject (OpenCms user context) with the user initialized as provided, with the "Online" project selected and "/" set as the current site root. |
static CmsResource |
initResource(CmsObject cms,
java.lang.String resourceName,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Reads the requested resource from the OpenCms VFS, and in case a directory name is requested, the default files of the directory will be looked up and the first match is returned. |
static void |
removeCmsEventListener(I_CmsEventListener listener)
Removes a cms event listener. |
static void |
setRuntimeProperty(java.lang.Object key,
java.lang.Object value)
This method adds an Object to the OpenCms runtime properties. |
static void |
writeConfiguration(java.lang.Class clazz)
Writes the XML configuration for the provided configuration class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int RUNLEVEL_0_OFFLINE
public static final int RUNLEVEL_1_CORE_OBJECT
public static final int RUNLEVEL_2_INITIALIZING
public static final int RUNLEVEL_3_SHELL_ACCESS
public static final int RUNLEVEL_4_SERVLET_ACCESS
Method Detail |
---|
public static void addCmsEventListener(I_CmsEventListener listener)
listener
- the listener to addpublic static void addCmsEventListener(I_CmsEventListener listener, int[] eventTypes)
listener
- the listener to addeventTypes
- the events to listen forpublic static void fireCmsEvent(CmsEvent event)
event
- a CmsEventpublic static void fireCmsEvent(int type, java.util.Map data)
The event will be given to all registered
objects.I_CmsEventListener
type
- event typedata
- event datapublic static I_CmsAuthorizationHandler getAuthorizationHandler()
public static java.util.List getDefaultFiles()
String
).Caution: This list can not be modified.
public static CmsDefaultUsers getDefaultUsers()
public static CmsEventManager getEventManager()
public static java.util.Set getExportPoints()
public static CmsImportExportManager getImportExportManager()
public static CmsLinkManager getLinkManager()
public static CmsLocaleManager getLocaleManager()
public static org.apache.commons.logging.Log getLog(java.lang.Object obj)
If the provided object is a String, this String will be used as channel name. Otherwise the objects class name will be used as channel name.
obj
- the object channel to use
public static CmsLoginManager getLoginManager()
public static CmsMemoryMonitor getMemoryMonitor()
public static CmsModuleManager getModuleManager()
public static CmsOrgUnitManager getOrgUnitManager()
public static I_CmsPasswordHandler getPasswordHandler()
public static CmsPublishManager getPublishManager()
public static CmsRepositoryManager getRepositoryManager()
public static CmsResourceManager getResourceManager()
public static CmsRoleManager getRoleManager()
public static int getRunLevel()
The following runlevels are defined:
RUNLEVEL_0_OFFLINE
:RUNLEVEL_1_CORE_OBJECT
:RUNLEVEL_2_INITIALIZING
:RUNLEVEL_3_SHELL_ACCESS
:RUNLEVEL_4_SERVLET_ACCESS
:
public static java.lang.Object getRuntimeProperty(java.lang.Object key)
key
- the key to look up in the runtime properties
public static CmsScheduleManager getScheduleManager()
public static CmsSearchManager getSearchManager()
public static CmsSessionManager getSessionManager()
public static CmsSiteManagerImpl getSiteManager()
public static CmsSqlManager getSqlManager()
public static CmsStaticExportManager getStaticExportManager()
public static CmsSystemInfo getSystemInfo()
public static java.util.List getSystemRoles()
CmsRole
).Caution: This list can not be modified.
public static CmsThreadStore getThreadStore()
public static I_CmsValidationHandler getValidationHandler()
public static CmsWorkplaceManager getWorkplaceManager()
public static CmsXmlContentTypeManager getXmlContentTypeManager()
public static CmsObject initCmsObject(CmsObject cms) throws CmsException
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.
cms
- the CmsObject to create a copy of
CmsException
- in case the initialization failedinitCmsObject(CmsObject)
,
initCmsObject(CmsObject, CmsContextInfo)
,
initCmsObject(String)
public static CmsObject initCmsObject(CmsObject adminCms, CmsContextInfo contextInfo) throws CmsException
Note: Only if the provided adminCms
CmsObject 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.
adminCms
- must either be initialized with "Admin" permissions, or nullcontextInfo
- the context info to create a CmsObject for
CmsException
- if an invalid user name was provided, or if something else goes wrongCmsDefaultUsers.getUserGuest()
,
CmsDefaultUsers.getUserExport()
,
initCmsObject(CmsObject)
,
initCmsObject(CmsObject, CmsContextInfo)
,
initCmsObject(String)
public static CmsObject initCmsObject(java.lang.String user) throws CmsException
Note: Only the default users 'Guest' and 'Export' can initialized with this method, all other user names will throw an Exception.
In order to initialize another user (for example, the CmsDefaultUsers.getUserAdmin()
),
you need to get the 'Guest' user context first, then login the target user with
his user name and password, using CmsObject.loginUser(String, String)
.
There is no way to obtain a user context other then the 'Guest' or 'Export' user
without the users password. This is a security feature.
user
- the user name to initialize, can only be
CmsDefaultUsers.getUserGuest()
or
CmsDefaultUsers.getUserExport()
CmsException
- if an invalid user name was provided, or if something else goes wrongCmsDefaultUsers.getUserGuest()
,
CmsDefaultUsers.getUserExport()
,
initCmsObject(CmsObject)
,
initCmsObject(CmsObject, CmsContextInfo)
,
initCmsObject(String)
public static CmsResource initResource(CmsObject cms, java.lang.String resourceName, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws CmsException
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.CmsFile
The 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
cms
- the current users OpenCms contextresourceName
- the path of the requested resource in the OpenCms VFSreq
- the current http requestres
- the current http response
CmsException
- in case the requested file does not exist or the user has insufficient access permissionspublic static void removeCmsEventListener(I_CmsEventListener listener)
listener
- the listener to removepublic static void setRuntimeProperty(java.lang.Object key, java.lang.Object value)
key
- the key to add the Object withvalue
- the value of the Object to addpublic static void writeConfiguration(java.lang.Class clazz)
clazz
- the configuration class to write the XML for
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |