public Item getAncestor()

in src/main/java/org/apache/sling/fsprovider/internal/mapper/jcr/FsItem.java [69:85]


    public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
        String path;
        if (depth == 0) {
            path = "/";
        } else {
            String[] pathParts = StringUtils.splitPreserveAllTokens(getPath(), "/");
            path = StringUtils.join(pathParts, "/", 0, depth + 1);
        }
        Resource resource = resolver.getResource(path);
        if (resource != null) {
            Node refNode = resource.adaptTo(Node.class);
            if (refNode != null) {
                return refNode;
            }
        }
        throw new ItemNotFoundException();
    }