JavaImageIOIdentify implements Identify { public IdentifyResult identify(DigitalObject dob, List<Parameter> parameters ) { ServicePerformanceHelper sph = new ServicePerformanceHelper(); ImageReader imageReader = null; if (dob.getContent() == null) { return returnWithErrorMessage(ServiceUtils .createErrorReport("The Content of the DigitalObject should not be NULL.")); } try { imageReader = getFormatName(dob.getContent().getInputStream()); sph.loaded(); if (imageReader == null || imageReader.getFormatName() == null) return returnWithErrorMessage(ServiceUtils.createErrorReport("Could not identify the image.")); 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)); } }  ServiceDescription describe(); IdentifyResult identify(DigitalObject dob, List<Parameter> parameters ); static String[] unique(String[] strings); static String sanitize( String format ); static final String NAME; }
@Test public void testIdentify() throws MalformedURLException, URISyntaxException { testIdentifyThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-jpg.test").toURI(), new URI("planets:fmt/ext/jpeg")); testIdentifyThis(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION+"PlanetsLogo-lowq-png.test").toURI(), new URI("planets:fmt/ext/png")); }