Package org.apache.jackrabbit.oak.plugins.tree

Examples of org.apache.jackrabbit.oak.plugins.tree.TreeLocation


        return compiledPermissions.isGranted(getImmutableTree(tree), property, permissions);
    }

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

        boolean isGranted = false;
        PropertyState property = location.getProperty();
        Tree tree = (property == null) ? location.getTree() : location.getParent().getTree();
        if (tree != null) {
            isGranted = isGranted(tree, property, permissions);
        } else if (!isVersionStorePath(oakPath)) {
            isGranted = compiledPermissions.isGranted(oakPath, permissions);
        }
View Full Code Here


        return compiledPermissions.isGranted(getImmutableTree(tree), property, permissions);
    }

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

        boolean isGranted = false;
        PropertyState property = location.getProperty();
        Tree tree = (property == null) ? location.getTree() : location.getParent().getTree();
        if (tree != null) {
            isGranted = isGranted(tree, property, permissions);
        } else if (!isVersionStorePath(oakPath)) {
            isGranted = compiledPermissions.isGranted(oakPath, permissions);
        }
View Full Code Here

        return compiledPermissions.isGranted(getImmutableTree(tree), property, permissions);
    }

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

        boolean isGranted = false;
        PropertyState property = location.getProperty();
        Tree tree = (property == null) ? location.getTree() : location.getParent().getTree();
        if (tree != null) {
            isGranted = isGranted(tree, property, permissions);
        } else if (!isVersionStorePath(oakPath)) {
            isGranted = compiledPermissions.isGranted(oakPath, permissions);
        }
View Full Code Here

    //---------------------------------------------< AuthorizableProperties >---
    @Override
    public Iterator<String> getNames(String relPath) throws RepositoryException {
        String oakPath = getOakPath(relPath);
        Tree tree = getTree();
        TreeLocation location = getLocation(tree, oakPath);
        Tree parent = location.getTree();
        if (parent != null && Text.isDescendantOrEqual(tree.getPath(), parent.getPath())) {
            List<String> l = new ArrayList<String>();
            for (PropertyState property : parent.getProperties()) {
                String propName = property.getName();
                if (isAuthorizableProperty(tree, location.getChild(propName), false)) {
                    l.add(namePathMapper.getJcrName(propName));
                }
            }
            return l.iterator();
        } else {
View Full Code Here

     */
    @Override
    public boolean removeProperty(String relPath) throws RepositoryException {
        String oakPath = getOakPath(relPath);
        Tree node = getTree();
        TreeLocation propertyLocation = getLocation(node, oakPath);
        if (propertyLocation.getProperty() != null) {
            if (isAuthorizableProperty(node, propertyLocation, true)) {
                return propertyLocation.remove();
            } else {
                throw new ConstraintViolationException("Property " + relPath + " isn't a modifiable authorizable property");
            }
        }
        // no such property or wasn't a property of this authorizable.
View Full Code Here

        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

        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

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.tree.TreeLocation

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.