Package org.apache.jackrabbit.oak.util

Examples of org.apache.jackrabbit.oak.util.TreeLocation$NodeLocation


        return targetTree;
    }

    @Nonnull
    private static TreeLocation getLocation(Tree tree, String relativePath) {
        TreeLocation loc = TreeLocation.create(tree);
        for (String element : Text.explode(relativePath, '/', false)) {
            if (PathUtils.denotesParent(element)) {
                loc = loc.getParent();
            } else if (!PathUtils.denotesCurrent(element)) {
                loc = loc.getChild(element);
            // else . -> skip to next element
        }
        return loc;
    }
View Full Code Here


        switch (type) {
            case TreeTypeProvider.TYPE_HIDDEN:
                // TODO: OAK-753 decide on where to filter out hidden items.
                return true;
            case TreeTypeProvider.TYPE_VERSION:
                TreeLocation location = getVersionableLocation(tree, property);
                if (location == null) {
                    // TODO: review permission evaluation on hierarchy nodes within the different version stores.
                    return compiledPermissions.isGranted(tree, property, permissions);
                }
                Tree versionableTree = (property == null) ? location.getTree() : location.getParent().getTree();
                if (versionableTree != null) {
                    return compiledPermissions.isGranted(versionableTree, property, permissions);
                } else {
                    return compiledPermissions.isGranted(location.getPath(), permissions);
                }
            default:
                return compiledPermissions.isGranted(tree, property, permissions);
        }
    }
View Full Code Here

        }
    }

    @Override
    public boolean isGranted(@Nonnull String oakPath, @Nonnull String jcrActions) {
        TreeLocation location = TreeLocation.create(getImmutableRoot(), oakPath);
        boolean isAcContent = acConfig.getContext().definesLocation(location);
        long permissions = Permissions.getPermissions(jcrActions, location, isAcContent);

        boolean isGranted = false;
        if (!location.exists()) {
            // TODO: deal with version content
            isGranted = compiledPermissions.isGranted(oakPath, permissions);
        } else {
            PropertyState property = location.getProperty();
            Tree tree = (property == null) ? location.getTree() : location.getParent().getTree();
            if (tree != null) {
                isGranted = isGranted(tree, property, permissions);
            }
        }
        return isGranted;
View Full Code Here

    private boolean canReadAccessControlContent(@Nonnull Tree acTree, @Nullable PropertyState acProperty) {
        return compiledPermissions.isGranted(acTree, acProperty, Permissions.READ_ACCESS_CONTROL);
    }

    private ReadStatus getVersionContentReadStatus(@Nonnull Tree versionStoreTree, @Nullable PropertyState property) {
        TreeLocation location = getVersionableLocation(versionStoreTree, property);
        ReadStatus status;
        if (location != null) {
            Tree tree = (property == null) ? location.getTree() : location.getParent().getTree();
            if (tree == null) {
                long permission = (property == null) ? Permissions.READ_NODE : Permissions.READ_PROPERTY;
                if (compiledPermissions.isGranted(location.getPath(), permission)) {
                    status = ReadStatus.ALLOW_THIS;
                } else {
                    status = ReadStatus.DENY_THIS;
                }
            } else {
View Full Code Here

        root = null;
    }

    @Test
    public void testNullLocation() {
        TreeLocation xyz = nullLocation.getChild("x").getChild("y").getChild("z");
        Assert.assertEquals("x/y/z", xyz.getPath());
        assertEquals("x/y", xyz.getParent().getPath());
        assertEquals("x", xyz.getParent().getParent().getPath());
        assertEquals(nullLocation, xyz.getParent().getParent().getParent());
    }
View Full Code Here

        assertEquals(nullLocation, xyz.getParent().getParent().getParent());
    }

    @Test
    public void testParentOfRoot() {
        TreeLocation rootLocation = TreeLocation.create(root);
        assertEquals(nullLocation, rootLocation.getParent());
    }
View Full Code Here

        assertEquals(nullLocation, rootLocation.getParent());
    }

    @Test
    public void testNodeLocation() {
        TreeLocation x = TreeLocation.create(root, "/x");
        assertNotNull(x.getTree());

        TreeLocation xyz = x.getChild("y").getChild("z");
        assertEquals("/x/y/z", xyz.getPath());
        assertNull(xyz.getTree());

        TreeLocation xy = xyz.getParent();
        assertEquals("/x/y", xy.getPath());
        assertNull(xy.getTree());

        assertEquals(x.getTree(), xy.getParent().getTree());
    }
View Full Code Here

        assertEquals(x.getTree(), xy.getParent().getTree());
    }

    @Test
    public void testPropertyLocation() {
        TreeLocation a = TreeLocation.create(root, "/a");
        assertNotNull(a.getProperty());

        TreeLocation abc = a.getChild("b").getChild("c");
        assertEquals("/a/b/c", abc.getPath());
        assertNull(abc.getProperty());

        TreeLocation ab = abc.getParent();
        assertEquals("/a/b", ab.getPath());
        assertNull(ab.getProperty());

        assertEquals(a.getProperty(), ab.getParent().getProperty());
    }
View Full Code Here

        assertEquals(a.getProperty(), ab.getParent().getProperty());
    }

    @Test
    public void getDeepLocation() {
        TreeLocation p = TreeLocation.create(root, "/z/1/2/p");
        assertNotNull(p.getProperty());
        assertEquals("/z/1/2/p", p.getPath());

        TreeLocation n = TreeLocation.create(root, "/z/1/2/3/4");
        assertNull(n.getTree());
        assertNull(n.getProperty());
        assertEquals("/z/1/2/3/4", n.getPath());

        TreeLocation two = n.getParent().getParent();
        assertNotNull(two.getTree());
        assertEquals("/z/1/2", two.getPath());
    }
View Full Code Here

        switch (type) {
            case TreeTypeProvider.TYPE_HIDDEN:
                // TODO: OAK-753 decide on where to filter out hidden items.
                return true;
            case TreeTypeProvider.TYPE_VERSION:
                TreeLocation location = getVersionableLocation(tree, property);
                if (location == null) {
                    // TODO: review permission evaluation on hierarchy nodes within the different version stores.
                    return compiledPermissions.isGranted(tree, property, permissions);
                }
                Tree versionableTree = (property == null) ? location.getTree() : location.getParent().getTree();
                if (versionableTree != null) {
                    return compiledPermissions.isGranted(versionableTree, property, permissions);
                } else {
                    return compiledPermissions.isGranted(location.getPath(), permissions);
                }
            default:
                return compiledPermissions.isGranted(tree, property, permissions);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.util.TreeLocation$NodeLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.