Package org.apache.jackrabbit.oak.spi.state

Examples of org.apache.jackrabbit.oak.spi.state.NodeBuilder


        private void remove(Set<String> principalNames) {
            String msg = "Unable to remove permission entry";
            for (String principalName: entries.keySet()) {
                if (permissionRoot.hasChildNode(principalName)) {
                    principalNames.add(principalName);
                    NodeBuilder principalRoot = permissionRoot.getChildNode(principalName);

                    // find the ACL node that for this path and principal
                    NodeBuilder parent = principalRoot.getChildNode(nodeName);
                    if (!parent.exists()) {
                        continue;
                    }

                    long numEntries = PermissionUtil.getNumPermissions(principalRoot);

                    // check if the node is the correct one
                    if (PermissionUtil.checkACLPath(parent, accessControlledPath)) {
                        // remove and reconnect child nodes
                        NodeBuilder newParent = null;
                        for (String childName : parent.getChildNodeNames()) {
                            if (childName.charAt(0) != 'c') {
                                numEntries--;
                                continue;
                            }
                            NodeBuilder child = parent.getChildNode(childName);
                            if (newParent == null) {
                                newParent = child;
                            } else {
                                newParent.setChildNode(childName, child.getNodeState());
                                child.remove();
                            }
                        }
                        parent.remove();
                        if (newParent != null) {
                            principalRoot.setChildNode(nodeName, newParent.getNodeState());
                        }
                    } else {
                        // check if any of the child nodes match
                        for (String childName : parent.getChildNodeNames()) {
                            if (childName.charAt(0) != 'c') {
                                continue;
                            }
                            NodeBuilder child = parent.getChildNode(childName);
                            if (PermissionUtil.checkACLPath(child, accessControlledPath)) {
                                // remove child
                                for (String n: child.getChildNodeNames()) {
                                    numEntries--;
                                }
                                child.remove();
                            }
                        }
                    }
                    touch(principalRoot, numEntries);
                } else {
View Full Code Here


    @Test
    public void testPropertyAddition() throws Exception {
        NodeState root = EMPTY_NODE;

        NodeBuilder builder = root.builder();
        builder.child("oak:index").child("solr")
                .setProperty(JCR_PRIMARYTYPE, "oak:QueryIndexDefinition")
                .setProperty("type", "solr");

        NodeState before = builder.getNodeState();
        builder.setProperty("foo", "bar");
        NodeState after = builder.getNodeState();

        NodeState indexed = hook.processCommit(before, after);

        QueryIndex queryIndex = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
View Full Code Here

    @Test
    public void testSomeNodesCreationWithFullText() throws Exception {
        NodeState root = EMPTY_NODE;

        NodeBuilder builder = root.builder();
        builder.child("oak:index").child("solr")
                .setProperty(JCR_PRIMARYTYPE, "oak:QueryIndexDefinition")
                .setProperty("type", "solr");

        NodeState before = builder.getNodeState();
        builder.setProperty("foo", "bar");
        builder.child("a").setProperty("foo", "bar");
        builder.child("a").child("b").setProperty("foo", "bar");
        builder.child("a").child("b").child("c").setProperty("foo", "bar");

        NodeState after = builder.getNodeState();

        NodeState indexed = hook.processCommit(before, after);

        QueryIndex queryIndex = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
View Full Code Here

public class BlobReferenceTest {
   
    @Test
    public void test() throws Exception {
        MongoNodeStore s = new MongoMK.Builder().getNodeStore();
        NodeBuilder a = s.getRoot().builder();
        HashSet<String> set = new HashSet<String>();
        for (int i = 0; i < 100; i++) {
            Blob b = a.createBlob(randomStream(i, 10));
            set.add(b.toString());
            a.child("c" + i).setProperty("x", b);
        }
        s.merge(a, EmptyHook.INSTANCE, null);
        Iterator<Blob> it = s.getReferencedBlobsIterator();
        while (it.hasNext()) {
            Blob b = it.next();
View Full Code Here

    private ImmutableTree tree;

    @Before
    public void setup() {
        NodeBuilder root = EMPTY_NODE.builder();
        createPath(root, "a/b/c/d");
        createPath(root, "q");
        createPath(root, "x/y/x/y/z");
        createPath(root, "r/s/t/u/v/r/s/t/u/v/r/s/t/u/v/w");
        tree = new ImmutableTree(root.getNodeState());
    }
View Full Code Here

        createPath(root, "r/s/t/u/v/r/s/t/u/v/r/s/t/u/v/w");
        tree = new ImmutableTree(root.getNodeState());
    }

    private static void createPath(NodeBuilder root, String path) {
        NodeBuilder builder = root;
        for (String name : elements(path)) {
            builder = builder.setChildNode(name);
        }
    }
View Full Code Here

                "/a/b/g",
                "/a/d",
                "/a/d/h",
        };
        final int totalPaths = paths.length + 1; //1 extra for root
        NodeBuilder root = c1.getRoot().builder();
        createTree(root,paths);
        c1.merge(root, EmptyHook.INSTANCE, null);

        assertEquals(totalPaths,ds(c1).getCache().size());
View Full Code Here

    @Test
    public void testCacheInvalidation() throws CommitFailedException {
        final int totalPaths = createScenario();

        NodeBuilder b2 = c2.getRoot().builder();
        builder(b2,"/a/d").setProperty("foo", "bar");
        c2.merge(b2, EmptyHook.INSTANCE, null);

        //Push pending changes at /a
        c2.runBackgroundOperations();
View Full Code Here

    @Test
    public void testCacheInvalidation_Hierarchical() throws CommitFailedException {
        final int totalPaths = createScenario();

        NodeBuilder b2 = c2.getRoot().builder();
        builder(b2,"/a/c").setProperty("foo", "bar");
        c2.merge(b2, EmptyHook.INSTANCE, null);

        //Push pending changes at /a
        c2.runBackgroundOperations();
View Full Code Here

    @Test
    public void testCacheInvalidation_Linear() throws CommitFailedException {
        final int totalPaths = createScenario();

        NodeBuilder b2 = c2.getRoot().builder();
        builder(b2,"/a/c").setProperty("foo", "bar");
        c2.merge(b2, EmptyHook.INSTANCE, null);

        //Push pending changes at /a
        c2.runBackgroundOperations();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.state.NodeBuilder

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.