Search in sources :

Example 1 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method isOperationIsValidForTheCurrentTenant.

/**
 * Check whether the instance belongs to the current tenant. If not, don't allow any operations.
 *
 * @param iid instance id
 * @throws IllegalAccessException if instance doesn't belong to the current tenant
 * @throws ProcessingException    if there a error getting instance data
 * @throws InstanceManagementException if the processId does not exist
 */
private void isOperationIsValidForTheCurrentTenant(final long iid) throws IllegalAccessException, ProcessingException, InstanceManagementException {
    QName processId = getProcess(iid);
    TenantProcessStoreImpl processStore = getTenantProcessForCurrentSession();
    if (processId != null) {
        if (!processStore.containsProcess(processId)) {
            log.error("Trying to invoke a illegal operation. Instance ID:" + iid);
            throw new IllegalAccessException("Operation is not permitted.");
        }
    } else {
        throw new InstanceManagementException("Process instance for instance ID " + iid + " does not exist");
    }
}
Also used : InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) QName(javax.xml.namespace.QName) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Example 2 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method getPaginatedProcessList.

public PaginatedProcessInfoList getPaginatedProcessList(String processListFilter, String processListOrderByKey, int page) throws ProcessManagementException {
    int tPage = page;
    PaginatedProcessInfoList processList = new PaginatedProcessInfoList();
    TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
    if (tPage < 0 || tPage == Integer.MAX_VALUE) {
        tPage = 0;
    }
    Integer itemsPerPage = 10;
    Integer startIndexForCurrentPage = tPage * itemsPerPage;
    Integer endIndexForCurrentPage = (tPage + 1) * itemsPerPage;
    final ProcessFilter processFilter = new ProcessFilter(processListFilter, processListOrderByKey);
    Collection<ProcessConf> processListForCurrentPage = processQuery(processFilter, tenantProcessStore);
    Integer processListSize = processListForCurrentPage.size();
    Integer pages = (int) Math.ceil((double) processListSize / itemsPerPage);
    processList.setPages(pages);
    ProcessConf[] processConfigurations = processListForCurrentPage.toArray(new ProcessConf[processListSize]);
    for (int i = startIndexForCurrentPage; (i < endIndexForCurrentPage && i < processListSize); i++) {
        processList.addProcessInfo(AdminServiceUtils.createLimitedProcessInfoObject(processConfigurations[i]));
    }
    return processList;
}
Also used : ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) ProcessFilter(org.apache.ode.bpel.common.ProcessFilter) PaginatedProcessInfoList(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PaginatedProcessInfoList) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Example 3 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method getAllProcesses.

public java.lang.String[] getAllProcesses(String getAllProcesses) throws ProcessManagementException {
    TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
    Set<QName> processIds = tenantProcessStore.getProcessConfigMap().keySet();
    List<String> pids = new ArrayList<String>();
    for (QName pid : processIds) {
        pids.add(pid.toString());
    }
    return pids.toArray(new String[pids.size()]);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Example 4 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method fillProcessInfo.

/**
 * Fill in the <code>ProcessInfo</code> element of the transfer object.
 *
 * @param info               destination XMLBean
 * @param pconf              process configuration object (from store)
 * @param custom             used to customize the quantity of information produced in the
 *                           info
 * @param tenantProcessStore Tenant's Process store
 * @throws ProcessManagementException If an error occurred while filling process information
 */
private void fillProcessInfo(ProcessInfoType info, ProcessConf pconf, ProcessInfoCustomizer custom, TenantProcessStoreImpl tenantProcessStore) throws ProcessManagementException {
    if (pconf == null) {
        String errMsg = "Process configuration cannot be null.";
        log.error(errMsg);
        throw new ProcessManagementException(errMsg);
    }
    info.setPid(pconf.getProcessId().toString());
    // Active process may be retired at the same time
    if (pconf.getState() == ProcessState.RETIRED) {
        info.setStatus(ProcessStatus.RETIRED);
        info.setOlderVersion(AdminServiceUtils.isOlderVersion(pconf, tenantProcessStore));
    } else if (pconf.getState() == ProcessState.DISABLED) {
        info.setStatus(ProcessStatus.DISABLED);
        info.setOlderVersion(0);
    } else {
        info.setStatus(ProcessStatus.ACTIVE);
        info.setOlderVersion(0);
    }
    info.setVersion(pconf.getVersion());
    DefinitionInfo defInfo = new DefinitionInfo();
    defInfo.setProcessName(pconf.getType());
    BpelDefinition bpelDefinition = new BpelDefinition();
    bpelDefinition.setExtraElement(getProcessDefinition(pconf));
    defInfo.setDefinition(bpelDefinition);
    info.setDefinitionInfo(defInfo);
    DeploymentInfo depInfo = new DeploymentInfo();
    depInfo.setPackageName(pconf.getPackage());
    depInfo.setDocument(pconf.getBpelDocument());
    depInfo.setDeployDate(AdminServiceUtils.toCalendar(pconf.getDeployDate()));
    // TODO: Need to fix this by adding info to process conf.
    depInfo.setDeployer(org.wso2.carbon.bpel.core.BPELConstants.BPEL_DEPLOYER_NAME);
    info.setDeploymentInfo(depInfo);
    if (custom.includeInstanceSummary()) {
        InstanceSummary instanceSummary = new InstanceSummary();
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.ACTIVE);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.COMPLETED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.FAILED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.SUSPENDED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.TERMINATED);
        addFailuresToInstanceSummary(instanceSummary, pconf);
        info.setInstanceSummary(instanceSummary);
    }
    if (custom.includeProcessProperties()) {
        ProcessProperties processProps = new ProcessProperties();
        for (Map.Entry<QName, Node> propEntry : pconf.getProcessProperties().entrySet()) {
            QName key = propEntry.getKey();
            if (key != null) {
                Property_type0 prop = new Property_type0();
                prop.setName(new QName(key.getNamespaceURI(), key.getLocalPart()));
                OMFactory omFac = OMAbstractFactory.getOMFactory();
                OMElement propEle = omFac.createOMElement("PropertyValue", null);
                propEle.setText(propEntry.getValue().getNodeValue());
                prop.addExtraElement(propEle);
                processProps.addProperty(prop);
            }
        }
        info.setProperties(processProps);
    }
    fillPartnerLinks(info, ((ProcessConfigurationImpl) pconf).getProcessDeploymentInfo());
}
Also used : DefinitionInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DefinitionInfo) BpelDefinition(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.BpelDefinition) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) OMElement(org.apache.axiom.om.OMElement) InstanceSummary(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InstanceSummary) Property_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Property_type0) ProcessProperty_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperty_type0) ProcessProperties(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperties) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) OMFactory(org.apache.axiom.om.OMFactory) DeploymentInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeploymentInfo) Map(java.util.Map)

Example 5 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method updateDeployInfo.

/*When a user modifies deploy info table they are updated in this method
    *
    * @param processDeployDetailsList
    *
    */
public void updateDeployInfo(ProcessDeployDetailsList_type0 processDeployDetailsListType) throws ProcessManagementException {
    final QName processId = processDeployDetailsListType.getProcessName();
    try {
        TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
        ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) tenantProcessStore.getProcessConfiguration(processId);
        final boolean oldIsInmemory = processConf.isTransient();
        final boolean newIsInmemory = processDeployDetailsListType.getIsInMemory();
        processConf.setState(getProcessState(processDeployDetailsListType));
        processConf.setIsTransient(newIsInmemory);
        processConf.setProcessEventsList(processDeployDetailsListType.getProcessEventsList());
        processConf.setGenerateType(processDeployDetailsListType.getProcessEventsList());
        processConf.setProcessCleanupConfImpl(processDeployDetailsListType.getCleanUpList());
        if (tenantProcessStore.getBPELPackageRepository() != null) {
            tenantProcessStore.getBPELPackageRepository().createPropertiesForUpdatedDeploymentInfo(processConf);
        }
        bpelServer.getODEBPELServer().getContexts().scheduler.execTransaction(new java.util.concurrent.Callable<Boolean>() {

            public Boolean call() throws Exception {
                ProcessDAO processDAO;
                ProcessDAO newProcessDAO;
                if (oldIsInmemory & !newIsInmemory) {
                    processDAO = bpelServer.getODEBPELServer().getContexts().getInMemDao().getConnection().getProcess(processId);
                    if (bpelServer.getODEBPELServer().getContexts().dao.getConnection().getProcess(processId) == null) {
                        newProcessDAO = bpelServer.getODEBPELServer().getContexts().dao.getConnection().createProcess(processDAO.getProcessId(), processDAO.getType(), processDAO.getGuid(), processDAO.getVersion());
                        Set<String> correlatorsSet = processDAO.getCorrelatorsSet();
                        for (String correlator : correlatorsSet) {
                            newProcessDAO.addCorrelator(correlator);
                        }
                    }
                } else if (!oldIsInmemory & newIsInmemory) {
                    QName pId = processId;
                    processDAO = bpelServer.getODEBPELServer().getContexts().dao.getConnection().getProcess(pId);
                    if (bpelServer.getODEBPELServer().getContexts().getInMemDao().getConnection().getProcess(pId) == null) {
                        newProcessDAO = bpelServer.getODEBPELServer().getContexts().getInMemDao().getConnection().createProcess(processDAO.getProcessId(), processDAO.getType(), processDAO.getGuid(), processDAO.getVersion());
                        Set<String> correlatorsSet = processDAO.getCorrelatorsSet();
                        for (String correlator : correlatorsSet) {
                            newProcessDAO.addCorrelator(correlator);
                        }
                    }
                }
                return true;
            }
        });
    } catch (Exception e) {
        String errMsg = "Error occurred while updating deployment info for: " + processId;
        log.error(errMsg, e);
        throw new ProcessManagementException(errMsg, e);
    }
}
Also used : Set(java.util.Set) QName(javax.xml.namespace.QName) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) XMLStreamException(javax.xml.stream.XMLStreamException) ParseException(java.text.ParseException) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) ProcessDAO(org.apache.ode.bpel.dao.ProcessDAO)

Aggregations

TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)16 QName (javax.xml.namespace.QName)6 ProcessConf (org.apache.ode.bpel.iapi.ProcessConf)5 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)5 Collection (java.util.Collection)4 InstanceFilter (org.apache.ode.bpel.common.InstanceFilter)4 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)4 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)4 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)4 BPELUIException (org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException)4 BPELPackageRepository (org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository)4 PackageManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException)4 Map (java.util.Map)3 ProcessNotFoundException (org.apache.ode.bpel.pmapi.ProcessNotFoundException)3 ProcessingException (org.apache.ode.bpel.pmapi.ProcessingException)3 ProcessConfigurationImpl (org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl)3 ProcessManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException)3 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2