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())); } }
private void open() { dataSourceManager = new DataSourceManager(new DownloadManager(new java.io.File(getSnapshotDirectory(), "update-queue.xml"))); dataSourceManager.getDownloadManager().loadQueue(); }
private void close() { dataSourceManager.getDownloadManager().saveQueue(); dataSourceManager.dispose(); }
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(); }
public DownloadManager getDownloadManager() { return getDataSourceManager().getDownloadManager(); }
public void queueForDownload(List<? extends RemoteResource> resources) { List<Download> downloads = new ArrayList<>(); for (RemoteResource resource : resources) { Downloadable downloadable = resource.getDownloadable(); DataSource dataSource = resource.getDataSource(); downloads.add(dataSourceManager.queueForDownload(dataSource, downloadable)); } dataSourceManager.getDownloadManager().waitForCompletion(downloads); }
public void initialize() { DataSourceService dataSourceService = dataSourceManager.getDataSourceService(); for (DataSource dataSource : dataSourceService.getDataSources()) { mapFiles.add(new MapFiles(dataSource)); } }
public void snapshot() throws IOException, JAXBException { open(); dataSourceManager.downloadRoot(getDataSourcesServer(), getRootDirectory()); DataSourceService root = loadAllDataSources(getRootDirectory()); dataSourceManager.downloadEditions(root.getEditions(), getEditionsDirectory()); DataSourceService editions = loadAllDataSources(getEditionsDirectory()); dataSourceManager.downloadDataSources(createDataSourceSet(editions.getEditions()), getDataSourcesDirectory()); DataSourceService dataSources = loadAllDataSources(getDataSourcesDirectory()); log.info(String.format("Snapshot contains %d editions and %d datasources", editions.getEditions().size(), dataSources.getDataSources().size())); close(); }
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); } } }
public void scanForFilesMissingInQueue() throws IOException { scanForFilesMissingInQueue(getApplicationDirectory()); }
protected void initializeServices() { System.setProperty("rest", parseVersionFromManifest().getVersion()); RouteFeedback routeFeedback = new RouteFeedback(System.getProperty("feedback", "https://www.routeconverter.com/feedback/"), getApiUrl(), RouteConverter.getInstance().getCredentials()); routeServiceOperator = new RouteServiceOperator(getFrame(), routeFeedback); updateChecker = new UpdateChecker(routeFeedback); DownloadManager downloadManager = new DownloadManager(new File(getApplicationDirectory(), getEditionId() + "-queue.xml")); downloadManager.addDownloadListener(new ChecksumSender()); downloadManager.addDownloadListener(new DownloadNotifier()); dataSourceManager = new DataSourceManager(downloadManager); timeZoneModel.addChangeListener(e -> { ColumbusV1000Device.setTimeZone(timeZoneModel.getTimeZoneId()); // for TimeAlbum }); tileServerMapManager = new TileServerMapManager(getTileServersDirectory()); }
protected void shutdown() { if (isMapViewAvailable()) getMapView().dispose(); getConvertPanel().dispose(); if (positionAugmenter != null) positionAugmenter.dispose(); if (audioPlayer != null) audioPlayer.dispose(); if (geoTagger != null) geoTagger.dispose(); getDataSourceManager().dispose(); getDownloadManager().saveQueue(); getTileServerMapManager().dispose(); super.shutdown(); log.info("Shutdown " + getTitle() + " for " + parseVersionFromManifest().getOperationSystem() + " with locale " + Locale.getDefault() + " on " + getJava() + " and " + getPlatform() + " with " + getMaximumMemory() + " MByte heap"); }
private Download head(String url) { Download download = dataSourceManager.getDownloadManager().queueForDownload("HEAD for " + url, url, Head, new FileAndChecksum(createMirrorFile(url), null), null); dataSourceManager.getDownloadManager().waitForCompletion(singletonList(download)); return download; }
private void configureRoutingServices() { DataSource brouterProfiles = getDataSourceManager().getDataSourceService().getDataSourceById("brouter-profiles"); DataSource brouterSegments = getDataSourceManager().getDataSourceService().getDataSourceById("brouter-segments-4"); if (brouterProfiles != null && brouterSegments != null) { BRouter router = getRoutingServiceFacade().getRoutingService(BRouter.class); router.setProfilesAndSegments(brouterProfiles, brouterSegments); } DataSource graphhopper = getDataSourceManager().getDataSourceService().getDataSourceById("graphhopper"); if (graphhopper != null) { GraphHopper hopper = getRoutingServiceFacade().getRoutingService(GraphHopper.class); hopper.setDataSource(graphhopper); } }
private void scanForFilesMissingInQueue() { // scan for files that are not in the queue but in the file system and put them in the queue if they're in a datasource try { getDataSourceManager().scanForFilesMissingInQueue(); } catch (IOException e) { log.warning("Could not scan for files missing in queue: " + e); getContext().getNotificationManager().showNotification(MessageFormat.format( getBundle().getString("scan-error"), getLocalizedMessage(e)), null); } }
private Download download(String url) { Download download = dataSourceManager.getDownloadManager().queueForDownload("GET for " + url, url, Copy, new FileAndChecksum(createMirrorFile(url), null), null); dataSourceManager.getDownloadManager().waitForCompletion(singletonList(download)); return download; }
private void open() throws IOException { dataSourceManager = new DataSourceManager(new DownloadManager(new File(getSnapshotDirectory(), "snapshot-queue.xml"))); if(reset) { dataSourceManager.getDownloadManager().clearQueue(); recursiveDelete(getSnapshotDirectory()); } else dataSourceManager.getDownloadManager().loadQueue(); }
private void close() { dataSourceManager.getDownloadManager().saveQueue(); dataSourceManager.dispose(); }
public void sendChecksums(final Download download) { final DataSource dataSource = RouteConverter.getInstance().getDataSourceManager(). getDataSourceService().getDataSourceByUrlPrefix(download.getUrl()); if (dataSource == null) { return; } final Map<FileAndChecksum, List<FileAndChecksum>> fileToFragments = new HashMap<>(); fileToFragments.put(download.getFile(), download.getFragments()); getRouteServiceOperator().executeOperation(new RouteServiceOperator.Operation() { public String getName() { return "SendChecksums"; } public void run() throws IOException { getRouteServiceOperator().getRouteFeedback().sendChecksums(dataSource, fileToFragments, download.getUrl()); } }); }
public void dispose() { dataSourceService.clear(); getDownloadManager().dispose(); }