public String getUrl() { return datasource.getBaseUrl() + downloadable.getUri(); } }
public String getName() { return dataSource.getName(); }
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 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)); }
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 Set<String> collectURIs(DataSource source) { Set<String> result = new HashSet<>(); switch (type) { case File: for (File file : source.getFiles()) result.add(file.getUri()); break; case Map: for (Map map : source.getMaps()) result.add(map.getUri()); break; case Theme: for (Theme theme : source.getThemes()) result.add(theme.getUri()); break; } return result; }
public synchronized void initialize() { hgtFiles.clear(); for (DataSource dataSource : dataSourceManager.getDataSourceService().getDataSources()) { if (DATASOURCE_URIS.contains(dataSource.getId())) hgtFiles.add(new HgtFiles(dataSource, dataSourceManager.getDownloadManager())); } }
public void update(String edition, String url, java.io.File directory) throws IOException, JAXBException { log.info(format("Updating edition '%s' from %s to %s", edition, url, directory)); java.io.File file = new java.io.File(directory, edition + DOT_XML); downloadEdition(edition, url, file); Edition anEdition = loadEdition(file); if(anEdition == null) return; downloadDataSources(anEdition.getDataSources(), directory); this.dataSourceService = loadDataSources(anEdition.getDataSources(), directory); updateQueueFromDataSources(); }
private void close() { dataSourceManager.getDownloadManager().saveQueue(); dataSourceManager.dispose(); }
public DownloadManager getDownloadManager() { return getDataSourceManager().getDownloadManager(); }
public String getDescription() { return getDownloadable().getUri(); }
public void initialize(String edition, java.io.File directory) throws IOException, JAXBException { java.io.File file = new File(directory, edition + DOT_XML); log.info(format("Initializing edition '%s' from %s", edition, file)); Edition anEdition = loadEdition(file); if(anEdition == null) return; this.dataSourceService = loadDataSources(anEdition.getDataSources(), directory); }
private boolean existsFile(File file) { return file != null && new java.io.File(directory, file.getUri()).exists(); }
public BoundingBox getBoundingBox() { Map map = (Map) getDownloadable(); return map.getBoundingBox(); } }
public String getImageUrl() { Theme theme = (Theme) getDownloadable(); return theme.getImageUrl(); } }
public void scanForFilesMissingInQueue() throws IOException { scanForFilesMissingInQueue(getApplicationDirectory()); }
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))); }
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); }
private void close() { dataSourceManager.getDownloadManager().saveQueue(); dataSourceManager.dispose(); }
private Download downloadSegment(Downloadable downloadable) { String uri = downloadable.getUri(); String url = getSegmentsBaseUrl() + uri; return downloadManager.queueForDownload(getName() + " Routing Segment: " + uri, url, Action.valueOf(getSegments().getAction()), new FileAndChecksum(createSegmentFile(downloadable.getUri()), downloadable.getLatestChecksum()), null); }