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())) throw new IllegalArgumentException( "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())); }
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; }