public DefaultInvocationContext gridJobSubmit(JobContext jobContext,GFacConfiguration gfacConfig,String workflowNodeId,String workflowInstanceId) throws Exception {
WorkflowTrackingNotification workflowNotification = new WorkflowTrackingNotification(jobContext.getBrokerURL(),
jobContext.getTopic(),workflowNodeId,workflowInstanceId);
LoggingNotification loggingNotification = new LoggingNotification();
DefaultInvocationContext invocationContext = new DefaultInvocationContext();
invocationContext.setExecutionContext(new DefaultExecutionContext());
invocationContext.setServiceName(jobContext.getServiceName());
invocationContext.getExecutionContext().setRegistryService(gfacConfig.getAiravataAPI());
invocationContext.getExecutionContext().addNotifiable(workflowNotification);
invocationContext.getExecutionContext().addNotifiable(loggingNotification);
GSISecurityContext gssContext = new GSISecurityContext();
// if (gridMyproxyRepository == null) {
gssContext.setMyproxyPasswd(gfacConfig.getMyProxyPassphrase());
gssContext.setMyproxyUserName(gfacConfig.getMyProxyUser());
gssContext.setMyproxyLifetime(gfacConfig.getMyProxyLifeCycle());
gssContext.setMyproxyServer(gfacConfig.getMyProxyServer());
// } else {
// gssContext.setMyproxyPasswd(gridMyproxyRepository.getPassword());
// gssContext.setMyproxyUserName(gridMyproxyRepository.getUsername());
// gssContext.setMyproxyLifetime(gridMyproxyRepository.getLifeTimeInhours());
// gssContext.setMyproxyServer(gridMyproxyRepository.getMyproxyServer());
// }
gssContext.setTrustedCertLoc(gfacConfig.getTrustedCertLocation());
invocationContext.addSecurityContext("myproxy", gssContext);
/*
* Add workflow context
*/
ServiceDescription serviceDescription = gfacConfig.getAiravataAPI().getApplicationManager().getServiceDescription(jobContext.getServiceName());
if(serviceDescription==null){
throw new RegistryException(new Exception("Service Description not found in registry."));
}
ServiceDescriptionType serviceDescriptionType = serviceDescription.getType();
ParameterContextImpl inputParam = new ParameterContextImpl();
WorkflowContextImpl workflowContext = new WorkflowContextImpl();
workflowContext.setValue(WorkflowContextImpl.WORKFLOW_ID, URI.create(jobContext.getTopic()).toString());
invocationContext.addMessageContext(WorkflowContextImpl.WORKFLOW_CONTEXT_NAME, workflowContext);
for(Parameter parameter:jobContext.getParameters().keySet()){
inputParam.add(parameter.getParameterName(), jobContext.getParameters().get(parameter));
}
/*
* Output
*/
ParameterContextImpl outputParam = new ParameterContextImpl();
// List<Parameter> outputs = serviceDescription.getOutputParameters();
for (OutputParameterType parameter : serviceDescriptionType.getOutputParametersArray()) {
ActualParameter actualParameter = new ActualParameter();
if ("String".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(StringParameterType.type);
} else if ("Double".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(DoubleParameterType.type);
} else if ("Integer".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(IntegerParameterType.type);
} else if ("Float".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(FloatParameterType.type);
} else if ("Boolean".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(BooleanParameterType.type);
} else if ("File".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(FileParameterType.type);
} else if ("URI".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(URIParameterType.type);
} else if ("StringArray".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(StringArrayType.type);
} else if ("DoubleArray".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(DoubleArrayType.type);
} else if ("IntegerArray".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(IntegerArrayType.type);
} else if ("FloatArray".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(FloatArrayType.type);
} else if ("BooleanArray".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(BooleanArrayType.type);
} else if ("FileArray".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(FileArrayType.type);
} else if ("URIArray".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(URIArrayType.type);
} else if ("StdOut".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(StdOutParameterType.type);
} else if ("StdErr".equals(parameter.getParameterType().getName())) {
actualParameter.getType().changeType(StdErrParameterType.type);
}
outputParam.add(parameter.getParameterName(), actualParameter);
}
invocationContext.setInput(inputParam);
invocationContext.setOutput(outputParam);
GenericService service = new PropertyServiceFactory(GfacAPI.REPOSITORY_PROPERTIES).createService();
service.execute(invocationContext);
return invocationContext;
}