Search in sources :

Example 21 with CommitHook

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

the class NodeStoreTest method addExistingNodeJCRLastModified.

@Test
public void addExistingNodeJCRLastModified() throws CommitFailedException {
    CommitHook hook = new CompositeHook(new ConflictHook(JcrConflictHandler.createJcrConflictHandler()), new EditorHook(new ConflictValidatorProvider()));
    NodeBuilder b1 = store.getRoot().builder();
    NodeBuilder b2 = store.getRoot().builder();
    Calendar calendar = Calendar.getInstance();
    b1.setChildNode("addExistingNodeJCRLastModified").setProperty(JCR_LASTMODIFIED, calendar);
    calendar.add(Calendar.MINUTE, 1);
    b2.setChildNode("addExistingNodeJCRLastModified").setProperty(JCR_LASTMODIFIED, calendar);
    b1.setChildNode("conflict");
    b2.setChildNode("conflict");
    store.merge(b1, hook, CommitInfo.EMPTY);
    store.merge(b2, hook, CommitInfo.EMPTY);
}
Also used : CompositeHook(org.apache.jackrabbit.oak.spi.commit.CompositeHook) CommitHook(org.apache.jackrabbit.oak.spi.commit.CommitHook) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Calendar(java.util.Calendar) ConflictHook(org.apache.jackrabbit.oak.plugins.commit.ConflictHook) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider) Test(org.junit.Test) OakBaseTest(org.apache.jackrabbit.oak.OakBaseTest)

Aggregations

CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)21 Test (org.junit.Test)12 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)10 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)9 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)9 Nonnull (javax.annotation.Nonnull)8 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)8 OakBaseTest (org.apache.jackrabbit.oak.OakBaseTest)5 ConflictHook (org.apache.jackrabbit.oak.plugins.commit.ConflictHook)4 ConflictValidatorProvider (org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)4 ArrayList (java.util.ArrayList)3 IndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider)3 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)3 CompositeHook (org.apache.jackrabbit.oak.spi.commit.CompositeHook)3 EditorProvider (org.apache.jackrabbit.oak.spi.commit.EditorProvider)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 Calendar (java.util.Calendar)2 CompositeIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider)2 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)2