Package slash.navigation.download

Examples of slash.navigation.download.Checksum


    public Validator(Download download) {
        this.download = download;
    }

    private Checksum createChecksum(File file) throws IOException {
        return new Checksum(fromMillis(file.lastModified()), file.length(), generateChecksum(file));
    }
View Full Code Here


        File file = download.getFile().getFile();
        return file.isFile() ? file : download.getTempFile();
    }

    private boolean isChecksumValid(FileAndChecksum file) throws IOException {
        Checksum expected = file.getExpectedChecksum();
        if (expected == null)
            return true;

        Checksum actual = file.getActualChecksum();
        boolean lastModifiedEquals = expected.getLastModified() == null ||
                expected.getLastModified().equals(actual.getLastModified());
        if (!lastModifiedEquals)
            log.warning(format("%s has last modified %s but expected %s", file.getFile(), actual.getLastModified(), expected.getLastModified()));
        boolean contentLengthEquals = expected.getContentLength() == null ||
                expected.getContentLength().equals(actual.getContentLength());
        if (!contentLengthEquals)
            log.warning(format("%s has %d bytes but expected %d", file.getFile(), actual.getContentLength(), expected.getContentLength()));
        boolean sha1Equals = expected.getSHA1() == null ||
                expected.getSHA1().equals(actual.getSHA1());
        if (!sha1Equals)
            log.warning(format("%s has SHA-1 %s but expected %s", file.getFile(), actual.getSHA1(), expected.getSHA1()));
        // TODO solve timezone problems first before making lastModifiedEquals relevant again
        boolean valid = /*lastModifiedEquals &&*/ contentLengthEquals && sha1Equals;
        if (valid)
            log.info(format("%s has valid checksum", file.getFile()));
        return valid;
View Full Code Here

        newMarshaller().marshal(new ObjectFactory().createDatasources(datasourcesType), writer);
    }


    public static Checksum asChecksum(ChecksumType checksumType) {
        return new Checksum(parseTime(checksumType.getLastModified()), checksumType.getContentLength(), checksumType.getSha1());
    }
View Full Code Here

        assertEquals(downloads, result.getDownloads());
        assertEquals(now, result.getLastSync());
    }

    private Checksum createChecksum() {
        return new Checksum(now(), 4711L, "sha1");
    }
View Full Code Here

                asList(createFileAndChecksum("fragmentkey" + id, CALENDARTF, 201L, "theme fragment")));
        return result;
    }

    private FileAndChecksum createFileAndChecksum(String fileUri, CompactCalendar lastModified, long contentLength, String sha1) {
        FileAndChecksum result = new FileAndChecksum(new File(fileUri), new Checksum(lastModified, contentLength, sha1));
        result.setActualChecksum(new Checksum(fromMillis(lastModified.getTimeInMillis() + 1000), contentLength + 1, sha1 + "-actual"));
        return result;
    }
View Full Code Here

TOP

Related Classes of slash.navigation.download.Checksum

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.