use of org.mycore.datamodel.ifs.MCRFile in project mycore by MyCoRe-Org.
the class MCRTransferPackage method getContent.
/**
* Returns the content for this transfer package. You have to call {@link #build()}
* before you can retrieve this data.
*
* @return a map where key = filename; value = MCRContent
*/
public Map<String, MCRContent> getContent() throws IOException {
Map<String, MCRContent> content = new HashMap<>();
// config
content.put(IMPORT_CONFIG_FILENAME, new MCRJDOMContent(buildImportConfiguration()));
// objects
for (MCRObject object : this.objects) {
String fileName = CONTENT_PATH + object.getId() + ".xml";
Document xml = object.createXML();
content.put(fileName, new MCRJDOMContent(xml));
}
// file containers
for (MCRTransferPackageFileContainer fc : this.fileContainers) {
// derivate
MCRObjectID derivateId = fc.getDerivateId();
MCRDerivate derivate = MCRMetadataManager.retrieveMCRDerivate(derivateId);
Document derivateXML = derivate.createXML();
String folder = CONTENT_PATH + fc.getName();
String derivateFileName = folder + "/" + fc.getName() + ".xml";
content.put(derivateFileName, new MCRJDOMContent(derivateXML));
// files of derivate
for (MCRFile file : fc.getFiles()) {
content.put(folder + file.getAbsolutePath(), file.getContent());
}
}
// classifications
for (String classId : this.classifications) {
Document classification = MCRClassificationUtils.asDocument(classId);
String path = CLASS_PATH + classId + ".xml";
content.put(path, new MCRJDOMContent(classification));
}
return content;
}
Aggregations