Class AppDeployerUtils

java.lang.Object
org.wso2.carbon.application.deployer.AppDeployerUtils

public final class AppDeployerUtils extends Object
  • Method Details

    • getAppUnzipDir

      public static String getAppUnzipDir()
    • getProjectArtifactName

      public static String getProjectArtifactName(org.osgi.framework.Bundle bundle)
      Check whether the given bundle is a project artifact. If yes, return the app name. If no, return null
      Parameters:
      bundle - - bundle to check
      Returns:
      - app name
    • getParentAppName

      public static String getParentAppName(org.osgi.framework.Bundle bundle)
    • isAppDeployer

      public static boolean isAppDeployer(org.osgi.framework.Bundle bundle)
      Checking whether a bundle contains the WSO2-Application-Deployer header
      Parameters:
      bundle - - input bundle
      Returns:
      - if found header - true, else - false
    • getAxis2Repo

      public static String getAxis2Repo()
      Finds the carbon repository location
      Returns:
      - repo path
    • copyFile

      public static void copyFile(String fromPath, String toPath) throws org.apache.axis2.deployment.DeploymentException
      Copy the artifact file at the fromPath to toPath
      Parameters:
      fromPath - - path at which the read the file to copy
      toPath - - path to which the file should be copied
      Throws:
      org.apache.axis2.deployment.DeploymentException
    • populateArtifact

      public static Artifact populateArtifact(org.apache.axiom.om.OMElement artifactEle)
      Builds the Artifact object when an artifact element is given
      Parameters:
      artifactEle - - artifact OMElement
      Returns:
      created Artifact object
    • populateRegistryConfig

      public static RegistryConfig populateRegistryConfig(org.apache.axiom.om.OMElement resourcesElement)
      Builds a RegistryConfig instance using an OMElement which is built using the registry config file inside and cApp Registry/Resource artifact
      Parameters:
      resourcesElement - - regConfig element
      Returns:
      - RegistryConfig instance built
    • readAttribute

      public static String readAttribute(org.apache.axiom.om.OMElement element, String attName)
      Reads an attribute in the given element and returns the value of that attribute
      Parameters:
      element - - Element to search
      attName - - attribute name
      Returns:
      if the attribute found, return value. else null.
    • readChildText

      public static String readChildText(org.apache.axiom.om.OMElement element, String ln)
    • readChildText

      public static String readChildText(org.apache.axiom.om.OMElement element, String ln, String ns)
      Reads a text node which is in a child element of the given element and returns the text value.
      Parameters:
      element - - Element to search
      ln - - Child element name
      ns - - Child element namespace
      Returns:
      if the child text element found, return text value. else null.
    • readServerRoles

      public static String[] readServerRoles(CarbonAppPersistenceManager capm)
      First checks for the "serverRoles" system property. If null, reads the ServerRoles property from carbon.xml.
      Parameters:
      capm - - persistance manager
      Returns:
      server roles array
    • getArchivePathFromBundle

      public static String getArchivePathFromBundle(org.osgi.framework.Bundle b)
      Computes the application artifact file path when the bundle is given
      Parameters:
      b - - App artifact as an OSGi bundle
      Returns:
      - App file path
    • getApplicationLocation

      public static String getApplicationLocation()
      Finds repo/carbonapps path
      Returns:
      - path
    • getFileExtension

      public static String getFileExtension(String fileName)
      Finds teh extension of a given file
      Parameters:
      fileName - - name of the file
      Returns:
      - extension
    • extractCarbonApp

      public static String extractCarbonApp(String appCarPath) throws org.wso2.carbon.CarbonException
      Extract the Carbon application at the provided path to the java temp dir. Return the extracted location
      Parameters:
      appCarPath - - Absolute path of the Carbon application .car file
      Returns:
      - extracted location
      Throws:
      org.wso2.carbon.CarbonException - - error on extraction
    • createAppExtractionPath

      public static String createAppExtractionPath(String parentAppName)
    • extractAppArtifact

      public static String extractAppArtifact(String artifactPath, String parentPath) throws org.wso2.carbon.CarbonException
      Extract an individual cApp artifact at the provided path to the java temp dir. Return the extracted location
      Parameters:
      artifactPath - - Absolute path of the cApp artifact file
      parentPath - - Parent's extracted path
      Returns:
      - extracted location
      Throws:
      org.wso2.carbon.CarbonException - - on error
    • attachArtifactToOwnerApp

      public static void attachArtifactToOwnerApp(String fileName, String artifactType, String runtimeObjectName, int tenantId)
      Finds the owner application of the provided artifact file name and sets the runtime object name in the corresponding artifact.
      Parameters:
      fileName - - file name of the artifact
      artifactType - - this can be a module or a service
      runtimeObjectName - - name of the runtime object corresponding to this file
      tenantId - - id of the tenant in which the artifact is deployed
    • formatPath

      public static String formatPath(String path)
      Format the string paths to match any platform.. windows, linux etc..
      Parameters:
      path - - input file path
      Returns:
      formatted file path
    • hasLibs

      public static boolean hasLibs(List<Artifact.Dependency> deps)
      Checks whether the given dependencies has library type artifacts
      Parameters:
      deps - - list of dependencies
      Returns:
      - true if found..
    • areAllFeaturesInstalled

      public static boolean areAllFeaturesInstalled(List<Feature> features)
      Checks whether the given list of features are already installed in the systme
      Parameters:
      features - - list of features
      Returns:
      - true if all are installed, else false
    • buildAcceptanceList

      public static Map<String,Boolean> buildAcceptanceList(Map<String,List<Feature>> features)
      For each artifact type, there's a set of features which are needed to be installed in the system to properly deploy the artifacts. If all those features don't exist in the system, artifacts of that type can't be accepted for deployment. This method builds the acceptance list by checking whether the needed features are already installed or not.
      Parameters:
      features - - contains the list of features needed for each artifact type
      Returns:
      whether each artifact type can be deployed or not
    • readRequiredFeaturs

      public static Map<String,List<Feature>> readRequiredFeaturs(org.apache.axiom.om.OMElement featureSets)
      Reads the root element of the required-features.xml file and returns a list of required features for each and every artifact type.
      Parameters:
      featureSets - - root element of the required-features.xml
      Returns:
      - map which includes the list of features for each artifact type
    • getTenantIdString

      @Deprecated public static String getTenantIdString(org.apache.axis2.engine.AxisConfiguration axisConfig)
      Deprecated.
    • getTenantIdString

      public static String getTenantIdString()
    • getTenantId

      @Deprecated public static int getTenantId(org.apache.axis2.engine.AxisConfiguration axisConfig)
      Deprecated.
    • getTenantId

      public static int getTenantId()
    • getTenantIdLogString

      public static String getTenantIdLogString(int tenantId)
    • computeResourcePath

      public static String computeResourcePath(String basePath, String resourceName)
    • readMediaType

      public static String readMediaType(String artifactExtractedPath, String fileName)
      Read the mediaType from the meta file of a resource. Currently we read only the mediaType from this file. If we need more info from this file in the future, create a Config instance for the meta file as well.
      Parameters:
      artifactExtractedPath - - extracted path of the artifact
      fileName - - original resource file name. this is used to figure out meta file name
      Returns:
      - mediaType if the file found. else null..
    • createDir

      public static void createDir(String path)
    • getArtifactDeployer

      public static org.apache.axis2.deployment.Deployer getArtifactDeployer(org.apache.axis2.engine.AxisConfiguration axisConfig, String directory, String extension)
      Finds the correct deployer for the given directory and extension
      Parameters:
      axisConfig - - AxisConfiguration instance
      directory - - Directory to retrieve the deployer
      extension - - Extension of the deployable artifact
      Returns:
      Deployer instance