Search in sources :

Example 41 with Node

use of org.wso2.charon3.core.utils.codeutils.Node in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method getProcessDeploymentInfo.

/* The methods gets data from ProcessConfigurationImpl and display the details
    *  @param  pid
    *  @return processDeployDetailsList
    *
    */
public ProcessDeployDetailsList_type0 getProcessDeploymentInfo(QName pid) {
    /* Configuring process basic information*/
    ProcessDeployDetailsList processDeployDetailsList = new ProcessDeployDetailsList();
    ProcessDeployDetailsList_type0 processDeployDetailsListType = new ProcessDeployDetailsList_type0();
    TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
    ProcessConf processConf = tenantProcessStore.getProcessConfiguration(pid);
    ProcessConfigurationImpl processConfiguration = (ProcessConfigurationImpl) processConf;
    QName processId = processConfiguration.getProcessId();
    processDeployDetailsListType.setProcessName(processId);
    ProcessStatus processStatus = ProcessStatus.Factory.fromValue(processConfiguration.getState().name());
    processDeployDetailsListType.setProcessState(processStatus);
    processDeployDetailsListType.setIsInMemory(processConfiguration.isTransient());
    /* Configuring invoked services by the process*/
    List<TInvoke> invokeList = processConfiguration.getInvokedServices();
    if (invokeList != null) {
        InvokeServiceListType ist = new InvokeServiceListType();
        for (TInvoke invoke : invokeList) {
            InvokedServiceType invokedServiceType = new InvokedServiceType();
            Service_type1 service = new Service_type1();
            service.setName(invoke.getService().getName());
            service.setPort(invoke.getService().getPort());
            invokedServiceType.setService(service);
            invokedServiceType.setPartnerLink(invoke.getPartnerLink());
            ist.addInvokedService(invokedServiceType);
            processDeployDetailsListType.setInvokeServiceList(ist);
        }
    }
    /* Configuring providing services by the process*/
    List<TProvide> provideList = processConfiguration.getProvidedServices();
    if (provideList != null) {
        ProvideServiceListType pst = new ProvideServiceListType();
        for (TProvide provide : provideList) {
            ProvidedServiceType providedServiceType = new ProvidedServiceType();
            Service_type0 service = new Service_type0();
            service.setName(provide.getService().getName());
            service.setPort(provide.getService().getPort());
            providedServiceType.setService(service);
            providedServiceType.setPartnerLink(provide.getPartnerLink());
            pst.addProvidedService(providedServiceType);
        }
        processDeployDetailsListType.setProvideServiceList(pst);
    }
    /* Configuring message exchange interceptors of the process*/
    MexInterpreterListType mxt = new MexInterpreterListType();
    List<String> mexInterceptor = processConfiguration.getMexInterceptors();
    if (mexInterceptor != null) {
        for (String mexInt : mexInterceptor) {
            mxt.addMexinterpreter(mexInt);
        }
    }
    processDeployDetailsListType.setMexInterperterList(mxt);
    /* Configuring process level and scope level enabled events of process*/
    Map<String, Set<BpelEvent.TYPE>> eventsMap = processConfiguration.getEvents();
    ProcessEventsListType processEventsListType = new ProcessEventsListType();
    EnableEventListType enableEventListType = new EnableEventListType();
    ScopeEventListType scopeEventListType = new ScopeEventListType();
    for (Map.Entry<String, Set<BpelEvent.TYPE>> eventEntry : eventsMap.entrySet()) {
        if (eventEntry.getKey() != null) {
            ScopeEventType scopeEvent = new ScopeEventType();
            String scopeName = eventEntry.getKey();
            EnableEventListType enableEventList = new EnableEventListType();
            Set<BpelEvent.TYPE> typeSetforScope = eventEntry.getValue();
            for (BpelEvent.TYPE type : typeSetforScope) {
                enableEventList.addEnableEvent(type.toString());
            }
            scopeEvent.setScope(scopeName);
            scopeEvent.setEnabledEventList(enableEventList);
            scopeEventListType.addScopeEvent(scopeEvent);
        } else {
            Set<BpelEvent.TYPE> typeSet = eventEntry.getValue();
            for (BpelEvent.TYPE aTypeSet : typeSet) {
                enableEventListType.addEnableEvent(aTypeSet.toString());
            }
        }
    }
    TProcessEvents.Generate.Enum genEnum = processConfiguration.getGenerateType();
    if (genEnum != null) {
        Generate_type1 generate = Generate_type1.Factory.fromValue(genEnum.toString());
        processEventsListType.setGenerate(generate);
    }
    processEventsListType.setEnableEventsList(enableEventListType);
    processEventsListType.setScopeEventsList(scopeEventListType);
    processDeployDetailsListType.setProcessEventsList(processEventsListType);
    // end of process events
    /* configuring properties defined in the process */
    PropertyListType propertyListType = new PropertyListType();
    Map<QName, Node> propertiesMap = processConfiguration.getProcessProperties();
    Set<Map.Entry<QName, Node>> entries = propertiesMap.entrySet();
    for (Map.Entry entry : entries) {
        ProcessProperty_type0 property = new ProcessProperty_type0();
        property.setName((QName) entry.getKey());
        Node node = (Node) entry.getValue();
        property.setValue(DOMUtils.domToStringLevel2(node));
        propertyListType.addProcessProperty(property);
    }
    processDeployDetailsListType.setPropertyList(propertyListType);
    CleanUpListType cleanUpList = new CleanUpListType();
    Set<ProcessConf.CLEANUP_CATEGORY> sucessTypeCleanups = processConfiguration.getCleanupCategories(true);
    Set<ProcessConf.CLEANUP_CATEGORY> failureTypeCleanups = processConfiguration.getCleanupCategories(false);
    if (sucessTypeCleanups != null) {
        CleanUpType cleanUp = new CleanUpType();
        On_type1 onType = On_type1.success;
        cleanUp.setOn(onType);
        CategoryListType categoryListType = new CategoryListType();
        for (ProcessConf.CLEANUP_CATEGORY sCategory : sucessTypeCleanups) {
            Category_type1 categoryType1 = Category_type1.Factory.fromValue(sCategory.name().toLowerCase());
            categoryListType.addCategory(categoryType1);
        }
        cleanUp.setCategoryList(categoryListType);
        cleanUpList.addCleanUp(cleanUp);
    }
    if (failureTypeCleanups != null) {
        CleanUpType cleanUp = new CleanUpType();
        On_type1 onType = On_type1.failure;
        cleanUp.setOn(onType);
        CategoryListType categoryListType = new CategoryListType();
        for (ProcessConf.CLEANUP_CATEGORY fCategory : failureTypeCleanups) {
            Category_type1 categoryType1 = Category_type1.Factory.fromValue(fCategory.name().toLowerCase());
            categoryListType.addCategory(categoryType1);
        }
        cleanUp.setCategoryList(categoryListType);
        cleanUpList.addCleanUp(cleanUp);
    }
    processDeployDetailsListType.setCleanUpList(cleanUpList);
    processDeployDetailsList.setProcessDeployDetailsList(processDeployDetailsListType);
    return processDeployDetailsListType;
}
Also used : ProcessEventsListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessEventsListType) Node(org.w3c.dom.Node) CleanUpType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CleanUpType) TInvoke(org.apache.ode.bpel.dd.TInvoke) ScopeEventListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ScopeEventListType) CleanUpListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CleanUpListType) InvokedServiceType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InvokedServiceType) TProvide(org.apache.ode.bpel.dd.TProvide) EnableEventListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EnableEventListType) Category_type1(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Category_type1) InvokeServiceListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InvokeServiceListType) MexInterpreterListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.MexInterpreterListType) Map(java.util.Map) Set(java.util.Set) ProcessStatus(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessStatus) ProvidedServiceType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProvidedServiceType) BpelEvent(org.apache.ode.bpel.evt.BpelEvent) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl) ScopeEventType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ScopeEventType) On_type1(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.On_type1) QName(javax.xml.namespace.QName) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) PropertyListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PropertyListType) ProcessDeployDetailsList(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessDeployDetailsList) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) ProvideServiceListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProvideServiceListType) Generate_type1(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Generate_type1) CategoryListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CategoryListType) ProcessDeployDetailsList_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessDeployDetailsList_type0) Service_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Service_type0) Service_type1(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Service_type1) ProcessProperty_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperty_type0)

Example 42 with Node

use of org.wso2.charon3.core.utils.codeutils.Node in project carbon-business-process by wso2.

the class BPMNDeployer method isWorkerNode.

/**
 * Whether a bps node is worker ( a node that does not participate in archive deployment and only handles
 * input/output . This is determined by looking at the registry read/only property
 * @return
 */
private boolean isWorkerNode() {
    RegistryService registryService = BPMNServerHolder.getInstance().getRegistryService();
    boolean isWorker = true;
    try {
        isWorker = (registryService.getConfigSystemRegistry().getRegistryContext().isReadOnly());
    } catch (RegistryException e) {
        log.error("Error accessing the configuration registry");
    }
    return isWorker;
}
Also used : RegistryService(org.wso2.carbon.registry.core.service.RegistryService) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Example 43 with Node

use of org.wso2.charon3.core.utils.codeutils.Node in project carbon-business-process by wso2.

the class HumanTaskStore method reloadExistingTaskVersions.

/**
 * Reload existing task versions for a given deployment unit
 * @param existingDeploymentUnitsForPackage
 * @param archiveFile
 * @param md5sum
 * @throws HumanTaskDeploymentException
 */
public void reloadExistingTaskVersions(List<DeploymentUnitDAO> existingDeploymentUnitsForPackage, File archiveFile, String md5sum, boolean isMasterServer) throws Exception {
    // deployment units list should not be null, having a safety check anyway
    if (existingDeploymentUnitsForPackage == null) {
        return;
    }
    if (log.isDebugEnabled()) {
        log.debug("Reloading existing task versions for human task archive [ " + archiveFile.getName() + "]");
    }
    for (DeploymentUnitDAO dao : existingDeploymentUnitsForPackage) {
        if (!isMasterServer) {
            // We need to avoid deployment of already loaded packages
            String versionedName = dao.getName();
            List<QName> qNames = taskConfigurationsInTaskPackage.get(versionedName);
            if (qNames != null && qNames.size() > 0) {
                // This dao is already loaded
                if (log.isDebugEnabled()) {
                    log.debug("This is already loaded package, skipping " + versionedName);
                }
                continue;
            }
        }
        try {
            File taskDirectory = findHumanTaskPackageInFileSystem(dao, archiveFile);
            ArchiveBasedHumanTaskDeploymentUnitBuilder deploymentUnitBuilder = null;
            if (log.isDebugEnabled()) {
                log.debug("Loading task : " + dao.getName());
            }
            if (taskDirectory.exists()) {
                // This is an existing task configuration
                deploymentUnitBuilder = new ArchiveBasedHumanTaskDeploymentUnitBuilder(taskDirectory, tenantId, dao.getVersion(), dao.getPackageName(), dao.getChecksum());
            } else if (dao.getStatus() == TaskPackageStatus.ACTIVE) {
                // This node is a salve node and task is being reloaded or new version has been deployed on master
                deploymentUnitBuilder = new ArchiveBasedHumanTaskDeploymentUnitBuilder(archiveFile, tenantId, dao.getVersion(), md5sum);
            } else {
                String errMsg = "Error loading task. Cannot find the task directory for retired task " + dao.getName();
                log.error(errMsg);
                throw new HumanTaskDeploymentException(errMsg);
            }
            // Check whether this is a new version deployment on a slave node
            if (!isMasterServer && dao.getStatus() == TaskPackageStatus.ACTIVE) {
                String currentDeployedVersion = loadedPackages.get(dao.getPackageName());
                if (currentDeployedVersion != null && currentDeployedVersion.equals(dao.getName()) == false) {
                    // This is a new version on the salve node  , retire the existing version
                    retireTaskPackageConfigurations(currentDeployedVersion);
                }
            }
            HumanTaskDeploymentUnit taskDeploymentUnit = deploymentUnitBuilder.createNewHumanTaskDeploymentUnit();
            taskDeploymentUnit.setTaskPackageStatus(dao.getStatus());
            deploy(taskDeploymentUnit);
            if (dao.getStatus() == TaskPackageStatus.ACTIVE) {
                // Add the active package to the loaded packages
                loadedPackages.put(dao.getPackageName(), dao.getName());
            }
        } catch (HumanTaskDeploymentException e) {
            String errMsg = "Error loading the task configuration ";
            log.error(errMsg, e);
            throw e;
        }
    }
}
Also used : DeploymentUnitDAO(org.wso2.carbon.humantask.core.dao.DeploymentUnitDAO) QName(javax.xml.namespace.QName) ArchiveBasedHumanTaskDeploymentUnitBuilder(org.wso2.carbon.humantask.core.deployment.ArchiveBasedHumanTaskDeploymentUnitBuilder) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) File(java.io.File) HumanTaskDeploymentUnit(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit)

Example 44 with Node

use of org.wso2.charon3.core.utils.codeutils.Node in project carbon-business-process by wso2.

the class XPathExpressionRuntime method evaluateAsPart.

/**
 * Evaluate the expression returns an OMElement
 *
 * @param exp      Expresion
 * @param partName Name of the part
 * @param evalCtx  EvaluationContext
 * @return Part as an Node
 */
@Override
public Node evaluateAsPart(String exp, String partName, EvaluationContext evalCtx) {
    Document document = DOMUtils.newDocument();
    Node node = document.createElement(partName);
    List<Node> nodeList = evaluate(exp, evalCtx);
    if (nodeList.size() == 0) {
        String errMsg = "0 nodes selected for the expression: " + exp;
        log.error(errMsg);
        throw new HumanTaskRuntimeException(errMsg);
    } else if (nodeList.size() > 1) {
        String errMsg = "More than one nodes are selected for the expression: " + exp;
        log.error(errMsg);
        throw new HumanTaskRuntimeException(errMsg);
    }
    Node partNode = nodeList.get(0);
    replaceElement((Element) node, (Element) partNode);
    return node;
}
Also used : HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 45 with Node

use of org.wso2.charon3.core.utils.codeutils.Node in project carbon-business-process by wso2.

the class CommonTaskUtil method setTaskOverrideContextAttributes.

public static void setTaskOverrideContextAttributes(TaskDAO task, Map<String, Element> headerElements) {
    // TODO fix this for remaining properties.
    try {
        if (headerElements != null) {
            Element contextRequest = headerElements.get(HumanTaskConstants.HT_CONTEXT_REQUEST);
            if (contextRequest != null) {
                if (!TaskType.NOTIFICATION.equals(task.getType())) {
                    // Notification can't be skipped.
                    NodeList nodeList = contextRequest.getElementsByTagNameNS(HumanTaskConstants.HT_CONTEXT_NAMESPACE, HumanTaskConstants.HT_CONTEXT_IS_SKIPABLE);
                    if (nodeList != null && nodeList.getLength() > 0) {
                        Node isSkipable = nodeList.item(0);
                        task.setSkipable(Boolean.parseBoolean(isSkipable.getTextContent()));
                    }
                }
                NodeList nodeList = contextRequest.getElementsByTagNameNS(HumanTaskConstants.HT_CONTEXT_NAMESPACE, HumanTaskConstants.HT_CONTEXT_PRIORITY);
                if (nodeList != null && nodeList.getLength() > 0) {
                    Node priority = nodeList.item(0);
                    task.setPriority(Integer.parseInt(priority.getTextContent()));
                }
            }
        }
    } catch (Exception e) {
        log.error("Error while setting override attributes to task", e);
    }
}
Also used : Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Aggregations

ArrayList (java.util.ArrayList)19 Node (org.w3c.dom.Node)13 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)13 BLangRecordLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral)13 List (java.util.List)12 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)11 Map (java.util.Map)10 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)10 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)10 QName (javax.xml.namespace.QName)8 NodeList (org.w3c.dom.NodeList)8 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)8 Name (org.wso2.ballerinalang.compiler.util.Name)8 Arrays (java.util.Arrays)7 HashMap (java.util.HashMap)7 AnnotationAttachmentNode (org.ballerinalang.model.tree.AnnotationAttachmentNode)7 Node (org.ballerinalang.model.tree.Node)7 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)7 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)7 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)7