org.hippoecm.hst.configuration.hosting
Class VirtualHostsService

java.lang.Object
  extended by org.hippoecm.hst.configuration.hosting.VirtualHostsService
All Implemented Interfaces:
MutableVirtualHosts, VirtualHosts

public class VirtualHostsService
extends Object
implements MutableVirtualHosts


Field Summary
static String DEFAULT_SCHEME
           
 
Constructor Summary
VirtualHostsService(HstNode virtualHostsConfigurationNode, HstManagerImpl hstManager)
           
 
Method Summary
 void addMount(Mount mount)
          Add this mount for lookup through getMountByGroupAliasAndType(String, String, String)
 void addVirtualHost(MutableVirtualHost virtualHost)
          Adds the virtualHost as child to this MutableVirtualHosts
protected  ResolvedVirtualHost findMatchingVirtualHost(String hostName, int portNumber)
          Override this method if you want a different algorithm to resolve hostName
 String getChannelManagerHostGroupName()
          Returns the virtual host group node name in use for the current environment.
 String getChannelManagerSitesName()
           
 String getCmsPreviewPrefix()
          The cmsPreviewPrefix will never start or end with a slash and will never be null
 String getDefaultContextPath()
          For external calls like the CMS REST api, an external app needs to know what context path to use.
 String getDefaultHostName()
           
 String getHomePage()
           
 List<String> getHostGroupNames()
           
 HstManager getHstManager()
           
 String getLocale()
           
 Mount getMountByGroupAliasAndType(String hostGroupName, String alias, String type)
          Returns the Mount for this hostGroupName, alias and type having Mount.getType() equal to type.
 Mount getMountByIdentifier(String uuid)
           
 List<Mount> getMountsByHostGroup(String hostGroupName)
           
 String getPageNotFound()
           
 Map<String,Map<String,MutableVirtualHost>> getRootVirtualHostsByGroup()
          The root virtualhosts are the first segment of a host.
 String getScheme()
           
 boolean isContextPathInUrl()
          This is the global setting for every VirtualHost / Mount whether contextPath should be in the URL or not
 boolean isExcluded(String pathInfo)
          Typically, some paths we do not want to be handle by the hst framework request processing.
 boolean isPortInUrl()
          This is the global setting for every VirtualHost / Mount whether the port number should be in the URL or not
 boolean isVersionInPreviewHeader()
           
 ResolvedMount matchMount(String hostName, String contextPath, String requestPath)
          This method tries to match a hostName, contextPath and requestPath to a flyweight ResolvedMount.
 ResolvedSiteMapItem matchSiteMapItem(HstContainerURL hstContainerURL)
          This method tries to match a hstContainerURL to a flyweight ResolvedSiteMapItem.
 ResolvedVirtualHost matchVirtualHost(String hostName)
           This method tries to match a request to a flyweight ResolvedVirtualHost
protected  VirtualHost traverseInToHost(VirtualHost matchedHost, String[] hostNameSegments, int depth)
          Override this method if you want a different algorithm to resolve requestServerName
static HashMap<String,MutableVirtualHost> virtualHostHashMap()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SCHEME

public static final String DEFAULT_SCHEME
See Also:
Constant Field Values
Constructor Detail

VirtualHostsService

public VirtualHostsService(HstNode virtualHostsConfigurationNode,
                           HstManagerImpl hstManager)
                    throws ServiceException
Throws:
ServiceException
Method Detail

getHstManager

public HstManager getHstManager()
Specified by:
getHstManager in interface VirtualHosts
Returns:
the HstManager for this VirtualHosts object

isExcluded

public boolean isExcluded(String pathInfo)
Description copied from interface: VirtualHosts
Typically, some paths we do not want to be handle by the hst framework request processing. Typically, this would be for example paths starting with /binaries/, or paths ending with some extension, like .pdf When a path must be excluded, this method return true.

Specified by:
isExcluded in interface VirtualHosts
Returns:
true when the path must be excluded for matching to a host.

addVirtualHost

public void addVirtualHost(MutableVirtualHost virtualHost)
                    throws IllegalArgumentException
Description copied from interface: MutableVirtualHosts
Adds the virtualHost as child to this MutableVirtualHosts

Specified by:
addVirtualHost in interface MutableVirtualHosts
Parameters:
virtualHost - the MutableVirtualHost to add
Throws:
IllegalArgumentException - if the virtualHost could not be added

getRootVirtualHostsByGroup

public Map<String,Map<String,MutableVirtualHost>> getRootVirtualHostsByGroup()
Description copied from interface: MutableVirtualHosts
The root virtualhosts are the first segment of a host. For example just 'com', or just 'org'. In case of an IP adres, for for example the hostName 127.0.0.1, the root virtualhost will be '1'

Specified by:
getRootVirtualHostsByGroup in interface MutableVirtualHosts
Returns:
all the root virtualhosts by hostgroup

addMount

public void addMount(Mount mount)
              throws ServiceException
Add this mount for lookup through getMountByGroupAliasAndType(String, String, String)

Specified by:
addMount in interface MutableVirtualHosts
Parameters:
mount -
Throws:
ServiceException

matchSiteMapItem

public ResolvedSiteMapItem matchSiteMapItem(HstContainerURL hstContainerURL)
                                     throws MatchException
Description copied from interface: VirtualHosts

This method tries to match a hstContainerURL to a flyweight ResolvedSiteMapItem. It does so, by first trying to match the correct ResolvedVirtualHost. If it does find a ResolvedVirtualHost, the match is delegated to ResolvedVirtualHost#matchSiteMount(HstContainerURL), which returns the ResolvedMount. This object delegates to ResolvedMount.matchSiteMapItem(String) which in the end returns the ResolvedSiteMapItem. If somewhere in the chain a match cannot be made a MatchException exception is thrown

Specified by:
matchSiteMapItem in interface VirtualHosts
Returns:
the resolvedSiteMapItem for this request
Throws:
MatchException - when the matching cannot be done, for example because no valid virtual hosts are configured or when the request path does not match a sitemap item

matchMount

public ResolvedMount matchMount(String hostName,
                                String contextPath,
                                String requestPath)
                         throws MatchException
Description copied from interface: VirtualHosts

This method tries to match a hostName, contextPath and requestPath to a flyweight ResolvedMount. It does so, by first trying to match the correct ResolvedVirtualHost. If it does find a ResolvedVirtualHost, the match is delegated to ResolvedVirtualHost.matchMount(String, String), which returns the ResolvedMount. If somewhere in the chain a match cannot be made, null will be returned. The contextPath will only be of influence in the matching when the SiteMount has a non-empty value for Mount.onlyForContextPath(). If Mount.onlyForContextPath() is null or empty, the contextPath is ignored for matching.

Specified by:
matchMount in interface VirtualHosts
Returns:
the ResolvedMount for this hstContainerUrl or null when it can not be matched to a Mount
Throws:
MatchException

matchVirtualHost

public ResolvedVirtualHost matchVirtualHost(String hostName)
                                     throws MatchException
Description copied from interface: VirtualHosts

This method tries to match a request to a flyweight ResolvedVirtualHost

Specified by:
matchVirtualHost in interface VirtualHosts
Returns:
the resolvedVirtualHost for this hostName or null when it can not be matched to a virtualHost
Throws:
MatchException

findMatchingVirtualHost

protected ResolvedVirtualHost findMatchingVirtualHost(String hostName,
                                                      int portNumber)
Override this method if you want a different algorithm to resolve hostName

Parameters:
hostName -
portNumber -
Returns:
the matched virtual host or null when no host can be matched

traverseInToHost

protected VirtualHost traverseInToHost(VirtualHost matchedHost,
                                       String[] hostNameSegments,
                                       int depth)
Override this method if you want a different algorithm to resolve requestServerName

Parameters:
matchedHost -
hostNameSegments -
depth -
Returns:

isContextPathInUrl

public boolean isContextPathInUrl()
Description copied from interface: VirtualHosts
This is the global setting for every VirtualHost / Mount whether contextPath should be in the URL or not

Specified by:
isContextPathInUrl in interface VirtualHosts
Returns:
true when the created url should have the contextPath in it

getDefaultContextPath

public String getDefaultContextPath()
Description copied from interface: VirtualHosts
For external calls like the CMS REST api, an external app needs to know what context path to use. Through this getter, the default context path can be retrieved. If not configured, null is returned and the external app must know the context path. If configured, the contextPath is either an empty string, or it has to start with a "/" and is not allowed to have any other "/".

Specified by:
getDefaultContextPath in interface VirtualHosts
Returns:
the default context path for the webapps or null when not configured

isPortInUrl

public boolean isPortInUrl()
Description copied from interface: VirtualHosts
This is the global setting for every VirtualHost / Mount whether the port number should be in the URL or not

Specified by:
isPortInUrl in interface VirtualHosts
Returns:
true when the created url should have the port number in it

getScheme

public String getScheme()

getLocale

public String getLocale()
Specified by:
getLocale in interface VirtualHosts
Returns:
the locale of this VirtualHosts object or null if no locale is configured

getDefaultHostName

public String getDefaultHostName()
Specified by:
getDefaultHostName in interface VirtualHosts
Returns:
the hostname that is configured as default, or null if none is configured as default.

getHomePage

public String getHomePage()

getPageNotFound

public String getPageNotFound()

isVersionInPreviewHeader

public boolean isVersionInPreviewHeader()

getMountByGroupAliasAndType

public Mount getMountByGroupAliasAndType(String hostGroupName,
                                         String alias,
                                         String type)
Description copied from interface: VirtualHosts
Returns the Mount for this hostGroupName, alias and type having Mount.getType() equal to type. Returns null when no match

Specified by:
getMountByGroupAliasAndType in interface VirtualHosts
alias - the alias the mount must have
type - the type (for example preview, live, composer) the siteMount must have.
Returns:
the Mount for this hostGroupName, alias and type having Mount.getType() equal to type. Returns null when no match

getMountsByHostGroup

public List<Mount> getMountsByHostGroup(String hostGroupName)
Specified by:
getMountsByHostGroup in interface VirtualHosts
Returns:
the List<Mount> belonging to hostGroupName or null when there are no Mount for hostGroupName

getHostGroupNames

public List<String> getHostGroupNames()
Specified by:
getHostGroupNames in interface VirtualHosts
Returns:
return the list of all hostGroupNames

virtualHostHashMap

public static final HashMap<String,MutableVirtualHost> virtualHostHashMap()
Returns:
a HashMap that throws an exception when you put in the same key twice

getMountByIdentifier

public Mount getMountByIdentifier(String uuid)
Specified by:
getMountByIdentifier in interface VirtualHosts
Returns:

getCmsPreviewPrefix

public String getCmsPreviewPrefix()
Description copied from interface: VirtualHosts
The cmsPreviewPrefix will never start or end with a slash and will never be null

Specified by:
getCmsPreviewPrefix in interface VirtualHosts
Returns:
the configured cmsPreviewPrefix with leading and trailing slashes removed. It will never be null. If configured to be empty, it will be ""

getChannelManagerHostGroupName

public String getChannelManagerHostGroupName()
Description copied from interface: VirtualHosts
Returns the virtual host group node name in use for the current environment. The ChannelManager will only be able to create links for channels that are reflected in the hostGroup

Specified by:
getChannelManagerHostGroupName in interface VirtualHosts
Returns:
the virtual host group node name used for this VirtualHosts. If not configured it returns null

getChannelManagerSitesName

public String getChannelManagerSitesName()
Specified by:
getChannelManagerSitesName in interface VirtualHosts
Returns:
the node name of the hst:sites that will be managed by the ChannelManager. If not configured it returns hst:sites


Copyright © 2008-2012 Hippo. All Rights Reserved.