Search in sources :

Example 11 with CompositeHook

use of org.apache.jackrabbit.oak.spi.commit.CompositeHook in project jackrabbit-oak by apache.

the class PropertyIndexTest method mountWithCommitInWritableMount.

@Test
public void mountWithCommitInWritableMount() throws Exception {
    NodeState root = INITIAL_CONTENT;
    // Add index definition
    NodeBuilder builder = root.builder();
    NodeBuilder index = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, false, ImmutableSet.of("foo"), null);
    index.setProperty("entryCount", -1);
    NodeState before = builder.getNodeState();
    // Add some content and process it through the property index hook
    builder.child("content").setProperty("foo", "abc");
    NodeState after = builder.getNodeState();
    MountInfoProvider mip = Mounts.newBuilder().readOnlyMount("foo", "/readOnly").build();
    CompositeHook hook = new CompositeHook(new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider().with(mip))), new EditorHook(new ValidatorProvider() {

        protected Validator getRootValidator(NodeState before, NodeState after, CommitInfo info) {
            return new PrivateStoreValidator("/", mip);
        }
    }));
    NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    Mount defMount = mip.getDefaultMount();
    assertTrue(getNode(indexed, pathInIndex(defMount, "/oak:index/foo", "/content", "abc")).exists());
}
Also used : CompositeHook(org.apache.jackrabbit.oak.spi.commit.CompositeHook) IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Mount(org.apache.jackrabbit.oak.spi.mount.Mount) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) ValidatorProvider(org.apache.jackrabbit.oak.spi.commit.ValidatorProvider) Test(org.junit.Test)

Example 12 with CompositeHook

use of org.apache.jackrabbit.oak.spi.commit.CompositeHook in project jackrabbit-oak by apache.

the class PropertyIndexCleaner method merge.

private void merge(NodeBuilder builder) throws CommitFailedException {
    // TODO Configure validator
    CompositeHook hooks = createCommitHook();
    nodeStore.merge(builder, hooks, createCommitInfo());
}
Also used : CompositeHook(org.apache.jackrabbit.oak.spi.commit.CompositeHook)

Aggregations

CompositeHook (org.apache.jackrabbit.oak.spi.commit.CompositeHook)12 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)11 ConflictValidatorProvider (org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)10 AnnotatingConflictHandler (org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler)7 ConflictHook (org.apache.jackrabbit.oak.plugins.commit.ConflictHook)7 Test (org.junit.Test)6 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)5 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 OakBaseTest (org.apache.jackrabbit.oak.OakBaseTest)3 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)3 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)3 EditorProvider (org.apache.jackrabbit.oak.spi.commit.EditorProvider)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 Calendar (java.util.Calendar)2 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)2 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)2 InvalidItemStateException (javax.jcr.InvalidItemStateException)1 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)1 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)1 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)1