Package eu.planets_project.services.identify

Examples of eu.planets_project.services.identify.IdentifyResult


     * @see eu.planets_project.services.validate.BasicValidateOneBinary#basicValidateOneBinary(byte[],
     *      java.net.URI)
     */
    private boolean basicValidateOneBinary(final DigitalObject digitalObject,
            final URI fmt) {
        IdentifyResult identify = identify(digitalObject);
        /* And check it it is what we expected: */
        for (URI uri : identify.getTypes()) {
            if (uri != null && uri.equals(fmt)) {
                /* One of the identified types is the one we expected: */
                return true;
            }
        }
View Full Code Here


    }

    private IdentifyResult identify(final DigitalObject digitalObject) {
        /* Identify the binary: */
        JhoveIdentification identification = new JhoveIdentification();
        IdentifyResult identify = identification.identify(digitalObject, null);
        return identify;
    }
View Full Code Here

        /* Given these, we can instantiate our object: */
        DigitalObject object = new DigitalObject.Builder(c1).permanentUri(purl)
                .build();

        /* Now pass this to the service */
        IdentifyResult ir = ids.identify(object, null);

        /* Check the result */
        System.out.println("Recieved type: " + ir.getTypes());
        System.out.println("Recieved service report: " + ir.getReport());
        assertEquals("The returned type did not match the expected;", type, ir
                .getTypes().get(0));

    }
View Full Code Here

                    "Could not identify " + file.getAbsolutePath()
                            + " (is the required Jhove module installed?)");
        } else {
            report = new ServiceReport(Type.INFO, Status.SUCCESS, status);
        }
        return new IdentifyResult(types, null, report);
    }
View Full Code Here

            Iterator<QName> ports = service.getPorts();
            while( ports.hasNext() ) {
                System.out.println("Got : "+ports.next());
            }
            Identify droid = (Identify) service.getPort( Identify.class );
            IdentifyResult result = droid.identify(new DigitalObject.Builder(
                    Content.byValue(new File("PC/droid/src/resources/Licence.rtf"))).build(), null);
            System.out.println("Result: "+result.getTypes());
            System.exit(1);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
View Full Code Here

        // Now prepare the result:
        List<MeasurementImpl> stage_m = stage.getMeasurements();
       
        // Invoke the service, timing it along the way:
        boolean success = true;
        IdentifyResult result = null;
        long msBefore = 0, msAfter = 0;
        msBefore = System.currentTimeMillis();
        try {
            log.info("Identifying "+dob);
            result = identify.identify(dob,null);
            wr.logReport(result.getReport());
        } catch( Exception e ) {
            log.error("Identification failed with exception: "+e);
            e.printStackTrace();
            success = false;
        }
        msAfter = System.currentTimeMillis();
        if( success ) {
            log.info("Identification succeeded: "+result);
            if( result != null ) {
                // URGENT Formalise and refactor this logic.
                log.info("Service Report: "+result.getReport().getMessage());
                log.info("Service Report: "+result.getReport().getStatus());
                log.info("Service Report: "+result.getReport().getType());
                if( result.getReport().getStatus() == Status.INSTALLATION_ERROR
                        || result.getReport().getStatus() == Status.TOOL_ERROR ) {
                    success = false;
                }
            }
        }
       
View Full Code Here

    public WorkflowResult execute( DigitalObject dob ) {

        // Invoke the service, timing it along the way:
        boolean success = true;
        String exceptionReport = "";
        IdentifyResult identify = null;
        long msBefore = 0, msAfter = 0;
        msBefore = System.currentTimeMillis();
        try {
            identify = identifier.identify(dob,null);
        } catch( Exception e ) {
            success = false;
            exceptionReport = "<p>Service Invocation Failed!<br/>" + e + "</p>";
        }
        msAfter = System.currentTimeMillis();

        // Now prepare the result:
        WorkflowResult wr = new WorkflowResult();
       
        // Record this one-stage experiment:
        ExecutionStageRecordImpl idStage = new ExecutionStageRecordImpl(null, STAGE_IDENTIFY);
        wr.getStages().add( idStage );
       
        // Record the endpoint of the service used for this stage.  FIXME Can this be done more automatically, from above?
        idStage.setEndpoint(identifierEndpoint);
       
        List<MeasurementImpl> recs = idStage.getMeasurements();
        recs.add(new MeasurementImpl(TecRegMockup.PROP_SERVICE_TIME, ""+((msAfter-msBefore)/1000.0) ));
       
        // Now record
        try {
            if( success && identify.getTypes() != null && identify.getTypes().size() > 0 ) {
                recs.add( new MeasurementImpl( TecRegMockup.PROP_SERVICE_EXECUTION_SUCEEDED, "true"));
                collectIdentifyResults(recs, identify, dob);
                wr.logReport(identify.getReport());
                return wr;
            }
        } catch( Exception e ) {
            exceptionReport += "<p>Failed with exception: "+e+"</p>";
        }

        // Build in a 'service failed' property.
        recs.add( new MeasurementImpl( TecRegMockup.PROP_SERVICE_EXECUTION_SUCEEDED, "false"));

        // Create a ServiceReport from the exception.
        // TODO can we distinguish tool and install error here?
        ServiceReport sr = new ServiceReport(Type.ERROR, Status.TOOL_ERROR,
                "No info");
        if (identify != null && identify.getReport() != null) {
            String info = identify.getReport().toString();
            sr = new ServiceReport(Type.ERROR, Status.TOOL_ERROR, info);
        }
        wr.logReport(sr);

        return wr;
View Full Code Here

        DigitalObjectContent c1 = Content.byReference(purl.toURL());
        /* Given these, we can instantiate our object: */
        DigitalObject object = new DigitalObject.Builder(c1).permanentUri(purl).build();
       
        /* Now pass this to the service */
        IdentifyResult ir = ids.identify(object,null);
       
        /* Check the result */
        System.out.println("Recieved type: " + ir.getTypes() );
        System.out.println("Recieved service report: " + ir.getReport() );
        System.out.println("Recieved service properties: " );
        ServiceProperties.printProperties(System.out, ir.getReport().getProperties());
        assertEquals("The returned type did not match the expected;", type, ir
                .getTypes().get(0));
       
    }
View Full Code Here

   
    private IdentifyResult runIdentifyService() {
        if( this.getIdentifyService() == null ) return null;
        try {
            Identify id = new IdentifyWrapper(new URL( this.getIdentifyService()));
            IdentifyResult ir = id.identify(this.getDob().getDob(), null);
            return ir;
        } catch( Exception e ) {
            log.error("FAILED! "+e);
            e.printStackTrace();
            return null;
View Full Code Here

   
    /**
     * @return
     */
    public String getIdentifyResult() {
        IdentifyResult ir = this.runIdentifyService();
        if( ir == null ) return null;
        String result = "";
        for( URI type : ir.getTypes() ) {
            result += type+" ";
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of eu.planets_project.services.identify.IdentifyResult

Copyright © 2018 www.massapicom. 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.