SecurityContextDocument parse =
SecurityContextDocument.Factory.parse(getHeader(messageContext).getFirstChildWithName
(new QName("http://schemas.airavata.apache.org/workflow-execution-context", "security-context")).toStringWithConsume());
SecurityContextDocument.SecurityContext.GridMyproxyRepository gridMyproxyRepository = parse.getSecurityContext().getGridMyproxyRepository();
OMElement header = getHeader(messageContext);
ContextHeaderDocument document = null;
try {
document = ContextHeaderDocument.Factory.parse(header.toStringWithConsume());
} catch (XMLStreamException e) {
e.printStackTrace();
} catch (XmlException e) {
e.printStackTrace();
}
//Set the WorkflowContext Header to the ThreadLocal of the Gfac Service, so that this can be accessed easilly
WorkflowContextHeaderBuilder.setCurrentContextHeader(document.getContextHeader());
Map<Parameter,ActualParameter> actualParameters = new LinkedHashMap<Parameter,ActualParameter>();
ServiceDescription serviceDescription = getRegistry(context).getServiceDescription(serviceName);
ServiceDescriptionType serviceDescriptionType = serviceDescription.getType();
for (Parameter parameter : serviceDescriptionType.getInputParametersArray()) {
OMElement element = input.getFirstChildWithName(new QName(null,parameter.getParameterName().replaceAll(WSDLConstants.HYPHEN, WSDLConstants.HYPHEN_REPLACEMENT)));
if(element == null){
element = input.getFirstChildWithName(new QName(GFacSchemaConstants.GFAC_NAMESPACE,parameter.getParameterName().replaceAll(WSDLConstants.HYPHEN, WSDLConstants.HYPHEN_REPLACEMENT)));
}
if (element == null) {
throw new Exception("Parameter is not found in the message");
}
//todo this implementation doesn't work when there are n number of nodes connecting .. need to fix
actualParameters.put(parameter, GfacUtils.getInputActualParameter(parameter, element));
}
DefaultInvocationContext invocationContext = null;
JobContext jobContext = new JobContext(actualParameters,topic,serviceName,brokerURL);
if(document.getContextHeader().getSecurityContext().getAmazonWebservices() != null){
// invocationContext.getExecutionContext().setSecurityContextHeader(header);
//todo if there's amazoneWebServices context we need to set that value, this will refer in EC2Provider
}else{
invocationContext = gfacAPI.gridJobSubmit(jobContext,(GFacConfiguration)context.getProperty(GFacService.GFAC_CONFIGURATION));
}