}
private void handleWSComponent(Node node) throws XBayaException {
WSComponent wsComponent = ((WSComponent) node.getComponent());
QName portTypeQName = wsComponent.getPortTypeQName();
Invoker invoker = this.invokerMap.get(node);
// We do this because invokers cannot be cached because the puretls
// expires
if (invoker != null) {
this.invokerMap.remove(invoker);
}
final WSNode wsNode = (WSNode) node;
String wsdlLocation = InterpreterUtil.getEPR(wsNode);
final String gfacURLString = this.configuration.getGFacURL().toString();
if (null == wsdlLocation) {
if (gfacURLString.startsWith("https")) {
GSSCredential proxy = null;
if (this.mode == GUI_MODE) {
this.myProxyChecker.loadIfNecessary();
MyProxyClient myProxyClient = this.engine
.getMyProxyClient();
proxy = myProxyClient.getProxy();
} else {
proxy = SecurityUtil.getGSSCredential(this.username,
this.password,
this.configuration.getMyProxyServer());
}
LeadContextHeader leadCtxHeader = null;
try {
if (this.mode == GUI_MODE) {
leadCtxHeader = XBayaUtil.buildLeadContextHeader(
this.getWorkflow(),
this.configuration,
new MonitorConfiguration(this.configuration
.getBrokerURL(), this.topic, true,
this.configuration.getMessageBoxURL()),
wsNode.getID(), null);
} else {
leadCtxHeader = XBayaUtil.buildLeadContextHeader(
this.getWorkflow(),
this.configuration,
new MonitorConfiguration(this.configuration
.getBrokerURL(), this.topic, true,
this.configuration.getMessageBoxURL()),
wsNode.getID(), null);
}
} catch (URISyntaxException e) {
throw new XBayaException(e);
}
leadCtxHeader.setServiceId(node.getID());
try {
leadCtxHeader.setWorkflowId(new URI(this.getWorkflow()
.getName()));
// We do this so that the wsdl resolver can is setup
// wsdlresolver.getInstance is static so once this is
// done
// rest of the loading should work.
XBayaSecurity.init();
} catch (URISyntaxException e) {
throw new XBayaRuntimeException(e);
}
/*
* Resource Mapping Header
*/
if (this.resourceMapping != null) {
leadCtxHeader.setResourceMapping(this.resourceMapping);
}
/*
* If there is a instance control component connects to this
* component send information in soap header
*/
for (Node n : wsNode.getControlInPort().getFromNodes()) {
if (n instanceof InstanceNode) {
// TODO make it as constant
LeadResourceMapping x = new LeadResourceMapping(
"AMAZON");
x.addAttribute("ACCESS_KEY", AmazonCredential
.getInstance().getAwsAccessKeyId());
x.addAttribute("SECRET_KEY", AmazonCredential
.getInstance().getAwsSecretAccessKey());
if (((InstanceNode) n).isStartNewInstance()) {
x.addAttribute("AMI_ID",
((InstanceNode) n).getIdAsValue());
x.addAttribute("INS_TYPE",
((InstanceNode) n).getInstanceType());
} else {
x.addAttribute("INS_ID",
((InstanceNode) n).getIdAsValue());
}
x.addAttribute("USERNAME",
((InstanceNode) n).getUsername());
// set to leadHeader
leadCtxHeader.setResourceMapping(x);
}
}
invoker = new WorkflowInvokerWrapperForGFacInvoker(
portTypeQName, gfacURLString, this.engine.getMonitor()
.getConfiguration().getMessageBoxURL()
.toString(), leadCtxHeader,
this.notifier.createServiceNotificationSender(node
.getID()));
} else {
if (this.mode == GUI_MODE) {
// if user configure the msgBox url using the UI we have to
// pick the latest one which
// set by the UI
if (this.gfacEmbeddedMode) {
invoker = new EmbeddedGFacInvoker(portTypeQName,
WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode
.getComponent().getWSDL()), node.getID(),
this.engine.getMonitor().getConfiguration()
.getMessageBoxURL().toASCIIString(),
this.engine.getMonitor().getConfiguration().getBrokerURL().toASCIIString(), this.notifier, this.topic,
this.engine.getConfiguration().getJcrComponentRegistry().getRegistry(),
portTypeQName.getLocalPart(),this.engine.getConfiguration());
} else {
invoker = new GenericInvoker(portTypeQName,
WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode
.getComponent().getWSDL()), node.getID(),
this.engine.getMonitor().getConfiguration()
.getMessageBoxURL().toASCIIString(),
gfacURLString, this.notifier);
}
} else {
if(this.gfacEmbeddedMode){
invoker = new EmbeddedGFacInvoker(portTypeQName,
WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode
.getComponent().getWSDL()), node.getID(),
this.configuration.getMessageBoxURL()
.toASCIIString(),
this.configuration.getBrokerURL().toASCIIString(), this.notifier, this.topic, configuration.getJcrComponentRegistry().getRegistry(),
portTypeQName.getLocalPart(),this.configuration);
}else{
invoker = new GenericInvoker(portTypeQName,
WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode
.getComponent().getWSDL()), node.getID(),
this.configuration.getMessageBoxURL()
.toASCIIString(), gfacURLString,
this.notifier);
}
}
}
} else {
if (wsdlLocation.endsWith("/")) {
wsdlLocation = wsdlLocation.substring(0,
wsdlLocation.length() - 1);
}
if (!wsdlLocation.endsWith("?wsdl")) {
wsdlLocation += "?wsdl";
}
invoker = new GenericInvoker(portTypeQName, wsdlLocation,
node.getID(), this.configuration.getMessageBoxURL()
.toString(), gfacURLString, this.notifier);
}
invoker.setup();
this.invokerMap.put(node, invoker);
invoker.setOperation(wsComponent.getOperationName());
// find inputs
List<DataPort> inputPorts = node.getInputPorts();
ODEClient odeClient = new ODEClient();
for (DataPort port : inputPorts) {
Object inputVal = InterpreterUtil.findInputFromPort(port,
this.invokerMap);
/*
* Need to override inputValue if it is odeClient
*/
if (port.getFromNode() instanceof InputNode) {
inputVal = ODEClientUtil.parseValue(
(WSComponentPort) port.getComponentPort(),
(String) inputVal);
}
if (null == inputVal) {
throw new WorkFlowInterpreterException(
"Unable to find inputs for the node:" + node.getID());
}
if (port.getFromNode() instanceof EndForEachNode) {
inputVal = ODEClientUtil.parseValue(
(WSComponentPort) port.getComponentPort(),
(String) inputVal);
// org.xmlpull.v1.builder.XmlElement inputElem = XMLUtil
// .stringToXmlElement3("<" + port.getName() + ">"
// + inputVal.toString() + "</" + port.getName()
// + ">");
// inputVal = inputElem;
}
invoker.setInput(port.getName(), inputVal);
}
invoker.invoke();
}