org.opencms.site
Class CmsSite

java.lang.Object
  extended by org.opencms.site.CmsSite
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public final class CmsSite
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable

Describes a configured site in OpenCms.

Since:
6.0.0
Version:
$Revision: 1.35 $
Author:
Alexander Kandzior, Jan Baudisch

Constructor Summary
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.
 
Method Summary
protected  void addAlias(CmsSiteMatcher aliasServer)
          Adds an alias for the site.
 java.lang.Object clone()
          Returns a clone of this Objects instance.
 int compareTo(java.lang.Object that)
           
 boolean equals(java.lang.Object obj)
           
 java.util.List getAliases()
          Returns the aliases for this site.
 float getPosition()
          Returns the sorting position.
 java.lang.String getSecureUrl()
          Returns the secure server url of this site root.
 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.
 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.
 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, or null in case the root path does not.
 java.lang.String getSiteRoot()
          Returns the server URL prefix to which this site is mapped.
 CmsUUID getSiteRootUUID()
          Returns the UUID of this site's root directory in the OpenCms VFS.
 java.lang.String getTitle()
          Returns the root directory of this site in the OpenCms VFS.
 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.
protected  void setAliases(java.util.List aliases)
          Sets the aliases for the site.
 void setExclusiveError(boolean error)
          Sets the exclusive error flag.
 void setExclusiveUrl(boolean exclusive)
          Sets the exclusive protocol flag.
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.
protected  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.
protected  void setTitle(java.lang.String name)
          Sets the display title of this site in the OpenCms VFS.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

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

clone

public java.lang.Object 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(java.lang.Object that)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(java.lang.Object)

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 getAliases()
Returns the aliases for this site.

Returns:
a ArrayList with the aliases

getPosition

public float getPosition()
Returns the sorting position.

Returns:
the sorting position

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:
getSecureUrl(), getUrl()

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 server URL prefix to which this site is mapped.

Returns:
the server URL prefix to which this site is mapped

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 root directory of this site in the OpenCms VFS.

Returns:
the root directory of this site in the OpenCms VFS

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.

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

addAlias

protected void addAlias(CmsSiteMatcher aliasServer)
Adds an alias for the site.

Parameters:
aliasServer - the sitematcher for the alias

setAliases

protected void setAliases(java.util.List aliases)
Sets the aliases for the site.

Parameters:
aliases - the aliases for the 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

setSiteRoot

protected 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

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 in the OpenCms VFS.

Parameters:
name - the display title of this site in the OpenCms VFS