Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.Root


        Tree principalRoot = getPrincipalRoot(EveryonePrincipal.NAME);
        assertEquals(2, cntEntries(principalRoot));

        ContentSession testSession = createTestSession();
        Root testRoot = testSession.getLatestRoot();

        assertTrue(testRoot.getTree(childPath).exists());
        assertFalse(testRoot.getTree(childPath + "/rep:policy").exists());

        testRoot.getTree(childPath).remove();
        testRoot.commit();
        testSession.close();

        root.refresh();
        assertFalse(root.getTree(testPath).hasChild("childNode"));
        assertFalse(root.getTree(childPath + "/rep:policy").exists());
View Full Code Here


    @Test
    public void testGetTree() throws Exception {
        setupPermission("/", testPrincipal, true, PrivilegeConstants.JCR_READ);
        setupPermission("/a/bb", testPrincipal, false, PrivilegeConstants.JCR_READ);

        Root testRoot = getTestRoot();

        List<String> accessible = ImmutableList.of("/", "/a", "/a/b", "/a/b/c");
        for (String path : accessible) {
            assertTrue(testRoot.getTree(path).exists());
        }

        assertFalse(testRoot.getTree("/a/bb").exists());
    }
View Full Code Here

    public void testGetTree2() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ);
        setupPermission("/a/b", testPrincipal, false, PrivilegeConstants.JCR_READ);
        setupPermission("/a/b/c", testPrincipal, true, PrivilegeConstants.JCR_READ);

        Root testRoot = getTestRoot();

        List<String> notAccessible = ImmutableList.of("/", "/a/b");
        for (String path : notAccessible) {
            assertFalse(path, testRoot.getTree(path).exists());
        }

        List<String> accessible = ImmutableList.of("/a", "/a/bb", "/a/b/c");
        for (String path : accessible) {
            assertTrue(path, testRoot.getTree(path).exists());
        }
    }
View Full Code Here

    @Test
    public void testGetNodeLocation() throws Exception {
        setupPermission("/", testPrincipal, true, PrivilegeConstants.REP_READ_NODES);
        setupPermission("/a/bb", testPrincipal, false, PrivilegeConstants.REP_READ_NODES);

        Root testRoot = getTestRoot();

        List<String> accessible = ImmutableList.of("/", "/a", "/a/b", "/a/b/c");
        for (String path : accessible) {
            Tree tree = testRoot.getTree(path);
            assertNotNull(tree);
            assertTrue(tree.exists());
        }

        Tree tree = testRoot.getTree("/a/bb");
        assertNotNull(tree);
        assertFalse(tree.exists());
    }
View Full Code Here

    public void testGetNodeLocation2() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.REP_READ_NODES);
        setupPermission("/a/b", testPrincipal, false, PrivilegeConstants.REP_READ_NODES);
        setupPermission("/a/b/c", testPrincipal, true, PrivilegeConstants.REP_READ_NODES);

        Root testRoot = getTestRoot();

        List<String> notAccessible = ImmutableList.of("/", "/a/b");
        for (String path : notAccessible) {
            Tree tree = testRoot.getTree(path);
            assertNotNull(path, tree);
            assertFalse(tree.exists());
        }

        List<String> accessible = ImmutableList.of("/a", "/a/bb", "/a/b/c");
        for (String path : accessible) {
            Tree tree = testRoot.getTree(path);
            assertNotNull(path, tree);
            assertTrue(tree.exists());
        }
    }
View Full Code Here

    @Test
    public void testGetNodeLocation3() throws Exception {
        // only property reading is allowed
        setupPermission("/", testPrincipal, true, PrivilegeConstants.REP_READ_PROPERTIES);

        Root testRoot = getTestRoot();

        List<String> notAccessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c");
        for (String path : notAccessible) {
            Tree tree = testRoot.getTree(path);
            assertNotNull(path, tree);
            assertFalse(tree.exists());
        }
    }
View Full Code Here

    @Test
    public void testGetPropertyLocation() throws Exception {
        setupPermission("/", testPrincipal, true, PrivilegeConstants.JCR_READ);

        Root testRoot = getTestRoot();

        List<String> accessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c");
        for (String path : accessible) {
            String propertyPath = PathUtils.concat(path, JcrConstants.JCR_PRIMARYTYPE);
            PropertyState property = testRoot.getTree(path).getProperty(JcrConstants.JCR_PRIMARYTYPE);
            assertNotNull(propertyPath, property);
        }

        List<String> propPaths = ImmutableList.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp");
        for (String path : propPaths) {
            PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path));
            assertNotNull(path, property);
        }
    }
View Full Code Here

    @Test
    public void testGetPropertyLocation2() throws Exception {
        setupPermission("/", testPrincipal, true, PrivilegeConstants.REP_READ_PROPERTIES);

        Root testRoot = getTestRoot();

        List<String> accessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c");
        for (String path : accessible) {
            String propertyPath = PathUtils.concat(path, JcrConstants.JCR_PRIMARYTYPE);
            PropertyState property = testRoot.getTree(path).getProperty(JcrConstants.JCR_PRIMARYTYPE);
            assertNotNull(propertyPath, property);
        }

        List<String> propPaths = ImmutableList.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp");
        for (String path : propPaths) {
            PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path));
            assertNotNull(path, property);
        }
    }
View Full Code Here

    public void testGetPropertyLocation3() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.REP_READ_PROPERTIES);
        setupPermission("/a/b", testPrincipal, false, PrivilegeConstants.REP_READ_PROPERTIES);
        setupPermission("/a/b/c", testPrincipal, true, PrivilegeConstants.REP_READ_PROPERTIES);

        Root testRoot = getTestRoot();

        List<String> accessible = ImmutableList.of("/a/aProp", "/a/bb/bbProp", "/a/b/c/cProp");
        for (String path : accessible) {
            PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path));
            assertNotNull(path, property);
        }

        List<String> notAccessible = ImmutableList.of("/jcr:primaryType", "/a/b/bProp");
        for (String path : notAccessible) {
            PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path));
            assertNull(path, property);
        }
    }
View Full Code Here

    public void testShadowInvisibleNode() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_ALL);
        setupPermission("/a/b", testPrincipal, false, PrivilegeConstants.JCR_ALL);
        setupPermission("/a/b/c", testPrincipal, true, PrivilegeConstants.JCR_ALL);

        Root testRoot = getTestRoot();
        Tree a = testRoot.getTree("/a");

        // /b not visible to this session
        assertFalse(a.hasChild("b"));

        // shadow /b with transient node of the same name
        Tree b = a.addChild("b");
        assertTrue(a.hasChild("b"));
        assertFalse(b.hasChild("c"));

        try {
            testRoot.commit();
            fail();
        } catch (CommitFailedException e) {
            assertTrue(e.isAccessViolation());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.Root

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.