use of org.apache.ode.bpel.dd.TInvoke in project carbon-business-process by wso2.
the class ProcessConfigurationImpl method readPackageConfiguration.
private void readPackageConfiguration() {
File depDir = du.getDeployDir();
/*
Read Endpoint Config for invokes
*/
List<TDeployment.Process> processList = du.getDeploymentDescriptor().getDeploy().getProcessList();
for (TDeployment.Process process : processList) {
List<TInvoke> tInvokeList = process.getInvokeList();
for (TInvoke tInvoke : tInvokeList) {
OMElement serviceEle;
if (tInvoke.getService() == null) {
String errMsg = "Service element missing for the invoke element in deploy.xml";
log.error(errMsg);
throw new BPELDeploymentException(errMsg);
}
try {
serviceEle = AXIOMUtil.stringToOM(tInvoke.getService().toString());
OMElement endpointEle = serviceEle.getFirstElement();
if (endpointEle == null || !endpointEle.getQName().equals(new QName(BusinessProcessConstants.BPEL_PKG_ENDPOINT_CONFIG_NS, BusinessProcessConstants.ENDPOINT))) {
continue;
}
EndpointConfiguration epConf = EndpointConfigBuilder.buildEndpointConfiguration(endpointEle, depDir.getAbsolutePath());
epConf.setServiceName(tInvoke.getService().getName().getLocalPart());
epConf.setServiceNS(tInvoke.getService().getName().getNamespaceURI());
epConf.setServicePort(tInvoke.getService().getPort());
bpelPackageConfiguration.addEndpoint(epConf);
} catch (XMLStreamException e) {
log.warn("Error occurred while reading endpoint configuration. " + "Endpoint config will not be applied to: " + tInvoke.getService());
}
}
List<TProvide> tProvideList = process.getProvideList();
for (TProvide tProvide : tProvideList) {
OMElement serviceEle;
if (tProvide.getService() == null) {
String errMsg = "Service element missing for the provide element in deploy.xml";
log.error(errMsg);
throw new BPELDeploymentException(errMsg);
}
try {
serviceEle = AXIOMUtil.stringToOM(tProvide.getService().toString());
OMElement endpointEle = serviceEle.getFirstElement();
if (endpointEle == null || !endpointEle.getQName().equals(new QName(BusinessProcessConstants.BPEL_PKG_ENDPOINT_CONFIG_NS, BusinessProcessConstants.ENDPOINT))) {
continue;
}
EndpointConfiguration epConf = EndpointConfigBuilder.buildEndpointConfiguration(endpointEle, depDir.getAbsolutePath());
epConf.setServiceName(tProvide.getService().getName().getLocalPart());
epConf.setServiceNS(tProvide.getService().getName().getNamespaceURI());
epConf.setServicePort(tProvide.getService().getPort());
bpelPackageConfiguration.addEndpoint(epConf);
} catch (XMLStreamException e) {
log.warn("Error occured while reading endpoint configuration. " + "Endpoint config will not be applied to: " + tProvide.getService());
}
}
}
}
use of org.apache.ode.bpel.dd.TInvoke in project carbon-business-process by wso2.
the class BPELUploadExecutor method validateBPELPackage.
public void validateBPELPackage(String directoryPath) throws Exception {
DeploymentUnitDir du;
try {
du = new DeploymentUnitDir(new File(directoryPath));
} catch (IllegalArgumentException iae) {
log.error("BPEL Package Validation Failure.", iae);
throw new Exception("BPEL Package Validation Failure.", iae);
}
// check package for illegal charactors which registry does not support. (~!@#$;%^*()+={}[]|\<>)
List<File> packageFiles = du.allFiles();
for (File packageFile : packageFiles) {
if (!packageFile.getName().matches("[^\\~\\!\\@\\#\\$\\;\\%\\^\\*\\(\\)\\+ " + "/\\=\\{\\}\\[\\]\\\\|\\<\\>\"\\'\\`]+")) {
log.error("BPEL Package Validation Failure: one or many of the following illegal characters are in " + "the package.\n ~!@#$;%^*()+={}[]| \\<>\"'`");
throw new Exception("BPEL Package Validation Failure: one or many of the following illegal characters" + " " + "are in the package. ~!@#$;%^*()+={}[]| \\<>\"'`");
}
}
try {
du.compile();
} catch (RuntimeException ce) {
log.error("BPEL Process Compilation Failure.", ce);
throw new Exception("BPEL Compilation Failure!", ce);
} catch (Exception e) {
log.error("BPEL Process Compilation Failure.", e);
throw new Exception("BPEL Compilation Failure!", e);
}
du.scan();
DeployDocument dd = du.getDeploymentDescriptor();
for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
QName processType = processDD.getType() != null ? processDD.getType() : processDD.getName();
DeploymentUnitDir.CBPInfo cbpInfo = du.getCBPInfo(processType);
if (cbpInfo == null) {
// removeDeploymentArtifacts(deploymentContext, du);
String logMessage = "Aborting deployment. Cannot find Process definition for type " + processType + ".";
log.error(logMessage);
throw new Exception(logMessage);
}
for (TProvide tProvide : processDD.getProvideList()) {
if (tProvide.getService() == null) {
String errMsg = "Service element missing for the provide element in deploy.xml";
log.error(errMsg);
throw new Exception(errMsg);
}
}
for (TInvoke tInvoke : processDD.getInvokeList()) {
if (tInvoke.getService() == null) {
String errMsg = "Service element missing for the invoke element in deploy.xml";
log.error(errMsg);
throw new Exception(errMsg);
}
}
}
}
use of org.apache.ode.bpel.dd.TInvoke in project carbon-business-process by wso2.
the class PeopleActivity method deriveServiceEPR.
private void deriveServiceEPR(DeploymentUnitDir du, ExtensionContext extensionContext) throws FaultException {
DeployDocument deployDocument = du.getDeploymentDescriptor();
BpelRuntimeContext runTimeContext = extensionContext.getInternalInstance();
// TODO neeed to extend ExtentionContext
OProcess oProcess = runTimeContext.getProcessModel();
TDeployment.Process hiProcess = null;
List<TDeployment.Process> processList = deployDocument.getDeploy().getProcessList();
for (TDeployment.Process process : processList) {
if (process.getName().equals(oProcess.getQName())) {
hiProcess = process;
break;
}
}
if (hiProcess == null) {
throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Related process: " + oProcess.getQName() + " not found");
}
List<TInvoke> tInvokeList = hiProcess.getInvokeList();
for (TInvoke tInvoke : tInvokeList) {
if (tInvoke.getPartnerLink().equals(partnerLinkName)) {
serviceName = tInvoke.getService().getName();
servicePort = tInvoke.getService().getPort();
break;
}
}
if (serviceName == null || servicePort == null) {
log.error("service and port for human interaction is not found in the deploy.xml");
throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service or port for human interaction is not found in the deploy.xml");
}
// get the callback information for the TASK
if (activityType.equals(InteractionType.TASK)) {
List<TProvide> tProvideList = hiProcess.getProvideList();
for (TProvide tProvide : tProvideList) {
if (tProvide.getPartnerLink().equals(partnerLinkName)) {
callbackServiceName = tProvide.getService().getName();
callbackServicePort = tProvide.getService().getPort();
break;
}
}
if (callbackServiceName == null || callbackServicePort == null) {
throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service or port for human task callback is not found in the deploy.xml");
}
}
hiWSDL = du.getDefinitionForService(serviceName);
Service service = hiWSDL.getService(serviceName);
Port port = service.getPort(servicePort);
List extList = port.getExtensibilityElements();
for (Object extEle : extList) {
if (extEle instanceof SOAPAddressImpl) {
SOAPAddressImpl soapAddress = (SOAPAddressImpl) extEle;
serviceURI = soapAddress.getLocationURI();
break;
}
}
if (serviceURI == null) {
throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service URI is not available");
}
}
use of org.apache.ode.bpel.dd.TInvoke 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.dd.TInvoke in project carbon-business-process by wso2.
the class ProcessConfigurationImpl method initPartnerLinks.
/**
* Initialize partner link details of the BPEL process. Details about partner link's service and
* port is in the deploy.xml file. This can be used to initialize partner links information in
* registry. After that we can co-relate this partner links with carbon endpoints. This will
* help us to dynamically configure endpoint properties like security, RM.
*/
private void initPartnerLinks() {
if (processInfo.getInvokeList() != null) {
for (TInvoke invoke : processInfo.getInvokeList()) {
String plinkName = invoke.getPartnerLink();
TService service = invoke.getService();
// configure this value
if (service == null) {
continue;
}
if (log.isDebugEnabled()) {
log.debug("Processing <invoke> element for process " + processInfo.getName() + ": partnerlink" + plinkName + " -->" + service);
}
QName serviceName = service.getName();
/* Validating configuration with package content before putting partner role endpoints to map */
Definition wsdlDef = getDefinitionForService(serviceName);
if (wsdlDef == null) {
String errMsg = "Cannot find WSDL definition for invoke service " + serviceName + ". Required resources not found in the BPEL package " + du.getName() + ".";
log.error(errMsg);
throw new ContextException(errMsg);
}
Service serviceDef = wsdlDef.getService(serviceName);
if (serviceDef.getPort(service.getPort()) == null) {
String errMsg = "Cannot find port for invoking service for the given name " + serviceName + ". Error in deploy.xml.";
log.error(errMsg);
throw new ContextException(errMsg);
}
partnerRoleInitialValues.put(plinkName, new Endpoint(service.getName(), service.getPort()));
// TODO add proper variable names
{
OFailureHandling g = null;
if (invoke.isSetFailureHandling()) {
FailureHandlingDocument.FailureHandling fh = invoke.getFailureHandling();
g = new OFailureHandling();
if (fh.isSetFaultOnFailure()) {
g.faultOnFailure = fh.getFaultOnFailure();
}
if (fh.isSetRetryDelay()) {
g.retryDelay = fh.getRetryDelay();
}
if (fh.isSetRetryFor()) {
g.retryFor = fh.getRetryFor();
}
}
PartnerRoleConfig c = new PartnerRoleConfig(g, invoke.getUsePeer2Peer());
if (log.isDebugEnabled()) {
log.debug("PartnerRoleConfig for " + plinkName + " " + c.failureHandling + " usePeer2Peer: " + c.usePeer2Peer);
}
partnerRoleConfigurations.put(plinkName, c);
}
}
}
if (processInfo.getProvideList() != null) {
for (TProvide proivde : processInfo.getProvideList()) {
String plinkName = proivde.getPartnerLink();
TService service = proivde.getService();
if (proivde.getCorrelationFilter() != null) {
if (B4P_NAMESPACE.equals(proivde.getCorrelationFilter().getNamespaceURI())) {
isB4PTaskIncluded = true;
}
}
/* NOTE:Service cannot be null for provider partner link*/
if (service == null) {
String errorMsg = "Error in <provide> element for process " + processInfo.getName() + ";partnerlink" + plinkName + "did not identify an endpoint";
log.error(errorMsg);
throw new ContextException(errorMsg);
}
if (log.isDebugEnabled()) {
log.debug("Processing <provide> element for process " + processInfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort());
}
QName serviceName = service.getName();
/* Validating configuration with package content before putting myRole endpoints to map */
Definition wsdlDef = getDefinitionForService(serviceName);
if (wsdlDef == null) {
String errMsg = "Cannot find WSDL definition for provide service " + serviceName + ". Required resources not found in the BPEL " + "package " + du.getName() + ".";
log.error(errMsg);
throw new ContextException(errMsg);
}
Service serviceDef = wsdlDef.getService(serviceName);
if (serviceDef.getPort(service.getPort()) == null) {
String errMsg = "Cannot find provide port in the given service " + serviceName + ". Error in deploy.xml.";
log.error(errMsg);
throw new ContextException(errMsg);
}
myRoleEndpoints.put(plinkName, new Endpoint(service.getName(), service.getPort()));
if (proivde.isSetEnableSharing()) {
sharedServices.add(service.getName());
}
}
}
}
Aggregations