/** * @param inFile * @param outFile * @param inExt * @param outExt * @throws IOException */ private void doMigrate(String inFile, String outFile, String inExt, String outExt) throws IOException { DigitalObject input = new DigitalObject.Builder(Content.byReference(new File(inFile).toURI().toURL())) .permanentUri(URI.create("http://some")) .build(); System.out.println("Input: " + input); FormatRegistry format = FormatRegistryFactory.getFormatRegistry(); MigrateResult mr = dom.migrate( input, format.createExtensionUri(inExt), format.createExtensionUri(outExt), null); ServiceReport sr = mr.getReport(); System.out.println("Got Report: " + sr); DigitalObject doOut = mr.getDigitalObject(); assertTrue("Resulting digital object is null.", doOut != null); System.out.println("Output: " + doOut); System.out.println("Output.content: " + doOut.getContent()); System.out.println( "Output.content.read().available(): " + doOut.getContent().getInputStream().available()); File out = new File(outFile); writeInStreamToOutStream(doOut.getContent().getInputStream(), new FileOutputStream(out)); }
/** * The default constructor. * * @param processingTemplate: The template that's calling the wrapper * @param pedigreeDigo: The migration processes pedigree's root element a migration roundtripp was * started from. * @param migrationService: The migration service that's being called * @param digOToMigrate: The digitalObject that's being migrated * @param dataRepositoryID: a 'planets://' scheme based repository identifier for storing the * created migration results if null - the default repository will be used * @param endOfRoundtripp: an indicator triggering the 'finalMigrationResult' flag in the logs */ public MigrationWFWrapper( WorkflowTemplate processingTemplate, URI pedigreeDigoRef, Migrate migrationService, URI digOToMigrateRef, URI dataRepositoryID, boolean endOfRoundtripp) { this.wfi = processingTemplate; this.pedigreeDigoRef = pedigreeDigoRef; this.migrationService = migrationService; this.digOToMigrateRef = digOToMigrateRef; this.endOfRoundtripp = endOfRoundtripp; this.dataRepositoryID = dataRepositoryID; this.dataRegistry = DataRegistryFactory.getDataRegistry(); MigrationWFWrapper.fr = FormatRegistryFactory.getFormatRegistry(); }