protected StorageItem retrieveVirtualPath(ResourceStoreRequest request, RequestRoute route) throws ItemNotFoundException { ResourceStoreRequest req = new ResourceStoreRequest(route.getOriginalRequestPath()); DefaultStorageCollectionItem result = new DefaultStorageCollectionItem(this, req, true, false); result.getItemContext().putAll(request.getRequestContext()); return result; }
protected Collection<StorageItem> listVirtualPath( ResourceStoreRequest request, RequestRoute route) throws ItemNotFoundException { if (route.getRequestDepth() == 0) { // 1st level ArrayList<StorageItem> result = new ArrayList<StorageItem>(); for (RepositoryTypeDescriptor rtd : repositoryTypeRegistry.getRegisteredRepositoryTypeDescriptors()) { // check is there any repo registered if (!repositoryRegistry.getRepositoriesWithFacet(rtd.getRole()).isEmpty()) { ResourceStoreRequest req = new ResourceStoreRequest( ItemPathUtils.concatPaths(request.getRequestPath(), rtd.getPrefix())); DefaultStorageCollectionItem repositories = new DefaultStorageCollectionItem(this, req, true, false); repositories.getItemContext().putAll(request.getRequestContext()); result.add(repositories); } } return result; } else if (route.getRequestDepth() == 1) { // 2nd level List<? extends Repository> repositories = null; Class<? extends Repository> kind = null; for (RepositoryTypeDescriptor rtd : repositoryTypeRegistry.getRegisteredRepositoryTypeDescriptors()) { if (route.getStrippedPrefix().startsWith("/" + rtd.getPrefix())) { kind = rtd.getRole(); repositories = repositoryRegistry.getRepositoriesWithFacet(kind); break; } } // if no prefix matched, Item not found if (repositories == null || repositories.isEmpty()) { throw new ItemNotFoundException(request); } // 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()) { DefaultStorageCollectionItem repoItem = null; ResourceStoreRequest req = null; if (Repository.class.equals(kind)) { req = new ResourceStoreRequest( ItemPathUtils.concatPaths(request.getRequestPath(), repository.getId())); } else { req = new ResourceStoreRequest( ItemPathUtils.concatPaths( request.getRequestPath(), repository.getPathPrefix())); } repoItem = new DefaultStorageCollectionItem(this, req, true, false); repoItem.getItemContext().putAll(request.getRequestContext()); result.add(repoItem); } } return result; } else { throw new ItemNotFoundException(request); } }