in taverna-robundle/src/main/java/org/apache/taverna/robundle/manifest/combine/CombineManifest.java [497:567]
public void readManifestXML() throws IOException {
Path manifestXml = manifestXmlPath(bundle);
OmexManifest omexManifest;
try (InputStream inStream = newInputStream(manifestXml)) {
InputSource src = new InputSource(inStream);
Source source = new SAXSource(src);
omexManifest = createUnMarshaller().unmarshal(source,
OmexManifest.class).getValue();
// omexManifest = (OmexManifest) createUnMarshaller().unmarshal(inStream);
} catch (JAXBException | ClassCastException e) {
// logger.warning("Could not parse " + manifestXml);
throw new IOException("Could not parse " + manifestXml, e);
}
if (!manifest.getManifest().contains(manifestXml))
manifest.getManifest().add(manifestXml);
for (Content c : omexManifest.getContent()) {
PathMetadata metadata;
if (c.getLocation().contains(":")) {
try {
URI uri = new URI(c.getLocation());
if (!uri.isAbsolute()) {
logger.warning("Not an absolute URI, but contains :"
+ c.getLocation());
continue;
}
metadata = manifest.getAggregation(uri);
} catch (URISyntaxException e) {
logger.warning("Invalid URI " + c.getLocation());
continue;
}
} else {
Path path = bundle.getRoot().resolve(c.getLocation());
if (Files.isSameFile(bundle.getRoot(), path)) {
// metadata about the archive itself
if (c.getFormat() != null && ! c.getFormat().isEmpty()) {
URI uri;
try {
uri = new URI(c.getFormat());
} catch (URISyntaxException e) {
logger.warning(MANIFEST_XML + " non-URI format for . expected http://identifiers.org/combine.specifications/omex");
continue;
}
if (! manifest.getConformsTo().contains(uri)) {
manifest.getConformsTo().add(uri);
}
}
// Don't add / to the list of aggregations in RO,
// as / is the RO itself!
continue;
}
if (!exists(path)) {
logger.warning(MANIFEST_XML + " listed relative path "
+ path + ", but it does not exist in bundle");
continue;
}
metadata = manifest.getAggregation(path);
}
// Format - is it an URI or media type?
if (c.getFormat().contains(":")) {
metadata.setConformsTo(URI.create(c.getFormat()));
} else if (!c.getFormat().isEmpty()) {
metadata.setMediatype(c.getFormat());
} else if (metadata.getFile() != null) {
metadata.setMediatype(manifest.guessMediaType(metadata
.getFile()));
} // else: Not needed for URIs
}
}