org.wso2.carbon.url.mapper.internal.util
Class HostUtil

java.lang.Object
  extended by org.wso2.carbon.url.mapper.internal.util.HostUtil

public class HostUtil
extends Object

util class which is doing add host to engine and getting resources from the registry.


Constructor Summary
HostUtil()
           
 
Method Summary
static void addDomainToServiceEpr(String hostName, String url, String appType)
          adding domain for service in registry
static org.apache.catalina.Host addHostToEngine(String hostName)
          add host to engine.
static void addServiceMapping(String epr)
          add the service mapping when an actual service got deleted.
static void addServiceParameter(String url)
           
static void addServiceUrlMapping(int tenantId, String serviceName)
           
static void addWebAppToHost(String hostName, String uri, String appType)
          It is taken the webApp which is already deployed in /repository/../webapps and redeploy it within added virtual host.
static void deleteHostDirectory(String hostName)
          edit the host from CATALINA-HOME directory
static void deleteResourceToRegistry(String host)
          deleting resource in registry when deleting host
static void deleteServiceMapping(String epr)
          edit the service mapping when an actual service got deleted.
static void editHostInEngine(String webAppName, String newHost, String oldHost)
          delete the existing host with the given name
static MappingData[] getAllMappingsFromRegistry()
           
static String getApplicationContextForHost(String hostName)
          retrieving host for a specific service
static String getContextFromUri(String uri)
          getting context of the webapp from the uri
static String getHttpPort()
           
static List<String> getMappingsPerEppr(String url)
          This method is used to retrieve list of host names for a given webapplication.
static List<String> getMappingsPerWebApp(String webAppName)
          This method is used to retrieve list of host names for a given webapplication.
static String getServiceEndpoint(String url)
          getting service endpoint from url
static String getServiceName(String serviceContext)
           
static String getServiceNameForHost(String hostName)
          retrieving host for a specific service
static String getTenantDomainFromTID(int tenantId)
           
static MappingData[] getTenantSpecificMappingsFromRegistry(String tenantName)
           
static String getUrlSuffix()
           
static String getWebappPath(String webappsDir, String uri, String appType)
           
static boolean isMappingExist(String mappingName)
          Find out whether the hostname exists already
static boolean isMappingLimitExceeded(String webAppName)
          This method is used to check if the maximum no of mappings are exceeded webapplication.
static boolean isServiceURLPattern(String url)
          checking for the pattern of the url for service
static void removeHost(String hostName)
          remove the host from the engine and registry
static void removeHostForCluster(String hostName)
           
static void removeServiceMapping(String epr)
          remove the service mapping when an actual service got deleted.
static void removeUrlMappingFromMap(int tenantId, String serviceName)
           
static void setUrlSuffix(String urlSuffix)
           
static void updateEprToRegistry(String newHost, String oldHost)
          update endpoint in the registry for host
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HostUtil

public HostUtil()
Method Detail

getMappingsPerWebApp

public static List<String> getMappingsPerWebApp(String webAppName)
                                         throws UrlMapperException
This method is used to retrieve list of host names for a given webapplication.

Parameters:
webAppName - the webapp name
Returns:
list of mapped hosts.
Throws:
UrlMapperException - throws it when failing to get resource from registry

isMappingLimitExceeded

public static boolean isMappingLimitExceeded(String webAppName)
                                      throws UrlMapperException
This method is used to check if the maximum no of mappings are exceeded webapplication.

Parameters:
webAppName - the webapp name
Returns:
list of mapped hosts.
Throws:
UrlMapperException - throws it when failing to get resource from registry

isMappingExist

public static boolean isMappingExist(String mappingName)
                              throws UrlMapperException
Find out whether the hostname exists already

Parameters:
mappingName - the host name to be mapped
Returns:
Whether the hostname is valid or not
Throws:
UrlMapperException - throws when error while retrieve from registry

getAllMappingsFromRegistry

public static MappingData[] getAllMappingsFromRegistry()
                                                throws UrlMapperException
Throws:
UrlMapperException

getTenantSpecificMappingsFromRegistry

public static MappingData[] getTenantSpecificMappingsFromRegistry(String tenantName)
                                                           throws UrlMapperException
Throws:
UrlMapperException

getMappingsPerEppr

public static List<String> getMappingsPerEppr(String url)
                                       throws UrlMapperException
This method is used to retrieve list of host names for a given webapplication.

Parameters:
url -
Returns:
list of mapped hosts.
Throws:
UrlMapperException

getServiceNameForHost

public static String getServiceNameForHost(String hostName)
                                    throws UrlMapperException
retrieving host for a specific service

Parameters:
hostName - name of the host
Returns:
Throws:
UrlMapperException

getApplicationContextForHost

public static String getApplicationContextForHost(String hostName)
                                           throws UrlMapperException
retrieving host for a specific service

Parameters:
hostName - name of the host
Returns:
Throws:
UrlMapperException

getHttpPort

public static String getHttpPort()
                          throws UrlMapperException
Throws:
UrlMapperException

addWebAppToHost

public static void addWebAppToHost(String hostName,
                                   String uri,
                                   String appType)
                            throws UrlMapperException
It is taken the webApp which is already deployed in /repository/../webapps and redeploy it within added virtual host.

Parameters:
hostName - The virtual host name
uri - The web app to be deployed in the virtual host
Throws:
UrlMapperException - When adding directory throws an Exception

getWebappPath

public static String getWebappPath(String webappsDir,
                                   String uri,
                                   String appType)

addHostToEngine

public static org.apache.catalina.Host addHostToEngine(String hostName)
add host to engine.

Parameters:
hostName - name of the host
Returns:
will return the added host of Engine

deleteHostDirectory

public static void deleteHostDirectory(String hostName)
edit the host from CATALINA-HOME directory

Parameters:
hostName -

editHostInEngine

public static void editHostInEngine(String webAppName,
                                    String newHost,
                                    String oldHost)
                             throws UrlMapperException
delete the existing host with the given name

Parameters:
webAppName - the associated webapp name of the host to be edited
oldHost - the existing hostname to be edited
newHost - the hostname given
Throws:
UrlMapperException - throws when error while removing oldHost or adding newHost

removeHost

public static void removeHost(String hostName)
                       throws UrlMapperException
remove the host from the engine and registry

Parameters:
hostName - name of the host to be removed
Throws:
UrlMapperException - throws when error while removing context or host from engine and from registry

removeHostForCluster

public static void removeHostForCluster(String hostName)
                                 throws UrlMapperException
Throws:
UrlMapperException

deleteServiceMapping

public static void deleteServiceMapping(String epr)
edit the service mapping when an actual service got deleted.

Parameters:
epr - service endpoint of a service

removeServiceMapping

public static void removeServiceMapping(String epr)
remove the service mapping when an actual service got deleted.

Parameters:
epr - service endpoint of a service

addServiceMapping

public static void addServiceMapping(String epr)
add the service mapping when an actual service got deleted.

Parameters:
epr - seice endpoint of a service

addDomainToServiceEpr

public static void addDomainToServiceEpr(String hostName,
                                         String url,
                                         String appType)
                                  throws UrlMapperException
adding domain for service in registry

Parameters:
hostName -
url -
Throws:
UrlMapperException

addServiceParameter

public static void addServiceParameter(String url)

updateEprToRegistry

public static void updateEprToRegistry(String newHost,
                                       String oldHost)
                                throws UrlMapperException
update endpoint in the registry for host

Parameters:
newHost - new host to be updated
oldHost - existing old host
Throws:
UrlMapperException

deleteResourceToRegistry

public static void deleteResourceToRegistry(String host)
                                     throws UrlMapperException
deleting resource in registry when deleting host

Parameters:
host - hostName
Throws:
UrlMapperException

getContextFromUri

public static String getContextFromUri(String uri)
getting context of the webapp from the uri

Parameters:
uri - uri of the actual webapp url
Returns:
returns the context

getServiceEndpoint

public static String getServiceEndpoint(String url)
                                 throws UrlMapperException
getting service endpoint from url

Parameters:
url - url of the service
Returns:
Throws:
UrlMapperException

isServiceURLPattern

public static boolean isServiceURLPattern(String url)
checking for the pattern of the url for service

Parameters:
url - url of the service invoked
Returns:
boolean

getServiceName

public static String getServiceName(String serviceContext)

addServiceUrlMapping

public static void addServiceUrlMapping(int tenantId,
                                        String serviceName)

removeUrlMappingFromMap

public static void removeUrlMappingFromMap(int tenantId,
                                           String serviceName)

getTenantDomainFromTID

public static String getTenantDomainFromTID(int tenantId)

getUrlSuffix

public static String getUrlSuffix()

setUrlSuffix

public static void setUrlSuffix(String urlSuffix)


Copyright © 2015 WSO2. All rights reserved.