Class CmsSiteManagerImpl
- java.lang.Object
-
- org.opencms.site.CmsSiteManagerImpl
-
- All Implemented Interfaces:
I_CmsEventListener
public final class CmsSiteManagerImpl extends java.lang.Object implements I_CmsEventListener
Manages all configured sites in OpenCms.To obtain the configured site manager instance, use
OpenCms.getSiteManager()
.- Since:
- 7.0.2
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_SHARED_FOLDER
The default shared folder name.static java.lang.String
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.static java.lang.String
SHARED_FOLDER_TITLE
A placeholder for the title of the shared folder.static java.lang.String
WEB_SERVER_CONFIG_CONFIGTEMPLATE
Path to config template.static java.lang.String
WEB_SERVER_CONFIG_FILENAMEPREFIX
prefix for files.static java.lang.String
WEB_SERVER_CONFIG_LOGGINGDIR
Path to write logs to.static java.lang.String
WEB_SERVER_CONFIG_SECURETEMPLATE
Path to secure template.static java.lang.String
WEB_SERVER_CONFIG_TARGETPATH
Path to target.static java.lang.String
WEB_SERVER_CONFIG_WEBSERVERSCRIPT
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_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_OU_ID, KEY_OU_NAME, KEY_PROJECTID, KEY_PUBLISHID, KEY_PUBLISHLIST, 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_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
Constructors Constructor Description CmsSiteManagerImpl()
Creates a new CmsSiteManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAliasToConfigSite(java.lang.String alias, java.lang.String redirect, java.lang.String offset)
Adds an alias to the currently configured site.void
addParamToConfigSite(java.lang.String name, java.lang.String value)
Adds a parameter to the currently configured site.void
addSite(java.lang.String server, java.lang.String uri, java.lang.String title, java.lang.String position, java.lang.String errorPage, java.lang.String webserver, java.lang.String sslMode, java.lang.String secureServer, java.lang.String exclusive, java.lang.String error, java.lang.String usePermanentRedirects)
Adds a new CmsSite to the list of configured sites, this is only allowed during configuration.void
addSite(CmsObject cms, CmsSite site)
Adds a site.void
addSiteInternally(java.lang.String server, java.lang.String uri, java.lang.String title, java.lang.String position, java.lang.String errorPage, java.lang.String webserver, java.lang.String sslMode, java.lang.String secureServer, java.lang.String exclusive, java.lang.String error, java.lang.String usePermanentRedirects)
Adds a new CmsSite to the list of configured sites, this is only allowed during configuration.void
addWorkplaceServer(java.lang.String workplaceServer, java.lang.String sslmode)
Adds a workplace server, this is only allowed during configuration.void
cmsEvent(CmsEvent event)
Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class.java.util.List<CmsSite>
getAvailableCorruptedSites(CmsObject cms, boolean workplaceMode)
Returns all wrong configured sites.java.util.List<CmsSite>
getAvailableSites(CmsObject cms, boolean workplaceMode)
Returns a list of all sites available (visible) for the current user.java.util.List<CmsSite>
getAvailableSites(CmsObject cms, boolean workplaceMode, boolean showShared, java.lang.String ouFqn)
Returns a list of allCmsSite
instances that are compatible to the given organizational unit.java.util.List<CmsSite>
getAvailableSites(CmsObject cms, boolean workplaceMode, boolean showShared, java.lang.String ouFqn, CmsSSLMode filterMode)
Returns a list of allCmsSite
instances that are compatible to the given organizational unit.java.util.List<CmsSite>
getAvailableSites(CmsObject cms, boolean workplaceMode, java.lang.String ouFqn)
Returns a list of allCmsSite
instances that are compatible to the given organizational unit.java.util.List<CmsSite>
getAvailableSites(CmsObject cms, boolean workplaceMode, CmsSSLMode filterMode)
Returns a list of all sites available (visible) for the current user.CmsSite
getCurrentSite(CmsObject cms)
Returns the current site for the provided OpenCms user context object.CmsSite
getDefaultSite()
Returns the default site.java.lang.String
getDefaultUri()
Returns the defaultUri.java.lang.String
getSharedFolder()
Returns the shared folder path.CmsSite
getSite(java.lang.String rootPath, java.lang.String fallbackSiteRoot)
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>
getSiteForDefaultUri()
Gets the site which is mapped to the default uri, or the 'absent' value of no such site exists.CmsSite
getSiteForRootPath(java.lang.String rootPath)
Returns the site for the given resources root path, ornull
if the resources root path does not match any site.CmsSite
getSiteForSiteRoot(java.lang.String siteRoot)
Returns the site with has the provided site root, ornull
if no configured site has that site root.java.lang.String
getSiteRoot(java.lang.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.java.util.Set<java.lang.String>
getSiteRoots()
Returns an unmodifiable set of all configured site roots (Strings).java.util.Map<CmsSiteMatcher,CmsSite>
getSites()
Returns the map of configured sites, usingCmsSiteMatcher
objects as keys andCmsSite
objects as values.java.lang.String
getSiteTitle(CmsObject cms, CmsResource resource)
Returns the site title.CmsSSLMode
getSSLModeForWorkplaceServer(java.lang.String server)
Gets the SSLMode for given workplace server.java.util.Map<java.lang.String,java.lang.String>
getWebServerConfig()
Get web server scripting configurations.java.lang.String
getWorkplaceServer()
Returns the workplace server.java.lang.String
getWorkplaceServer(CmsObject cms)
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.java.util.List<java.lang.String>
getWorkplaceServers()
Returns the configured worklace servers.java.util.List<java.lang.String>
getWorkplaceServers(CmsSSLMode filterMode)
Returns the configured worklace servers.java.util.Map<java.lang.String,CmsSSLMode>
getWorkplaceServersMap()
Returns the configured worklace servers.CmsSiteMatcher
getWorkplaceSiteMatcher()
Returns the site matcher that matches the workplace site.void
initialize(CmsObject cms)
Initializes the site manager with the OpenCms system configuration.boolean
isConfigurableWebServer()
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
isOldStyleSecureServerAllowed()
Checks if old style secure server is allowed.boolean
isOnlyOfflineSite(CmsSite site)
Indicates if given site is only available for offline repository.boolean
isSharedFolder(java.lang.String name)
Checks if the given path is that of a shared folder.boolean
isSiteRoot(java.lang.String rootPath)
Checks whether a given root path is a site root.boolean
isSiteUnderSite(java.lang.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.CmsSite
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.CmsSite
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(java.lang.String defaultUri)
Sets the default URI, this is only allowed during configuration.void
setOldStyleSecureServerAllowed(java.lang.String value)
Sets the old style secure server boolean.void
setSharedFolder(java.lang.String sharedFolder)
Sets the shared folder path.void
setWebServerScripting(java.lang.String webserverscript, java.lang.String targetpath, java.lang.String configtemplate, java.lang.String securetemplate, java.lang.String filenameprefix, java.lang.String loggingdir)
Set webserver script configuration.boolean
startsWithShared(java.lang.String path)
Returns true if the path starts with the shared folder path.void
updateGeneralSettings(CmsObject cms, java.lang.String defaultUri, java.util.List<java.lang.String> workplaceServersList, java.lang.String sharedFolder)
Method for backward compability reasons.void
updateGeneralSettings(CmsObject cms, java.lang.String defaulrUri, java.util.Map<java.lang.String,CmsSSLMode> workplaceServers, java.lang.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(java.lang.String siteRoot)
Validates the site root, throwing an exception if the validation fails.
-
-
-
Field Detail
-
DEFAULT_SHARED_FOLDER
public static final java.lang.String DEFAULT_SHARED_FOLDER
The default shared folder name.- See Also:
- Constant Field Values
-
PATH_SYSTEM_SHARED_FOLDER
public static final java.lang.String 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:
- Constant Field Values
-
SHARED_FOLDER_TITLE
public static final java.lang.String SHARED_FOLDER_TITLE
A placeholder for the title of the shared folder.- See Also:
- Constant Field Values
-
WEB_SERVER_CONFIG_CONFIGTEMPLATE
public static final java.lang.String WEB_SERVER_CONFIG_CONFIGTEMPLATE
Path to config template.- See Also:
- Constant Field Values
-
WEB_SERVER_CONFIG_FILENAMEPREFIX
public static final java.lang.String WEB_SERVER_CONFIG_FILENAMEPREFIX
prefix for files.- See Also:
- Constant Field Values
-
WEB_SERVER_CONFIG_LOGGINGDIR
public static final java.lang.String WEB_SERVER_CONFIG_LOGGINGDIR
Path to write logs to.- See Also:
- Constant Field Values
-
WEB_SERVER_CONFIG_SECURETEMPLATE
public static final java.lang.String WEB_SERVER_CONFIG_SECURETEMPLATE
Path to secure template.- See Also:
- Constant Field Values
-
WEB_SERVER_CONFIG_TARGETPATH
public static final java.lang.String WEB_SERVER_CONFIG_TARGETPATH
Path to target.- See Also:
- Constant Field Values
-
WEB_SERVER_CONFIG_WEBSERVERSCRIPT
public static final java.lang.String WEB_SERVER_CONFIG_WEBSERVERSCRIPT
Path of webserver script.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsSiteManagerImpl
public CmsSiteManagerImpl()
Creates a new CmsSiteManager.
-
-
Method Detail
-
addAliasToConfigSite
public void addAliasToConfigSite(java.lang.String alias, java.lang.String redirect, java.lang.String offset)
Adds an alias to the currently configured site.- Parameters:
alias
- the URL of the alias serverredirect
-true
to always redirect to main URLoffset
- the optional time offset for this alias
-
addParamToConfigSite
public void addParamToConfigSite(java.lang.String name, java.lang.String value)
Adds a parameter to the currently configured site.- Parameters:
name
- the parameter namevalue
- the parameter value
-
addSite
public void addSite(CmsObject cms, CmsSite site) throws CmsException
Adds a site.- Parameters:
cms
- the CMS objectsite
- the site to add- Throws:
CmsException
- if something goes wrong
-
addSite
public void addSite(java.lang.String server, java.lang.String uri, java.lang.String title, java.lang.String position, java.lang.String errorPage, java.lang.String webserver, java.lang.String sslMode, java.lang.String secureServer, java.lang.String exclusive, java.lang.String error, java.lang.String usePermanentRedirects) throws CmsConfigurationException
Adds 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 URL- Throws:
CmsConfigurationException
- if the site contains a server name, that is already assigned
-
addSiteInternally
public void addSiteInternally(java.lang.String server, java.lang.String uri, java.lang.String title, java.lang.String position, java.lang.String errorPage, java.lang.String webserver, java.lang.String sslMode, java.lang.String secureServer, java.lang.String exclusive, java.lang.String error, java.lang.String usePermanentRedirects) throws CmsConfigurationException
Adds 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 URL- Throws:
CmsConfigurationException
- in case the site was not configured correctly
-
addWorkplaceServer
public void addWorkplaceServer(java.lang.String workplaceServer, java.lang.String sslmode)
Adds a workplace server, this is only allowed during configuration.- Parameters:
workplaceServer
- the workplace serversslmode
- CmsSSLMode of workplace server
-
cmsEvent
public void cmsEvent(CmsEvent event)
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:
I_CmsEventListener.cmsEvent(org.opencms.main.CmsEvent)
-
getAvailableCorruptedSites
public java.util.List<CmsSite> getAvailableCorruptedSites(CmsObject cms, boolean workplaceMode)
Returns all wrong configured sites.- Parameters:
cms
- CmsObjectworkplaceMode
- workplace mode- Returns:
- List of CmsSite
-
getAvailableSites
public java.util.List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode)
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 java.util.List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, boolean showShared, java.lang.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 java.util.List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, boolean showShared, java.lang.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
public java.util.List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, CmsSSLMode filterMode)
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
public java.util.List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, java.lang.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 rootouFqn
- the organizational unit- Returns:
- a list of all site available for the current user
-
getCurrentSite
public CmsSite getCurrentSite(CmsObject cms)
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
public CmsSite getDefaultSite()
Returns the default site.- Returns:
- the default site
-
getDefaultUri
public java.lang.String getDefaultUri()
Returns the defaultUri.- Returns:
- the defaultUri
-
getSharedFolder
public java.lang.String getSharedFolder()
Returns the shared folder path.- Returns:
- the shared folder path
-
getSite
public CmsSite getSite(java.lang.String rootPath, java.lang.String fallbackSiteRoot)
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:
getSiteForRootPath(String)
-
getSiteForDefaultUri
public com.google.common.base.Optional<CmsSite> 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
public CmsSite getSiteForRootPath(java.lang.String rootPath)
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(String)
,getSiteRoot(String)
-
getSiteForSiteRoot
public CmsSite getSiteForSiteRoot(java.lang.String siteRoot)
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:
getSiteForRootPath(String)
-
getSiteRoot
public java.lang.String getSiteRoot(java.lang.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.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:
getSiteForRootPath(String)
-
getSiteRoots
public java.util.Set<java.lang.String> getSiteRoots()
Returns an unmodifiable set of all configured site roots (Strings).- Returns:
- an unmodifiable set of all configured site roots (Strings)
-
getSites
public java.util.Map<CmsSiteMatcher,CmsSite> 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
public java.lang.String getSiteTitle(CmsObject cms, CmsResource resource) throws CmsException
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
public CmsSSLMode getSSLModeForWorkplaceServer(java.lang.String server)
Gets the SSLMode for given workplace server.- Parameters:
server
- to obtain ssl mode for- Returns:
- CmsSSLMode
-
getWebServerConfig
public java.util.Map<java.lang.String,java.lang.String> getWebServerConfig()
Get web server scripting configurations.- Returns:
- Map with configuration data
-
getWorkplaceServer
public java.lang.String getWorkplaceServer()
Returns the workplace server.- Returns:
- the workplace server
-
getWorkplaceServer
public java.lang.String getWorkplaceServer(CmsObject cms)
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
public java.util.List<java.lang.String> getWorkplaceServers()
Returns the configured worklace servers.- Returns:
- the workplace servers
-
getWorkplaceServers
public java.util.List<java.lang.String> getWorkplaceServers(CmsSSLMode filterMode)
Returns the configured worklace servers.- Parameters:
filterMode
- CmsSSLMode to filter results for.- Returns:
- the workplace servers
-
getWorkplaceServersMap
public java.util.Map<java.lang.String,CmsSSLMode> getWorkplaceServersMap()
Returns the configured worklace servers.- Returns:
- the workplace servers
-
getWorkplaceSiteMatcher
public CmsSiteMatcher getWorkplaceSiteMatcher()
Returns the site matcher that matches the workplace site.- Returns:
- the site matcher that matches the workplace site
-
initialize
public void initialize(CmsObject cms)
Initializes the site manager with the OpenCms system configuration.- Parameters:
cms
- an OpenCms context object that must have been initialized with "Admin" permissions
-
isConfigurableWebServer
public boolean isConfigurableWebServer()
Checks if web server scripting is enabled.- Returns:
- true if web server scripting is set to available
-
isMatching
public boolean isMatching(CmsSiteMatcher matcher)
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
public boolean isMatchingCurrentSite(CmsObject cms, CmsSiteMatcher matcher)
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
public boolean isOldStyleSecureServerAllowed()
Checks if old style secure server is allowed.- Returns:
- boolean
-
isOnlyOfflineSite
public boolean isOnlyOfflineSite(CmsSite site)
Indicates if given site is only available for offline repository.- Parameters:
site
- to be looked up- Returns:
- true if only offline exists, false otherwise
-
isSharedFolder
public boolean isSharedFolder(java.lang.String name)
Checks if the given path is that of a shared folder.- Parameters:
name
- a path prefix- Returns:
- true if the given prefix represents a shared folder
-
isSiteRoot
public boolean isSiteRoot(java.lang.String rootPath)
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
public boolean isSiteUnderSite(CmsSite site)
Checks if a given site is under another site.- Parameters:
site
- CmsSite to check- Returns:
- true if given site is invalid
-
isSiteUnderSite
public boolean isSiteUnderSite(java.lang.String siteRootPath)
Checks if a given site is under another site.- Parameters:
siteRootPath
- site root path to check- Returns:
- true if given site is invalid
-
isWorkplaceRequest
public boolean isWorkplaceRequest(CmsSiteMatcher matcher)
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
public boolean isWorkplaceRequest(javax.servlet.http.HttpServletRequest req)
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
public CmsSite 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.- Parameters:
req
- the request to match- Returns:
- the matching site, or the default site if no sites matches
-
matchSite
public CmsSite matchSite(CmsSiteMatcher matcher)
Return the configured site that matches the given site matcher, or the default site if no sites matches.- Parameters:
matcher
- the site matcher to match the site with- Returns:
- the matching site, or the default site if no sites matches
-
removeSite
public void removeSite(CmsObject cms, CmsSite site) throws CmsException
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
public void setDefaultUri(java.lang.String defaultUri)
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
public void setOldStyleSecureServerAllowed(java.lang.String value)
Sets the old style secure server boolean.- Parameters:
value
- value
-
setSharedFolder
public void setSharedFolder(java.lang.String sharedFolder)
Sets the shared folder path.- Parameters:
sharedFolder
- the shared folder path
-
setWebServerScripting
public void setWebServerScripting(java.lang.String webserverscript, java.lang.String targetpath, java.lang.String configtemplate, java.lang.String securetemplate, java.lang.String filenameprefix, java.lang.String loggingdir)
Set webserver script configuration.- Parameters:
webserverscript
- pathtargetpath
- pathconfigtemplate
- pathsecuretemplate
- pathfilenameprefix
- to add to filesloggingdir
- path
-
startsWithShared
public boolean startsWithShared(java.lang.String path)
Returns true if the path starts with the shared folder path.- Parameters:
path
- the path to check- Returns:
- true if the path starts with the shared folder path
-
updateGeneralSettings
public void updateGeneralSettings(CmsObject cms, java.lang.String defaultUri, java.util.List<java.lang.String> workplaceServersList, java.lang.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, java.lang.String defaulrUri, java.util.Map<java.lang.String,CmsSSLMode> workplaceServers, java.lang.String sharedFolder) throws CmsException
Updates 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
public void updateSite(CmsObject cms, CmsSite oldSite, CmsSite newSite) throws CmsException
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
public boolean usesSecureSite(javax.servlet.http.HttpServletRequest req)
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
public void validateSiteRoot(java.lang.String siteRoot)
Validates the site root, throwing an exception if the validation fails.- Parameters:
siteRoot
- the site root to check
-
-