Package slash.navigation.download

Examples of slash.navigation.download.FileAndChecksum


        String uri = edition.toLowerCase() + ".xml";
        String url = System.getProperty("datasources", "http://www.routeconverter.com/datasources/") + "edition/" + uri;
        log.info(format("Downloading edition '%s'", url));

        Download download = downloadManager.queueForDownload("RouteConverter " + edition + " Edition: Catalog of Data Sources",
                url, Copy, null, new FileAndChecksum(new java.io.File(getTarget(), uri), null), null);
        downloadManager.waitForCompletion(asList(download));

        java.io.File target = download.getFile().getFile();
        if (!target.exists()) {
            log.warning(format("Cannot find %s to load '%s' data", target, download.getDescription()));
View Full Code Here


            for (File file : dataSource.getFiles()) {
                String url = dataSource.getBaseUrl() + file.getUri();
                log.info(format("Downloading data source '%s'", url));

                Download download = downloadManager.queueForDownload(dataSource.getName() + ": Data Source " + file.getUri(),
                        url, Copy, null, new FileAndChecksum(new java.io.File(getTarget(), file.getUri().toLowerCase()), file.getLatestChecksum()), null);
                downloads.add(download);
            }
        }
        downloadManager.waitForCompletion(downloads);
View Full Code Here

    private Download download(Fragment<File> fragment) {
        File downloadable = fragment.getDownloadable();

        List<FileAndChecksum> fragments = new ArrayList<>();
        for (Fragment otherFragments : downloadable.getFragments())
            fragments.add(new FileAndChecksum(createFile(otherFragments.getKey()), otherFragments.getLatestChecksum()));

        String uri = downloadable.getUri();
        String url = getBaseUrl() + uri;
        return downloadManager.queueForDownload(getName() + ": Elevation Data " + uri, url, Flatten,
                null, new FileAndChecksum(getDirectory(), downloadable.getLatestChecksum()), fragments);
    }
View Full Code Here

    public void progressed(Download download, int percentage) {
    }

    public void failed(Download download) {
        FileAndChecksum file = download.getFile();
        if (file.getActualChecksum() == null)
            return;
        if (file.getActualChecksum().laterThan(file.getExpectedChecksum()) ||
                file.getExpectedChecksum().getSHA1() == null && file.getActualChecksum().getSHA1() != null)
            sendChecksums(download);
    }
View Full Code Here

    @Test
    public void testSaveAndLoadDownloads() throws IOException {
        CompactCalendar now = now();
        List<Download> downloads = new ArrayList<>();
        downloads.add(new Download("description", "url", Flatten, new FileAndChecksum(fileTarget, createChecksum()),
                asList(new FileAndChecksum(fragmentTarget1, createChecksum()), new FileAndChecksum(fragmentTarget2, createChecksum())),
                "etag", Downloading, tempFile));
        persister.save(queueFile, downloads, now);

        QueuePersister.Result result = persister.load(queueFile);
        assertEquals(downloads, result.getDownloads());
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.FileAndChecksum

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.