Search in sources :

Example 6 with DeploymentUnitDir

use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.

the class AnalyticsPublisherExtensionOperation method getTenantId.

private Integer getTenantId(ExtensionContext context) {
    DeploymentUnitDir du = new DeploymentUnitDir(new File(context.getDUDir()));
    QName processIdQname = new QName(context.getProcessModel().getQName().getNamespaceURI(), context.getProcessModel().getQName().getLocalPart() + "-" + du.getStaticVersion());
    return AnalyticsPublisherServiceComponent.getBPELServer().getMultiTenantProcessStore().getTenantId(processIdQname);
}
Also used : QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) File(java.io.File)

Example 7 with DeploymentUnitDir

use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method validateBPELPackage.

/**
 * Check whether processes in this package are already available in the process store or check
 * whether processes are correctly compiled.
 *
 * @param du BPEL deployment unit
 * @throws BPELDeploymentException if there's a error in BPEL package
 */
private void validateBPELPackage(DeploymentUnitDir du) throws BPELDeploymentException {
    DeployDocument dd = du.getDeploymentDescriptor();
    for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
        QName processId = Utils.toPid(processDD.getName(), du.getVersion());
        if (processConfigMap.containsKey(processId)) {
            String logMessage = "Aborting deployment. Duplicate process ID " + processId + ".";
            log.error(logMessage);
            throw new BPELDeploymentException(logMessage);
        }
        QName processType = Utils.getProcessType(processDD);
        DeploymentUnitDir.CBPInfo cbpInfo = du.getCBPInfo(processType);
        if (cbpInfo == null) {
            // removeDeploymentArtifacts(deploymentContext, du);
            String logMessage = "Aborting deployment. Cannot find Process definition for type " + processType + ".";
            log.error(logMessage);
            throw new BPELDeploymentException(logMessage);
        }
    }
}
Also used : DeployDocument(org.apache.ode.bpel.dd.DeployDocument) QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) TDeployment(org.apache.ode.bpel.dd.TDeployment)

Example 8 with DeploymentUnitDir

use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method validateBPELPackage.

private boolean validateBPELPackage(BPELDeploymentContext bpelDeploymentContext, boolean isExistingPackage) {
    DeploymentUnitDir du;
    try {
        du = new DeploymentUnitDir(bpelDeploymentContext.getBPELPackageContent());
    } catch (IllegalArgumentException e) {
        bpelDeploymentContext.setDeploymentFailureCause(e.getMessage());
        bpelDeploymentContext.setStackTrace(e);
        return false;
    }
    if (!isExistingPackage) {
        DeployDocument deployDocument = du.getDeploymentDescriptor();
        List<TDeployment.Process> processList = deployDocument.getDeploy().getProcessList();
        for (TDeployment.Process process : processList) {
            List<TProvide> provideList = process.getProvideList();
            for (TProvide provide : provideList) {
                if (getDeployedServices().containsKey(provide.getService().getName())) {
                    String errMsg = "Service: " + provide.getService().getName() + " already " + "used by another process. Try again with a different " + "service name";
                    bpelDeploymentContext.setDeploymentFailureCause(errMsg);
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : DeployDocument(org.apache.ode.bpel.dd.DeployDocument) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) TProvide(org.apache.ode.bpel.dd.TProvide) TDeployment(org.apache.ode.bpel.dd.TDeployment)

Example 9 with DeploymentUnitDir

use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method deployBPELPackageInODE.

/**
 * Deploy BPEL package in ODE and add process configuration objects to necessary maps in process
 * store.
 *
 * @param deploymentContext information about current deployment
 * @throws Exception in case of duplicate deployment unit or if error occurred during deploying package in ODE
 */
private void deployBPELPackageInODE(BPELDeploymentContext deploymentContext) throws Exception {
    File bpelPackage = deploymentContext.getBPELPackageContent();
    log.info("Starting deployment of processes from directory " + bpelPackage.getAbsolutePath());
    final Date deployDate = new Date();
    // Create the DU and compile/scan it before doing any other work.
    final DeploymentUnitDir deploymentUnitDir = new DeploymentUnitDir(bpelPackage);
    // Before coming to this stage, we create the bpel package directory with the static version
    // so we don't need to get the version from database. We can directly use static version
    // calculated from bpel package directory name.
    deploymentUnitDir.setVersion(deploymentUnitDir.getStaticVersion());
    try {
        deploymentUnitDir.compile();
    } catch (CompilationException ce) {
        String logMessage = "Deployment failed due to compilation issues. " + ce.getMessage();
        log.error(logMessage, ce);
        deploymentContext.setFailed(true);
        deploymentContext.setDeploymentFailureCause(logMessage);
        deploymentContext.setStackTrace(ce);
        handleDeploymentError(deploymentContext);
        throw new BPELDeploymentException(logMessage, ce);
    }
    deploymentUnitDir.scan();
    DeployDocument deployDocument = deploymentUnitDir.getDeploymentDescriptor();
    List<ProcessConfigurationImpl> processConfs = new ArrayList<ProcessConfigurationImpl>();
    List<QName> processIds = new ArrayList<QName>();
    if (deploymentUnits.containsKey(deploymentUnitDir.getName())) {
        String logMessage = "Aborting deployment. Duplicate Deployment unit " + deploymentUnitDir.getName() + ".";
        log.error(logMessage);
        deploymentContext.setFailed(true);
        deploymentContext.setDeploymentFailureCause(logMessage);
        handleDeploymentError(deploymentContext);
        throw new BPELDeploymentException(logMessage);
    }
    // Validate BPEL package partially before retiring old versions.
    validateBPELPackage(deploymentUnitDir);
    if (deploymentContext.isExistingPackage()) {
        reloadExistingVersionsOfBPELPackage(deploymentContext);
    }
    // Before updating a BPEL package we need to retire processes in old version
    retirePreviousPackageVersions(deploymentUnitDir);
    for (TDeployment.Process processDD : deployDocument.getDeploy().getProcessList()) {
        QName processId = Utils.toPid(processDD.getName(), deploymentUnitDir.getVersion());
        ProcessConfigurationImpl processConf = new ProcessConfigurationImpl(tenantId, processDD, deploymentUnitDir, deployDate, parentProcessStore.getEndpointReferenceContext(), tenantConfigContext);
        processConf.setAbsolutePathForBpelArchive(deploymentContext.getBpelArchive().getAbsolutePath());
        processIds.add(processId);
        processConfs.add(processConf);
        readAnalyticsServerProfiles(processDD, deploymentUnitDir);
    }
    deploymentUnits.put(deploymentUnitDir.getName(), deploymentUnitDir);
    processesInDeploymentUnit.put(deploymentUnitDir.getName(), processIds);
    for (ProcessConfigurationImpl processConf : processConfs) {
        processConfigMap.put(processConf.getProcessId(), processConf);
        deploymentContext.addProcessId(processConf.getProcessId());
    }
    try {
        parentProcessStore.onBPELPackageDeployment(tenantId, deploymentUnitDir.getName(), BPELPackageRepositoryUtils.getResourcePathForBPELPackageContent(deploymentContext), processConfs);
    } catch (ContextException ce) {
        deploymentContext.setDeploymentFailureCause("BPEL Package deployment failed at " + "ODE layer. Possible cause: " + ce.getMessage());
        deploymentContext.setStackTrace(ce);
        deploymentContext.setFailed(true);
        handleDeploymentError(deploymentContext);
        throw ce;
    }
}
Also used : CompilationException(org.apache.ode.bpel.compiler.api.CompilationException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) Date(java.util.Date) TDeployment(org.apache.ode.bpel.dd.TDeployment) ContextException(org.apache.ode.bpel.iapi.ContextException) DeployDocument(org.apache.ode.bpel.dd.DeployDocument) File(java.io.File)

Aggregations

DeploymentUnitDir (org.apache.ode.store.DeploymentUnitDir)9 QName (javax.xml.namespace.QName)7 File (java.io.File)5 TDeployment (org.apache.ode.bpel.dd.TDeployment)5 DeployDocument (org.apache.ode.bpel.dd.DeployDocument)4 ArrayList (java.util.ArrayList)2 TProvide (org.apache.ode.bpel.dd.TProvide)2 IOException (java.io.IOException)1 Date (java.util.Date)1 FaultException (org.apache.ode.bpel.common.FaultException)1 CompilationException (org.apache.ode.bpel.compiler.api.CompilationException)1 TInvoke (org.apache.ode.bpel.dd.TInvoke)1 ContextException (org.apache.ode.bpel.iapi.ContextException)1 DeploymentUnitDAO (org.apache.ode.store.DeploymentUnitDAO)1 ProcessConfDAO (org.apache.ode.store.ProcessConfDAO)1 CarbonException (org.wso2.carbon.CarbonException)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1