Search in sources :

Example 6 with AnnotatingConflictHandler

use of org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler in project jackrabbit-oak by apache.

the class NodeStoreUtils method mergeWithConcurrentCheck.

static void mergeWithConcurrentCheck(NodeStore nodeStore, NodeBuilder builder, IndexEditorProvider indexEditorProvider) throws CommitFailedException {
    CompositeHook hooks = new CompositeHook(ResetCommitAttributeHook.INSTANCE, new EditorHook(new IndexUpdateProvider(indexEditorProvider, null, true)), new ConflictHook(new AnnotatingConflictHandler()), new EditorHook(CompositeEditorProvider.compose(singletonList(new ConflictValidatorProvider()))));
    nodeStore.merge(builder, hooks, createCommitInfo());
}
Also used : CompositeHook(org.apache.jackrabbit.oak.spi.commit.CompositeHook) IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) AnnotatingConflictHandler(org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) ConflictHook(org.apache.jackrabbit.oak.plugins.commit.ConflictHook) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)

Example 7 with AnnotatingConflictHandler

use of org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler in project jackrabbit-oak by apache.

the class NodeStoreDiffTest method diffWithConflict.

@Test
public void diffWithConflict() throws Exception {
    // Last rev on /var would be 1-0-1
    createNodes("/var/a", "/var/b/b1");
    // 1. Dummy commits to bump the version no
    createNodes("/fake/b");
    createNodes("/fake/c");
    // Root rev = 3-0-1
    // Root rev = 3-0-1
    // 2. Create a node under /var/a but hold on commit
    NodeBuilder b1 = ns.getRoot().builder();
    createNodes(b1, "/var/a/a1");
    // 3. Remove a node under /var/b and commit it
    NodeBuilder b2 = ns.getRoot().builder();
    b2.child("var").child("b").child("b1").remove();
    merge(b2);
    // 4. Now merge and commit the changes in b1 and include conflict hooks
    // For now exception would be thrown
    ns.merge(b1, new CompositeHook(ConflictHook.of(new AnnotatingConflictHandler()), new EditorHook(new ConflictValidatorProvider())), CommitInfo.EMPTY);
}
Also used : CompositeHook(org.apache.jackrabbit.oak.spi.commit.CompositeHook) AnnotatingConflictHandler(org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider) Test(org.junit.Test)

Aggregations

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