Class CmsSystemInfo
- java.lang.Object
-
- org.opencms.main.CmsSystemInfo
-
public class CmsSystemInfo extends java.lang.Object
Provides access to system wide "read only" information about the running OpenCms instance.Contains information about:
- version and build number
- server name
- mail settings
- configuration paths
- default character encoding
- ...and more.
- Since:
- 6.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CmsSystemInfo.BuildInfoItem
Wrapper class used to access build information.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONFIG_FOLDER_PROPERTY
Name of the config folder property provides as Java VM parameter -Dopencms.config=.static java.lang.String
FILE_PERSISTENCE
Relative path to persistence.xml file.static java.lang.String
FILE_PROPERTIES
The name of the opencms.properties file.static java.lang.String
FILE_TLD
The name of the opencms.tld file.static java.lang.String
FOLDER_CONFIG_DEFAULT
Path to the default "config" folder relative to the "WEB-INF" directory of the application.static java.lang.String
FOLDER_MODULES
The name of the module folder in the package path.static java.lang.String
FOLDER_PACKAGES
Path to the "packages" folder relative to the "WEB-INF" directory of the application.static java.lang.String
FOLDER_WEBINF
Path to the "WEB-INF" folder relative to the directory of the application.static java.lang.String
VFS_CONFIG_FOLDER
The VFS config files folder.static java.lang.String
VFS_CONFIG_OVERRIDE_FOLDER
The folder to contain configuration file overrides.static java.lang.String
WORKPLACE_PATH
The workplace UI servlet name.
-
Constructor Summary
Constructors Constructor Description CmsSystemInfo()
Creates a new system info container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAbsoluteRfsPathRelativeToWebApplication(java.lang.String path)
Returns an absolute path (to a directory or a file in the "real" file system) from a path relative to the web application folder of OpenCms.java.lang.String
getAbsoluteRfsPathRelativeToWebInf(java.lang.String path)
Returns an absolute path (to a directory or a file in the "real" file system) from a path relative to the "WEB-INF" folder of the OpenCms web application.java.util.Map<java.lang.String,CmsSystemInfo.BuildInfoItem>
getBuildInfo()
Returns the map of additional build information that was contained in the version.properties file.java.lang.String
getConfigFilePath(CmsObject cms, java.lang.String configFile)
Returns the path to a configuration file.java.lang.String
getConfigFolder()
Gets the path of the opencms config folder.java.lang.String
getConfigurationFileRfsPath()
Returns the absolute path to the "opencms.properties" configuration file (in the "real" file system).java.lang.String
getContextPath()
Returns the web application context path, e.g.java.lang.String
getDefaultEncoding()
Return the OpenCms default character encoding.java.lang.String
getDefaultWebApplicationName()
Returns the default web application name (usually "ROOT").I_CmsJspDeviceSelector
getDeviceSelector()
Gets the device selector.int
getHistoryVersions()
Returns the maximum number of versions that are kept per file in the VFS version history.int
getHistoryVersionsAfterDeletion()
Returns the number of versions in the VFS version history that should be kept after a resource is deleted.CmsHttpAuthenticationSettings
getHttpAuthenticationSettings()
Returns the HTTP authentication settings.java.lang.String
getLogFileRfsFolder()
Returns the absolute path to the folder of the main OpenCms log file (in the "real" file system).java.lang.String
getLogFileRfsPath()
Returns the filename of the log file (in the "real" file system).CmsMailSettings
getMailSettings()
Returns the settings for the internal OpenCms email service.java.lang.String
getNotificationProject()
Returns the project in which time stamps for the content notification are read.int
getNotificationTime()
Returns the duration after which responsible resource owners will be notified about out-dated content (in days).java.lang.String
getOpenCmsContext()
Returns the OpenCms request context, e.g.java.lang.String
getPackagesRfsPath()
Returns the absolute path to the "packages" folder (in the "real" file system).java.lang.String
getPersistenceFileRfsPath()
Returns the absolute path to the "persistence.xml" file (in the "real" file system).long
getRuntime()
Returns the time this OpenCms instance is running in milliseconds.java.lang.String
getServerName()
Returns the OpenCms server name, e.g.CmsServletContainerSettings
getServletContainerSettings()
Returns the servlet container specific settings.java.lang.String
getServletPath()
Returns the OpenCms servlet path, e.g.long
getStartupTime()
Returns the time this OpenCms instance was started in milliseconds.java.lang.String
getStaticResourceContext()
Returns the context for static resources served from the class path, e.g.java.lang.String
getVersion()
Returns the identifier "OpenCms/" plus the OpenCms version number.java.lang.String
getVersionId()
Returns the version ID of this OpenCms system.java.lang.String
getVersionNumber()
Returns the version number of this OpenCms system, for example9.5.0
.java.lang.String
getWebApplicationName()
Returns the OpenCms web application name, e.g.java.lang.String
getWebApplicationRfsPath()
Returns the OpenCms web application folder in the servlet container.java.lang.String
getWebInfRfsPath()
Returns the OpenCms web application "WEB-INF" directory path.java.lang.String
getWorkplaceContext()
Returns the OpenCms workplace request context, e.g.protected void
init(CmsServletContainerSettings settings)
Sets the OpenCms web application "WEB-INF" directory path (in the "real" file system).boolean
isHistoryEnabled()
Returns if the VFS version history is enabled.boolean
isRestrictDetailContents()
Return true if detail contents are restricted to detail pages from the same site.protected void
setDefaultEncoding(java.lang.String encoding)
Sets the default encoding, called after the configuration files have been read.protected void
setDeviceSelector(I_CmsJspDeviceSelector selector)
Sets the device selector.protected void
setHttpAuthenticationSettings(CmsHttpAuthenticationSettings httpAuthenticationSettings)
Sets the HTTP authentication settings.protected void
setMailSettings(CmsMailSettings mailSettings)
Sets the settings for the internal OpenCms email service.void
setNotificationProject(java.lang.String notificationProject)
Sets the project in which time stamps for the content notification are read.void
setNotificationTime(int notificationTime)
Sets the duration after which responsible resource owners will be notified about out-dated content (in days).protected void
setRestrictDetailContents(boolean restrictDetailContents)
Sets the value of the 'restrict detail contents' option.protected void
setServerName(java.lang.String serverName)
Sets the server name.void
setVersionHistorySettings(boolean historyEnabled, int historyVersions, int historyVersionsAfterDeletion)
VFS version history settings are set here.
-
-
-
Field Detail
-
CONFIG_FOLDER_PROPERTY
public static final java.lang.String CONFIG_FOLDER_PROPERTY
Name of the config folder property provides as Java VM parameter -Dopencms.config=.- See Also:
- Constant Field Values
-
FILE_PERSISTENCE
public static final java.lang.String FILE_PERSISTENCE
Relative path to persistence.xml file.
-
FILE_PROPERTIES
public static final java.lang.String FILE_PROPERTIES
The name of the opencms.properties file.- See Also:
- Constant Field Values
-
FILE_TLD
public static final java.lang.String FILE_TLD
The name of the opencms.tld file.- See Also:
- Constant Field Values
-
FOLDER_CONFIG_DEFAULT
public static final java.lang.String FOLDER_CONFIG_DEFAULT
Path to the default "config" folder relative to the "WEB-INF" directory of the application.
-
FOLDER_MODULES
public static final java.lang.String FOLDER_MODULES
The name of the module folder in the package path.
-
FOLDER_PACKAGES
public static final java.lang.String FOLDER_PACKAGES
Path to the "packages" folder relative to the "WEB-INF" directory of the application.
-
FOLDER_WEBINF
public static final java.lang.String FOLDER_WEBINF
Path to the "WEB-INF" folder relative to the directory of the application.
-
WORKPLACE_PATH
public static final java.lang.String WORKPLACE_PATH
The workplace UI servlet name.- See Also:
- Constant Field Values
-
VFS_CONFIG_FOLDER
public static final java.lang.String VFS_CONFIG_FOLDER
The VFS config files folder.- See Also:
- Constant Field Values
-
VFS_CONFIG_OVERRIDE_FOLDER
public static final java.lang.String VFS_CONFIG_OVERRIDE_FOLDER
The folder to contain configuration file overrides.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsSystemInfo
public CmsSystemInfo()
Creates a new system info container.
-
-
Method Detail
-
getAbsoluteRfsPathRelativeToWebApplication
public java.lang.String getAbsoluteRfsPathRelativeToWebApplication(java.lang.String path)
Returns an absolute path (to a directory or a file in the "real" file system) from a path relative to the web application folder of OpenCms.If the provided path is already absolute, then it is returned unchanged. If the provided path is a folder, the result will always end with a folder separator.
- Parameters:
path
- the path (relative) to generate an absolute path from- Returns:
- an absolute path (to a directory or a file) from a path relative to the web application folder of OpenCms
-
getAbsoluteRfsPathRelativeToWebInf
public java.lang.String getAbsoluteRfsPathRelativeToWebInf(java.lang.String path)
Returns an absolute path (to a directory or a file in the "real" file system) from a path relative to the "WEB-INF" folder of the OpenCms web application.If the provided path is already absolute, then it is returned unchanged.
- Parameters:
path
- the path (relative) to generate an absolute path from- Returns:
- an absolute path (to a directory or a file) from a path relative to the "WEB-INF" folder
-
getBuildInfo
public java.util.Map<java.lang.String,CmsSystemInfo.BuildInfoItem> getBuildInfo()
Returns the map of additional build information that was contained in the version.properties file.The values are String arrays of length 2. First in this array is the actual value, and second the "nice name" for the value that can be used to display the value somewhere. In case no nice name was provided, the second value will repeat the key name.
- Returns:
- the map of additional build information that was contained in the version.properties file
- Since:
- 9.5.0
-
getConfigFilePath
public java.lang.String getConfigFilePath(CmsObject cms, java.lang.String configFile)
Returns the path to a configuration file.This will either be a file below /system/config/ or in case an override file exists below /system/config/overrides/.
- Parameters:
cms
- the cms ontextconfigFile
- the config file path within /system/config/- Returns:
- the file path
-
getConfigFolder
public java.lang.String getConfigFolder()
Gets the path of the opencms config folder.Per default this is the "/WEB-INF/config/ folder. If configured with the "-Dopencms.config=..." java startup parameter, OpenCms can access an external config folder outside its webapplication.
- Returns:
- complete rfs path to the config folder.
-
getConfigurationFileRfsPath
public java.lang.String getConfigurationFileRfsPath()
Returns the absolute path to the "opencms.properties" configuration file (in the "real" file system).- Returns:
- the absolute path to the "opencms.properties" configuration file
-
getContextPath
public java.lang.String getContextPath()
Returns the web application context path, e.g. "" (empty String) if the web application is the default web application (usually "ROOT"), or "/opencms" if the web application is called "opencms".From the Java Servlet Specification v2.4:
Context Path: The path prefix associated with the ServletContext that this servlet is a part of. If this context is the "default" context rooted at the base of the web server's URL name space, this path will be an empty string. Otherwise, if the context is not rooted at the root of the server's name space, the path starts with a "/" character but does not end with a "/" character.- Returns:
- the web application context path
- See Also:
getWebApplicationName()
,getServletPath()
,getOpenCmsContext()
-
getDefaultEncoding
public java.lang.String getDefaultEncoding()
Return the OpenCms default character encoding.The default is set in the opencms-system.xml file. If this is not set in opencms-system.xml the default is "UTF-8".
- Returns:
- the default encoding, e.g. "UTF-8" or "ISO-8859-1"
-
getDefaultWebApplicationName
public java.lang.String getDefaultWebApplicationName()
Returns the default web application name (usually "ROOT").- Returns:
- the default web application name
-
getDeviceSelector
public I_CmsJspDeviceSelector getDeviceSelector()
Gets the device selector.- Returns:
- the device selector
-
getHistoryVersions
public int getHistoryVersions()
Returns the maximum number of versions that are kept per file in the VFS version history.If the version history is disabled, this setting has no effect.
- Returns:
- the maximum number of versions that are kept per file
- See Also:
isHistoryEnabled()
-
getHistoryVersionsAfterDeletion
public int getHistoryVersionsAfterDeletion()
Returns the number of versions in the VFS version history that should be kept after a resource is deleted.For resources in folders where the history.removedeleted property is set to "true", this setting is ignored.
- Returns:
- the number versions in the VFS version history for deleted resources
-
getHttpAuthenticationSettings
public CmsHttpAuthenticationSettings getHttpAuthenticationSettings()
Returns the HTTP authentication settings.- Returns:
- the HTTP authentication settings
-
getLogFileRfsPath
public java.lang.String getLogFileRfsPath()
Returns the filename of the log file (in the "real" file system).If the method returns
null
, this means that the log file is not managed by OpenCms.- Returns:
- the filename of the log file (in the "real" file system)
-
getLogFileRfsFolder
public java.lang.String getLogFileRfsFolder()
Returns the absolute path to the folder of the main OpenCms log file (in the "real" file system).If the method returns
null
, this means that the log file is not managed by OpenCms.- Returns:
- the absolute path to the folder of the main OpenCms log file (in the "real" file system)
-
getMailSettings
public CmsMailSettings getMailSettings()
Returns the settings for the internal OpenCms email service.- Returns:
- the settings for the internal OpenCms email service
-
getNotificationProject
public java.lang.String getNotificationProject()
Returns the project in which time stamps for the content notification are read.- Returns:
- the project in which time stamps for the content notification are read
-
getNotificationTime
public int getNotificationTime()
Returns the duration after which responsible resource owners will be notified about out-dated content (in days).- Returns:
- the duration after which responsible resource owners will be notified about out-dated content
-
getOpenCmsContext
public java.lang.String getOpenCmsContext()
Returns the OpenCms request context, e.g. "/opencms/opencms".The OpenCms context will always start with a "/" and never have a trailing "/". The OpenCms context is identical to
getContexPath() + getServletPath()
.- Returns:
- the OpenCms request context, e.g. "/opencms/opencms"
- See Also:
getContextPath()
,getServletPath()
-
getPackagesRfsPath
public java.lang.String getPackagesRfsPath()
Returns the absolute path to the "packages" folder (in the "real" file system).- Returns:
- the absolute path to the "packages" folder
-
getPersistenceFileRfsPath
public java.lang.String getPersistenceFileRfsPath()
Returns the absolute path to the "persistence.xml" file (in the "real" file system).- Returns:
- the absolute path to the "persistence.xml" configuration file
-
getRuntime
public long getRuntime()
Returns the time this OpenCms instance is running in milliseconds.- Returns:
- the time this OpenCms instance is running in milliseconds
-
getServerName
public java.lang.String getServerName()
Returns the OpenCms server name, e.g. "OpenCmsServer".The server name is set in
opencms.properties
. It is not related to any DNS name the server might also have. The server name is useful e.g. in a cluster to distinguish different servers, or if you compare log files from multiple servers.- Returns:
- the OpenCms server name
-
getServletContainerSettings
public CmsServletContainerSettings getServletContainerSettings()
Returns the servlet container specific settings.- Returns:
- the servlet container specific settings
-
getServletPath
public java.lang.String getServletPath()
Returns the OpenCms servlet path, e.g. "/opencms".From the Java Servlet Specification v2.4:
Servlet Path: The path section that directly corresponds to the mapping which activated this request. This path starts with a?/? character except in the case where the request is matched with the ?/*? pattern, in which case it is the empty string.- Returns:
- the OpenCms servlet path
- See Also:
getContextPath()
,getWebApplicationName()
,getOpenCmsContext()
-
getStartupTime
public long getStartupTime()
Returns the time this OpenCms instance was started in milliseconds.- Returns:
- the time this OpenCms instance was started in milliseconds
-
getStaticResourceContext
public java.lang.String getStaticResourceContext()
Returns the context for static resources served from the class path, e.g. "/opencms/opencms/handleStatic".- Returns:
- the static resource context
-
getVersion
public java.lang.String getVersion()
Returns the identifier "OpenCms/" plus the OpenCms version number.This information is used for example to identify OpenCms in HTTP response headers.
- Returns:
- the identifier "OpenCms/" plus the OpenCms version number
-
getVersionId
public java.lang.String getVersionId()
Returns the version ID of this OpenCms system.The version ID is usually set dynamically by the build system. It can be used to identify intermediate builds when the main version number has not changed.
- Returns:
- the version ID of this OpenCms system
- Since:
- 9.5.0
-
getVersionNumber
public java.lang.String getVersionNumber()
Returns the version number of this OpenCms system, for example9.5.0
.- Returns:
- the version number of this OpenCms system
- Since:
- 7.0.2
-
getWebApplicationName
public java.lang.String getWebApplicationName()
Returns the OpenCms web application name, e.g. "opencms" or "ROOT" (no leading or trailing "/").The web application name is stored for informational purposes only. If you want to construct an URI, use either
getContextPath()
andgetServletPath()
, or for links to the OpenCms VFS usegetOpenCmsContext()
.- Returns:
- the OpenCms web application name
- See Also:
getContextPath()
,getServletPath()
,getOpenCmsContext()
-
getWebApplicationRfsPath
public java.lang.String getWebApplicationRfsPath()
Returns the OpenCms web application folder in the servlet container.- Returns:
- the OpenCms web application folder in the servlet container
-
getWebInfRfsPath
public java.lang.String getWebInfRfsPath()
Returns the OpenCms web application "WEB-INF" directory path.- Returns:
- the OpenCms web application "WEB-INF" directory path
-
getWorkplaceContext
public java.lang.String getWorkplaceContext()
Returns the OpenCms workplace request context, e.g. "/opencms/workplace".The OpenCms workplace context will always start with a "/" and never have a trailing "/". The OpenCms context is identical to
getContexPath() + WORKPLACE_PATH
.- Returns:
- the OpenCms request context, e.g. "/opencms/workplace"
- See Also:
getContextPath()
,WORKPLACE_PATH
-
isHistoryEnabled
public boolean isHistoryEnabled()
Returns if the VFS version history is enabled.- Returns:
- if the VFS version history is enabled
-
isRestrictDetailContents
public boolean isRestrictDetailContents()
Return true if detail contents are restricted to detail pages from the same site.- Returns:
- true if detail contents are restricted to detail pages from the same site
-
setNotificationProject
public void setNotificationProject(java.lang.String notificationProject)
Sets the project in which time stamps for the content notification are read.- Parameters:
notificationProject
- the project in which time stamps for the content notification are read
-
setNotificationTime
public void setNotificationTime(int notificationTime)
Sets the duration after which responsible resource owners will be notified about out-dated content (in days).- Parameters:
notificationTime
- the duration after which responsible resource owners will be notified about out-dated content
-
setVersionHistorySettings
public void setVersionHistorySettings(boolean historyEnabled, int historyVersions, int historyVersionsAfterDeletion)
VFS version history settings are set here.- Parameters:
historyEnabled
- if true the history is enabledhistoryVersions
- the maximum number of versions that are kept per VFS resourcehistoryVersionsAfterDeletion
- the maximum number of versions that are kept for deleted resources
-
init
protected void init(CmsServletContainerSettings settings)
Sets the OpenCms web application "WEB-INF" directory path (in the "real" file system).- Parameters:
settings
- container specific information needed for this system info
-
setDefaultEncoding
protected void setDefaultEncoding(java.lang.String encoding)
Sets the default encoding, called after the configuration files have been read.- Parameters:
encoding
- the default encoding to set
-
setDeviceSelector
protected void setDeviceSelector(I_CmsJspDeviceSelector selector)
Sets the device selector.- Parameters:
selector
- the device selector to set
-
setHttpAuthenticationSettings
protected void setHttpAuthenticationSettings(CmsHttpAuthenticationSettings httpAuthenticationSettings)
Sets the HTTP authentication settings.- Parameters:
httpAuthenticationSettings
- the HTTP authentication settings to set
-
setMailSettings
protected void setMailSettings(CmsMailSettings mailSettings)
Sets the settings for the internal OpenCms email service.- Parameters:
mailSettings
- the settings for the internal OpenCms email service to set
-
setRestrictDetailContents
protected void setRestrictDetailContents(boolean restrictDetailContents)
Sets the value of the 'restrict detail contents' option.- Parameters:
restrictDetailContents
- the new value for the option
-
setServerName
protected void setServerName(java.lang.String serverName)
Sets the server name.The server name is set in
opencms.properties
. It is not related to any DNS name the server might also have. The server name is useful e.g. in a cluster to distinguish different servers, or if you compare log files from multiple servers.- Parameters:
serverName
- the server name to set
-
-