private void examineDirectoryContents(File directory, Set<URI> webLocationsFoundInParentDirectory) { Set<URI> newWebLocations = new HashSet<>(); if (algorithms == null || algorithms.isEmpty() || directory == null) { return; } Set<File> subFolders = new HashSet<>(); File[] directoryEntries = directory.listFiles(); if (directoryEntries == null) { // I think that this means that there was an I/O error return; } for (File physicalLocation : directoryEntries) { if (!physicalLocation.isHidden()) { if (recursive && physicalLocation.exists() && physicalLocation.isDirectory()) { subFolders.add(physicalLocation); } else if (physicalLocation.exists() && physicalLocation.isFile() && isValidOWLFile(physicalLocation)) { examineSingleFile(physicalLocation, webLocationsFoundInParentDirectory, newWebLocations); } } } webLocationsFoundInParentDirectory.addAll(newWebLocations); for (File physicalLocation : subFolders) { examineDirectoryContents(physicalLocation, webLocationsFoundInParentDirectory); } }
examineDirectoryContents(physicalLocation, webLocationsFoundInParentDirectory, nonOwlFiles, depth + 1);
public boolean update(Entry entry) { this.ge = (GroupEntry) entry; reset(); ensureLatestVersion(); try { logger.info(LogBanner.start("Starting Catalog Update")); logger.info("Update of group entry {} started at {}.", ge.getId(), new Date(timeOfCurrentUpdate)); retainEntries(); if(folder != null) { HashSet<File> nonOwlFiles = new HashSet<>(); examineDirectoryContents(folder, new HashSet<>(), nonOwlFiles, 0); if(nonOwlFiles.size() > NON_ONTOLOGY_DOCUMENT_TERMINATION_LIMIT) { logger.warn("Search for ontology documents in {} and sub-folders has been terminated as over {} non-ontology documents have been found.", folder.getAbsolutePath(), NON_ONTOLOGY_DOCUMENT_TERMINATION_LIMIT); } } if(modified) { clearEntries(); writeEntries(); } logger.info("Catalog Update Complete"); logger.info(LogBanner.end()); return modified; } finally { this.ge = null; reset(); } }
public boolean update(Entry entry) { this.ge = (GroupEntry) entry; reset(); ensureLatestVersion(); try { logger.debug("********************************* Starting Catalog Update ************************************************"); logger.debug("Update of group entry {} started at {}.", ge.getId(), new Date(timeOfCurrentUpdate)); retainEntries(); examineDirectoryContents(folder, new HashSet<>()); if (modified) { clearEntries(); writeEntries(); } logger.debug("********************************* Catalog Update Complete ************************************************"); return modified; } finally { this.ge = null; reset(); } }