Class 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.
    • 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.
    • 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 VFS
        siteMatcher - 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 VFS
        siteRootUUID - UUID of this site's root directory in the OpenCms VFS
        title - 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 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​(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 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​(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 VFS
        siteURL - 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 class java.lang.Object
        Returns:
        a clone of this instance
      • compareTo

        public int compareTo​(CmsSite that)
        Specified by:
        compareTo in interface java.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 class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)
      • getAliases

        public java.util.List<CmsSiteMatchergetAliases()
        Returns the aliases for this site.

        Returns:
        a ArrayList with the aliases
      • getAllMatchers

        public java.util.List<CmsSiteMatchergetAllMatchers()
        Gets all site matchers which should be used for matching the site.

        Returns:
        all site matchers to be used for matching the site
      • getErrorPage

        public java.lang.String getErrorPage()
        Returns the errorPage.

        Returns:
        the errorPage
      • 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
      • 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/ 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(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/ 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:
        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, 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 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
      • 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 class java.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, 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​(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
      • 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 class java.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