public final class CmsSiteManagerImpl
extends java.lang.Object
To obtain the configured site manager instance, use OpenCms.getSiteManager()
.
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
SHARED_FOLDER_TITLE
A placeholder for the title of the shared folder.
|
构造器和说明 |
---|
CmsSiteManagerImpl()
Creates a new CmsSiteManager.
|
限定符和类型 | 方法和说明 |
---|---|
void |
addAliasToConfigSite(java.lang.String alias,
java.lang.String offset)
Adds an alias to the currently configured site.
|
void |
addSite(CmsObject cms,
CmsSite site)
Adds a 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 secureServer,
java.lang.String exclusive,
java.lang.String error)
Adds a new CmsSite to the list of configured sites,
this is only allowed during configuration.
|
java.util.List<CmsSite> |
getAvailableSites(CmsObject cms,
boolean workplaceMode)
Returns a list of all sites available for the current user.
|
java.util.List<CmsSite> |
getAvailableSites(CmsObject cms,
boolean workplaceMode,
boolean showShared,
java.lang.String ouFqn)
Returns a list of all
CmsSite 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 all
CmsSite instances that are compatible to the given organizational unit. |
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.
|
CmsSite |
getSiteForRootPath(java.lang.String rootPath)
Returns the site for the given resources root path,
or
null 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,
or
null 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,
or
null 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, using
CmsSiteMatcher objects as keys and CmsSite objects as values. |
java.lang.String |
getWorkplaceServer()
Returns the workplace server.
|
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 |
isMatching(CmsSiteMatcher matcher)
Returns
true if the given site matcher matches any configured site,
which includes the workplace site. |
boolean |
isMatchingCurrentSite(CmsObject cms,
CmsSiteMatcher matcher)
Returns
true if the given site matcher matches the current site. |
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 |
isWorkplaceRequest(CmsSiteMatcher matcher)
Returns
true if the given site matcher matches the configured OpenCms workplace. |
boolean |
isWorkplaceRequest(javax.servlet.http.HttpServletRequest req)
Returns
true if the given request is against 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)
Removed a site.
|
void |
setDefaultUri(java.lang.String defaultUri)
Sets the default URI, this is only allowed during configuration.
|
void |
setSharedFolder(java.lang.String sharedFolder)
Sets the shared folder path.
|
void |
setWorkplaceServer(java.lang.String workplaceServer)
Sets the workplace server, this is only allowed during 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 defaulrUri,
java.lang.String workplaceServer,
java.lang.String sharedFolder)
Updates the general settings.
|
void |
updateSite(CmsObject cms,
CmsSite oldSite,
CmsSite newSite)
Updates an existing site.
|
public static final java.lang.String SHARED_FOLDER_TITLE
public void addAliasToConfigSite(java.lang.String alias, java.lang.String offset)
alias
- the URL of the alias serveroffset
- the optional time offset for this aliaspublic void addSite(CmsObject cms, CmsSite site) throws CmsException
cms
- the CMS objectsite
- the site to addCmsException
- if something goes wrongpublic 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 secureServer, java.lang.String exclusive, java.lang.String error) throws CmsConfigurationException
If this method is called after the configuration is finished,
a RuntimeException
is thrown.
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 sitewebserver
- indicates whether to write the web server configuration for this site or notsecureServer
- a secure server, can be null
exclusive
- if set to true
, secure resources will only be available using the configured secure urlerror
- if exclusive, and set to true
will generate a 404 error,
if set to false
will redirect to secure URLCmsConfigurationException
- if the site contains a server name, that is already assignedpublic java.util.List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode)
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 rootpublic java.util.List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, boolean showShared, java.lang.String ouFqn)
CmsSite
instances that are compatible to the given organizational unit.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 unitpublic java.util.List<CmsSite> getAvailableSites(CmsObject cms, boolean workplaceMode, java.lang.String ouFqn)
CmsSite
instances that are compatible to the given organizational unit.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 unitpublic CmsSite getCurrentSite(CmsObject cms)
In the unlikely case that no site matches with the provided OpenCms user context, the default site is returned.
cms
- the OpenCms user context object to check for the sitepublic CmsSite getDefaultSite()
public java.lang.String getDefaultUri()
public java.lang.String getSharedFolder()
public CmsSite getSite(java.lang.String rootPath, java.lang.String fallbackSiteRoot)
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 the
resourcePath
parameter, and if this fails calling
getSiteForSiteRoot(String)
with the fallbackSiteRoot
parameter,
and if this fails calling getDefaultSite()
.
rootPath
- the resource root path to get the site forfallbackSiteRoot
- site root to use in case the resource path is no root pathgetSiteForRootPath(String)
public CmsSite getSiteForRootPath(java.lang.String rootPath)
null
if the resources root path does not match any site.rootPath
- the root path of a resourcenull
if the resources root path does not match any sitegetSiteForSiteRoot(String)
,
getSiteRoot(String)
public CmsSite getSiteForSiteRoot(java.lang.String siteRoot)
null
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.
siteRoot
- the site root to look up the site fornull
if no configured site has that site rootgetSiteForRootPath(String)
public java.lang.String getSiteRoot(java.lang.String rootPath)
null
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.
rootPath
- the root path of a resourcenull
if the path does not match any site rootgetSiteForRootPath(String)
public java.util.Set<java.lang.String> getSiteRoots()
public java.util.Map<CmsSiteMatcher,CmsSite> getSites()
CmsSiteMatcher
objects as keys and CmsSite
objects as values.CmsSiteMatcher
objects as keys and CmsSite
objects as valuespublic java.lang.String getWorkplaceServer()
public CmsSiteMatcher getWorkplaceSiteMatcher()
public void initialize(CmsObject cms)
cms
- an OpenCms context object that must have been initialized with "Admin" permissionspublic boolean isMatching(CmsSiteMatcher matcher)
true
if the given site matcher matches any configured site,
which includes the workplace site.matcher
- the site matcher to match the site withtrue
if the matcher matches a sitepublic boolean isMatchingCurrentSite(CmsObject cms, CmsSiteMatcher matcher)
true
if the given site matcher matches the current site.cms
- the current OpenCms user contextmatcher
- the site matcher to match the site withtrue
if the matcher matches the current sitepublic boolean isSharedFolder(java.lang.String name)
name
- a path prefixpublic boolean isSiteRoot(java.lang.String rootPath)
rootPath
- a root pathpublic boolean isWorkplaceRequest(CmsSiteMatcher matcher)
true
if the given site matcher matches the configured OpenCms workplace.matcher
- the site matcher to match the site withtrue
if the given site matcher matches the configured OpenCms workplacepublic boolean isWorkplaceRequest(javax.servlet.http.HttpServletRequest req)
true
if the given request is against the configured OpenCms workplace.req
- the request to matchtrue
if the given request is against the configured OpenCms workplacepublic CmsSite matchRequest(javax.servlet.http.HttpServletRequest req)
req
- the request to matchpublic CmsSite matchSite(CmsSiteMatcher matcher)
matcher
- the site matcher to match the site withpublic void removeSite(CmsObject cms, CmsSite site) throws CmsException
cms
- the cms objectsite
- the site to removeCmsException
- if something goes wrongpublic void setDefaultUri(java.lang.String defaultUri)
If this method is called after the configuration is finished,
a RuntimeException
is thrown.
defaultUri
- the defaultUri to setpublic void setSharedFolder(java.lang.String sharedFolder)
sharedFolder
- the shared folder pathpublic void setWorkplaceServer(java.lang.String workplaceServer)
If this method is called after the configuration is finished,
a RuntimeException
is thrown.
workplaceServer
- the workplace server to setpublic boolean startsWithShared(java.lang.String path)
path
- the path to checkpublic void updateGeneralSettings(CmsObject cms, java.lang.String defaulrUri, java.lang.String workplaceServer, java.lang.String sharedFolder) throws CmsException
cms
- the cms to usedefaulrUri
- the default URIworkplaceServer
- the workplace server URLsharedFolder
- the shared folder URICmsException
- if something goes wrongpublic void updateSite(CmsObject cms, CmsSite oldSite, CmsSite newSite) throws CmsException
cms
- the CMS objectoldSite
- the site to remove if not null
newSite
- the site to add if not null
CmsException
- if something goes wrong