|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.site.CmsSiteManagerImpl
public final class CmsSiteManagerImpl
Manages all configured sites in OpenCms.
To obtain the configured site manager instance, use OpenCms.getSiteManager()
.
Constructor Summary | |
---|---|
CmsSiteManagerImpl()
Creates a new CmsSiteManager. |
Method Summary | |
---|---|
void |
addAliasToConfigSite(java.lang.String alias,
java.lang.String offset)
Adds an alias to the currently configured site. |
void |
addSite(java.lang.String server,
java.lang.String uri,
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 |
getAvailableSites(CmsObject cms,
boolean workplaceMode)
Returns a list of all sites available for the current user. |
java.util.List |
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. |
CmsSite |
getSite(java.lang.String siteRoot)
Deprecated. use getSiteForSiteRoot(String) instead |
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 |
getSiteRoots()
Returns an unmodifiable set of all configured site roots (Strings). |
java.util.Map |
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 |
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 |
setDefaultUri(java.lang.String defaultUri)
Sets the default URI, this is only allowed during configuration. |
void |
setWorkplaceServer(java.lang.String workplaceServer)
Sets the workplace server, this is only allowed during configuration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CmsSiteManagerImpl()
Method Detail |
---|
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(java.lang.String server, java.lang.String uri, 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 pathsecureServer
- 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 URL
CmsConfigurationException
- if the site contains a server name, that is already assignedpublic java.util.List 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 root
public java.util.List 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 unit
public 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 site
public CmsSite getDefaultSite()
public java.lang.String getDefaultUri()
public CmsSite getSite(java.lang.String siteRoot)
getSiteForSiteRoot(String)
instead
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 for
null
if no configured site has that site rootgetSiteForSiteRoot(String)
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 path
getSiteForRootPath(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 resource
null
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 for
null
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 resource
null
if the path does not match any site rootgetSiteForRootPath(String)
public java.util.Set getSiteRoots()
public java.util.Map 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 with
true
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 with
true
if the matcher matches the current sitepublic boolean isWorkplaceRequest(CmsSiteMatcher matcher)
true
if the given site matcher matches the configured OpenCms workplace.
matcher
- the site matcher to match the site with
true
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 match
true
if the given request is against the configured OpenCms workplacepublic CmsSite matchRequest(javax.servlet.http.HttpServletRequest req)
req
- the request to match
public CmsSite matchSite(CmsSiteMatcher matcher)
matcher
- the site matcher to match the site with
public 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 setWorkplaceServer(java.lang.String workplaceServer)
If this method is called after the configuration is finished,
a RuntimeException
is thrown.
workplaceServer
- the workplace server to set
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |