public Node getNode()

in src/main/java/org/apache/sling/fsprovider/internal/mapper/jcr/FsNode.java [93:130]


    public Node getNode(String relPath) throws PathNotFoundException, RepositoryException {
        if (relPath == null) {
            throw new PathNotFoundException();
        }

        // get absolute node path
        String path = relPath;
        if (!StringUtils.startsWith(path, "/")) {
            path = ResourceUtil.normalize(getPath() + "/" + relPath);
        }

        if (StringUtils.equals(path, contentFile.getPath())
                || StringUtils.startsWith(path, contentFile.getPath() + "/")) {
            // node is contained in content file
            String subPath;
            if (StringUtils.equals(path, contentFile.getPath())) {
                subPath = null;
            } else {
                subPath = path.substring(contentFile.getPath().length() + 1);
            }
            ContentFile referencedFile = contentFile.navigateToAbsolute(subPath);
            if (referencedFile.hasContent()) {
                return new FsNode(referencedFile, resolver);
            }
        }

        // check if node is outside content file
        Node refNode = null;
        Resource resource = resolver.getResource(path);
        if (resource != null) {
            refNode = resource.adaptTo(Node.class);
            if (refNode != null) {
                return refNode;
            }
        }

        throw new PathNotFoundException(relPath);
    }