Examples of MigrateResult


Examples of eu.planets_project.services.migrate.MigrateResult

    @Test public void byReferenceToFile() { test(Content.byReference(file())); }
    @Test public void byReferenceToInputStream() { test(Content.byReference(stream)); }

    private void test(DigitalObjectContent content) {
        DigitalObject in = new DigitalObject.Builder(content).build();
        MigrateResult res = migrate.migrate(in, null, null, null);
        DigitalObject out = res.getDigitalObject();
        // We require the input and output object to be equal:
        Assert.assertEquals("Input and output objects must be equal", in, out);
    }
View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

             * expect one back:
             */
            DigitalObject input = new DigitalObject.Builder(Content.byReference(new URL("http://some"))).build();
            System.out.println("Input: " + input);

            MigrateResult mr = dom.migrate(input, null, null, null);
            DigitalObject doOut = mr.getDigitalObject();

            assertTrue("Resulting digital object is null.", doOut != null);

            System.out.println("Output: " + doOut);

View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

            factory.title(digitalObject.getTitle() + ".txt");
            // Unicode File format (UTF-16)
            factory.format(outputformatUnicode);
            final DigitalObject textObject = factory.build();

            return new MigrateResult(textObject, report);

        } catch (Exception e) {
            e.printStackTrace();
            return this.fail(new ServiceReport(Type.ERROR, Status.TOOL_ERROR, e
                    .toString()));
View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

            factory.title(digitalObject.getTitle() + ".html");
            // HTML 4.0 File format
            factory.format(outputformatHtml);
            DigitalObject htmlObject = factory.build();

            return new MigrateResult(htmlObject, report);

        } catch (Exception e) {
            log.severe(e.getClass().getName()+": "+e.getMessage());
            return this.fail(new ServiceReport(Type.ERROR, Status.TOOL_ERROR, e
                    .toString()));
View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

     * Handles the failure of a migration.
     * @param report Planets ServiceReport containing a status of the migration.
     * @return MigrateResult.
     */
    private MigrateResult fail(final ServiceReport report) {
        return new MigrateResult(null, report);
    }
View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

            URI outputformatUnicode = null;

            inputformatpdf = new URI("info:pronom/fmt/18");
            outputformatUnicode = new URI("info:pronom/x-fmt/16");

            final MigrateResult mr = dom.migrate(doInput, inputformatpdf,
                outputformatUnicode, null);
            final DigitalObject doOutput = mr.getDigitalObject();

            assertNotNull("Resulting digital object is null.", doOutput);

            System.out.println("Output" + doOutput);
View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

            URI outputformatHtmlUnicode = null;

            inputformatpdf = new URI("info:pronom/fmt/18");
            outputformatHtmlUnicode = new URI("info:pronom/fmt/99");

            final MigrateResult mr = dom.migrate(doInput, inputformatpdf,
                outputformatHtmlUnicode, null);
            final DigitalObject doOutput = mr.getDigitalObject();

            assertNotNull("Resulting digital object is null.", doOutput);

            System.out.println("Output" + doOutput);
View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

        // Record the endpoint of the service used for this stage.
        migrateStage.setEndpoint(migratorEndpoint);
       
        // Invoke the service, timing it along the way:
        boolean success = true;
        MigrateResult migrated = null;
        long msBefore = 0, msAfter = 0;
        URI from = null, to = null;
        msBefore = System.currentTimeMillis();
        try {
            log.info("Migrating "+dob);
            from = new URI(getFromFormat());
            to = new URI(getToFormat());
            migrated = migrator.migrate(dob, from, to, null);
        } catch( Exception e ) {
            success = false;
            e.printStackTrace();
            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?
        throw new Exception("Migration failed.  No Digital Object was created. "+migrated.getReport().getMessage());
       
        // FIXME Add a 'toString' on the report that makes a text summary of the whole state?
       
    }
View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

                        AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo.png")
                .toURI().toURL())).build();
        System.out.println("Input: " + input);

        FormatRegistry format = FormatRegistryFactory.getFormatRegistry();
        MigrateResult mr = dom.migrate(input, format.createExtensionUri("png"),
                format.createExtensionUri( newExt ), 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());

        File out = new File("src/test/results/test."+newExt);

        FileOutputStream fo = new FileOutputStream(out);
        IOUtils.copyLarge( doOut.getContent().getInputStream(), fo);
        fo.close();

        System.out.println("Recieved service report: " + mr.getReport() );
        System.out.println("Recieved service properties: " );
        ServiceProperties.printProperties(System.out, mr.getReport().getProperties());
       
        // TODO Test that the output looks okay. How?

    }
View Full Code Here

Examples of eu.planets_project.services.migrate.MigrateResult

            return this.returnWithErrorMessage("Could not write the Image. ",e);
        }
       
        ServiceReport rep = new ServiceReport(Type.INFO, Status.SUCCESS, "OK", sph.getPerformanceProperties());
        DigitalObject ndo = new DigitalObject.Builder(Content.byValue(bytes)).build();
        return new MigrateResult( ndo, rep );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.