Search in sources :

Example 26 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException 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 27 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException 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)

Example 28 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException in project carbon-business-process by wso2.

the class BPELDeployer method undeploy.

public void undeploy(String bpelArchivePath) throws DeploymentException {
    File bpelArchiveFile = new File(bpelArchivePath);
    if (bpelArchiveFile.exists()) {
        if (log.isTraceEnabled()) {
            log.trace("Assumption: this as an update of the bpel package: " + bpelArchivePath + ", Therefore no need to do undeploy");
        }
        // here
        return;
    }
    log.info("Undeploying BPEL archive " + bpelArchivePath);
    try {
        String archiveName = bpelArchivePath.substring(bpelArchivePath.lastIndexOf(File.separator) + 1);
        String bpelPackageName = archiveName.substring(0, archiveName.lastIndexOf("." + BPELConstants.BPEL_PACKAGE_EXTENSION));
        tenantProcessStore.undeploy(bpelPackageName);
    } catch (Exception e) {
        String errMsg = "BPEL Package: " + bpelArchivePath + " undeployment failed.";
        log.error(errMsg, e);
        throw new DeploymentException(errMsg, e);
    }
}
Also used : DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) DeploymentException(org.apache.axis2.deployment.DeploymentException)

Example 29 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException in project carbon-business-process by wso2.

the class BPELBindingContextImpl method publishAxisService.

private BPELProcessProxy publishAxisService(ProcessConf processConfiguration, QName serviceName, String portName) throws AxisFault {
    // TODO: Need to fix this to suite multi-tenant environment
    // TODO: There is a problem in this, in this manner we can't have two axis services with
    // same QName
    BPELProcessProxy processProxy = new BPELProcessProxy(processConfiguration, bpelServer, serviceName, portName);
    ConfigurationContext tenantConfigCtx = getConfigurationContextFromProcessConfiguration(processConfiguration);
    AxisService axisService;
    try {
        axisService = AxisServiceUtils.createAxisService(tenantConfigCtx.getAxisConfiguration(), processProxy);
        EndpointConfiguration endpointConfig = ((ProcessConfigurationImpl) processConfiguration).getEndpointConfiguration(new WSDL11Endpoint(serviceName, portName));
        ServiceConfigurationUtil.configureService(axisService, endpointConfig, tenantConfigCtx);
    } catch (AxisFault e) {
        log.error("Error occurred creating the axis service " + serviceName.toString());
        throw new DeploymentException("BPEL Package deployment failed.", e);
    }
    processProxy.setAxisService(axisService);
    removeBPELProcessProxyAndAxisService(processConfiguration.getDeployer(), serviceName, portName);
    services.put(processConfiguration.getDeployer(), serviceName, portName, processProxy);
    ArrayList<AxisService> serviceList = new ArrayList<AxisService>();
    serviceList.add(axisService);
    DeploymentEngine.addServiceGroup(createServiceGroupForService(axisService), serviceList, null, null, tenantConfigCtx.getAxisConfiguration());
    // 
    if (log.isDebugEnabled()) {
        log.debug("BPELProcessProxy created for process " + processConfiguration.getProcessId());
        log.debug("AxisService " + serviceName + " created for BPEL process " + processConfiguration.getProcessId());
    }
    return processProxy;
}
Also used : WSDL11Endpoint(org.apache.ode.bpel.epr.WSDL11Endpoint) AxisFault(org.apache.axis2.AxisFault) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisService(org.apache.axis2.description.AxisService) ArrayList(java.util.ArrayList) DeploymentException(org.apache.axis2.deployment.DeploymentException) EndpointConfiguration(org.wso2.carbon.bpel.common.config.EndpointConfiguration) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl)

Example 30 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException in project carbon-business-process by wso2.

the class BPMNDeployer method undeploy.

/**
 * Undeployment operation for Bpmn Deployer
 *
 * @param bpmnArchivePath        archivePatch
 * @throws DeploymentException   Deployment failure will result in this exception
 */
public void undeploy(String bpmnArchivePath) throws DeploymentException {
    if (isWorkerNode()) {
        return;
    }
    if (System.getProperty(BPMNConstants.RESOLVE_DEPLOYMENT_SYS_PROP) != null && Boolean.parseBoolean(System.getProperty(BPMNConstants.RESOLVE_DEPLOYMENT_SYS_PROP)) || System.getProperty(BPMNConstants.RESOLVE_DEPLOYMENT_SYS_PROP) == null) {
        File bpmnArchiveFile = new File(bpmnArchivePath);
        if (bpmnArchiveFile.exists()) {
            if (log.isTraceEnabled()) {
                log.trace("BPMN package: " + bpmnArchivePath + " exists in the deployment folder. " + "Therefore, this can be an update of the package and the undeployment will be aborted.");
            }
            return;
        }
        Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        log.info("Undeploying BPMN archive " + bpmnArchivePath + " for tenant: " + tenantId);
        String deploymentName = FilenameUtils.getBaseName(bpmnArchivePath);
        try {
            tenantRepository.undeploy(deploymentName, true);
        } catch (BPSFault be) {
            String errorMsg = "Error un deploying BPMN Package " + deploymentName;
            throw new DeploymentException(errorMsg, be);
        }
    }
}
Also used : BPSFault(org.wso2.carbon.bpmn.core.BPSFault) DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File)

Aggregations

DeploymentException (org.apache.axis2.deployment.DeploymentException)32 File (java.io.File)23 Deployer (org.apache.axis2.deployment.Deployer)6 Artifact (org.wso2.carbon.application.deployer.config.Artifact)6 CappFile (org.wso2.carbon.application.deployer.config.CappFile)6 IOException (java.io.IOException)4 AxisFault (org.apache.axis2.AxisFault)3 DeploymentFileData (org.apache.axis2.deployment.repository.util.DeploymentFileData)3 Library (org.apache.synapse.libraries.model.Library)3 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)3 QName (javax.xml.namespace.QName)2 OMElement (org.apache.axiom.om.OMElement)2 Mediator (org.apache.synapse.Mediator)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 ZipInputStream (java.util.zip.ZipInputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1