Search in sources :

Example 1 with DeploymentUnitDAO

use of org.apache.ode.store.DeploymentUnitDAO 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 2 with DeploymentUnitDAO

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

the class ProcessStoreImpl method setProperty.

public void setProperty(final QName pid, final QName propName, final String value) {
    if (log.isDebugEnabled()) {
        log.debug("Setting property " + propName + " on process " + propName);
    }
    if (processes.indexOf(pid) == -1) {
        String errMsg = "Process " + pid + " not found.";
        log.error(errMsg);
        throw new ContextException(errMsg);
    }
    final String duName = getDeploymentUnitForProcess(pid);
    if (duName == null) {
        // This cannot happen if every thing in process store is in sync
        String errMsg = "Deployment unit for process " + pid + " not found.";
        log.error(errMsg);
        throw new ContextException(errMsg);
    }
    exec(new Callable<Object>() {

        public Object call(ConfStoreConnection conn) {
            DeploymentUnitDAO duDao = conn.getDeploymentUnit(duName);
            if (duDao == null) {
                return null;
            }
            ProcessConfDAO pConfDao = duDao.getProcess(pid);
            if (pConfDao == null) {
                return null;
            }
            pConfDao.setProperty(propName, value);
            return null;
        }
    });
    fireEvent(new ProcessStoreEvent(ProcessStoreEvent.Type.PROPERTY_CHANGED, pid, duName));
}
Also used : DeploymentUnitDAO(org.apache.ode.store.DeploymentUnitDAO) ConfStoreConnection(org.apache.ode.store.ConfStoreConnection) ProcessConfDAO(org.apache.ode.store.ProcessConfDAO) ProcessStoreEvent(org.apache.ode.bpel.iapi.ProcessStoreEvent) ContextException(org.apache.ode.bpel.iapi.ContextException)

Example 3 with DeploymentUnitDAO

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

the class ProcessStoreImpl method onBPELPackageDeployment.

public void onBPELPackageDeployment(Integer tenantId, final String duName, final String duLocation, final List<ProcessConfigurationImpl> processConfs) {
    boolean status = exec(new Callable<Boolean>() {

        @Override
        public Boolean call(ConfStoreConnection conn) {
            DeploymentUnitDAO duDao = conn.getDeploymentUnit(duName);
            if (duDao != null) {
                /*
                    This is for clustering scenario. update/deployment
                     */
                return true;
            }
            duDao = conn.createDeploymentUnit(duName);
            duDao.setDeploymentUnitDir(duLocation);
            for (ProcessConf pConf : processConfs) {
                try {
                    ProcessConfDAO processConfDao = duDao.createProcess(pConf.getProcessId(), pConf.getType(), pConf.getVersion());
                    processConfDao.setState(pConf.getState());
                    for (Map.Entry<QName, Node> prop : pConf.getProcessProperties().entrySet()) {
                        processConfDao.setProperty(prop.getKey(), DOMUtils.domToString(prop.getValue()));
                    }
                    conn.setVersion(pConf.getVersion());
                } catch (Exception e) {
                    String errmsg = "Error persisting deployment record for " + pConf.getProcessId() + "; process will not be available after restart!";
                    log.error(errmsg, e);
                    return false;
                }
            }
            return true;
        }
    });
    if (status) {
        CopyOnWriteArrayList<QName> pids = new CopyOnWriteArrayList<QName>();
        for (ProcessConf pConf : processConfs) {
            pids.add(pConf.getProcessId());
        }
        updateProcessAndDUMaps(tenantId, duName, pids, true);
        for (ProcessConfigurationImpl processConf : processConfs) {
            fireEvent(new ProcessStoreEvent(ProcessStoreEvent.Type.DEPLOYED, processConf.getProcessId(), duName));
            fireStateChange(processConf.getProcessId(), processConf.getState(), duName);
        }
    }
}
Also used : DeploymentUnitDAO(org.apache.ode.store.DeploymentUnitDAO) QName(javax.xml.namespace.QName) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) ConfStoreConnection(org.apache.ode.store.ConfStoreConnection) ProcessStoreEvent(org.apache.ode.bpel.iapi.ProcessStoreEvent) SQLException(java.sql.SQLException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) ContextException(org.apache.ode.bpel.iapi.ContextException) ProcessConfDAO(org.apache.ode.store.ProcessConfDAO) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 4 with DeploymentUnitDAO

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

the class ProcessStoreImpl method setState.

public void setState(final QName pid, final ProcessState processState) {
    validateMethodParameters(pid, processState);
    final String duName = getDeploymentUnitForProcess(pid);
    validateDeploymentUnitForTheProcess(duName, pid);
    ProcessState old = exec(new Callable<ProcessState>() {

        public ProcessState call(ConfStoreConnection conn) {
            DeploymentUnitDAO duDao = conn.getDeploymentUnit(duName);
            if (duDao == null) {
                String errMsg = "Deployment unit " + duName + " not found.";
                log.error(errMsg);
                throw new ContextException(errMsg);
            }
            ProcessConfDAO pConfDao = duDao.getProcess(pid);
            if (pConfDao == null) {
                String errMsg = "Process " + pid + " not found in deployment unit " + duName + ".";
                log.error(errMsg);
                throw new ContextException(errMsg);
            }
            ProcessState old = pConfDao.getState();
            pConfDao.setState(processState);
            return old;
        }
    });
    ProcessConfigurationImpl pConf = (ProcessConfigurationImpl) getProcessConfiguration(pid);
    pConf.setState(processState);
    if (old != null && !old.equals(processState)) {
        fireStateChange(pid, processState, duName);
    }
}
Also used : ProcessState(org.apache.ode.bpel.iapi.ProcessState) DeploymentUnitDAO(org.apache.ode.store.DeploymentUnitDAO) ConfStoreConnection(org.apache.ode.store.ConfStoreConnection) ProcessConfDAO(org.apache.ode.store.ProcessConfDAO) ContextException(org.apache.ode.bpel.iapi.ContextException)

Aggregations

DeploymentUnitDAO (org.apache.ode.store.DeploymentUnitDAO)4 ProcessConfDAO (org.apache.ode.store.ProcessConfDAO)4 ContextException (org.apache.ode.bpel.iapi.ContextException)3 ConfStoreConnection (org.apache.ode.store.ConfStoreConnection)3 QName (javax.xml.namespace.QName)2 ProcessStoreEvent (org.apache.ode.bpel.iapi.ProcessStoreEvent)2 File (java.io.File)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 TDeployment (org.apache.ode.bpel.dd.TDeployment)1 ProcessConf (org.apache.ode.bpel.iapi.ProcessConf)1 ProcessState (org.apache.ode.bpel.iapi.ProcessState)1 DeploymentUnitDir (org.apache.ode.store.DeploymentUnitDir)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1