Package uk.gov.nationalarchives.droid.command.action

Examples of uk.gov.nationalarchives.droid.command.action.CommandExecutionException


        binarySignatureIdentifier = new BinarySignatureIdentifier();
        binarySignatureIdentifier.setSignatureFile(standardSignatures);
        try {
            binarySignatureIdentifier.init();
        } catch (SignatureParseException e) {
            throw new CommandExecutionException("Can't parse signature file");
        }
        try {
            InputStream in = new FileInputStream(containerSignatures);
            ContainerSignatureSaxParser parser = new ContainerSignatureSaxParser();
            containerSignatureDefinitions = parser.parse(in);
        } catch (SignatureParseException e) {
            throw new CommandExecutionException ("Can't parse container signature file");
        } catch (Exception e) {
            throw new CommandExecutionException(e);
        }
        gZipArchiveContentIdentifier =
                new GZipArchiveContentIdentifier(binarySignatureIdentifier,
                    containerSignatureDefinitions, "", "/", "/");
    }
View Full Code Here


            InputStream gZipStream = new FileInputStream(file);
            request.open(gZipStream);
            gZipArchiveContentIdentifier.identify(uri, request);

        } catch (IOException e) {
            throw new CommandExecutionException(e);
        }
    }
View Full Code Here

        binarySignatureIdentifier = new BinarySignatureIdentifier();
        binarySignatureIdentifier.setSignatureFile(standardSignatures);
        try {
            binarySignatureIdentifier.init();
        } catch (SignatureParseException e) {
            throw new CommandExecutionException("Can't parse signature file");
        }
        try {
            InputStream in = new FileInputStream(containerSignatures);
            ContainerSignatureSaxParser parser = new ContainerSignatureSaxParser();
            containerSignatureDefinitions = parser.parse(in);
        } catch (SignatureParseException e) {
            throw new CommandExecutionException ("Can't parse container signature file");
        } catch (Exception e) {
            throw new CommandExecutionException(e);
        }
        tarArchiveContentIdentifier =
                new TarArchiveContentIdentifier(binarySignatureIdentifier,
                    containerSignatureDefinitions, "", "/", "/");
    }
View Full Code Here

            InputStream tarStream = new FileInputStream(file);
            request.open(tarStream);
            tarArchiveContentIdentifier.identify(uri, request);

        } catch (IOException e) {
            throw new CommandExecutionException(e);
        }
    }
View Full Code Here

        binarySignatureIdentifier = new BinarySignatureIdentifier();
        binarySignatureIdentifier.setSignatureFile(standardSignatures);
        try {
            binarySignatureIdentifier.init();
        } catch (SignatureParseException e) {
            throw new CommandExecutionException("Can't parse signature file");
        }
        try {
            InputStream in = new FileInputStream(containerSignatures);
            ContainerSignatureSaxParser parser = new ContainerSignatureSaxParser();
            containerSignatureDefinitions = parser.parse(in);
        } catch (SignatureParseException e) {
            throw new CommandExecutionException ("Can't parse container signature file");
        } catch (Exception e) {
            throw new CommandExecutionException(e);
        }
        zipArchiveContentIdentifier =
                new ZipArchiveContentIdentifier(binarySignatureIdentifier,
                    containerSignatureDefinitions, "", "/", "/");
    }
View Full Code Here

            InputStream zipStream = new FileInputStream(file);
            request.open(zipStream);
            zipArchiveContentIdentifier.identify(uri, request);
        } catch (IOException e) {
            throw new CommandExecutionException(e);
        }
    }
View Full Code Here

        try {
            InputStream in = new FileInputStream(containerSignatures);
            ContainerSignatureSaxParser parser = new ContainerSignatureSaxParser();
            containerSignatureDefinitions = parser.parse(in);
        } catch (SignatureParseException e) {
            throw new CommandExecutionException ("Can't parse container signature file");
        } catch (Exception e) {
            throw new CommandExecutionException(e);
        }
       
        ole2ContainerContentIdentifier.init(containerSignatureDefinitions, "OLE2");
        object = ole2ContainerContentIdentifier.getContainerIdentifierInit();
        assertEquals(object.getClass(), containerIdentifierInit.getClass());
       
        object = ole2ContainerContentIdentifier.getFormats();
        assertEquals(object.getClass(), formats.getClass());

        String fileName;
        File file = new File(ole2File);
        if (!file.exists()) {
            fail("OLE2 test file not found");
        }
        URI uri = file.toURI();
        RequestIdentifier identifier = new RequestIdentifier(uri);
        identifier.setParentId(1L);
        try {
            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");
        } catch (IOException e) {
            throw new CommandExecutionException(e);
        }
    }
View Full Code Here

        try {
            InputStream in = new FileInputStream(containerSignatures);
            ContainerSignatureSaxParser parser = new ContainerSignatureSaxParser();
            containerSignatureDefinitions = parser.parse(in);
        } catch (SignatureParseException e) {
            throw new CommandExecutionException ("Can't parse container signature file");
        } catch (Exception e) {
            throw new CommandExecutionException(e);
        }
       
        zipContainerContentIdentifier.init(containerSignatureDefinitions, "ZIP");
        object = zipContainerContentIdentifier.getContainerIdentifierInit();
        assertEquals(object.getClass(), containerIdentifierInit.getClass());
       
        object = zipContainerContentIdentifier.getFormats();
        assertEquals(object.getClass(), formats.getClass());

        String fileName;
        File file = new File(zipFile);
        if (!file.exists()) {
            fail("ZIP test file not found");
        }
        URI uri = file.toURI();
        RequestIdentifier identifier = new RequestIdentifier(uri);
        identifier.setParentId(1L);
        try {
            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");
        } catch (IOException e) {
            throw new CommandExecutionException(e);
        }
    }
View Full Code Here

                                    request.getSourceInputStream(), containerResults);
                            } catch (IOException e) {   // carry on after container i/o problems
                                System.err.println(e + SPACE + L_BRACKET + fileName + R_BRACKET);
                            }
                        } else {
                            throw new CommandExecutionException("Unknown container type: " + containerPuid);
                        }
                    }
                }
            }
        }
View Full Code Here

        } finally {
            if (tarIn != null) {
                try {
                    tarIn.close();
                } catch (IOException ioe) {
                    throw new CommandExecutionException(ioe.getMessage(), ioe);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.command.action.CommandExecutionException

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.