}
}
// if no prefix matched, Item not found
if (repositories == null || repositories.isEmpty()) {
throw new ItemNotFoundException(reasonFor(request,
"No repositories found for given %s prefix!", route.getStrippedPrefix()));
}
// filter access to the repositories
// NOTE: do this AFTER the null/empty check so we return an empty list vs. an ItemNotFound
repositories = filterAccessToRepositories(repositories);
ArrayList<StorageItem> result = new ArrayList<StorageItem>(repositories.size());
for (Repository repository : repositories) {
if (repository.isExposed() && repository.isBrowseable()) {
ResourceStoreRequest req = null;
if (Repository.class.equals(kind)) {
req =
new ResourceStoreRequest(PathUtils.concatPaths(request.getRequestPath(),
repository.getId()));
}
else {
req =
new ResourceStoreRequest(PathUtils.concatPaths(request.getRequestPath(),
repository.getPathPrefix()));
}
req.getRequestContext().setParentContext(request.getRequestContext());
DefaultStorageCollectionItem repoItem = new DefaultStorageCollectionItem(this, req, true, false);
result.add(repoItem);
}
}
return result;
}
else {
throw new ItemNotFoundException(reasonFor(request,
"BUG: request depth is bigger than 1, route=%s", route));
}
}