Search in sources :

Example 1 with DeploymentUnitDir

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

the class TenantProcessStoreImpl method undeploySpecificVersionOfBPELPackage.

private void undeploySpecificVersionOfBPELPackage(final String packageName, final Collection<QName> undeployedProcesses) {
    DeploymentUnitDir du = deploymentUnits.remove(packageName);
    processesInDeploymentUnit.remove(packageName);
    if (du != null) {
        long version = du.getVersion();
        for (QName name : du.getProcessNames()) {
            QName pid = Utils.toPid(name, version);
            undeployedProcesses.add(pid);
        }
    }
}
Also used : QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir)

Example 2 with DeploymentUnitDir

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

the class TenantProcessStoreImpl method loadExistingBPELPackage.

private void loadExistingBPELPackage(String bpelPackageName) throws RegistryException, ProcessManagementException, BPELDeploymentException {
    DeploymentUnitDAO duDAO = parentProcessStore.getDeploymentUnitDAO(bpelPackageName);
    if (duDAO == null) {
        String errMsg = "Cannot find DeploymentUnitDAO instance for package " + bpelPackageName + ".";
        log.error(errMsg);
        throw new BPELDeploymentException(errMsg);
    }
    File bpelPackage = findBPELPackageInFileSystem(duDAO);
    if (bpelPackage == null || !bpelPackage.exists()) {
        throw new BPELDeploymentException("Deployed directory " + bpelPackage + " no longer there!");
    }
    DeploymentUnitDir du = new DeploymentUnitDir(bpelPackage);
    du.setVersion(du.getStaticVersion());
    du.scan();
    List<ProcessConfigurationImpl> loaded = new ArrayList<ProcessConfigurationImpl>();
    List<QName> processIds = new ArrayList<QName>();
    for (ProcessConfDAO pConfDAO : duDAO.getProcesses()) {
        TDeployment.Process processDD = du.getProcessDeployInfo(pConfDAO.getType());
        if (processDD == null) {
            log.warn("Cannot load " + pConfDAO.getPID() + "; cannot find descriptor.");
            continue;
        }
        // TODO: update the props based on the values in the DB.
        ProcessConfigurationImpl pConf = new ProcessConfigurationImpl(tenantId, processDD, du, duDAO.getDeployDate(), parentProcessStore.getEndpointReferenceContext(), tenantConfigContext);
        pConf.setAbsolutePathForBpelArchive(bpelPackage.getAbsolutePath());
        pConf.setState(pConfDAO.getState());
        processIds.add(pConfDAO.getPID());
        // if the deployment descriptor is updated at runtime, first load the updated data in
        // registry and use them with the specific process
        repository.readPropertiesOfUpdatedDeploymentInfo(pConf, bpelPackageName);
        readAnalyticsServerProfiles(processDD, du);
        processConfigMap.put(pConf.getProcessId(), pConf);
        loaded.add(pConf);
    }
    deploymentUnits.put(du.getName(), du);
    processesInDeploymentUnit.put(du.getName(), processIds);
    parentProcessStore.onBPELPackageReload(tenantId, du.getName(), loaded);
}
Also used : DeploymentUnitDAO(org.apache.ode.store.DeploymentUnitDAO) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) TDeployment(org.apache.ode.bpel.dd.TDeployment) ProcessConfDAO(org.apache.ode.store.ProcessConfDAO) File(java.io.File)

Example 3 with DeploymentUnitDir

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

the class TenantProcessStoreImpl method findBPELPackageInFileSystem.

private File findBPELPackageInFileSystem(DeploymentUnitDAO dudao) {
    String duName = dudao.getName();
    // Done: Fix the logic to handle registry
    log.info("Looking for BPEL package in file system for deployment unit " + duName);
    File bpelDUDirectory = new File(bpelDURepo, duName);
    if (bpelDUDirectory.exists()) {
        return bpelDUDirectory;
    } else {
        String registryCollectionPath = dudao.getDeploymentUnitDir();
        try {
            if (tenantConfigRegistry.resourceExists(registryCollectionPath)) {
                if (!bpelDUDirectory.exists() && !bpelDUDirectory.mkdirs()) {
                    String errMsg = "Error creating BPEL deployment unit repository for " + "tenant " + tenantId;
                    log.error(errMsg);
                    log.error("Failed to load BPEL deployment unit " + duName + " due to above error.");
                    throw new BPELDeploymentException(errMsg);
                }
                boolean deployedOnCarbon310 = false;
                // Check whether the registry repo is of type carbon 3.1.0
                if (tenantConfigRegistry.resourceExists(registryCollectionPath + RegistryConstants.PATH_SEPARATOR + duName)) {
                    registryCollectionPath += RegistryConstants.PATH_SEPARATOR + duName;
                    deployedOnCarbon310 = true;
                    if (log.isDebugEnabled()) {
                        log.debug("Found a carbon 3.1.0 compatible deployment unit at " + registryCollectionPath);
                    }
                }
                RegistryClientUtils.exportFromRegistry(bpelDUDirectory, registryCollectionPath, tenantConfigRegistry);
                if (deployedOnCarbon310) {
                    if (log.isDebugEnabled()) {
                        log.debug("Recompiling the carbon 3.1.0 compatible deployment unit at " + bpelDUDirectory);
                    }
                    // Re-compiling to get rid of binary compatibility issues.
                    DeploymentUnitDir du = new DeploymentUnitDir(bpelDUDirectory);
                    for (File file : du.allFiles()) {
                        if (file.getAbsolutePath().endsWith(".cbp") && !file.delete()) {
                            log.warn("Unable to delete " + file);
                        }
                    }
                    du.compile();
                }
                return bpelDUDirectory;
            } else {
                String errMsg = "Expected resource: " + registryCollectionPath + " not found in the registry";
                log.error(errMsg);
                throw new BPELDeploymentException(errMsg);
            }
        } catch (RegistryException re) {
            String errMsg = "Error while exporting deployment unit: " + duName + " to file system from the registry.";
            log.error(errMsg, re);
            throw new BPELDeploymentException(errMsg, re);
        }
    }
}
Also used : DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) File(java.io.File) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Example 4 with DeploymentUnitDir

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

the class BPELUploadExecutor method validateBPELPackage.

public void validateBPELPackage(String directoryPath) throws Exception {
    DeploymentUnitDir du;
    try {
        du = new DeploymentUnitDir(new File(directoryPath));
    } catch (IllegalArgumentException iae) {
        log.error("BPEL Package Validation Failure.", iae);
        throw new Exception("BPEL Package Validation Failure.", iae);
    }
    // check package for illegal charactors which registry does not support. (~!@#$;%^*()+={}[]|\<>)
    List<File> packageFiles = du.allFiles();
    for (File packageFile : packageFiles) {
        if (!packageFile.getName().matches("[^\\~\\!\\@\\#\\$\\;\\%\\^\\*\\(\\)\\+ " + "/\\=\\{\\}\\[\\]\\\\|\\<\\>\"\\'\\`]+")) {
            log.error("BPEL Package Validation Failure: one or many of the following illegal characters are in " + "the package.\n ~!@#$;%^*()+={}[]| \\<>\"'`");
            throw new Exception("BPEL Package Validation Failure: one or many of the following illegal characters" + " " + "are in the package. ~!@#$;%^*()+={}[]| \\<>\"'`");
        }
    }
    try {
        du.compile();
    } catch (RuntimeException ce) {
        log.error("BPEL Process Compilation Failure.", ce);
        throw new Exception("BPEL Compilation Failure!", ce);
    } catch (Exception e) {
        log.error("BPEL Process Compilation Failure.", e);
        throw new Exception("BPEL Compilation Failure!", e);
    }
    du.scan();
    DeployDocument dd = du.getDeploymentDescriptor();
    for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
        QName processType = processDD.getType() != null ? processDD.getType() : processDD.getName();
        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 Exception(logMessage);
        }
        for (TProvide tProvide : processDD.getProvideList()) {
            if (tProvide.getService() == null) {
                String errMsg = "Service element missing for the provide element in deploy.xml";
                log.error(errMsg);
                throw new Exception(errMsg);
            }
        }
        for (TInvoke tInvoke : processDD.getInvokeList()) {
            if (tInvoke.getService() == null) {
                String errMsg = "Service element missing for the invoke element in deploy.xml";
                log.error(errMsg);
                throw new Exception(errMsg);
            }
        }
    }
}
Also used : QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) IOException(java.io.IOException) CarbonException(org.wso2.carbon.CarbonException) TDeployment(org.apache.ode.bpel.dd.TDeployment) TInvoke(org.apache.ode.bpel.dd.TInvoke) DeployDocument(org.apache.ode.bpel.dd.DeployDocument) TProvide(org.apache.ode.bpel.dd.TProvide) File(java.io.File)

Example 5 with DeploymentUnitDir

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

the class PeopleActivity method init.

private void init(ExtensionContext extensionContext, Element element) throws FaultException {
    if (!element.getLocalName().equals(BPEL4PeopleConstants.PEOPLE_ACTIVITY) || !element.getNamespaceURI().equals(BPEL4PeopleConstants.B4P_NAMESPACE)) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "No " + BPEL4PeopleConstants.PEOPLE_ACTIVITY + " activity found");
    }
    name = element.getAttribute(BPEL4PeopleConstants.PEOPLE_ACTIVITY_NAME);
    inputVarName = element.getAttribute(BPEL4PeopleConstants.PEOPLE_ACTIVITY_INPUT_VARIABLE);
    outputVarName = element.getAttribute(BPEL4PeopleConstants.PEOPLE_ACTIVITY_OUTPUT_VARIABLE);
    isSkipable = "yes".equalsIgnoreCase(element.getAttribute(BPEL4PeopleConstants.PEOPLE_ACTIVITY_IS_SKIPABLE));
    processStandardElement(element);
    processAttachmentPropagationElement(element);
    String duDir = extensionContext.getDUDir().toString();
    String duVersion = duDir.substring(duDir.lastIndexOf('-') + 1);
    if (duVersion.endsWith("/")) {
        duVersion = duVersion.substring(0, duVersion.lastIndexOf("/"));
    } else if (duVersion.endsWith("\\")) {
        duVersion = duVersion.substring(0, duVersion.lastIndexOf("\\"));
    }
    // //Commenting this logic to fix memory issues.
    // DeploymentUnitDir du = new DeploymentUnitDir(new File(extensionContext.getDUDir()));
    // processId = new QName(extensionContext.getProcessModel().getQName().getNamespaceURI(),
    // extensionContext.getProcessModel().getQName().getLocalPart() + "-" +
    // du.getStaticVersion());
    processId = new QName(extensionContext.getProcessModel().getQName().getNamespaceURI(), extensionContext.getProcessModel().getQName().getLocalPart() + "-" + duVersion);
    Integer tenantId = B4PServiceComponent.getBPELServer().getMultiTenantProcessStore().getTenantId(processId);
    DeploymentUnitDir du = B4PServiceComponent.getBPELServer().getMultiTenantProcessStore().getTenantsProcessStore(tenantId).getDeploymentUnitDir(processId);
    isTwoWay = activityType.equals(InteractionType.TASK);
    deriveServiceEPR(du, extensionContext);
}
Also used : FaultException(org.apache.ode.bpel.common.FaultException) QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir)

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