public synchronized DataSource getDataSourceByUrlPrefix(String url) { for (DataSource dataSource : getDataSources()) { if (url.startsWith(dataSource.getBaseUrl())) return dataSource; } return null; }
public String getUrl() { return datasource.getBaseUrl() + downloadable.getUri(); } }
public Downloadable getDownloadable(String url) { for (DataSource dataSource : getDataSources()) { if(!url.startsWith(dataSource.getBaseUrl())) continue; String uri = url.substring(dataSource.getBaseUrl().length()); Downloadable downloadable = dataSource.getDownloadable(uri); if (downloadable != null) return downloadable; } return null; }
private String getSegmentsBaseUrl() { return preferences.get(SEGMENTS_BASE_URL_PREFERENCE, getSegments().getBaseUrl()); }
private String getBaseUrl() { return preferences.get(BASE_URL_PREFERENCE, getDataSource().getBaseUrl()); }
private String getProfilesBaseUrl() { return preferences.get(PROFILES_BASE_URL_PREFERENCE, getProfiles().getBaseUrl()); }
String getBaseUrl() { return preferences.get(BASE_URL_PREFERENCE + getName(), dataSource.getBaseUrl()); }
private void scan() throws IOException, JAXBException { List<String> collectedUris = collectUris(); log.info(format("Collected URIs: %s (%d elements)", collectedUris, collectedUris.size())); DataSource source = loadDataSource(getId()); if (!getUrl().equals(source.getBaseUrl()) && !baseUrl.equals(source.getBaseUrl())) log.warning("Data source URL: " + source.getBaseUrl() + " doesn't match URL: " + getUrl()); Set<String> files = collectURIs(source); Set<String> addedUris = new HashSet<>(collectedUris); addedUris.removeAll(files); Set<String> removedUris = new HashSet<>(files); removedUris.removeAll(collectedUris); if (hasDataSourcesServer()) { if (addedUris.size() > 0) addUrisInChunks(source, addedUris); if (removedUris.size() > 0) removeUris(source, removedUris); } log.info(format("Added %d URIs, removed %d URIs out of %d URIs", addCount, removeCount, collectedUris.size())); }
if (!contains(filterUrls, dataSource.getBaseUrl() + aFile.getUri())) continue; if (!contains(filterUrls, dataSource.getBaseUrl() + map.getUri())) continue; if (!contains(filterUrls, dataSource.getBaseUrl() + theme.getUri())) continue;
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 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))); }
public static DatasourceType asDatasourceType(DataSource dataSource) { DatasourceType datasourceType = new ObjectFactory().createDatasourceType(); datasourceType.setId(dataSource.getId()); datasourceType.setName(dataSource.getName()); datasourceType.setBaseUrl(dataSource.getBaseUrl()); datasourceType.setDirectory(dataSource.getDirectory()); datasourceType.setAction(ActionType.fromValue(dataSource.getAction())); return datasourceType; }