org.wso2.carbon.webapp.mgt.utils

## Class WebAppUtils

- java.lang.Object
- - org.wso2.carbon.webapp.mgt.utils.WebAppUtils

-     public class WebAppUtils
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static List<String>` | `appBases`
    `static List<String>` | `vhostNames`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebAppUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `checkJaxApplication(WebApplication webApplication)` This util method is used to check if the given application is a Jax-RS/WS app
    `static String` | `generateMetaFileDirName(String webappFilePath, org.apache.axis2.context.ConfigurationContext configurationContext)`
    `static Map<String,WebApplicationsHolder>` | `getAllWebappHolders(org.apache.axis2.context.ConfigurationContext configurationContext)`
    `static String` | `getAppbase(String hostName)` This util method will return appbase value of matching host name from catalina-server.xml
    `static List<String>` | `getAppBases()`
    `static String` | `getDefaultHost()`
    `static WebApplicationsHolder` | `getDefaultWebappHolder(org.apache.axis2.context.ConfigurationContext configurationContext)`
    `static org.apache.catalina.Host` | `getHost(String webappFilePath)`
    `static String` | `getMatchingHostName(String filePath)`
    `static org.apache.catalina.Host` | `getMatchingVirtualHost(String baseDir)`
    `static String` | `getServerConfigHostName()` This will read "HostName" value from carbon.xml and will return default host (from catalina-server.xml) if the value is null (or not defined)
    `static List<String>` | `getVhostNames()`
    `static String` | `getWebappDir(String webappFilePath)` This util method is used to return base dir name of webapp.
    `static String` | `getWebappDirPath(String webappFilePath)` This util method is used to return file path of base dir.
    `static WebApplicationsHolder` | `getWebappHolder(String webappFilePath, org.apache.axis2.context.ConfigurationContext configurationContext)` This util method will return the web application holder of the given web app file
    `static String` | `getWebappKey(File webappFile)` This will return a key with pair hostname:webappFileName
    `static String` | `getWebappName(String webappFilePath)`
    `static String` | `getWebappResourcePath(WebApplication webApplication)` Returns the registry path for the webapp
    `static boolean` | `isWebappUploadedToVirtualAppBase(String webAppBaseDir, String appBase)`
    `static boolean` | `validateWebappFileName(String filename)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### vhostNames

          public static List<String> vhostNames

    - #### appBases

          public static List<String> appBases

  - ### Constructor Detail

    - #### WebAppUtils

          public WebAppUtils()

  - ### Method Detail

    - #### checkJaxApplication

          public static String checkJaxApplication(WebApplication webApplication)

      This util method is used to check if the given application is a Jax-RS/WS app
      Parameters:
        `webApplication` - application object
      Returns:
        relevant servlet mapping of the cxf servlet if its a Jax-RS/WS application. Null, if its not a Jax-RS/WS application.

    - #### validateWebappFileName

          public static boolean validateWebappFileName(String filename)

    - #### getWebappDirPath

          public static String getWebappDirPath(String webappFilePath)

      This util method is used to return file path of base dir. eg: for input "/deployment/server/webapps/calenda.war" will return "/deployment/server/webapps"
      Parameters:
        `webappFilePath` - path to webapp
      Returns:
        absolute path to base dir

    - #### getMatchingHostName

          public static String getMatchingHostName(String filePath)

      Parameters:
        `filePath` - web app base dir path
      Returns:
        virtual host name for web app dir

    - #### getMatchingVirtualHost

          public static org.apache.catalina.Host getMatchingVirtualHost(String baseDir)

      Parameters:
        `baseDir` - web application directory path
      Returns:
        host name that matches the directory path

    - #### isWebappUploadedToVirtualAppBase

          public static boolean isWebappUploadedToVirtualAppBase(String webAppBaseDir,
                                                                 String appBase)

      Parameters:
        `webAppBaseDir` - path to the webapp
        `appBase` - virtual host path
      Returns:
        true if Webapp is uploaded to Virtual Host, else false

    - #### getHost

          public static org.apache.catalina.Host getHost(String webappFilePath)
                                                  throws org.wso2.carbon.tomcat.CarbonTomcatException

      Parameters:
        `webappFilePath` - Webapp path
      Returns:
        virtualHost if webapp is uploaded to Virtual Host else defaultHost
      Throws:
        `org.wso2.carbon.tomcat.CarbonTomcatException`

    - #### getWebappKey

          public static String getWebappKey(File webappFile)

      This will return a key with pair hostname:webappFileName
      Parameters:
        `webappFile` - web application file
      Returns:
        :

    - #### getVhostNames

          public static List<String> getVhostNames()

      Returns:
        List of virtual hosts

    - #### getAppbase

          public static String getAppbase(String hostName)

      This util method will return appbase value of matching host name from catalina-server.xml
      Parameters:
        `hostName` - hostname of Host element
      Returns:
        relevant appBase for the host

    - #### getAllWebappHolders

          public static Map<String,WebApplicationsHolder> getAllWebappHolders(org.apache.axis2.context.ConfigurationContext configurationContext)

      Parameters:
        `configurationContext` - ConfigurationContext instance
      Returns:
        list of web application holders

    - #### getWebappHolder

          public static WebApplicationsHolder getWebappHolder(String webappFilePath,
                                                              org.apache.axis2.context.ConfigurationContext configurationContext)

      This util method will return the web application holder of the given web app file
      Parameters:
        `webappFilePath` - AbsolutePath of webapp
        `configurationContext` - ConfigurationContext instance
      Returns:
        relevant webapplication holder

    - #### getWebappDir

          public static String getWebappDir(String webappFilePath)

      This util method is used to return base dir name of webapp. eg: for input "/deployment/server/webapps/calenda.war" will return "webapps"
      Parameters:
        `webappFilePath` - path to web app
      Returns:
        parent dir of web application

    - #### getWebappName

          public static String getWebappName(String webappFilePath)

      Parameters:
        `webappFilePath` - path to webapp
      Returns:
        web application name

    - #### getDefaultWebappHolder

          public static WebApplicationsHolder getDefaultWebappHolder(org.apache.axis2.context.ConfigurationContext configurationContext)

    - #### getDefaultHost

          public static String getDefaultHost()

      Returns:
        default host of engine element

    - #### getServerConfigHostName

          public static String getServerConfigHostName()

      This will read "HostName" value from carbon.xml and will return default host (from catalina-server.xml) if the value is null (or not defined)
      Returns:
        host name read from carbon.xml

    - #### getAppBases

          public static List<String> getAppBases()

    - #### generateMetaFileDirName

          public static String generateMetaFileDirName(String webappFilePath,
                                                       org.apache.axis2.context.ConfigurationContext configurationContext)

    - #### getWebappResourcePath

          public static String getWebappResourcePath(WebApplication webApplication)

      Returns the registry path for the webapp
      Parameters:
        `webApplication` - WebApplication instance
      Returns:

Copyright © 2017 WSO2. All rights reserved.