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

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


    private NodeState state;

    @Before
    public void setUp() throws CommitFailedException {
        NodeStore store = new KernelNodeStore(new MicroKernelImpl());
        NodeStoreBranch branch = store.branch();

        NodeBuilder builder = branch.getHead().builder();
        builder.setProperty("a", 1);
        builder.setProperty("b", 2);
        builder.setProperty("c", 3);
        builder.child("x");
        builder.child("y");
        builder.child("z");
        branch.setRoot(builder.getNodeState());

        state = branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
    }
View Full Code Here


    private NodeState state;

    @Before
    public void setUp() throws CommitFailedException {
        NodeStore store = new KernelNodeStore(new MicroKernelImpl());
        NodeStoreBranch branch = store.branch();

        NodeBuilder builder = branch.getHead().builder();
        builder.setProperty("a", 1);
        for (int i = 0; i <= N; i++) {
            builder.child("x" + i);
        }
        branch.setRoot(builder.getNodeState());

        state = branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
    }
View Full Code Here

                        .compose(new ArrayList<IndexEditorProvider>()));
    }

    @Test
    public void nodeType() throws Exception {
        NodeStoreBranch branch = store.branch();
        NodeBuilder root = branch.getHead().builder();

        // remove "rep:security" as it interferes with tests
        root.getChildNode("rep:security").remove();
       
        addFolder(root, "folder-1");
        addFolder(root, "folder-2");
        addFile(root, "file-1");

        branch.setRoot(root.getNodeState());
        branch.merge(new EditorHook(new IndexUpdateProvider(
                new PropertyIndexEditorProvider())), PostCommitHook.EMPTY);

        NodeState rootState = store.getRoot();
        NodeTypeIndex index = new NodeTypeIndex();
        FilterImpl filter;
View Full Code Here

    @Override
    public NodeState initialize(NodeState workspaceRoot, String workspaceName,
                                QueryIndexProvider indexProvider,
                                CommitHook commitHook) {
        MemoryNodeStore store = new MemoryNodeStore();
        NodeStoreBranch branch = store.branch();
        branch.setRoot(workspaceRoot);
        try {
            branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
        } catch (CommitFailedException e) {
            throw new RuntimeException(e);
        }

        Root root = new SystemRoot(store, commitHook, workspaceName, securityProvider, indexProvider);
View Full Code Here

        init(store);
        run(store);
    }

    private static void init(NodeStore store) throws CommitFailedException {
        NodeStoreBranch branch = store.branch();
        NodeBuilder builder = branch.getHead().builder();
        builder.child("x").child("y").child("z");
        branch.setRoot(builder.getNodeState());
        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
    }
View Full Code Here

        branch.setRoot(builder.getNodeState());
        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
    }

    private static void run(NodeStore store) throws CommitFailedException {
        NodeStoreBranch branch = store.branch();
        NodeBuilder builder = branch.getHead().builder();

        assertTrue("child node x should be present", builder.hasChildNode("x"));
        assertTrue("child node x/y should be present", builder.child("x")
                .hasChildNode("y"));
        assertTrue("child node x/y/z should be present", builder.child("x")
                .child("y").hasChildNode("z"));

        builder.getChildNode("x").remove();
        assertFalse("child node x not should be present",
                builder.hasChildNode("x"));
        assertFalse("child node x/y not should be present", builder.child("x")
                .hasChildNode("y"));

        // See OAK-531
        assertFalse("child node x/y/z not should not be present", builder
                .child("x").child("y").hasChildNode("z"));

        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
    }
View Full Code Here

        NodeBuilder builder = oldState.builder();
        builder.setProperty("foo", "bar");
        NodeState newState = builder.getNodeState();

        NodeStoreBranch branch = root.branch();
        branch.setRoot(newState);
        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);

        assertEquals(newState, root.getRoot());
        assertEquals(oldState, left.getRoot());
        assertEquals(oldState, right.getRoot());
View Full Code Here

        NodeBuilder builder = oldState.builder();
        builder.setProperty("foo", "bar");
        NodeState newState = builder.getNodeState();

        NodeStoreBranch branch = left.branch();
        branch.setRoot(newState);
        branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);

        assertEquals(oldState, root.getRoot());
        assertEquals(newState, left.getRoot());
        assertEquals(oldState, right.getRoot());
View Full Code Here

        NodeBuilder leftBuilder = oldState.builder();
        leftBuilder.setProperty("foo", "bar");
        NodeState leftState = leftBuilder.getNodeState();

        NodeStoreBranch leftBranch = left.branch();
        leftBranch.setRoot(leftState);
        leftBranch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);

        assertEquals(oldState, root.getRoot());
        assertEquals(leftState, left.getRoot());
        assertEquals(oldState, right.getRoot());

        store.getJournal("left").merge();
        assertEquals(leftState, root.getRoot());
        assertEquals(leftState, left.getRoot());
        assertEquals(oldState, right.getRoot());

        NodeBuilder rightBuilder = oldState.builder();
        rightBuilder.setProperty("bar", "foo");
        NodeState rightState = rightBuilder.getNodeState();

        NodeStoreBranch rightBranch = right.branch();
        rightBranch.setRoot(rightState);
        rightBranch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);

        store.getJournal("right").merge();
        NodeState newState = root.getRoot();
        assertEquals("bar", newState.getProperty("foo").getValue(Type.STRING));
        assertEquals("foo", newState.getProperty("bar").getValue(Type.STRING));
View Full Code Here

    public void copy() throws RepositoryException {
        logger.info(
                "Copying repository content from {} to Oak",
                source.getRepositoryConfig().getHomeDir());
        try {
            NodeStoreBranch branch = target.branch();
            NodeBuilder builder = branch.getHead().builder();

            copyNamespaces(builder);
            copyNodeTypes(builder);
            copyVersionStore(builder);
            copyWorkspaces(builder);

            branch.setRoot(builder.getNodeState());
            branch.merge(new EditorHook(new RegistrationEditorProvider()), PostCommitHook.EMPTY); // TODO: default hooks?
        } catch (Exception e) {
            throw new RepositoryException("Failed to copy content", e);
        }
    }
View Full Code Here

TOP

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

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.