in taverna-scufl2-ucfpackage/src/main/java/org/apache/taverna/scufl2/ucfpackage/UCFPackage.java [460:504]
public void setRootFile(String path, String version) {
ResourceEntry rootFile = getResourceEntry(path);
if (rootFile == null)
throw new IllegalArgumentException("Unknown resource: " + path);
odfPackage.getManifestEntries().get(path).setVersion(version);
Container container = containerXml.getValue();
RootFiles rootFiles = getRootFiles(container);
String mediaType = rootFile.getMediaType();
boolean foundExisting = false;
// Check any existing files for matching path/mime type
Iterator<Object> anyOrRootIt = rootFiles.getAnyOrRootFile().iterator();
while (anyOrRootIt.hasNext()) {
Object anyOrRoot = anyOrRootIt.next();
if (anyOrRoot instanceof JAXBElement)
anyOrRoot = ((JAXBElement) anyOrRoot).getValue();
if (!(anyOrRoot instanceof RootFile))
continue;
RootFile rootFileElem = (RootFile) anyOrRoot;
if (!rootFileElem.getFullPath().equals(path)
&& !rootFileElem.getMediaType().equals(mediaType))
// Different path and media type - ignore
continue;
if (foundExisting) {
// Duplicate path/media type, we'll remove it
anyOrRootIt.remove();
continue;
}
rootFileElem.setFullPath(rootFile.getPath());
if (mediaType != null)
rootFileElem.setMediaType(mediaType);
foundExisting = true;
}
if (!foundExisting) {
RootFile rootFileElem = containerFactory.createRootFile();
rootFileElem.setFullPath(rootFile.getPath());
rootFileElem.setMediaType(mediaType);
rootFiles.getAnyOrRootFile().add(
containerFactory
.createContainerRootFilesRootFile(rootFileElem));
// rootFiles.getAnyOrRootFile().add(rootFileElem);
}
}