Class CmsSiteManagerImpl
- All Implemented Interfaces:
I_CmsEventListener
To obtain the configured site manager instance, use OpenCms.getSiteManager()
.
- Since:
- 7.0.2
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default shared folder name.static final String
The VFS root path to the system shared folder, where shared content that belongs to modules, and that should not be edited by normal editors can be stored.static final String
A placeholder for the title of the shared folder.static final String
Path to config template.static final String
prefix for files.static final String
Path to write logs to.static final String
Path to secure template.static final String
Path to target.static final String
Path of webserver script.Fields inherited from interface org.opencms.main.I_CmsEventListener
EVENT_BEFORE_PUBLISH_PROJECT, EVENT_CLEAR_CACHES, EVENT_CLEAR_OFFLINE_CACHES, EVENT_CLEAR_ONLINE_CACHES, EVENT_CLEAR_PRINCIPAL_CACHES, EVENT_FLEX_CACHE_CLEAR, EVENT_FLEX_PURGE_JSP_REPOSITORY, EVENT_FULLSTATIC_EXPORT, EVENT_GROUP_MODIFIED, EVENT_LOGIN_USER, EVENT_OU_MODIFIED, EVENT_PROJECT_MODIFIED, EVENT_PROPERTY_DEFINITION_CREATED, EVENT_PROPERTY_DEFINITION_MODIFIED, EVENT_PROPERTY_MODIFIED, EVENT_PUBLISH_PROJECT, EVENT_REBUILD_SEARCHINDEXES, EVENT_REINDEX_OFFLINE, EVENT_REINDEX_ONLINE, EVENT_RESOURCE_AND_PROPERTIES_MODIFIED, EVENT_RESOURCE_COPIED, EVENT_RESOURCE_CREATED, EVENT_RESOURCE_DELETED, EVENT_RESOURCE_MODIFIED, EVENT_RESOURCE_MOVED, EVENT_RESOURCES_AND_PROPERTIES_MODIFIED, EVENT_RESOURCES_MODIFIED, EVENT_SITEMAP_CHANGED, EVENT_UPDATE_EXPORTS, EVENT_USER_MODIFIED, KEY_CHANGE, KEY_DBCONTEXT, KEY_GROUP_ID, KEY_GROUP_NAME, KEY_INDEX_NAMES, KEY_IS_ONLINE, KEY_OU_ID, KEY_OU_NAME, KEY_PROJECTID, KEY_PUBLISHID, KEY_PUBLISHLIST, KEY_REINDEX_RELATED, KEY_REPORT, KEY_RESOURCE, KEY_RESOURCES, KEY_SKIPINDEX, KEY_USER_ACTION, KEY_USER_CHANGES, KEY_USER_ID, KEY_USER_NAME, LISTENERS_FOR_ALL_EVENTS, VALUE_CREATE_SIBLING, VALUE_GROUP_MODIFIED_ACTION_CREATE, VALUE_GROUP_MODIFIED_ACTION_DELETE, VALUE_GROUP_MODIFIED_ACTION_WRITE, VALUE_OU_MODIFIED_ACTION_CREATE, VALUE_OU_MODIFIED_ACTION_DELETE, VALUE_USER_MODIFIED_ACTION_ADD_USER_TO_GROUP, VALUE_USER_MODIFIED_ACTION_CREATE_USER, VALUE_USER_MODIFIED_ACTION_DELETE_USER, VALUE_USER_MODIFIED_ACTION_REMOVE_USER_FROM_GROUP, VALUE_USER_MODIFIED_ACTION_RESET_PASSWORD, VALUE_USER_MODIFIED_ACTION_SET_OU, VALUE_USER_MODIFIED_ACTION_WRITE_USER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSite
(String server, String uri, String title, String position, String errorPage, String webserver, String sslMode, String secureServer, String exclusive, String error, String usePermanentRedirects, String subsiteSelection, SortedMap<String, String> params, List<CmsSiteMatcher> aliases, Optional<CmsAlternativeSiteRootMapping> alternativeSiteRootMapping) Adds a new CmsSite to the list of configured sites, this is only allowed during configuration.void
Adds a site.void
addSiteInternally
(String server, String uri, String title, String position, String errorPage, String webserver, String sslMode, String secureServer, String exclusive, String error, String usePermanentRedirects, String subsiteSelection, SortedMap<String, String> params, List<CmsSiteMatcher> aliases, Optional<CmsAlternativeSiteRootMapping> alternativeSiteRoot) Adds a new CmsSite to the list of configured sites, this is only allowed during configuration.void
addWorkplaceServer
(String workplaceServer, String sslmode) Adds a workplace server, this is only allowed during configuration.void
Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class.static CmsSiteMatcher
createAliasSiteMatcher
(String alias, String redirect, String offset) Creates a site matcher for an alias read from the configuration.getAvailableCorruptedSites
(CmsObject cms, boolean workplaceMode) Returns all wrong configured sites.getAvailableSites
(CmsObject cms, boolean workplaceMode) Returns a list of all sites available (visible) for the current user.getAvailableSites
(CmsObject cms, boolean workplaceMode, boolean showShared, String ouFqn) Returns a list of allCmsSite
instances that are compatible to the given organizational unit.getAvailableSites
(CmsObject cms, boolean workplaceMode, boolean showShared, String ouFqn, CmsSSLMode filterMode) Returns a list of allCmsSite
instances that are compatible to the given organizational unit.getAvailableSites
(CmsObject cms, boolean workplaceMode, String ouFqn) Returns a list of allCmsSite
instances that are compatible to the given organizational unit.getAvailableSites
(CmsObject cms, boolean workplaceMode, CmsSSLMode filterMode) Returns a list of all sites available (visible) for the current user.getCurrentSite
(CmsObject cms) Returns the current site for the provided OpenCms user context object.Returns the default site.Returns the defaultUri.Returns the shared folder path.Returns the site for the given resource path, using the fall back site root in case the resource path is no root path.com.google.common.base.Optional<CmsSite>
Gets the site which is mapped to the default uri, or the 'absent' value of no such site exists.getSiteForRootPath
(String rootPath) Returns the site for the given resources root path, ornull
if the resources root path does not match any site.getSiteForSiteRoot
(String siteRoot) Returns the site with has the provided site root, ornull
if no configured site has that site root.getSiteRoot
(String rootPath) Returns the site root part for the given resources root path, ornull
if the given resources root path does not match any site root.Returns an unmodifiable set of all configured site roots (Strings).getSites()
Returns the map of configured sites, usingCmsSiteMatcher
objects as keys andCmsSite
objects as values.getSiteTitle
(CmsObject cms, CmsResource resource) Returns the site title.getSSLModeForWorkplaceServer
(String server) Gets the SSLMode for given workplace server.Get web server scripting configurations.Returns the workplace server.Gets the first configured workplace server that matches the host from the current CmsRequestContext, or the first configured workplace server if there is no match.Returns the configured worklace servers.getWorkplaceServers
(CmsSSLMode filterMode) Returns the configured worklace servers.Returns the configured worklace servers.Returns the site matcher that matches the workplace site.void
initialize
(CmsObject cms) Initializes the site manager with the OpenCms system configuration.boolean
Checks if web server scripting is enabled.boolean
isMatching
(CmsSiteMatcher matcher) Returnstrue
if the given site matcher matches any configured site, which includes the workplace site.boolean
isMatchingCurrentSite
(CmsObject cms, CmsSiteMatcher matcher) Returnstrue
if the given site matcher matches the current site.boolean
Checks if old style secure server is allowed.boolean
isOnlyOfflineSite
(CmsSite site) Indicates if given site is only available for offline repository.boolean
isSharedFolder
(String name) Checks if the given path is that of a shared folder.boolean
isSiteRoot
(String rootPath) Checks whether a given root path is a site root.boolean
isSiteUnderSite
(String siteRootPath) Checks if a given site is under another site.boolean
isSiteUnderSite
(CmsSite site) Checks if a given site is under another site.boolean
isWorkplaceRequest
(javax.servlet.http.HttpServletRequest req) Returnstrue
if the given request is against the configured OpenCms workplace.boolean
isWorkplaceRequest
(CmsSiteMatcher matcher) Returnstrue
if the given site matcher matches the configured OpenCms workplace.matchRequest
(javax.servlet.http.HttpServletRequest req) Matches the given request against all configures sites and returns the matching site, or the default site if no sites matches.matchSite
(CmsSiteMatcher matcher) Return the configured site that matches the given site matcher, or the default site if no sites matches.void
removeSite
(CmsObject cms, CmsSite site) Removes a site from the list of configured sites.void
setDefaultUri
(String defaultUri) Sets the default URI, this is only allowed during configuration.void
Sets the old style secure server boolean.void
setSharedFolder
(String sharedFolder) Sets the shared folder path.void
setWebServerScripting
(String webserverscript, String targetpath, String configtemplate, String securetemplate, String filenameprefix, String loggingdir) Set webserver script configuration.boolean
startsWithShared
(String path) Returns true if the path starts with the shared folder path.void
updateGeneralSettings
(CmsObject cms, String defaultUri, List<String> workplaceServersList, String sharedFolder) Method for backward compability reasons.void
updateGeneralSettings
(CmsObject cms, String defaulrUri, Map<String, CmsSSLMode> workplaceServers, String sharedFolder) Updates the general settings.void
updateSite
(CmsObject cms, CmsSite oldSite, CmsSite newSite) Updates or creates a site.boolean
usesSecureSite
(javax.servlet.http.HttpServletRequest req) Returns true if this request goes to a secure site.void
validateSiteRoot
(String siteRoot) Validates the site root, throwing an exception if the validation fails.
-
Field Details
-
DEFAULT_SHARED_FOLDER
The default shared folder name.- See Also:
-
PATH_SYSTEM_SHARED_FOLDER
The VFS root path to the system shared folder, where shared content that belongs to modules, and that should not be edited by normal editors can be stored. The folder is searched in the gallery search when shared folders should be searched.- See Also:
-
SHARED_FOLDER_TITLE
A placeholder for the title of the shared folder.- See Also:
-
WEB_SERVER_CONFIG_CONFIGTEMPLATE
Path to config template.- See Also:
-
WEB_SERVER_CONFIG_FILENAMEPREFIX
prefix for files.- See Also:
-
WEB_SERVER_CONFIG_LOGGINGDIR
Path to write logs to.- See Also:
-
WEB_SERVER_CONFIG_SECURETEMPLATE
Path to secure template.- See Also:
-
WEB_SERVER_CONFIG_TARGETPATH
Path to target.- See Also:
-
WEB_SERVER_CONFIG_WEBSERVERSCRIPT
Path of webserver script.- See Also:
-
-
Constructor Details
-
CmsSiteManagerImpl
public CmsSiteManagerImpl()Creates a new CmsSiteManager.
-
-
Method Details
-
createAliasSiteMatcher
Creates a site matcher for an alias read from the configuration.- Parameters:
alias
- the aliasredirect
- redirection enabled (true/false)offset
- time offset or empty- Returns:
- the alias site matcher
-
addSite
Adds a site.- Parameters:
cms
- the CMS objectsite
- the site to add- Throws:
CmsException
- if something goes wrong
-
addSite
public void addSite(String server, String uri, String title, String position, String errorPage, String webserver, String sslMode, String secureServer, String exclusive, String error, String usePermanentRedirects, String subsiteSelection, SortedMap<String, String> params, List<CmsSiteMatcher> aliases, Optional<CmsAlternativeSiteRootMapping> alternativeSiteRootMapping) throws CmsConfigurationExceptionAdds a new CmsSite to the list of configured sites, this is only allowed during configuration.If this method is called after the configuration is finished, a
RuntimeException
is thrown.- Parameters:
server
- the Serveruri
- the VFS pathtitle
- the display title for this siteposition
- the display order for this siteerrorPage
- the URI to use as error page for this sitesslMode
- the SSLMode of the sitewebserver
- indicates whether to write the web server configuration for this site or notsecureServer
- a secure server, can benull
exclusive
- if set totrue
, secure resources will only be available using the configured secure urlerror
- if exclusive, and set totrue
will generate a 404 error, if set tofalse
will redirect to secure URLusePermanentRedirects
- if set to "true", permanent redirects should be used when redirecting to the secure URLsubsiteSelection
- true if subsite selection should be enabledparams
- the site parametersaliases
- the aliases for the sitealternativeSiteRootMapping
- an optional alternative site root mapping- Throws:
CmsConfigurationException
- if the site contains a server name, that is already assigned
-
addSiteInternally
public void addSiteInternally(String server, String uri, String title, String position, String errorPage, String webserver, String sslMode, String secureServer, String exclusive, String error, String usePermanentRedirects, String subsiteSelection, SortedMap<String, String> params, List<CmsSiteMatcher> aliases, Optional<CmsAlternativeSiteRootMapping> alternativeSiteRoot) throws CmsConfigurationExceptionAdds a new CmsSite to the list of configured sites, this is only allowed during configuration.If this method is called after the configuration is finished, a
RuntimeException
is thrown.- Parameters:
server
- the Serveruri
- the VFS pathtitle
- the display title for this siteposition
- the display order for this siteerrorPage
- the URI to use as error page for this sitesslMode
- the SSLMode of the sitewebserver
- indicates whether to write the web server configuration for this site or notsecureServer
- a secure server, can benull
exclusive
- if set totrue
, secure resources will only be available using the configured secure urlerror
- if exclusive, and set totrue
will generate a 404 error, if set tofalse
will redirect to secure URLusePermanentRedirects
- if set to "true", permanent redirects should be used when redirecting to the secure URLsubsiteSelection
- true if subsite selection should be enabled for this siteparams
- the site parametersaliases
- the aliasesalternativeSiteRoot
- an optional alternative site root mapping- Throws:
CmsConfigurationException
- in case the site was not configured correctly
-
addWorkplaceServer
Adds a workplace server, this is only allowed during configuration.- Parameters:
workplaceServer
- the workplace serversslmode
- CmsSSLMode of workplace server
-
cmsEvent
Description copied from interface:I_CmsEventListener
Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class.- Specified by:
cmsEvent
in interfaceI_CmsEventListener
- Parameters:
event
- CmsEvent that has occurred- See Also:
-
getAvailableCorruptedSites
Returns all wrong configured sites.- Parameters:
cms
- CmsObjectworkplaceMode
- workplace mode- Returns:
- List of CmsSite
-
getAvailableSites
Returns a list of all sites available (visible) for the current user.- Parameters:
cms
- the current OpenCms user contextworkplaceMode
- if true, the root and current site is included for the admin user and the view permission is required to see the site root- Returns:
- a list of all sites available for the current user
-
getAvailableSites
public List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, boolean showShared, String ouFqn) Returns a list of allCmsSite
instances that are compatible to the given organizational unit.- Parameters:
cms
- the current OpenCms user contextworkplaceMode
- if true, the root and current site is included for the admin user and the view permission is required to see the site rootshowShared
- if the shared folder should be shownouFqn
- the organizational unit- Returns:
- a list of all site available for the current user
-
getAvailableSites
public List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, boolean showShared, String ouFqn, CmsSSLMode filterMode) Returns a list of allCmsSite
instances that are compatible to the given organizational unit.- Parameters:
cms
- the current OpenCms user contextworkplaceMode
- if true, the root and current site is included for the admin user and the view permission is required to see the site rootshowShared
- if the shared folder should be shownouFqn
- the organizational unitfilterMode
- The CmsSLLMode to filter, null if no filter- Returns:
- a list of all site available for the current user
-
getAvailableSites
Returns a list of all sites available (visible) for the current user.- Parameters:
cms
- the current OpenCms user contextworkplaceMode
- if true, the root and current site is included for the admin user and the view permission is required to see the site rootfilterMode
- The CmsSLLMode to filter, null if no filter- Returns:
- a list of all sites available for the current user
-
getAvailableSites
Returns a list of allCmsSite
instances that are compatible to the given organizational unit.- Parameters:
cms
- the current OpenCms user contextworkplaceMode
- if true, the root and current site is included for the admin user and the view permission is required to see the site rootouFqn
- the organizational unit- Returns:
- a list of all site available for the current user
-
getCurrentSite
Returns the current site for the provided OpenCms user context object.In the unlikely case that no site matches with the provided OpenCms user context, the default site is returned.
- Parameters:
cms
- the OpenCms user context object to check for the site- Returns:
- the current site for the provided OpenCms user context object
-
getDefaultSite
Returns the default site.- Returns:
- the default site
-
getDefaultUri
Returns the defaultUri.- Returns:
- the defaultUri
-
getSite
Returns the site for the given resource path, using the fall back site root in case the resource path is no root path.In case neither the given resource path, nor the given fall back site root matches any configured site, the default site is returned.
Usually the fall back site root should be taken from
CmsRequestContext.getSiteRoot()
, in which case a site for the site root should always exist.This is the same as first calling
getSiteForRootPath(String)
with theresourcePath
parameter, and if this fails callinggetSiteForSiteRoot(String)
with thefallbackSiteRoot
parameter, and if this fails callinggetDefaultSite()
.- Parameters:
rootPath
- the resource root path to get the site forfallbackSiteRoot
- site root to use in case the resource path is no root path- Returns:
- the site for the given resource path, using the fall back site root in case the resource path is no root path
- See Also:
-
getSiteForDefaultUri
Gets the site which is mapped to the default uri, or the 'absent' value of no such site exists.- Returns:
- the optional site mapped to the default uri
-
getSiteForRootPath
Returns the site for the given resources root path, ornull
if the resources root path does not match any site.- Parameters:
rootPath
- the root path of a resource- Returns:
- the site for the given resources root path,
or
null
if the resources root path does not match any site - See Also:
-
getSiteForSiteRoot
Returns the site with has the provided site root, ornull
if no configured site has that site root.The site root must have the form:
/sites/default
.
That means there must be a leading, but no trailing slash.- Parameters:
siteRoot
- the site root to look up the site for- Returns:
- the site with has the provided site root,
or
null
if no configured site has that site root - See Also:
-
getSiteRoot
Returns the site root part for the given resources root path, ornull
if the given resources root path does not match any site root.The site root returned will have the form:
/sites/default
.
That means there will a leading, but no trailing slash.- Parameters:
rootPath
- the root path of a resource- Returns:
- the site root part of the resources root path,
or
null
if the path does not match any site root - See Also:
-
getSiteRoots
Returns an unmodifiable set of all configured site roots (Strings).- Returns:
- an unmodifiable set of all configured site roots (Strings)
-
getSites
Returns the map of configured sites, usingCmsSiteMatcher
objects as keys andCmsSite
objects as values.- Returns:
- the map of configured sites, using
CmsSiteMatcher
objects as keys andCmsSite
objects as values
-
getSiteTitle
Returns the site title.- Parameters:
cms
- the cms contextresource
- the site root resource- Returns:
- the title
- Throws:
CmsException
- in case reading the title property fails
-
getSSLModeForWorkplaceServer
Gets the SSLMode for given workplace server.- Parameters:
server
- to obtain ssl mode for- Returns:
- CmsSSLMode
-
getWebServerConfig
Get web server scripting configurations.- Returns:
- Map with configuration data
-
getWorkplaceServer
Returns the workplace server.- Returns:
- the workplace server
-
getWorkplaceServer
Gets the first configured workplace server that matches the host from the current CmsRequestContext, or the first configured workplace server if there is no match.If there are no workplace configured at all, null is returned.
- Parameters:
cms
- the CmsObject used to check the host- Returns:
- the workplace server
-
getWorkplaceServers
Returns the configured worklace servers.- Returns:
- the workplace servers
-
getWorkplaceServers
Returns the configured worklace servers.- Parameters:
filterMode
- CmsSSLMode to filter results for.- Returns:
- the workplace servers
-
getWorkplaceServersMap
Returns the configured worklace servers.- Returns:
- the workplace servers
-
getWorkplaceSiteMatcher
Returns the site matcher that matches the workplace site.- Returns:
- the site matcher that matches the workplace site
-
initialize
Initializes the site manager with the OpenCms system configuration.- Parameters:
cms
- an OpenCms context object that must have been initialized with "Admin" permissions
-
isConfigurableWebServer
Checks if web server scripting is enabled.- Returns:
- true if web server scripting is set to available
-
isMatching
Returnstrue
if the given site matcher matches any configured site, which includes the workplace site.- Parameters:
matcher
- the site matcher to match the site with- Returns:
true
if the matcher matches a site
-
isMatchingCurrentSite
Returnstrue
if the given site matcher matches the current site.- Parameters:
cms
- the current OpenCms user contextmatcher
- the site matcher to match the site with- Returns:
true
if the matcher matches the current site
-
isOldStyleSecureServerAllowed
Checks if old style secure server is allowed.- Returns:
- boolean
-
isOnlyOfflineSite
Indicates if given site is only available for offline repository.- Parameters:
site
- to be looked up- Returns:
- true if only offline exists, false otherwise
-
isSiteRoot
Checks whether a given root path is a site root.- Parameters:
rootPath
- a root path- Returns:
- true if the given path is the path of a site root
-
isSiteUnderSite
Checks if a given site is under another site.- Parameters:
site
- CmsSite to check- Returns:
- true if given site is invalid
-
isSiteUnderSite
Checks if a given site is under another site.- Parameters:
siteRootPath
- site root path to check- Returns:
- true if given site is invalid
-
isWorkplaceRequest
Returnstrue
if the given site matcher matches the configured OpenCms workplace.- Parameters:
matcher
- the site matcher to match the site with- Returns:
true
if the given site matcher matches the configured OpenCms workplace
-
isWorkplaceRequest
Returnstrue
if the given request is against the configured OpenCms workplace.- Parameters:
req
- the request to match- Returns:
true
if the given request is against the configured OpenCms workplace
-
matchRequest
Matches the given request against all configures sites and returns the matching site, or the default site if no sites matches.- Parameters:
req
- the request to match- Returns:
- the matching site, or the default site if no sites matches
-
matchSite
Return the configured site that matches the given site matcher, or the default site if no sites matches.Does NOT match auto-generated sites from alternative site root mappings, since the site matcher does not contain path information.
- Parameters:
matcher
- the site matcher to match the site with- Returns:
- the matching site, or the default site if no sites matches
-
removeSite
Removes a site from the list of configured sites.- Parameters:
cms
- the cms objectsite
- the site to remove- Throws:
CmsException
- if something goes wrong
-
setDefaultUri
Sets the default URI, this is only allowed during configuration.If this method is called after the configuration is finished, a
RuntimeException
is thrown.- Parameters:
defaultUri
- the defaultUri to set
-
setOldStyleSecureServerAllowed
Sets the old style secure server boolean.- Parameters:
value
- value
-
setWebServerScripting
public void setWebServerScripting(String webserverscript, String targetpath, String configtemplate, String securetemplate, String filenameprefix, String loggingdir) Set webserver script configuration.- Parameters:
webserverscript
- pathtargetpath
- pathconfigtemplate
- pathsecuretemplate
- pathfilenameprefix
- to add to filesloggingdir
- path
-
updateGeneralSettings
public void updateGeneralSettings(CmsObject cms, String defaultUri, List<String> workplaceServersList, String sharedFolder) throws CmsException Method for backward compability reasons. Not sure if really needed //TODO check! CmsSSLMode are set to No as default.- Parameters:
cms
- the cms to usedefaultUri
- the default URIworkplaceServersList
- the workplace server URLssharedFolder
- the shared folder URI- Throws:
CmsException
- if something goes wrong
-
updateGeneralSettings
public void updateGeneralSettings(CmsObject cms, String defaulrUri, Map<String, CmsSSLMode> workplaceServers, String sharedFolder) throws CmsExceptionUpdates the general settings.- Parameters:
cms
- the cms to usedefaulrUri
- the default URIworkplaceServers
- the workplace server URLssharedFolder
- the shared folder URI- Throws:
CmsException
- if something goes wrong
-
updateSite
Updates or creates a site.- Parameters:
cms
- the CMS objectoldSite
- the site to remove if notnull
newSite
- the site to add if notnull
- Throws:
CmsException
- if something goes wrong
-
usesSecureSite
Returns true if this request goes to a secure site.- Parameters:
req
- the request to check- Returns:
- true if the request goes to a secure site
-
validateSiteRoot
Validates the site root, throwing an exception if the validation fails.- Parameters:
siteRoot
- the site root to check
-