Class CmsSite

java.lang.Object
org.opencms.site.CmsSite
All Implemented Interfaces:
Serializable, Cloneable, Comparable<CmsSite>

public final class CmsSite extends Object implements Cloneable, Comparable<CmsSite>, Serializable
Describes a configured site in OpenCms.

Since:
6.0.0
See Also:
  • Field Details

  • Constructor Details

    • CmsSite

      public CmsSite(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 VFS
      siteMatcher - the site matcher for this site
    • CmsSite

      public CmsSite(String siteRoot, CmsUUID siteRootUUID, 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 VFS
      siteRootUUID - UUID of this site's root directory in the OpenCms VFS
      title - display name of this site
    • CmsSite

      public CmsSite(String siteRoot, CmsUUID siteRootUUID, String title, CmsSiteMatcher siteMatcher, String position)
      Constructs a new site object.

      Parameters:
      siteRoot - root directory of this site in the OpenCms VFS
      siteRootUUID - UUID of this site's root directory in the OpenCms VFS
      title - display name of this site
      siteMatcher - the site matcher for this site
      position - the sorting position
    • CmsSite

      public CmsSite(String siteRoot, CmsUUID siteRootUUID, String title, CmsSiteMatcher siteMatcher, String position, String errorPage, CmsSiteMatcher secureSite, boolean exclusiveUrl, boolean exclusiveError, boolean webserver, List<CmsSiteMatcher> aliases, boolean subsiteSelection)
      Constructs a new site object.

      Parameters:
      siteRoot - root directory of this site in the OpenCms VFS
      siteRootUUID - UUID of this site's root directory in the OpenCms VFS
      title - display name of this site
      siteMatcher - the site matcher for this site
      position - the sorting position
      errorPage - the optional error page for this site
      secureSite - the secure site
      exclusiveUrl - the exclusive flag
      exclusiveError - the exclusive error flag
      webserver - indicates whether to write the web server configuration for this site or not
      aliases - the aliases
      subsiteSelection - enable/disable subsite selection for this site
    • CmsSite

      public CmsSite(String siteRoot, 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 VFS
      siteURL - the URL to create the site matcher for this site from
  • Method Details

    • clone

      public CmsSite clone()
      Returns a clone of this Objects instance.

      Overrides:
      clone in class Object
      Returns:
      a clone of this instance
    • compareTo

      public int compareTo(CmsSite that)
      Specified by:
      compareTo in interface Comparable<CmsSite>
      See Also:
    • 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(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • getAliases

      Returns the aliases for this site.

      Returns:
      a ArrayList with the aliases
    • 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

      Gets the (optional) alternative site root mapping.
      Returns:
      the alternative site root mapping
    • getErrorPage

      public String getErrorPage()
      Returns the errorPage.

      Returns:
      the errorPage
    • getLocalizationMode

      Returns the localization mode.

      Returns:
      the localization mode
    • getMainTranslationLocale

      public Locale getMainTranslationLocale(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

      Returns the parameters.

      Returns:
      the parameters
    • getPosition

      public float getPosition()
      Returns the sorting position.

      Returns:
      the sorting position
    • getSecondaryTranslationLocales

      Gets the list of secondary translation locales.

      Returns:
      the list of secondary translation locales
    • getSecureServer

      Returns the secureServer.

      Returns:
      the secureServer
    • getSecureUrl

      public String getSecureUrl()
      Returns the secure server url of this site root.

      Returns:
      the secure server url
    • getServerPrefix

      public 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/ or https://site.enterprise.com/.

      Parameters:
      cms - the current users OpenCms context
      resource - the resource to use
      Returns:
      the server prefix for the given resource in this site
      See Also:
    • getServerPrefix

      public String getServerPrefix(CmsObject cms, 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/ or https://site.enterprise.com/.

      Parameters:
      cms - the current users OpenCms context
      resourceName - the resource name
      Returns:
      the server prefix for the given resource in this site
      See Also:
    • 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 String getSitePath(String rootPath)
      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.

      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 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

      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

      Gets the SSLMode of the site.

      Returns:
      CmsSSLMode
    • getTitle

      public String getTitle()
      Returns the display title of this site.

      Returns:
      the display title of this site
    • 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 String getUrl()
      Returns the server url of this site root.

      Returns:
      the server url
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • 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, or false 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, or false 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, or false 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(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(Optional<CmsAlternativeSiteRootMapping> alternativeSiteRootMapping)
      Sets the alternative site root mapping.
      Parameters:
      alternativeSiteRootMapping - the alternative site root mapping
    • setErrorPage

      public void setErrorPage(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(SortedMap<String,String> parameters)
      Sets the parameters.

      Parameters:
      parameters - the parameters to set
    • setSiteRoot

      public void setSiteRoot(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 String toString()
      Overrides:
      toString in class Object
      See Also:
    • 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

      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(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(String name)
      Sets the display title of this site.

      Parameters:
      name - the display title of this site