Package eu.planets_project.services.datatypes

Examples of eu.planets_project.services.datatypes.ServiceReport


            List<URI> types = new ArrayList<URI>();
            URI typeURI = FormatRegistryFactory.getFormatRegistry().createExtensionUri(sanitize(imageReader.getFormatName()));
            types.add(typeURI);
            log.fine(String.format("Identified %s as %s", dob, types));
           
            ServiceReport rep = new ServiceReport(Type.INFO, Status.SUCCESS, "OK", sph.getPerformanceProperties() );
            return new IdentifyResult(types,
                    IdentifyResult.Method.PARTIAL_PARSE, rep);
        } catch (IOException e) {
            return returnWithErrorMessage(ServiceUtils.createErrorReport("IOException reading the image: " + e));
        }
View Full Code Here


            return new MigrateResult(ndo, rep);
        } catch (Exception e) {
            log.log(Level.SEVERE, "Could not return content by reference. ", e);
        }
        */
        ServiceReport rep = new ServiceReport(Type.INFO, Status.SUCCESS, "OK", sph.getPerformanceProperties() );
        DigitalObject ndo = new DigitalObject.Builder(Content.byReference(outfile)).build();
        return new MigrateResult(ndo, rep);
    }
View Full Code Here

     * @see Validate#validate(eu.planets_project.services.datatypes.DigitalObject,
     *      java.net.URI, eu.planets_project.services.datatypes.Parameter)
     */
    public ValidateResult validate(final DigitalObject digitalObject,
            final URI format, final List<Parameter> parameters) {
        ServiceReport report;
        boolean valid = false;
        if (!JhoveIdentification.supported(format)) {
            report = new ServiceReport(Type.ERROR, Status.SUCCESS,
                    "Unsupported format: " + format);
        } else {
            valid = basicValidateOneBinary(digitalObject, format);
            report = new ServiceReport(Type.INFO, Status.SUCCESS, "OK");
        }
        ValidateResult result = new ValidateResult.Builder(format, report)
                .ofThisFormat(valid).build();
        return result;
    }
View Full Code Here

        // Start timing...
        ServicePerformanceHelper sph = new ServicePerformanceHelper();
       
        // Initialise what will be built:
        List<PropertyComparison> props = new ArrayList<PropertyComparison>();
        ServiceReport sr = null;
       
        // Load the images.
        BufferedImage i1;
        BufferedImage i2;
        try {
            i1 = ImageIO.read( first.getContent().getInputStream() );
            i2 = ImageIO.read( second.getContent().getInputStream() );
        } catch (IOException e) {
            return new CompareResult(null, ServiceUtils.createExceptionErrorReport("IOException reading the images. ", e));
        }
        if( i1 == null || i2 == null ) {
            log.warning("One of the images was null when loaded!");
            return new CompareResult(null, ServiceUtils.createErrorReport("Error reading the images, got a NULL."));
        }
        // Record time take to load the inputs into memory:
        sph.loaded();
       
        // Check comparison is possible: Are the dimensions the same?
        if (i1.getWidth() != i2.getWidth() || i1.getHeight() != i2.getHeight()) {
            // FIXME is this really an error, or rather a 'images are different' result?
            return new CompareResult(null, ServiceUtils.createErrorReport("The image dimensions must match!"));
        }
        // FIXME Check comparison is sensible: are there the same number of channels? This is probably a WARNING?
        if( i1.getColorModel().getNumComponents() != i2.getColorModel().getNumComponents()) {
            System.out.println("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents());
            log.warning("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents());
            sr = new ServiceReport(ServiceReport.Type.WARN, ServiceReport.Status.SUCCESS, "Number of colour components was not the same. The missing channels, e.g. the alpha channel, will be assumed to be zero.");
            // FIXME I think this should be more serious, as the results can be rather misleading.
            // The comparison assumes the bit-mask to be zero everywhere, but this did not lead to such a bad PSNR?!
        }

        // Run the comparison:
        double psnr = psnr(i1, i2);
        props.add( buildPsnrProperty(psnr) );
       
        // Create a happy service report if no problems occurred.
        if( sr == null) {
            // Also store some service properties:
            sr = new ServiceReport(ServiceReport.Type.INFO, ServiceReport.Status.SUCCESS,
                    "Comparison succeeded.", sph.getPerformanceProperties() );
        }
       
        // Halt performance measurement:
        sph.stop();
View Full Code Here

    public void testUnsupported() throws MalformedURLException {
        ValidateResult vr = jhove.validate(new DigitalObject.Builder(Content
                .byReference(new File(TestFile.BMP.getLocation()).toURI()
                        .toURL())).build(), TestFile.BMP.getTypes().iterator()
                .next(), null);
        ServiceReport report = vr.getReport();
        /*
         * If validation was attempted for an unsupported format, the report
         * will be of type ERROR:
         */
        Assert.assertEquals(ServiceReport.Type.ERROR, report.getType());
        /* More info is available in the report message: */
        System.err.println("Report message: " + report.getMessage());
    }
View Full Code Here

     */
    public CharacteriseResult characterise(final DigitalObject digitalObject,
            final List<Parameter> parameters) {
        String resultString = basicCharacteriseOneBinary(digitalObject);
        List<Property> props = readProperties(resultString);
        return new CharacteriseResult(props, new ServiceReport(Type.INFO, Status.SUCCESS, "OK"));
    }
View Full Code Here

  {
    ValidateResult result;
    File tempFile =  DigitalObjectUtils.toFile(o);
    boolean valid = basicValidateOneBinary(tempFile, fmt);

    result = new ValidateResult.Builder(fmt, new ServiceReport(Type.INFO,
                Status.SUCCESS, "OK")).ofThisFormat(valid).build();

    return result;
  }
View Full Code Here

     * java.net.URI, eu.planets_project.services.datatypes.Parameter)
     */
    public final MigrateResult migrate(final DigitalObject digitalObject,
                                       final URI inputFormat, final URI outputFormat,
                                       final List<Parameter> parameters) {
        final ServiceReport report = new ServiceReport(Type.INFO, Status.SUCCESS, "OK");

        ServiceReport sr = checkMigrateArgs(digitalObject, inputFormat, outputFormat, report);
      
        if (sr.getStatus() != report.getStatus()){
            return this.fail(sr);
        }
       
        if (outputFormat.equals(outputformatUnicode)) {
            return textMigration(digitalObject, report);
        }

        if (outputFormat.equals(outputformatHtml)) {
            return htmlMigration(digitalObject, report);
        } else {
            return this.fail(new ServiceReport(Type.ERROR,
                    Status.INSTALLATION_ERROR,
                    "The chosen output format is not supported"));
        }
    }
View Full Code Here

            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

            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

TOP

Related Classes of eu.planets_project.services.datatypes.ServiceReport

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.