Package uk.gov.nationalarchives.droid.core.interfaces

Examples of uk.gov.nationalarchives.droid.core.interfaces.IdentificationResultCollection


            init.getUniqueFileEntries(),
            maxBytesToScan);

        process(request, matches);
       
        final IdentificationResultCollection results = new IdentificationResultCollection(request);
        for (final ContainerSignatureMatch match : matches.getContainerSignatureMatches()) {
            if (match.isMatch()) {
                List<FileFormatMapping> mappings = formats.get(match.getSignature().getId());
                for (final FileFormatMapping mapping : mappings) {
                    final IdentificationResultImpl result = new IdentificationResultImpl();
                    result.setMethod(IdentificationMethod.CONTAINER);
                    result.setRequestMetaData(request.getRequestMetaData());
                    result.setPuid(mapping.getPuid());
                    results.addResult(result);
                }
            }
        }
       
        return results;
View Full Code Here


        when(request.getSourceInputStream()).thenReturn(word97Stream);
        when(request.getRequestMetaData()).thenReturn(metaData);
        RequestIdentifier requestIdentifier = mock(RequestIdentifier.class);
        when(request.getIdentifier()).thenReturn(requestIdentifier);

        IdentificationResultCollection results = ooXmlIdentifier.submit(request);
       
        assertEquals("fmt/666", results.getResults().iterator().next().getPuid());
    }
View Full Code Here

        when(request.getSourceInputStream()).thenReturn(word97Stream);
        when(request.getRequestMetaData()).thenReturn(metaData);
        RequestIdentifier requestIdentifier = mock(RequestIdentifier.class);
        when(request.getIdentifier()).thenReturn(requestIdentifier);
       
        IdentificationResultCollection results = ole2Identifier.submit(request);
       
        assertEquals("fmt/666", results.getResults().iterator().next().getPuid());
    }
View Full Code Here

        IdentificationRequestFactory requestFactory = mock(IdentificationRequestFactory.class);
        when(requestFactory.newRequest(null, null))
            .thenReturn(request);
//        ole2Identifier.setRequestFactory(requestFactory);
       
        IdentificationResultCollection results = ole2Identifier.submit(request);
       
        assertEquals("fmt/666", results.getResults().iterator().next().getPuid());
    }
View Full Code Here

       
        IdentificationRequestFactory requestFactory = mock(IdentificationRequestFactory.class);
        when(requestFactory.newRequest(null, null)).thenReturn(request);
//        ole2Identifier.setRequestFactory(requestFactory);
       
        IdentificationResultCollection results = ole2Identifier.submit(request);
       
        assertEquals("fmt/666", results.getResults().iterator().next().getPuid());
    }
View Full Code Here

        when(request.getSourceInputStream()).thenReturn(odfTextStream);
        when(request.getRequestMetaData()).thenReturn(metaData);
        RequestIdentifier requestIdentifier = mock(RequestIdentifier.class);
        when(request.getIdentifier()).thenReturn(requestIdentifier);
       
        IdentificationResultCollection results = odfIdentifier.submit(request);
       
        assertEquals("fmt/667", results.getResults().iterator().next().getPuid());
    }
View Full Code Here

            fileName = file.getCanonicalPath();
            RequestMetaData metaData =
                new RequestMetaData(file.length(), file.lastModified(), fileName);
            FileSystemIdentificationRequest request =
                new FileSystemIdentificationRequest(metaData, identifier);
            IdentificationResultCollection results =
                new IdentificationResultCollection(request);
            InputStream ole2Stream = new FileInputStream(file);
            request.open(ole2Stream);
            results = ole2ContainerContentIdentifier.process(request.getSourceInputStream(), results);
            if (results.getResults().isEmpty()) {
                fail("OLE2 file not identified");
            }
            String fmtExpected = "";
            for (IdentificationResult identResult : results.getResults()) {
                if (identResult.getPuid().equals("fmt/40")) {
                    fmtExpected = identResult.getPuid();
                }
            }
            assertEquals(fmtExpected, "fmt/40");
View Full Code Here

            fileName = file.getCanonicalPath();
            RequestMetaData metaData =
                new RequestMetaData(file.length(), file.lastModified(), fileName);
            FileSystemIdentificationRequest request =
                new FileSystemIdentificationRequest(metaData, identifier);
            IdentificationResultCollection results =
                new IdentificationResultCollection(request);
            InputStream zipStream = new FileInputStream(file);
            request.open(zipStream);
            results = zipContainerContentIdentifier.process(request.getSourceInputStream(), results);
            if (results.getResults().isEmpty()) {
                fail("ZIP file not identified");
            }
            String fmtExpected = "";
            for (IdentificationResult identResult : results.getResults()) {
                if (identResult.getPuid().equals("fmt/189")) {
                    fmtExpected = identResult.getPuid();
                }
            }
            assertEquals(fmtExpected, "fmt/189");
View Full Code Here

                        final RequestMetaData metaData = new RequestMetaData(1L, 2L, name);
                        final RequestIdentifier identifier = new RequestIdentifier(uri);
                        final TarEntryIdentificationRequest tarRequest =
                            new TarEntryIdentificationRequest(metaData, identifier, tmpDir);
                        tarRequest.open(in);
                        final IdentificationResultCollection tarResults =
                                binarySignatureIdentifier.matchBinarySignatures(tarRequest);
                        final ResultPrinter resultPrinter =
                                new ResultPrinter(binarySignatureIdentifier,
                                    containerSignatureDefinitions, newPath, slash, slash1, true);
                        resultPrinter.print(tarResults, tarRequest);
View Full Code Here

     */
    public void print(final IdentificationResultCollection results,
            final IdentificationRequest request) throws CommandExecutionException {
       
        final String fileName = (path + request.getFileName()).replace(wrongSlash, slash);
        final IdentificationResultCollection containerResults =
                getContainerResults(results, request, fileName);

        IdentificationResultCollection finalResults = new IdentificationResultCollection(request);
        boolean container = false;
        if (containerResults.getResults().size() > 0) {
            container = true;
            finalResults = containerResults;
        } else if (results.getResults().size() > 0) {
            finalResults = results;
        }
        if (finalResults.getResults().size() > 0) {
            binarySignatureIdentifier.removeLowerPriorityHits(finalResults);
        }
        if (finalResults.getResults().size() > 0) {
            for (IdentificationResult identResult : finalResults.getResults()) {
                String puid = identResult.getPuid();
                if (!container && JIP_ARCHIVE.equals(puid)) {
                    puid = ZIP_ARCHIVE;
                }
                System.out.println(fileName + "," + puid);
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.core.interfaces.IdentificationResultCollection

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.