airavataAPI.getApplicationManager().getApplicationDescription(serviceName, registeredHost.getType().getHostName());
// When we run getInParameters we set the actualParameter object, this has to be fixed
URL resource = EmbeddedGFacInvoker.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
OMElement inputMessage = getInParameters();
Object wsifMessageElement = new WSIFMessageElement(XMLUtil.stringToXmlElement3(inputMessage.toStringWithConsume()));
this.notifier.invokingService(new WSIFMessageElement((XmlElement) wsifMessageElement));
Properties configurationProperties = ServerSettings.getProperties();
GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()), airavataAPI, configurationProperties);
JobExecutionContext jobExecutionContext = new JobExecutionContext(gFacConfiguration, serviceName);
//Here we get only the contextheader information sent specific for this node
//Add security context
//FIXME - We no longer using job execution context
// jobExecutionContext.setContextHeader(WorkflowContextHeaderBuilder.removeOtherSchedulingConfig(nodeID, configuration.getContextHeader()));
jobExecutionContext.setProperty(Constants.PROP_WORKFLOW_NODE_ID, this.nodeID);
jobExecutionContext.setProperty(Constants.PROP_TOPIC, this.configuration.getTopic());
jobExecutionContext.setProperty(Constants.PROP_BROKER_URL, this.configuration.getBrokerURL().toASCIIString());
jobExecutionContext.setProperty(Constants.PROP_WORKFLOW_INSTANCE_ID, this.configuration.getTopic());
ApplicationContext applicationContext = new ApplicationContext();
applicationContext.setApplicationDeploymentDescription(applicationDescription);
applicationContext.setHostDescription(registeredHost);
applicationContext.setServiceDescription(serviceDescription);
jobExecutionContext.setApplicationContext(applicationContext);
jobExecutionContext.setOutMessageContext(getOutParameters(serviceDescription));
jobExecutionContext.setInMessageContext(new MessageContext(actualParameters));
addSecurityContext(registeredHost, configurationProperties, jobExecutionContext,
configuration.getContextHeader());
GFacImpl gfacAPI1 = new GFacImpl();
gfacAPI1.submitJob(jobExecutionContext);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2/xsd", "ns1");
OMElement outputElement = fac.createOMElement("invokeResponse", omNs);
MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
Set<String> paramNames = outMessageContext.getParameters().keySet();
for (String paramName : paramNames) {
/*
* Process Output
*/
String outputString = ((ActualParameter) outMessageContext.getParameter(paramName)).toXML().replaceAll("GFacParameter", paramName);
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(outputString));
StAXOMBuilder builder = new StAXOMBuilder(reader);
outputElement.addChild(builder.getDocumentElement());
}
// Send notification
logger.debug("outputMessage: " + outputElement.toString());
outPut = new WSIFMessageElement(XMLUtil.stringToXmlElement3(outputElement.toStringWithConsume()));
this.result = true;
EmbeddedGFacInvoker.this.notifier.serviceFinished(new WSIFMessageElement((XmlElement) outPut));
//todo check whether ActualParameter values are set or not, if they are null have to through an error or handle this in gfac level.
// {
// // An implementation of WSIFMessage,
// // WSIFMessageElement, implements toString(), which
// // serialize the message XML.