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

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


            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();
            } catch (IOException e) {
                log.error("Error closing file writer", e);
View Full Code Here


            String dateString = DateUtil.formatDate(versionDate);
            get.addRequestHeader("If-Modified-Since", dateString);
           
            int statusCode = client.executeMethod(get);
            if (statusCode == HttpStatus.SC_NOT_FOUND) {
                throw new SignatureServiceException(
                        String.format(FILE_NOT_FOUND_404, endpointUrl));
            } 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) {
            throw new SignatureServiceException(e);
        } catch (DateParseException e) {
            throw new SignatureServiceException(e);
        } catch (ParseException e) {
            throw new SignatureServiceException(e);
        } finally {
            get.releaseConnection();
        }
    }
View Full Code Here

        FileWriter writer = null;
       
        try {
            int statusCode = client.executeMethod(get);
            if (statusCode == HttpStatus.SC_NOT_FOUND) {
                throw new SignatureServiceException(
                        String.format(FILE_NOT_FOUND_404, endpointUrl));
            } 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);
            String fileName = String.format(FILENAME_PATTERN, version);

            final File targetFile = new File(targetDir, fileName);
            writer = new FileWriter(targetFile);
            IOUtils.copy(get.getResponseBodyAsStream(), writer);
           
            signatureFileInfo.setFile(targetFile);
            return signatureFileInfo;
           
        } catch (UnknownHostException e) {
            throw new SignatureServiceException(
                    String.format(COULD_NOT_FIND_SERVER, endpointUrl));
        } catch (IOException e) {
            throw new SignatureServiceException(e);
        } catch (DateParseException e) {
            throw new SignatureServiceException(e);
        } finally {
            get.releaseConnection();
            try {
                if (writer != null) {
                    writer.close();
View Full Code Here

TOP

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

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.