Class CmsSite
- java.lang.Object
-
- org.opencms.site.CmsSite
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<CmsSite>
public final class CmsSite extends java.lang.Object implements java.lang.Cloneable, java.lang.Comparable<CmsSite>, java.io.Serializable
Describes a configured site in OpenCms.- Since:
- 6.0.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsSite.LocalizationMode
The site localization modes.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PARAM_LOCALIZATION_MODE
The localization mode parameter name.static java.lang.String
PARAM_MAIN_LOCALE
Parameter name for the main locale.static java.lang.String
PARAM_SECONDARY_LOCALES
Parameter name for the secondary locales.
-
Constructor Summary
Constructors Constructor Description CmsSite(java.lang.String siteRoot, java.lang.String siteURL)
Constructs a new site object without title and id information, with a site matcher generated from the provided URL.CmsSite(java.lang.String siteRoot, CmsSiteMatcher siteMatcher)
Constructs a new site object without title and id information, this is to be used for lookup purposes only.CmsSite(java.lang.String siteRoot, CmsUUID siteRootUUID, java.lang.String title)
Constructs a new site object with a default (wildcard) a site matcher, this is to be used for display purposes only.CmsSite(java.lang.String siteRoot, CmsUUID siteRootUUID, java.lang.String title, CmsSiteMatcher siteMatcher, java.lang.String position)
Constructs a new site object.CmsSite(java.lang.String siteRoot, CmsUUID siteRootUUID, java.lang.String title, CmsSiteMatcher siteMatcher, java.lang.String position, java.lang.String errorPage, CmsSiteMatcher secureSite, boolean exclusiveUrl, boolean exclusiveError, boolean webserver, java.util.List<CmsSiteMatcher> aliases, boolean subsiteSelection)
Constructs a new site object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAlias(CmsSiteMatcher aliasServer)
Adds an alias for the site.CmsSite
clone()
Returns a clone of this Objects instance.int
compareTo(CmsSite that)
CmsSite
createAlternativeSiteRootSite()
Creates a generated site for the extension folder configured on this site, or null if no extension folder is set.boolean
equals(java.lang.Object obj)
java.util.List<CmsSiteMatcher>
getAliases()
Returns the aliases for this site.java.util.List<CmsSiteMatcher>
getAllMatchers()
Gets all site matchers which should be used for matching the site.java.util.Optional<CmsAlternativeSiteRootMapping>
getAlternativeSiteRootMapping()
Gets the (optional) alternative site root mapping.java.lang.String
getErrorPage()
Returns the errorPage.CmsSite.LocalizationMode
getLocalizationMode()
Returns the localization mode.java.util.Locale
getMainTranslationLocale(java.util.Locale defaultValue)
Gets the main translation locale for this site.java.util.SortedMap<java.lang.String,java.lang.String>
getParameters()
Returns the parameters.float
getPosition()
Returns the sorting position.java.util.List<java.util.Locale>
getSecondaryTranslationLocales()
Gets the list of secondary translation locales.CmsSiteMatcher
getSecureServer()
Returns the secureServer.protected CmsSiteMatcher
getSecureServerMatcher()
Returns the site matcher for the secure site, or null if no secure site is defined.java.lang.String
getSecureUrl()
Returns the secure server url of this site root.java.lang.String
getServerPrefix(CmsObject cms, java.lang.String resourceName)
Returns the server prefix for the given resource in this site, used to distinguish between secure (https) and non-secure (http) sites.java.lang.String
getServerPrefix(CmsObject cms, CmsResource resource)
Returns the server prefix for the given resource in this site, used to distinguish between secure (https) and non-secure (http) sites.CmsSiteMatcher
getSiteMatcher()
Returns the site matcher that describes the URL of this site.java.lang.String
getSitePath(java.lang.String rootPath)
Returns the site path for the given root path in case the root path actually starts with this site root, ornull
in case the root path does not.java.lang.String
getSiteRoot()
Returns the path of this site's root directory in the OpenCms VFS without tailing slash.CmsUUID
getSiteRootUUID()
Returns the UUID of this site's root directory in the OpenCms VFS.CmsSSLMode
getSSLMode()
Gets the SSLMode of the site.java.lang.String
getTitle()
Returns the display title of this site.java.util.List<java.util.Locale>
getTranslationLocales()
Returns all configured translation locales for this site.java.lang.String
getUrl()
Returns the server url of this site root.int
hashCode()
boolean
hasSecureServer()
Returns true, if the site has a secure server.boolean
isExclusiveError()
Returns the exclusive error flag.boolean
isExclusiveUrl()
Returns the exclusive protocol flag.boolean
isGenerated()
Returns true if this is an automatically generated site (and thus should not be used in the site management UI).boolean
isOnlineUpdated()
Checks if the site it in the online project.boolean
isSharedSite()
Returns a flag indicating if the site is the shared site.boolean
isSubsiteSelectionEnabled()
Returns true if subsite selection is enabled for this site.boolean
isWebserver()
Returns the web server.boolean
matchAlternativeSiteRoot(java.lang.String path)
Returns true if there is an alternative site root mapping configured for this site, and it matches the given path.protected void
setAliases(java.util.List<CmsSiteMatcher> aliases)
Sets the aliases for the site.void
setAlternativeSiteRootMapping(java.util.Optional<CmsAlternativeSiteRootMapping> alternativeSiteRootMapping)
Sets the alternative site root mapping.void
setErrorPage(java.lang.String errorPage)
Sets the errorPage.void
setExclusiveError(boolean error)
Sets the exclusive error flag.void
setExclusiveUrl(boolean exclusive)
Sets the exclusive protocol flag.void
sethasOnlineUpdated(boolean isOnline)
Sets the online status.void
setParameters(java.util.SortedMap<java.lang.String,java.lang.String> parameters)
Sets the parameters.protected void
setPosition(float position)
Sets the display title of this site.protected void
setSecureServer(CmsSiteMatcher secureServer)
Sets the secure server.protected void
setSiteMatcher(CmsSiteMatcher siteMatcher)
Sets the site matcher that describes the URL of this site.void
setSiteRoot(java.lang.String siteRoot)
Sets the server URL prefix to which this site is mapped.protected void
setSiteRootUUID(CmsUUID siteRootUUID)
Sets the UUID of this site's root directory in the OpenCms VFS.void
setSSLMode(CmsSSLMode mode)
Sets the SSLMode of the site.void
setSubsiteSelectionEnabled(boolean enabled)
Enables / disables subsite selection for this site.protected void
setTitle(java.lang.String name)
Sets the display title of this site.void
setUsePermanentRedirects(boolean usePermanentRedirects)
Enables use of permanent redirects instead of temporary redirects to the secure site.void
setWebserver(boolean webserver)
Sets the web server.java.lang.String
toString()
boolean
usesPermanentRedirects()
Returns true if permanent redirects should be used for redirecting to the secure URL for this site.
-
-
-
Field Detail
-
PARAM_LOCALIZATION_MODE
public static final java.lang.String PARAM_LOCALIZATION_MODE
The localization mode parameter name.- See Also:
- Constant Field Values
-
PARAM_MAIN_LOCALE
public static final java.lang.String PARAM_MAIN_LOCALE
Parameter name for the main locale.- See Also:
- Constant Field Values
-
PARAM_SECONDARY_LOCALES
public static final java.lang.String PARAM_SECONDARY_LOCALES
Parameter name for the secondary locales.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsSite
public CmsSite(java.lang.String siteRoot, CmsSiteMatcher siteMatcher)
Constructs a new site object without title and id information, this is to be used for lookup purposes only.- Parameters:
siteRoot
- root directory of this site in the OpenCms VFSsiteMatcher
- the site matcher for this site
-
CmsSite
public CmsSite(java.lang.String siteRoot, CmsUUID siteRootUUID, java.lang.String title)
Constructs a new site object with a default (wildcard) a site matcher, this is to be used for display purposes only.- Parameters:
siteRoot
- root directory of this site in the OpenCms VFSsiteRootUUID
- UUID of this site's root directory in the OpenCms VFStitle
- display name of this site
-
CmsSite
public CmsSite(java.lang.String siteRoot, CmsUUID siteRootUUID, java.lang.String title, CmsSiteMatcher siteMatcher, java.lang.String position)
Constructs a new site object.- Parameters:
siteRoot
- root directory of this site in the OpenCms VFSsiteRootUUID
- UUID of this site's root directory in the OpenCms VFStitle
- display name of this sitesiteMatcher
- the site matcher for this siteposition
- the sorting position
-
CmsSite
public CmsSite(java.lang.String siteRoot, CmsUUID siteRootUUID, java.lang.String title, CmsSiteMatcher siteMatcher, java.lang.String position, java.lang.String errorPage, CmsSiteMatcher secureSite, boolean exclusiveUrl, boolean exclusiveError, boolean webserver, java.util.List<CmsSiteMatcher> aliases, boolean subsiteSelection)
Constructs a new site object.- Parameters:
siteRoot
- root directory of this site in the OpenCms VFSsiteRootUUID
- UUID of this site's root directory in the OpenCms VFStitle
- display name of this sitesiteMatcher
- the site matcher for this siteposition
- the sorting positionerrorPage
- the optional error page for this sitesecureSite
- the secure siteexclusiveUrl
- the exclusive flagexclusiveError
- the exclusive error flagwebserver
- indicates whether to write the web server configuration for this site or notaliases
- the aliasessubsiteSelection
- enable/disable subsite selection for this site
-
CmsSite
public CmsSite(java.lang.String siteRoot, java.lang.String siteURL)
Constructs a new site object without title and id information, with a site matcher generated from the provided URL.This is to be used for test purposes only.
- Parameters:
siteRoot
- root directory of this site in the OpenCms VFSsiteURL
- the URL to create the site matcher for this site from
-
-
Method Detail
-
clone
public CmsSite clone()
Returns a clone of this Objects instance.- Overrides:
clone
in classjava.lang.Object
- Returns:
- a clone of this instance
-
compareTo
public int compareTo(CmsSite that)
- Specified by:
compareTo
in interfacejava.lang.Comparable<CmsSite>
- See Also:
Comparable.compareTo(java.lang.Object)
-
createAlternativeSiteRootSite
public CmsSite createAlternativeSiteRootSite()
Creates a generated site for the extension folder configured on this site, or null if no extension folder is set.- Returns:
- the generated site for the extension folder
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
getAliases
public java.util.List<CmsSiteMatcher> getAliases()
Returns the aliases for this site.- Returns:
- a ArrayList with the aliases
-
getAllMatchers
public java.util.List<CmsSiteMatcher> getAllMatchers()
Gets all site matchers which should be used for matching the site.- Returns:
- all site matchers to be used for matching the site
-
getAlternativeSiteRootMapping
public java.util.Optional<CmsAlternativeSiteRootMapping> getAlternativeSiteRootMapping()
Gets the (optional) alternative site root mapping.- Returns:
- the alternative site root mapping
-
getErrorPage
public java.lang.String getErrorPage()
Returns the errorPage.- Returns:
- the errorPage
-
getLocalizationMode
public CmsSite.LocalizationMode getLocalizationMode()
Returns the localization mode.- Returns:
- the localization mode
-
getMainTranslationLocale
public java.util.Locale getMainTranslationLocale(java.util.Locale defaultValue)
Gets the main translation locale for this site.- Parameters:
defaultValue
- the value to return as a default when no main translation locale is set- Returns:
- the main translation locale
-
getParameters
public java.util.SortedMap<java.lang.String,java.lang.String> getParameters()
Returns the parameters.- Returns:
- the parameters
-
getPosition
public float getPosition()
Returns the sorting position.- Returns:
- the sorting position
-
getSecondaryTranslationLocales
public java.util.List<java.util.Locale> getSecondaryTranslationLocales()
Gets the list of secondary translation locales.- Returns:
- the list of secondary translation locales
-
getSecureServer
public CmsSiteMatcher getSecureServer()
Returns the secureServer.- Returns:
- the secureServer
-
getSecureUrl
public java.lang.String getSecureUrl()
Returns the secure server url of this site root.- Returns:
- the secure server url
-
getServerPrefix
public java.lang.String getServerPrefix(CmsObject cms, CmsResource resource)
Returns the server prefix for the given resource in this site, used to distinguish between secure (https) and non-secure (http) sites.This is required since a resource may have an individual "secure" setting using the property
CmsPropertyDefinition.PROPERTY_SECURE
, which means this resource must be delivered only using a secure protocol.The result will look like
http://site.enterprise.com:8080/
orhttps://site.enterprise.com/
.- Parameters:
cms
- the current users OpenCms contextresource
- the resource to use- Returns:
- the server prefix for the given resource in this site
- See Also:
getServerPrefix(CmsObject, String)
-
getServerPrefix
public java.lang.String getServerPrefix(CmsObject cms, java.lang.String resourceName)
Returns the server prefix for the given resource in this site, used to distinguish between secure (https) and non-secure (http) sites.This is required since a resource may have an individual "secure" setting using the property
CmsPropertyDefinition.PROPERTY_SECURE
, which means this resource must be delivered only using a secure protocol.The result will look like
http://site.enterprise.com:8080/
orhttps://site.enterprise.com/
.- Parameters:
cms
- the current users OpenCms contextresourceName
- the resource name- Returns:
- the server prefix for the given resource in this site
- See Also:
getSecureUrl()
,getUrl()
-
getSiteMatcher
public CmsSiteMatcher getSiteMatcher()
Returns the site matcher that describes the URL of this site.- Returns:
- the site matcher that describes the URL of this site
-
getSitePath
public java.lang.String getSitePath(java.lang.String rootPath)
Returns the site path for the given root path in case the root path actually starts with this site root, ornull
in case the root path does not.- Parameters:
rootPath
- the root path to get the site path for- Returns:
- the site path for the given root path in case the root path
actually starts with this site root, or
null
in case the root path does not
-
getSiteRoot
public java.lang.String getSiteRoot()
Returns the path of this site's root directory in the OpenCms VFS without tailing slash.e.g. /sites/default
- Returns:
- the path of this site's root directory in the OpenCms VFS without tailing slash
-
getSiteRootUUID
public CmsUUID getSiteRootUUID()
Returns the UUID of this site's root directory in the OpenCms VFS.- Returns:
- the UUID of this site's root directory in the OpenCms VFS
-
getSSLMode
public CmsSSLMode getSSLMode()
Gets the SSLMode of the site.- Returns:
- CmsSSLMode
-
getTitle
public java.lang.String getTitle()
Returns the display title of this site.- Returns:
- the display title of this site
-
getTranslationLocales
public java.util.List<java.util.Locale> getTranslationLocales()
Returns all configured translation locales for this site.The first entry in the list will be the main translation locale. If the main translation locale is not correctly configured, an empty list is returned.
- Returns:
- all configured translation locales for this site
-
getUrl
public java.lang.String getUrl()
Returns the server url of this site root.- Returns:
- the server url
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
hasSecureServer
public boolean hasSecureServer()
Returns true, if the site has a secure server.- Returns:
- true, if the site has a secure server
-
isExclusiveError
public boolean isExclusiveError()
Returns the exclusive error flag.- Returns:
true
will generate a 404 error, orfalse
will redirect to secure url.
-
isExclusiveUrl
public boolean isExclusiveUrl()
Returns the exclusive protocol flag.- Returns:
true
secure resources will only be available using the configured secure url, orfalse
if the uri (protocol + servername) does not really matter.
-
isGenerated
public boolean isGenerated()
Returns true if this is an automatically generated site (and thus should not be used in the site management UI).- Returns:
- true if this is a generated site
-
isOnlineUpdated
public boolean isOnlineUpdated()
Checks if the site it in the online project.- Returns:
- true if it is in online project
-
isSharedSite
public boolean isSharedSite()
Returns a flag indicating if the site is the shared site.- Returns:
true
if the site is the shared site, orfalse
if it is not the shared site.
-
isSubsiteSelectionEnabled
public boolean isSubsiteSelectionEnabled()
Returns true if subsite selection is enabled for this site.- Returns:
- true if subsite selection is enabled for this site
-
isWebserver
public boolean isWebserver()
Returns the web server.- Returns:
- the web server
-
matchAlternativeSiteRoot
public boolean matchAlternativeSiteRoot(java.lang.String path)
Returns true if there is an alternative site root mapping configured for this site, and it matches the given path.- Parameters:
path
- the path from the request- Returns:
- true if the alternative site root mapping matches the path
-
setAlternativeSiteRootMapping
public void setAlternativeSiteRootMapping(java.util.Optional<CmsAlternativeSiteRootMapping> alternativeSiteRootMapping)
Sets the alternative site root mapping.- Parameters:
alternativeSiteRootMapping
- the alternative site root mapping
-
setErrorPage
public void setErrorPage(java.lang.String errorPage)
Sets the errorPage.- Parameters:
errorPage
- the errorPage to set
-
setExclusiveError
public void setExclusiveError(boolean error)
Sets the exclusive error flag.- Parameters:
error
- the exclusive error flag
-
setExclusiveUrl
public void setExclusiveUrl(boolean exclusive)
Sets the exclusive protocol flag.- Parameters:
exclusive
- the exclusive protocol flag
-
sethasOnlineUpdated
public void sethasOnlineUpdated(boolean isOnline)
Sets the online status.- Parameters:
isOnline
- true -> site has online version
-
setParameters
public void setParameters(java.util.SortedMap<java.lang.String,java.lang.String> parameters)
Sets the parameters.- Parameters:
parameters
- the parameters to set
-
setSiteRoot
public void setSiteRoot(java.lang.String siteRoot)
Sets the server URL prefix to which this site is mapped.- Parameters:
siteRoot
- the server URL prefix to which this site is mapped
-
setSSLMode
public void setSSLMode(CmsSSLMode mode)
Sets the SSLMode of the site.- Parameters:
mode
- the CmsSSLMode
-
setSubsiteSelectionEnabled
public void setSubsiteSelectionEnabled(boolean enabled)
Enables / disables subsite selection for this site.- Parameters:
enabled
- true if subsite selection should be enabled
-
setUsePermanentRedirects
public void setUsePermanentRedirects(boolean usePermanentRedirects)
Enables use of permanent redirects instead of temporary redirects to the secure site.- Parameters:
usePermanentRedirects
- true if permanent redirects should be used
-
setWebserver
public void setWebserver(boolean webserver)
Sets the web server.- Parameters:
webserver
- the web server to set
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
usesPermanentRedirects
public boolean usesPermanentRedirects()
Returns true if permanent redirects should be used for redirecting to the secure URL for this site.- Returns:
- true if permanent redirects should be used
-
addAlias
protected void addAlias(CmsSiteMatcher aliasServer)
Adds an alias for the site.- Parameters:
aliasServer
- the sitematcher for the alias
-
getSecureServerMatcher
protected CmsSiteMatcher getSecureServerMatcher()
Returns the site matcher for the secure site, or null if no secure site is defined.- Returns:
- the site matcher for the secure site
-
setAliases
protected void setAliases(java.util.List<CmsSiteMatcher> aliases)
Sets the aliases for the site.- Parameters:
aliases
- the aliases for the site
-
setPosition
protected void setPosition(float position)
Sets the display title of this site.- Parameters:
position
- the display title of this site
-
setSecureServer
protected void setSecureServer(CmsSiteMatcher secureServer)
Sets the secure server.- Parameters:
secureServer
- the sitematcher of the secure server
-
setSiteMatcher
protected void setSiteMatcher(CmsSiteMatcher siteMatcher)
Sets the site matcher that describes the URL of this site.- Parameters:
siteMatcher
- the site matcher that describes the URL of this site
-
setSiteRootUUID
protected void setSiteRootUUID(CmsUUID siteRootUUID)
Sets the UUID of this site's root directory in the OpenCms VFS.- Parameters:
siteRootUUID
- the UUID of this site's root directory in the OpenCms VFS
-
setTitle
protected void setTitle(java.lang.String name)
Sets the display title of this site.- Parameters:
name
- the display title of this site
-
-