Search in sources :

Example 56 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class CompositeNodeStoreTest method resetOnMountedStore.

@Test
public void resetOnMountedStore() {
    NodeBuilder rootBuilder = store.getRoot().builder();
    NodeBuilder builder = rootBuilder.getChildNode("tmp");
    builder.child("newChild");
    store.reset(rootBuilder);
    assertFalse("Newly added child should no longer be visible after reset", builder.getChildNode("tmp").hasChildNode("newChild"));
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 57 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class CompositeNodeStoreTest method builderStateIsUpdatedBeforeMergeinMountedStore.

@Test
public void builderStateIsUpdatedBeforeMergeinMountedStore() throws Exception {
    NodeBuilder builder = store.getRoot().getChildNode("tmp").builder();
    builder.child("newChild");
    assertTrue("Newly created node should be visible in the builder's node state", builder.hasChildNode("newChild"));
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 58 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class CompositeNodeStoreTest method checkpoint.

@Test
public void checkpoint() throws Exception {
    String checkpoint = store.checkpoint(TimeUnit.DAYS.toMillis(1));
    assertNotNull("checkpoint reference is null", checkpoint);
    // create a new child /new in the root store
    NodeBuilder globalBuilder = globalStore.getRoot().builder();
    globalBuilder.child("new");
    globalStore.merge(globalBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // create a new child /tmp/new in the mounted store
    NodeBuilder mountedBuilder = mountedStore.getRoot().builder();
    mountedBuilder.getChildNode("tmp").child("new");
    mountedStore.merge(mountedBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // create a new child /libs/mount/new in the deeply mounted store
    NodeBuilder deepMountBuilder = deepMountedStore.getRoot().builder();
    deepMountBuilder.getChildNode("libs").getChildNode("mount").child("new");
    deepMountedStore.merge(deepMountBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    assertFalse("store incorrectly exposes child at /new", store.retrieve(checkpoint).hasChildNode("new"));
    assertFalse("store incorrectly exposes child at /tmp/new", store.retrieve(checkpoint).getChildNode("tmp").hasChildNode("new"));
    assertFalse("store incorrectly exposes child at /libs/mount/new", store.retrieve(checkpoint).getChildNode("libs").getChildNode("mount").hasChildNode("new"));
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 59 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class NodeStateFacetsConfig method setMultiValued.

@Override
public synchronized void setMultiValued(String dimName, boolean v) {
    super.setMultiValued(dimName, v);
    if (v) {
        NodeBuilder current = this.nodeBuilder;
        for (String p : PathUtils.elements(dimName)) {
            NodeBuilder child = current.child(p);
            if (!child.hasProperty(JcrConstants.JCR_PRIMARYTYPE)) {
                child.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
            }
            child.setProperty(MULTIVALUED, true);
            current = child;
        }
    }
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 60 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class NodeStateFacetsConfig method readMVFacets.

private void readMVFacets(NodeBuilder current, String prefix) {
    for (String childName : current.getChildNodeNames()) {
        NodeBuilder child = current.child(childName);
        super.setMultiValued(childName, child.getProperty(MULTIVALUED).getValue(Type.BOOLEAN));
        if (prefix.length() > 0) {
            super.setMultiValued(prefix + "/" + childName, child.getProperty(MULTIVALUED).getValue(Type.BOOLEAN));
            readMVFacets(child, childName);
        }
    }
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Aggregations

NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1190 Test (org.junit.Test)849 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)338 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)96 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)82 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)80 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)77 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)75 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)73 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)69 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)64 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)61 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)43 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)40 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)38 Blob (org.apache.jackrabbit.oak.api.Blob)36 ArrayList (java.util.ArrayList)29 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)29 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)28 Nonnull (javax.annotation.Nonnull)26