WorkflowResult wfResult = null;
int count = 0;
List<DigitalObject> objects = new ArrayList<DigitalObject>();
log.trace(WorkflowTemplateHelper.overview(this));
String metadata;
DigitalObject tmpDo;
try {
for (DigitalObject dgo : this.getData()) {
metadata = null;
tmpDo = dgo;
log.info("Processing file #" + (count + 1));
try {
// Identify
String[] types = runIdentification(dgo, wfResult);
log.info(new Message("Identification", new Parameter("File", dgo.getTitle()), new Parameter(
"Result", Arrays.asList(types).toString())));
// Extract metadata - will otherwise get lost between steps!
List<Metadata> mList = dgo.getMetadata();
if ((mList != null) && (mList.size() > 0)) {
metadata = mList.get(0).getContent();
}
if (metadata == null) {
log.warn("No metadata contained in DigitalObject!");
} else {
log.info("Extracted metadata: " + metadata);
}
// Migrate
try {
FormatRegistry fr = FormatRegistryFactory.getFormatRegistry();
String ext = fr.getFirstExtension(new URI(types[0]));
log.info("Getting extension: " + ext);
if (ext != null) {
dgo = runMigrateService(dgo, fr.createExtensionUri(ext), wfResult);
dgo = new DigitalObject.Builder(dgo.getContent())
.title(tmpDo.getTitle().substring(0, tmpDo.getTitle().lastIndexOf(".")))
.build();
objects.add(dgo);
log.info(new Message("Migration", new Parameter("Input", ext), new Parameter("Result", dgo
.getTitle())));
}