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

Examples of uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileInfo


    @Override
    public SignatureFileInfo install(SignatureType type, File signatureFile, boolean setDefault)
        throws SignatureFileException {
       
        SignatureInfoParser parser = new SignatureInfoParser();
        SignatureFileInfo sigFileInfo = forBinarySigFile(signatureFile, parser);

        try {
            FileUtils.copyFileToDirectory(signatureFile, config.getSignatureFileDir(), true);
            File newSignatureFile = new File(config.getSignatureFileDir(), signatureFile.getName());
           
            sigFileInfo.setFile(newSignatureFile);
           
            if (setDefault) {
                config.getProperties().setProperty(defaultVersionProperties.get(type).getName(),
                        FilenameUtils.getBaseName(newSignatureFile.getName()));
            }
View Full Code Here


        public void startElement(String uri, String localName, String qName,
                Attributes attributes) throws SAXException {

            if (ROOT_ELEMENT.equals(qName)) {
                int version = Integer.valueOf(attributes.getValue("Version"));
                SignatureFileInfo info = new SignatureFileInfo(version, false, SignatureType.BINARY);
                throw new ValidSignatureFileException(info);
            }
           
            throw new SAXException(
                    String.format("Invalid signature file - root element was not [%s]", ROOT_ELEMENT));
View Full Code Here

        // get the version number, which needs to be part of the filename...
        int version = Integer.valueOf(sigFile.getAttribute("Version"));
        boolean deprecated = Boolean
                .valueOf(sigFile.getAttribute("Deprecated"));

        SignatureFileInfo sigInfo = new SignatureFileInfo(version, deprecated, SignatureType.BINARY);
        String fileName = String.format(filenamePattern, version);

        BufferedWriter writer = null;
        try {
            File outputFile = new File(targetDir, fileName);
            outputFile.createNewFile();
            writer = new BufferedWriter(new FileWriter(outputFile));
            XMLSerializer serializer = new XMLSerializer(writer,
                    new OutputFormat(Method.XML, "UTF-8", true));
            serializer.serialize(sigFile);
            sigInfo.setFile(outputFile);
        } catch (IOException e) {
            throw new SignatureServiceException(e);
        } finally {
            try {
                writer.close();
View Full Code Here

        Holder<Boolean> deprecated = new Holder<Boolean>();

        pronomService.getSignatureFileVersionV1(version, deprecated);
       

        SignatureFileInfo info = new SignatureFileInfo(version.value
                .getVersion(), deprecated.value.booleanValue(), SignatureType.BINARY);
        return info;

    }
View Full Code Here

    @Test
    public void testGetLatestVersion() throws SignatureServiceException {
        when(proxySettings.isEnabled()).thenReturn(false);
        httpService.onProxyChange(proxySettings);

        SignatureFileInfo sigFileInfo = httpService.getLatestVersion(20100101);
        assertNull(sigFileInfo.getFile());
        assertTrue(sigFileInfo.getVersion() > 20110114);
        //assertEquals(20110114, sigFileInfo.getVersion());
        assertEquals(false, sigFileInfo.isDeprecated());
    }
View Full Code Here

        when(proxySettings.isEnabled()).thenReturn(true);
        when(proxySettings.getProxyHost()).thenReturn("wb-cacheclst1.web.local");
        when(proxySettings.getProxyPort()).thenReturn(8080);
        httpService.onProxyChange(proxySettings);
       
        SignatureFileInfo sigFileInfo = httpService.getLatestVersion(20100101);
        assertNull(sigFileInfo.getFile());
        assertTrue(sigFileInfo.getVersion() > 20110114);
        //assertEquals(20110114, sigFileInfo.getVersion());
        assertEquals(false, sigFileInfo.isDeprecated());
    }
View Full Code Here

        File tmpDir = new File("tmp");
        FileUtils.deleteQuietly(tmpDir);

        tmpDir.mkdir();
        assertEquals(0, tmpDir.list().length);
        SignatureFileInfo sigFileInfo;
        try {
            sigFileInfo = httpService.importSignatureFile(tmpDir);
            assertEquals(false, sigFileInfo.isDeprecated());
            //assertEquals(20110114, sigFileInfo.getVersion());
            assertTrue(sigFileInfo.getVersion() > 20110114);
        } catch (SignatureServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
View Full Code Here

        File tmpDir = new File("tmp");
        FileUtils.deleteQuietly(tmpDir);

        tmpDir.mkdir();
        assertEquals(0, tmpDir.list().length);
        SignatureFileInfo sigFileInfo;
        try {
            sigFileInfo = httpService.importSignatureFile(tmpDir);
            assertEquals(false, sigFileInfo.isDeprecated());
            //assertEquals(20110114, sigFileInfo.getVersion());
            assertTrue(sigFileInfo.getVersion() > 20110114);
        } catch (SignatureServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
View Full Code Here

    }
   
    @Test
    public void testCheckForUpdatesWhenNewFileIsAvailable() throws Exception {
       
        SignatureFileInfo sigFileInfo = new SignatureFileInfo(666, true, SignatureType.BINARY);
        Map<SignatureType, SignatureFileInfo> updates = new HashMap<SignatureType, SignatureFileInfo>();
        updates.put(SignatureType.BINARY, sigFileInfo);
       
        when(signatureManager.getLatestSignatureFiles()).thenReturn(updates);
       
View Full Code Here

            } else if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_NOT_MODIFIED) {
                throw new SignatureServiceException(
                        String.format(ERROR_MESSAGE_PATTERN, endpointUrl, statusCode));
            }
            int version = getVersion(get);
            SignatureFileInfo signatureFileInfo = new SignatureFileInfo(version, false, SignatureType.CONTAINER);
            return signatureFileInfo;
        } catch (UnknownHostException e) {
            throw new SignatureServiceException(
                    String.format(COULD_NOT_FIND_SERVER, endpointUrl));
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileInfo

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.