//fine, is alreade written
}
//Execute the tool
final ProcessRunner toolProcessRunner = new ProcessRunner();
ServiceReport serviceReport = executeToolProcess(toolProcessRunner,
command, processStandardInput);
if (serviceReport.getType() == Type.ERROR) {
String message = "Failed migrating object with title '"
+ sourceObject.getTitle() + "' from format URI: "
+ sourceFormat + " to " + destinationFormat
+ " Standard output: "
+ toolProcessRunner.getProcessOutputAsString()
+ "\nStandard error output: "
+ toolProcessRunner.getProcessErrorAsString();
serviceReport = new ServiceReport(Type.ERROR,
Status.TOOL_ERROR, message);
return new MigrateResult(null, serviceReport);
}
//cleanup
if (migrationPath.useTempSourceFile()){
migrationPath.getTempSourceFile().getFile().delete();
}
for (TempFile tempFile : migrationPath.getTempFileDeclarations()) {
tempFile.getFile().delete();
}
//READING THE OUTPUT
//TODO return a reference to the outputfile
DigitalObject.Builder builder;
if (migrationPath.useTempDestinationFile()){
//we should read a temp file afterwards
File outputfile = migrationPath.getTempOutputFile().getFile();
if (returnByReference){
builder = new DigitalObject.Builder(Content.byReference(outputfile));
} else {
builder = new DigitalObject.Builder(Content.byValue(outputfile));
outputfile.delete();
}
String message = "Successfully migrated object with title '"
+ sourceObject.getTitle() + "' from format URI: "
+ sourceFormat + " to " + destinationFormat
+ " Standard output: "
+ toolProcessRunner.getProcessOutputAsString()
+ "\nStandard error output: "
+ toolProcessRunner.getProcessErrorAsString();
serviceReport = new ServiceReport(Type.INFO, Status.SUCCESS,
message);
} else {
if (returnByReference){
//we should read the output
builder = new DigitalObject.Builder(Content.byReference(toolProcessRunner.getProcessOutput()));
} else{
builder = new DigitalObject.Builder(Content.byValue(toolProcessRunner.getProcessOutput()));
}
String message = "Successfully migrated object with title '"
+ sourceObject.getTitle() + "' from format URI: "
+ sourceFormat + " to " + destinationFormat
+ " Standard error output: "
+ toolProcessRunner.getProcessErrorAsString();
serviceReport = new ServiceReport(Type.INFO, Status.SUCCESS,
message);
}