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;
}
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;
}
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;
}
}
}
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;
}
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);
}
}
Aggregations