throw new Exception ("Service Invocation Failed! : " + e.getMessage() );
}
msAfter = System.currentTimeMillis();
// Compute the run time.
stage_m.add( new MeasurementImpl(TecRegMockup.PROP_SERVICE_TIME, ""+((msAfter-msBefore)/1000.0)) );
// Add the object size:
stage_m.add( new MeasurementImpl(TecRegMockup.PROP_DO_SIZE, ""+IdentifyWorkflow.getContentSize(dob) ) );
// Now record
if( success && migrated.getDigitalObject() != null ) {
stage_m.add( new MeasurementImpl( TecRegMockup.PROP_SERVICE_EXECUTION_SUCEEDED, "true"));
// Take the digital object, put it in a temp file, and give it a sensible name, using the new format extension.
File doTmp = File.createTempFile("migrateResult", ".tmp");
doTmp.deleteOnExit();
DigitalObjectUtils.toFile(migrated.getDigitalObject(), doTmp);
DigitalObject.Builder newdob = new DigitalObject.Builder(migrated.getDigitalObject());
newdob.content( Content.byReference(doTmp) );
// FIXME The above need to be a full recursive storage operation!
if( to != null ) {
//Format f = new Format(to);
Set<String> extensionsTo = ServiceBrowser.fr.getExtensions(to);
String title = dob.getTitle();
if(extensionsTo.iterator().hasNext()){
title += "."+extensionsTo.iterator().next();
}
title = title.substring( title.lastIndexOf("/") + 1);
newdob.title( title );
}
wr.setResult(newdob.build());
wr.setResultType(WorkflowResult.RESULT_DIGITAL_OBJECT);
wr.logReport(migrated.getReport());
log.info("Migration succeeded.");
return;
}
// Only get to here if there was not a valid result.
// Build in a 'service failed' property, i.e. the call worked, but no result.
stage_m.add( new MeasurementImpl( TecRegMockup.PROP_SERVICE_EXECUTION_SUCEEDED, "false"));
// ADD a report, so the full set is known.
wr.logReport(migrated.getReport());
// FIXME Should now throw an Exception, as the WF cannot proceed?