public long calculateRemainingDownloadSize(List<BoundingBox> boundingBoxes) { Collection<Downloadable> downloadables = finder.getDownloadableFor(boundingBoxes); long notExists = 0L; for(Downloadable downloadable : downloadables) { Long contentLength = downloadable.getLatestChecksum().getContentLength(); if(contentLength == null) continue; java.io.File file = createFile(downloadable.getUri()); if(!file.exists()) notExists += contentLength; } return notExists; }
private void putDownloadables(List<? extends Downloadable> downloadables) { for (Downloadable downloadable : downloadables) { downloadableMap.put(downloadable.getUri(), downloadable); for (Fragment<Downloadable> fragment : downloadable.getFragments()) fragmentMap.put(fragment.getKey(), fragment); } }
public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Downloadable downloadable = (Downloadable) o; return getDataSource().equals(downloadable.getDataSource()) && getUri().equals(downloadable.getUri()); }
public Download queueForDownload(DataSource dataSource, Downloadable downloadable) { Action action = Action.valueOf(dataSource.getAction()); File directory = getApplicationDirectory(dataSource.getDirectory()); File target = new File(directory, downloadable.getUri()); if (action.equals(Extract) || action.equals(Flatten)) target = ensureDirectory(target.getParentFile()); return downloadManager.queueForDownload(dataSource.getName() + ": " + downloadable.getUri(), dataSource.getBaseUrl() + downloadable.getUri(), action, new FileAndChecksum(target, downloadable.getLatestChecksum()), asFragments(target, downloadable.getFragments(), false)); }
public Downloadable getDownloadableBySHA1(String sha1) { initialize(); for(Downloadable downloadable : downloadableMap.values()) { Checksum checksum = downloadable.getLatestChecksum(); if(checksum != null && sha1.equals(checksum.getSHA1())) return downloadable; } return null; }
public String getUrl() { return datasource.getBaseUrl() + downloadable.getUri(); } }
private void scanForFilesMissingInQueue(File directory) throws IOException { java.io.File[] files = directory.listFiles(); if (files != null) { for (File file : files) { if (file.isFile()) { Downloadable downloadable = dataSourceService.getDownloadable(file); if(downloadable != null) { DataSource dataSource = downloadable.getDataSource(); addOrUpdateInQueue(dataSource, downloadable); } else log.fine("Cannot find downloadable for " + file); } else if (file.isDirectory()) scanForFilesMissingInQueue(file); } } }
private void addOrUpdateInQueue(DataSource dataSource, Downloadable downloadable) { Action action = Action.valueOf(dataSource.getAction()); File directory = getApplicationDirectory(dataSource.getDirectory()); File target = directory; // Flatten if (action.equals(Copy)) target = new File(directory, downloadable.getUri()); else if (action.equals(Extract)) target = target.getParentFile(); downloadManager.addOrUpdateInQueue(dataSource.getName() + ": " + downloadable.getUri(), dataSource.getBaseUrl() + downloadable.getUri(), action, new FileAndChecksum(target, downloadable.getLatestChecksum()), asFragments(directory, downloadable.getFragments(), action.equals(Extract))); }
static Long getContentLength(RemoteResource resource) { return resource.getDownloadable().getLatestChecksum() != null ? resource.getDownloadable().getLatestChecksum().getContentLength() : null; } }
public String getDescription() { return getDownloadable().getUri(); }
private void updateQueueFromDataSources() { for(Download download : downloadManager.getModel().getDownloads()) { Downloadable downloadable = dataSourceService.getDownloadable(download.getUrl()); if(downloadable != null) { DataSource dataSource = downloadable.getDataSource(); addOrUpdateInQueue(dataSource, downloadable); } else log.fine("Cannot find downloadable for " + download.getUrl()); } } }
public long calculateRemainingDownloadSize(List<BoundingBox> boundingBoxes) { Collection<Downloadable> downloadables = getDownloadablesFor(boundingBoxes); long notExists = 0L; for (Downloadable downloadable : downloadables) { Long contentLength = downloadable.getLatestChecksum().getContentLength(); if (contentLength == null) continue; java.io.File file = createSegmentFile(downloadable.getUri()); if (!file.exists()) notExists += contentLength; } return notExists; }
private Download download(Downloadable downloadable) { List<FileAndChecksum> fragments = new ArrayList<>(); for (Fragment otherFragments : downloadable.getFragments()) { String key = otherFragments.getKey(); // ignore fragment keys without extension which are reported by old RouteConverter releases if (key.endsWith(DOT_HGT)) fragments.add(new FileAndChecksum(createFile(key), otherFragments.getLatestChecksum())); } String uri = downloadable.getUri(); String url = getBaseUrl() + uri; return downloadManager.queueForDownload(getName() + " Elevation Tile: " + uri, url, Action.valueOf(dataSource.getAction()), new FileAndChecksum(getDirectory(), downloadable.getLatestChecksum()), fragments); }
private long getSize(RemoteMap map) { Checksum checksum = map.getDownloadable().getLatestChecksum(); return checksum != null && checksum.getContentLength() != null ? checksum.getContentLength() : 0L; }
Downloadable downloadable = getSegments().getDownloadable(key); if (downloadable != null) { if (!createSegmentFile(downloadable.getUri()).exists()) notExistingSegments.add(downloadable); if (isInitialized()) { for (Downloadable downloadable : getProfiles().getFiles()) { if (!createProfileFile(downloadable.getUri()).exists()) notExistingProfiles.add(downloadable);
private Download download(Downloadable downloadable) { String uri = downloadable.getUri(); String url = getBaseUrl() + uri; return downloadManager.queueForDownload(getName() + " Routing Data: " + uri, url, Action.valueOf(dataSource.getAction()), new FileAndChecksum(createFile(downloadable.getUri()), downloadable.getLatestChecksum()), null); }
private long getSize(RemoteTheme theme) { Checksum checksum = theme.getDownloadable().getLatestChecksum(); return checksum != null && checksum.getContentLength() != null ? checksum.getContentLength() : 0L; }
public DownloadFuture downloadRoutingDataFor(List<LongitudeAndLatitude> longitudeAndLatitudes) { BoundingBox routeBoundingBox = createBoundingBox(longitudeAndLatitudes); final Downloadable downloadable = finder.getDownloadableFor(routeBoundingBox); final java.io.File file = downloadable != null ? createFile(downloadable.getUri()) : null; setOsmPbfFile(file); return new DownloadFuture() { public boolean isRequiresDownload() { return file != null && !file.exists(); } public boolean isRequiresProcessing() { if(file == null) return false; File path = createPath(file); File edges = new File(path, "edges"); return !path.exists() || !edges.exists(); } public void download() { downloadAndWait(downloadable); } public void process() { initializeHopper(); } }; }
private Download downloadProfile(Downloadable downloadable) { String uri = downloadable.getUri(); String url = getProfilesBaseUrl() + uri; return downloadManager.queueForDownload(getName() + " Routing Profile: " + uri, url, Action.valueOf(getProfiles().getAction()), new FileAndChecksum(createProfileFile(downloadable.getUri()), downloadable.getLatestChecksum()), null); }
public long calculateRemainingDownloadSize(List<BoundingBox> boundingBoxes) { Collection<Fragment<Downloadable>> fragments = getDownloadablesFor(boundingBoxes); Collection<Downloadable> downloadables = new HashSet<>(); for (Fragment<Downloadable> fragment : fragments) { java.io.File file = createFile(fragment.getKey()); if (!file.exists()) downloadables.add(fragment.getDownloadable()); } long notExists = 0L; for (Downloadable downloadable : downloadables) { Long contentLength = downloadable.getLatestChecksum().getContentLength(); if (contentLength == null) continue; notExists += contentLength; } return notExists; }