}
public Map<String, ?> processOutput(InvocationContext invocationContext) throws ProviderException {
GlobusHostType host = (GlobusHostType) invocationContext.getExecutionDescription().getHost().getType();
ApplicationDeploymentDescriptionType app = invocationContext.getExecutionDescription().getApp().getType();
GridFtp ftp = new GridFtp();
File localStdErrFile = null;
try {
GSSCredential gssCred = gssContext.getGssCredentails();
String[] hostgridFTP = host.getGridFTPEndPointArray();
if (hostgridFTP == null || hostgridFTP.length == 0) {
hostgridFTP = new String[] { host.getHostAddress() };
}
ProviderException pe = null;
for (String endpoint : host.getGridFTPEndPointArray()) {
try {
/*
* Read Stdout and Stderror
*/
URI stdoutURI = GfacUtils.createGsiftpURI(endpoint, app.getStandardOutput());
URI stderrURI = GfacUtils.createGsiftpURI(endpoint, app.getStandardError());
log.info("STDOUT:" + stdoutURI.toString());
log.info("STDERR:" + stderrURI.toString());
File logDir = new File("./service_logs");
if (!logDir.exists()) {
logDir.mkdir();
}
String timeStampedServiceName = GfacUtils.createUniqueNameForService(invocationContext
.getServiceName());
File localStdOutFile = File.createTempFile(timeStampedServiceName, "stdout");
localStdErrFile = File.createTempFile(timeStampedServiceName, "stderr");
String stdout = ftp.readRemoteFile(stdoutURI, gssCred, localStdOutFile);
String stderr = ftp.readRemoteFile(stderrURI, gssCred, localStdErrFile);
Map<String,ActualParameter> stringMap = null;
MessageContext<Object> output = invocationContext.getOutput();
for (Iterator<String> iterator = output.getNames(); iterator.hasNext(); ) {
String paramName = iterator.next();
ActualParameter actualParameter = (ActualParameter) output.getValue(paramName);
if ("URIArray".equals(actualParameter.getType().getType().toString())) {
URI outputURI = GfacUtils.createGsiftpURI(endpoint,app.getOutputDataDirectory());
List<String> outputList = ftp.listDir(outputURI,gssCred);
String[] valueList = outputList.toArray(new String[outputList.size()]);
((URIArrayType) actualParameter.getType()).setValueArray(valueList);
stringMap = new HashMap<String, ActualParameter>();
stringMap.put(paramName, actualParameter);
invocationContext.getExecutionContext().getNotifier().output(invocationContext, actualParameter.toString());