use of org.apache.archiva.metadata.repository.filter.Filter in project archiva by apache.
the class Maven2RepositoryStorage method listProjects.
@Override
public Collection<String> listProjects(String repoId, String namespace, Filter<String> filter) throws RepositoryStorageRuntimeException {
Path dir = pathTranslator.toFile(getRepositoryBasedir(repoId), namespace);
if (!(Files.exists(dir) && Files.isDirectory(dir))) {
return Collections.emptyList();
}
// scan all directories in the namespace, and only include those that are known to be projects
final Predicate<Path> dFilter = new DirectoryFilter(filter);
try (Stream<Path> stream = Files.list(dir)) {
return stream.filter(dFilter).filter(path -> isProject(path, filter)).map(path -> path.getFileName().toString()).sorted().collect(Collectors.toList());
} catch (IOException e) {
LOGGER.error("Could not read directory {}: {}", dir, e.getMessage(), e);
return Collections.emptyList();
}
}
use of org.apache.archiva.metadata.repository.filter.Filter in project archiva by apache.
the class Maven2RepositoryStorage method listNamespaces.
@Override
public Collection<String> listNamespaces(String repoId, String namespace, Filter<String> filter) throws RepositoryStorageRuntimeException {
Path dir = pathTranslator.toFile(getRepositoryBasedir(repoId), namespace);
if (!(Files.exists(dir) && Files.isDirectory(dir))) {
return Collections.emptyList();
}
// scan all the directories which are potential namespaces. Any directories known to be projects are excluded
Predicate<Path> dFilter = new DirectoryFilter(filter);
try (Stream<Path> stream = Files.list(dir)) {
return stream.filter(dFilter).filter(path -> !isProject(path, filter)).map(path -> path.getFileName().toString()).sorted().collect(Collectors.toList());
} catch (IOException e) {
LOGGER.error("Could not read directory {}: {}", dir, e.getMessage(), e);
return Collections.emptyList();
}
}
Aggregations