Class AppDeployerUtils
java.lang.Object
org.wso2.carbon.application.deployer.AppDeployerUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareAllFeaturesInstalled(List<Feature> features) Checks whether the given list of features are already installed in the systmestatic voidattachArtifactToOwnerApp(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.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.static StringcomputeResourcePath(String basePath, String resourceName) static voidCopy the artifact file at the fromPath to toPathstatic StringcreateAppExtractionPath(String parentAppName) static voidstatic StringextractAppArtifact(String artifactPath, String parentPath) Extract an individual cApp artifact at the provided path to the java temp dir.static StringextractCarbonApp(String appCarPath) Extract the Carbon application at the provided path to the java temp dir.static StringformatPath(String path) Format the string paths to match any platform..static StringFinds repo/carbonapps pathstatic Stringstatic StringgetArchivePathFromBundle(org.osgi.framework.Bundle b) Computes the application artifact file path when the bundle is givenstatic org.apache.axis2.deployment.DeployergetArtifactDeployer(org.apache.axis2.engine.AxisConfiguration axisConfig, String directory, String extension) Finds the correct deployer for the given directory and extensionstatic StringFinds the carbon repository locationstatic StringgetFileExtension(String fileName) Finds teh extension of a given filestatic StringgetParentAppName(org.osgi.framework.Bundle bundle) static StringgetProjectArtifactName(org.osgi.framework.Bundle bundle) Check whether the given bundle is a project artifact.static intstatic intgetTenantId(org.apache.axis2.engine.AxisConfiguration axisConfig) Deprecated.static StringgetTenantIdLogString(int tenantId) static Stringstatic StringgetTenantIdString(org.apache.axis2.engine.AxisConfiguration axisConfig) Deprecated.static booleanhasLibs(List<Artifact.Dependency> deps) Checks whether the given dependencies has library type artifactsstatic booleanisAppDeployer(org.osgi.framework.Bundle bundle) Checking whether a bundle contains the WSO2-Application-Deployer headerstatic ArtifactpopulateArtifact(org.apache.axiom.om.OMElement artifactEle) Builds the Artifact object when an artifact element is givenstatic RegistryConfigpopulateRegistryConfig(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 artifactstatic StringreadAttribute(org.apache.axiom.om.OMElement element, String attName) Reads an attribute in the given element and returns the value of that attributestatic StringreadChildText(org.apache.axiom.om.OMElement element, String ln) static StringreadChildText(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.static StringreadMediaType(String artifactExtractedPath, String fileName) Read the mediaType from the meta file of a resource.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.static String[]First checks for the "serverRoles" system property.
-
Method Details
-
getAppUnzipDir
-
getProjectArtifactName
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
-
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
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 copytoPath- - path to which the file should be copied- Throws:
org.apache.axis2.deployment.DeploymentException
-
populateArtifact
Builds the Artifact object when an artifact element is given- Parameters:
artifactEle- - artifact OMElement- Returns:
- created Artifact object
-
populateRegistryConfig
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
Reads an attribute in the given element and returns the value of that attribute- Parameters:
element- - Element to searchattName- - attribute name- Returns:
- if the attribute found, return value. else null.
-
readChildText
-
readChildText
Reads a text node which is in a child element of the given element and returns the text value.- Parameters:
element- - Element to searchln- - Child element namens- - Child element namespace- Returns:
- if the child text element found, return text value. else null.
-
readServerRoles
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
Computes the application artifact file path when the bundle is given- Parameters:
b- - App artifact as an OSGi bundle- Returns:
- - App file path
-
getApplicationLocation
Finds repo/carbonapps path- Returns:
- - path
-
getFileExtension
Finds teh extension of a given file- Parameters:
fileName- - name of the file- Returns:
- - extension
-
extractCarbonApp
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
-
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 fileparentPath- - 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 artifactartifactType- - this can be a module or a serviceruntimeObjectName- - name of the runtime object corresponding to this filetenantId- - id of the tenant in which the artifact is deployed
-
formatPath
Format the string paths to match any platform.. windows, linux etc..- Parameters:
path- - input file path- Returns:
- formatted file path
-
hasLibs
Checks whether the given dependencies has library type artifacts- Parameters:
deps- - list of dependencies- Returns:
- - true if found..
-
areAllFeaturesInstalled
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
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
-
getTenantId
Deprecated. -
getTenantId
public static int getTenantId() -
getTenantIdLogString
-
computeResourcePath
-
readMediaType
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 artifactfileName- - original resource file name. this is used to figure out meta file name- Returns:
- - mediaType if the file found. else null..
-
createDir
-
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 instancedirectory- - Directory to retrieve the deployerextension- - Extension of the deployable artifact- Returns:
- Deployer instance
-