in taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/local/LocalToolInvocation.java [127:193]
private String setOneBinaryInput(ReferenceService referenceService,
T2Reference t2Reference, ScriptInput input, String targetSuffix)
throws InvocationException {
if (input.isFile() || input.isTempFile()) {
// Try to get it as a file
String target = tempDir.getAbsolutePath() + "/" + targetSuffix;
FileReference fileRef = getAsFileReference(referenceService,
t2Reference);
if (fileRef != null) {
if (!input.isForceCopy()) {
if (linkCommand != null) {
String source = fileRef.getFile().getAbsolutePath();
String actualLinkCommand = getActualOsCommand(
linkCommand, source, targetSuffix, target);
logger.info("Link command is " + actualLinkCommand);
String[] splitCmds = actualLinkCommand.split(" ");
ProcessBuilder builder = new ProcessBuilder(splitCmds);
builder.directory(tempDir);
try {
int code = builder.start().waitFor();
if (code == 0) {
return target;
} else {
logger.error("Link command gave errorcode: "
+ code);
}
} catch (InterruptedException e) {
// go through
} catch (IOException e) {
// go through
}
}
}
}
InputStream is = null;
OutputStream os = null;
is = getAsStream(referenceService, t2Reference);
try {
os = new FileOutputStream(target);
} catch (FileNotFoundException e) {
throw new InvocationException(e);
}
try {
IOUtils.copyLarge(is, os);
} catch (IOException e) {
throw new InvocationException(e);
}
try {
is.close();
os.close();
} catch (IOException e) {
throw new InvocationException(e);
}
return target;
} else {
String value = (String) referenceService.renderIdentifier(
t2Reference, String.class, this.getContext());
return value;
}
}