use of org.apache.ode.bpel.iapi.ProcessConf in project carbon-business-process by wso2.
the class AxisServiceUtils method createAxisServiceBuilder.
private static WSDL11ToAxisServiceBuilder createAxisServiceBuilder(BPELProcessProxy processProxy) throws AxisFault {
Definition wsdlDef = processProxy.getWsdlDefinition();
QName serviceName = processProxy.getServiceName();
String portName = processProxy.getPort();
ProcessConf pConf = processProxy.getProcessConfiguration();
QName pid = pConf.getProcessId();
InputStream wsdlInStream = null;
URI wsdlBaseURI = pConf.getBaseURI().resolve(wsdlDef.getDocumentBaseURI());
try {
wsdlInStream = wsdlBaseURI.toURL().openStream();
} catch (MalformedURLException e) {
String errMsg = "Malformed WSDL base URI.";
handleException(pid, errMsg, e);
} catch (IOException e) {
String errMsg = "Error opening stream.";
handleException(pid, errMsg, e);
}
WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisPatchedBuilder(wsdlInStream, serviceName, portName);
serviceBuilder.setBaseUri(wsdlBaseURI.toString());
serviceBuilder.setCustomResolver(new Axis2UriResolver());
try {
serviceBuilder.setCustomWSDLResolver(new Axis2WSDLLocator(wsdlBaseURI));
} catch (URISyntaxException e) {
String errorMessage = "URI syntax invalid.";
handleException(pid, errorMessage, e);
}
serviceBuilder.setServerSide(true);
return serviceBuilder;
}
use of org.apache.ode.bpel.iapi.ProcessConf in project carbon-business-process by wso2.
the class AxisServiceUtils method createAxisService.
/**
* Build the underlying Axis Service from Service QName and Port Name of interest using given WSDL
* for BPEL document.
* In the current implementation we are extracting service name from the soap:address' location property.
* But specified port may not contain soap:adress instead it may contains http:address. We need to handle that
* situation.
*
* @param axisConfiguration AxisConfiguration to which we should publish the service
* @param processProxy BPELProcessProxy
* @return Axis Service build using WSDL, Service and Port
* @throws org.apache.axis2.AxisFault on error
*/
public static AxisService createAxisService(AxisConfiguration axisConfiguration, BPELProcessProxy processProxy) throws AxisFault {
QName serviceName = processProxy.getServiceName();
String portName = processProxy.getPort();
Definition wsdlDefinition = processProxy.getWsdlDefinition();
ProcessConf processConfiguration = processProxy.getProcessConfiguration();
if (log.isDebugEnabled()) {
log.debug("Creating AxisService: Service=" + serviceName + " port=" + portName + " WSDL=" + wsdlDefinition.getDocumentBaseURI() + " BPEL=" + processConfiguration.getBpelDocument());
}
WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(processProxy);
/**
* Need to figure out a way to handle service name extractoin. According to my perspective extracting
* the service name from the EPR is not a good decision. But we need to handle JMS case properly.
* I am keeping JMS handling untouched until we figureout best solution.
*/
/* String axisServiceName = extractServiceName(processConf, wsdlServiceName, portName);*/
AxisService axisService = populateAxisService(processProxy, axisConfiguration, serviceBuilder);
Iterator operations = axisService.getOperations();
BPELMessageReceiver messageRec = new BPELMessageReceiver();
/**
* Set the corresponding BPELService to message receivers
*/
messageRec.setProcessProxy(processProxy);
while (operations.hasNext()) {
AxisOperation operation = (AxisOperation) operations.next();
// Setting WSDLAwareMessage Receiver even if operation has a message receiver specified.
// This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
// is set to operations).
operation.setMessageReceiver(messageRec);
axisConfiguration.getPhasesInfo().setOperationPhases(operation);
}
/**
* TODO: JMS Destination handling.
*/
return axisService;
}
use of org.apache.ode.bpel.iapi.ProcessConf 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;
}
use of org.apache.ode.bpel.iapi.ProcessConf 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.apache.ode.bpel.iapi.ProcessConf in project carbon-business-process by wso2.
the class ProcessManagementServiceSkeleton method processQuery.
/**
* Query processes based on a {@link org.apache.ode.bpel.common.ProcessFilter} criteria. This is
* implemented in memory rather than via database calls since the processes
* are managed by the {@link org.apache.ode.bpel.iapi.ProcessStore} object and we don't want to make
* this needlessly complicated.
*
* @param filter process filter
* @param tenantsProcessStore Current Tenant's process store
* @return ProcessConf collection
* @throws ProcessManagementException if an error occurred while processing query
*/
private Collection<ProcessConf> processQuery(ProcessFilter filter, TenantProcessStoreImpl tenantsProcessStore) throws ProcessManagementException {
Map<QName, ProcessConfigurationImpl> processes = tenantsProcessStore.getProcessConfigMap();
if (log.isDebugEnabled()) {
for (Map.Entry<QName, ProcessConfigurationImpl> process : processes.entrySet()) {
log.debug("Process " + process.getKey() + " in state " + process.getValue());
}
}
Set<QName> pids = processes.keySet();
// Name filter can be implemented using only the PIDs.
if (filter != null && filter.getNameFilter() != null) {
// adding escape sequences to [\^$.|?*+(){} characters
String nameFilter = filter.getNameFilter().replace("\\", "\\\\").replace("]", "\\]").replace("[", "\\[").replace("^", "\\^").replace("$", "\\$").replace("|", "\\|").replace("?", "\\?").replace(".", "\\.").replace("+", "\\+").replace("(", "\\(").replace(")", "\\)").replace("{", "\\{").replace("}", "\\}").replace("*", ".*");
final Pattern pattern = Pattern.compile(nameFilter + "(-\\d*)?");
CollectionsX.remove_if(pids, new MemberOfFunction<QName>() {
@Override
public boolean isMember(QName o) {
return !pattern.matcher(o.getLocalPart()).matches();
}
});
}
if (filter != null && filter.getNamespaceFilter() != null) {
// adding escape sequences to [\^$.|?*+(){} characters
String namespaceFilter = filter.getNamespaceFilter().replace("\\", "\\\\").replace("]", "\\]").replace("[", "\\[").replace("^", "\\^").replace("$", "\\$").replace("|", "\\|").replace("?", "\\?").replace(".", "\\.").replace("+", "\\+").replace("(", "\\(").replace(")", "\\)").replace("{", "\\{").replace("}", "\\}").replace("*", ".*");
final Pattern pattern = Pattern.compile(namespaceFilter);
CollectionsX.remove_if(pids, new MemberOfFunction<QName>() {
@Override
public boolean isMember(QName o) {
String ns = o.getNamespaceURI() == null ? "" : o.getNamespaceURI();
return !pattern.matcher(ns).matches();
}
});
}
// Now we need the process conf objects, we need to be
// careful since someone could have deleted them by now
List<ProcessConf> confs = new LinkedList<ProcessConf>();
for (QName pid : pids) {
ProcessConf pConf = tenantsProcessStore.getProcessConfiguration(pid);
if (pConf != null) {
confs.add(pConf);
}
}
if (filter != null) {
// Specific filter for deployment date.
if (filter.getDeployedDateFilter() != null) {
for (final String ddf : filter.getDeployedDateFilter()) {
final Date dd;
try {
dd = ISO8601DateParser.parse(Filter.getDateWithoutOp(ddf));
} catch (ParseException e) {
// Should never happen.
String errMsg = "Exception while parsing date";
log.error(errMsg, e);
throw new ProcessManagementException(errMsg, e);
}
CollectionsX.remove_if(confs, new MemberOfFunction<ProcessConf>() {
@Override
public boolean isMember(ProcessConf o) {
if (ddf.startsWith("=")) {
return !o.getDeployDate().equals(dd);
}
if (ddf.startsWith("<=")) {
return o.getDeployDate().getTime() > dd.getTime();
}
if (ddf.startsWith(">=")) {
return o.getDeployDate().getTime() < dd.getTime();
}
if (ddf.startsWith("<")) {
return o.getDeployDate().getTime() >= dd.getTime();
}
return ddf.startsWith(">") && (o.getDeployDate().getTime() <= dd.getTime());
}
});
}
}
// Ordering
if (filter.getOrders() != null) {
ComparatorChain cChain = new ComparatorChain();
for (String key : filter.getOrders()) {
boolean ascending = true;
String orderKey = key;
if (key.startsWith("+") || key.startsWith("-")) {
orderKey = key.substring(1, key.length());
if (key.startsWith("-")) {
ascending = false;
}
}
Comparator c;
if ("name".equals(orderKey)) {
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
return o1.getProcessId().getLocalPart().compareTo(o2.getProcessId().getLocalPart());
}
};
} else if ("namespace".equals(orderKey)) {
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
String ns1 = o1.getProcessId().getNamespaceURI() == null ? "" : o1.getProcessId().getNamespaceURI();
String ns2 = o2.getProcessId().getNamespaceURI() == null ? "" : o2.getProcessId().getNamespaceURI();
return ns1.compareTo(ns2);
}
};
} else if ("version".equals(orderKey)) {
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
return (int) (o1.getVersion() - o2.getVersion());
}
};
} else if ("deployed".equals(orderKey)) {
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
return o1.getDeployDate().compareTo(o2.getDeployDate());
}
};
} else if ("status".equals(orderKey)) {
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
return o1.getState().compareTo(o2.getState());
}
};
} else {
// unrecognized
if (log.isDebugEnabled()) {
log.debug("unrecognized order key" + orderKey);
}
continue;
}
cChain.addComparator(c, !ascending);
}
Collections.sort(confs, cChain);
}
}
return confs;
}
Aggregations