in taverna-execution-local/src/main/java/org/apache/taverna/platform/execution/impl/local/LocalExecutionMonitor.java [425:487]
public void convertReferenceToPath(Path path, T2Reference reference,
InvocationContext context) throws IOException, URISyntaxException {
ReferenceService referenceService = context.getReferenceService();
if (reference.getReferenceType() == T2ReferenceType.ReferenceSet) {
if (DataBundles.isMissing(path)) {
ReferenceSet rs = referenceService.getReferenceSetService()
.getReferenceSet(reference);
if (rs == null)
throw new ReferenceServiceException(
"Could not find ReferenceSet " + reference);
// Check that there are references in the set
if (rs.getExternalReferences().isEmpty())
throw new ReferenceServiceException("ReferenceSet "
+ reference + " is empty");
for (ExternalReferenceSPI ers : rs.getExternalReferences()) {
if (ers instanceof FileReference) {
URI uri = ((FileReference) ers).getFile().toURI();
DataBundles.setReference(path, uri);
} else if (ers instanceof HttpReference) {
URI uri = ((HttpReference) ers).getHttpUrl().toURI();
DataBundles.setReference(path, uri);
} else {
try (InputStream in = ers.openStream(context)) {
Files.copy(in, path);
}
}
}
}
} else if (reference.getReferenceType() == T2ReferenceType.ErrorDocument) {
if (DataBundles.isMissing(path)) {
ErrorDocument errorDocument = referenceService
.getErrorDocumentService().getError(reference);
String message = errorDocument.getMessage();
StringBuilder trace = new StringBuilder();
if (errorDocument.getExceptionMessage() != null
&& !errorDocument.getExceptionMessage().isEmpty()) {
trace.append(errorDocument.getExceptionMessage());
trace.append("\n");
}
List<StackTraceElementBean> stackTraceStrings = errorDocument
.getStackTraceStrings();
for (StackTraceElementBean stackTraceElement : stackTraceStrings) {
trace.append(getStackTraceElementString(stackTraceElement));
trace.append("\n");
}
List<Path> causes = new ArrayList<>();
for (T2Reference errorReference : errorDocument
.getErrorReferences())
causes.add(getIntermediate(errorReference, context));
DataBundles.setError(path, message, trace.toString(),
causes.toArray(new Path[causes.size()]));
}
} else { // it is an IdentifiedList<T2Reference>
IdentifiedList<T2Reference> identifiedList = referenceService
.getListService().getList(reference);
if (!DataBundles.isList(path))
DataBundles.createList(path);
for (T2Reference ref : identifiedList)
convertReferenceToPath(DataBundles.newListItem(path), ref,
context);
}
}