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

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


        InputStream in = new FileInputStream(file);
        RequestMetaData metaData = new RequestMetaData(file.length(), file.lastModified(), SCANFILE);
        RequestIdentifier identifier = new RequestIdentifier(resourceUri);
        identifier.setParentId(1L);
       
        IdentificationRequest request = new FileSystemIdentificationRequest(metaData, identifier);
        request.open(in);

        IdentificationResultCollection resultsCollection = droid.matchBinarySignatures(request);
        List<IdentificationResult> results = resultsCollection.getResults();
       
        assertEquals(EXPECTED_HITS, results.size());
View Full Code Here


        RequestIdentifier identifier = new RequestIdentifier(resourceUri);
        identifier.setParentId(1L);
        identifier.setParentPrefix("X");
        identifier.setAncestorId(1L);
       
        IdentificationRequest request = new FileSystemIdentificationRequest(metaData, identifier);
        request.open(in);

        Future<IdentificationResultCollection> future = submissionGateway.submit(request);
        future.get();

        // Wait for the done() method to complete.
View Full Code Here

        File file = new File("test_sig_files/sample.pdf");
        assertTrue(file.exists());

        RequestIdentifier identifier = new RequestIdentifier(file.toURI());
       
        IdentificationRequest request = mock(IdentificationRequest.class);
        when(request.getIdentifier()).thenReturn(identifier);
        when(request.getRequestMetaData()).thenThrow(new RuntimeException("I failed"));

        Future<IdentificationResultCollection> future = submissionGateway.submit(request);

        try {
            future.get();
View Full Code Here

        InputStream in = new FileInputStream(file);
        RequestMetaData metaData = new RequestMetaData(file.length(), file.lastModified(), SCANFILE);
        RequestIdentifier identifier = new RequestIdentifier(resourceUri);
        identifier.setParentId(1L);
       
        IdentificationRequest request = new FileSystemIdentificationRequest(metaData, identifier);
        request.open(in);

        IdentificationResultCollection resultsCollection = droid.matchBinarySignatures(request);
        List<IdentificationResult> results = resultsCollection.getResults();
       
        assertEquals(EXPECTED_HITS, results.size());
View Full Code Here

        InputStream in = new FileInputStream(file);
        RequestMetaData metaData = new RequestMetaData(file.length(), file.lastModified(), SCANFILE);
        RequestIdentifier identifier = new RequestIdentifier(resourceUri);
        identifier.setParentId(1L);
       
        IdentificationRequest request = new FileSystemIdentificationRequest(metaData, identifier);
        request.open(in);

        IdentificationResultCollection resultsCollection = droid.matchBinarySignatures(request);
        List<IdentificationResult> results = resultsCollection.getResults();
       
        assertEquals(EXPECTED_HITS, results.size());
View Full Code Here

        InputStream in = new FileInputStream(file);
        RequestMetaData metaData = new RequestMetaData(file.length(), file.lastModified(), "sample.pdf");
        RequestIdentifier identifier = new RequestIdentifier(resourceUri);
        identifier.setParentId(1L);
       
        IdentificationRequest request = new FileSystemIdentificationRequest(metaData, identifier);
        request.open(in);
//        IdentificationRequest request = ResourceWrapperFactoryImpl.newResourceWrapper(resourceUri, 1L);
       
        IdentificationResultCollection results = droid.matchBinarySignatures(request);
       
//        ArgumentCaptor<IdentificationResultCollection> resultCaptor =
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void handleError(IdentificationException e) {
        final IdentificationRequest request = e.getRequest();
        final RequestIdentifier identifier = request.getIdentifier();
        URI uri = identifier.getUri();
        //log.debug(String.format("handling error for job [%s]", uri));
       
        final Long nodeId = identifier.getNodeId();
        ProfileResourceNode node;
        if (nodeId != null) {
            node = resultHandlerDao.loadNode(nodeId);
            node.getMetaData().setNodeStatus(NodeStatus.ERROR);
            // Need to initialise the collection eagerly...
            node.getFormatIdentifications().size();
        } else {
            node = new ProfileResourceNode(uri);
            node.setFinished(new Date());
            final NodeMetaData metaData = node.getMetaData();
           
            metaData.setNodeStatus(getNodeStatus(e.getErrorType()));
            metaData.setResourceType(ResourceType.FILE);
            node.setNoFormatsIdentified();
           
            RequestMetaData requestMetaData = request.getRequestMetaData();
           
            metaData.setName(requestMetaData.getName());
            metaData.setSize(requestMetaData.getSize());
            metaData.setExtension(request.getExtension());
            metaData.setLastModified(request.getRequestMetaData().getTime());
            metaData.setHash(requestMetaData.getHash());
           
            node.addFormatIdentification(Format.NULL);
            resultHandlerDao.save(node, identifier.getParentResourceId());
        }
View Full Code Here

        handler.setResultHandler(resultHandler);

        handler.setFactory(factory);
        handler.setDroidCore(droidCore);
       
        IdentificationRequest originalRequest = mock(IdentificationRequest.class);
        RequestIdentifier identifier = new RequestIdentifier(file.toURI());
        identifier.setAncestorId(10L);
        identifier.setResourceId(nodeId);
        identifier.setParentResourceId(parentId);
       
        when(originalRequest.getIdentifier()).thenReturn(identifier);
       
        when(originalRequest.getSourceInputStream()).thenReturn(new FileInputStream(file));
        handler.handle(originalRequest);

        verify(mockRequests.get(0)).open(any(InputStream.class));
        verify(mockRequests.get(1)).open(any(InputStream.class));
        verify(mockRequests.get(2)).open(any(InputStream.class));
View Full Code Here

        handler.setFactory(new ZipEntryRequestFactory());
       
        AsynchDroid droidCore = mock(AsynchDroid.class);
        handler.setDroidCore(droidCore);
       
        IdentificationRequest originalRequest = mock(IdentificationRequest.class);
        RequestIdentifier identifier = new RequestIdentifier(jarFile.toURI());
        identifier.setAncestorId(10L);
        identifier.setParentId(20L);
        identifier.setNodeId(30L);
       
        when(originalRequest.getIdentifier()).thenReturn(identifier);
        when(originalRequest.getSourceInputStream()).thenReturn(new FileInputStream(jarFile));
        handler.handle(originalRequest);
       
        ArgumentCaptor<IdentificationRequest> captor = ArgumentCaptor.forClass(IdentificationRequest.class);
        verify(droidCore, times(1)).submit(captor.capture());
       
View Full Code Here

        String multipartZip = getClass().getResource("/problem_zip/package2.zip").getFile();
        File multipartFile = new File(multipartZip);
       
       
        ZipArchiveHandler handler = new ZipArchiveHandler();
        IdentificationRequest originalRequest = mock(IdentificationRequest.class);
        RequestIdentifier identifier = new RequestIdentifier(multipartFile.toURI());
        identifier.setAncestorId(1L);
        identifier.setParentId(10L);
        identifier.setNodeId(30L);
       
        when(originalRequest.getIdentifier()).thenReturn(identifier);
       
       
//        when(originalRequest.getOriginatorNodeId()).thenReturn(10L);
//        when(originalRequest.getCorrelationId()).thenReturn(20L);
//        when(originalRequest.getUri()).thenReturn(multipartFile.toURI());
        when(originalRequest.getSourceInputStream()).thenReturn(new FileInputStream(multipartFile));
        handler.handle(originalRequest);

       
    }
View Full Code Here

TOP

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

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.