Search in sources :

Example 6 with DeploymentFileData

use of org.apache.axis2.deployment.repository.util.DeploymentFileData in project carbon-business-process by wso2.

the class BPELAppDeployer method deployArtifacts.

/**
 * Check the artifact type and if it is a BPEL, copy it to the BPEL deployment hot folder
 *
 * @param carbonApp  - CarbonApplication instance to check for BPEL artifacts
 * @param axisConfig - AxisConfiguration of the current tenant
 */
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
    List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
    // loop through all artifacts
    for (Artifact.Dependency dep : artifacts) {
        Deployer deployer;
        Artifact artifact = dep.getArtifact();
        if (artifact == null) {
            continue;
        }
        if (!isAccepted(artifact.getType())) {
            log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " + artifact.getType() + ". Required features are not installed in the system");
            continue;
        }
        if (BPEL_TYPE.equals(artifact.getType())) {
            deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPEL_DIR, "zip");
        } else {
            continue;
        }
        List<CappFile> files = artifact.getFiles();
        if (files.size() != 1) {
            log.error("BPEL workflows must have a single file to " + "be deployed. But " + files.size() + " files found.");
            continue;
        }
        if (deployer != null) {
            String fileName = artifact.getFiles().get(0).getName();
            String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            try {
                deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
                artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
            } catch (DeploymentException e) {
                artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
                throw e;
            }
        }
    }
}
Also used : DeploymentFileData(org.apache.axis2.deployment.repository.util.DeploymentFileData) DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File) CappFile(org.wso2.carbon.application.deployer.config.CappFile) Artifact(org.wso2.carbon.application.deployer.config.Artifact) Deployer(org.apache.axis2.deployment.Deployer) CappFile(org.wso2.carbon.application.deployer.config.CappFile)

Example 7 with DeploymentFileData

use of org.apache.axis2.deployment.repository.util.DeploymentFileData in project carbon-business-process by wso2.

the class BPMNAppDeployer method deployArtifacts.

/**
 * Check the artifact type and if it is a BPMN artifact, copy it to the BPMN deployment hot folder
 *
 * @param carbonApp  - CarbonApplication instance to check for BPMN artifacts
 * @param axisConfig - AxisConfiguration of the current tenant
 */
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
    List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
    // loop through all dependencies
    for (Artifact.Dependency dep : artifacts) {
        Deployer deployer;
        Artifact artifact = dep.getArtifact();
        if (artifact == null) {
            continue;
        }
        if (!isAccepted(artifact.getType())) {
            log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " + artifact.getType() + ". Required features are not installed in the system");
            continue;
        }
        if (BPMN_TYPE.equals(artifact.getType())) {
            deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPMN_DIR, "bar");
        } else {
            continue;
        }
        List<CappFile> files = artifact.getFiles();
        if (files.size() != 1) {
            log.error("BPMN artifacts must have a single file to " + "be deployed. But " + files.size() + " files found.");
            continue;
        }
        if (deployer != null) {
            String fileName = artifact.getFiles().get(0).getName();
            String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            try {
                deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
                artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
                File artifactFile = new File(artifactPath);
                if (artifactFile.exists() && !artifactFile.delete()) {
                    log.warn("Couldn't delete App artifact file : " + artifactPath);
                }
            } catch (DeploymentException e) {
                artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
                throw e;
            }
        }
    }
}
Also used : DeploymentFileData(org.apache.axis2.deployment.repository.util.DeploymentFileData) DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File) CappFile(org.wso2.carbon.application.deployer.config.CappFile) Artifact(org.wso2.carbon.application.deployer.config.Artifact) Deployer(org.apache.axis2.deployment.Deployer) CappFile(org.wso2.carbon.application.deployer.config.CappFile)

Aggregations

DeploymentException (org.apache.axis2.deployment.DeploymentException)7 File (java.io.File)4 IOException (java.io.IOException)3 Deployer (org.apache.axis2.deployment.Deployer)3 DeploymentFileData (org.apache.axis2.deployment.repository.util.DeploymentFileData)3 Artifact (org.wso2.carbon.application.deployer.config.Artifact)3 CappFile (org.wso2.carbon.application.deployer.config.CappFile)3 InputStream (java.io.InputStream)1 URLClassLoader (java.net.URLClassLoader)1 Properties (java.util.Properties)1 QName (javax.xml.namespace.QName)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 OMElement (org.apache.axiom.om.OMElement)1 OMException (org.apache.axiom.om.OMException)1 StAXOMBuilder (org.apache.axiom.om.impl.builder.StAXOMBuilder)1 DeploymentClassLoader (org.apache.axis2.deployment.DeploymentClassLoader)1 MediatorFactory (org.apache.synapse.config.xml.MediatorFactory)1 MediatorSerializer (org.apache.synapse.config.xml.MediatorSerializer)1 StartupFactory (org.apache.synapse.config.xml.StartupFactory)1 StartupFinder (org.apache.synapse.config.xml.StartupFinder)1