@Override public boolean isDirectory() { return delegate.isDirectory(); } }
@Override public Resource<ResourceMeta> getPath(AuthContext auth, Path path) { if (!authorizedPath(auth, path, READ)) { throw new StorageAuthorizationException("Unauthorized access", StorageException.Event.READ, path); } Resource<ResourceMeta> resource = storageTree.getPath(path); if (resource.isDirectory()) { return resource; } return resource; }
@Override public Resource<T> getPath(Path path) { final Resource<T> resource = super.getPath(path); if (!resource.isDirectory() && MatcherUtil.matches(path, resource.getContents(), pathSelector, resourceSelector)) { return filterGetResource(path, resource); } return resource; }
@Override public Resource<T> getResource(Path path) { final Resource<T> resource = super.getResource(path); if (!resource.isDirectory() && MatcherUtil.matches(path, resource.getContents(), pathSelector, resourceSelector)) { return filterGetResource(path, resource); } return resource; }
/** * Delete all resources and subdirectories of the given resource path * @param tree tree * @param path path * @return true if all resources were deleted successfully. */ public static boolean deletePathRecursive(Tree<ResourceMeta> tree, Path path){ if(tree.hasResource(path)) { //delete just this resource return tree.deleteResource(path); }else if (tree.hasDirectory(path)) { //list resources and delete Set<Resource<ResourceMeta>> resources = tree.listDirectory(path); boolean failed=false; for (Resource<ResourceMeta> resource : resources) { if(resource.isDirectory()){ if(!deletePathRecursive(tree,resource.getPath())){ failed=true; } }else { if(!tree.deleteResource(resource.getPath())){ failed=true; } } } return !failed; }else{ return true; } }