use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class LuceneIndexEditorTest method setup.
@Before
public void setup() throws Exception {
if (useBlobStore) {
LuceneIndexEditorProvider provider = new LuceneIndexEditorProvider();
CachingFileDataStore ds = DataStoreUtils.createCachingFDS(temporaryFolder.newFolder().getAbsolutePath(), temporaryFolder.newFolder().getAbsolutePath());
provider.setBlobStore(new DataStoreBlobStore(ds));
HOOK = new EditorHook(new IndexUpdateProvider(provider));
} else {
HOOK = new EditorHook(new IndexUpdateProvider(new LuceneIndexEditorProvider()));
}
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class NodeStoreUtils method mergeWithConcurrentCheck.
public static void mergeWithConcurrentCheck(NodeStore nodeStore, NodeBuilder builder) throws CommitFailedException {
List<EditorProvider> editorProviders = Lists.newArrayList();
editorProviders.add(new ConflictValidatorProvider());
CompositeHook hooks = new CompositeHook(new ConflictHook(new AnnotatingConflictHandler()), new EditorHook(CompositeEditorProvider.compose(editorProviders)));
nodeStore.merge(builder, hooks, CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class CrossMountReferenceValidatorTest method initializeHook.
@Before
public void initializeHook() {
MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/a").build();
hook = new EditorHook(new CompositeEditorProvider(new IndexUpdateProvider(new CompositeIndexEditorProvider(new PropertyIndexEditorProvider().with(mip), new ReferenceEditorProvider().with(mip))), new CrossMountReferenceValidatorProvider().with(mip).withFailOnDetection(true)));
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class IndexUpdateTest method contextAwareCallback_async.
@Test
public void contextAwareCallback_async() throws Exception {
NodeState before = builder.getNodeState();
NodeBuilder idx = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null);
idx.setProperty("async", asList("sync", "async"), Type.STRINGS);
NodeState after = builder.getNodeState();
CallbackCapturingProvider provider = new CallbackCapturingProvider();
EditorHook hook = new EditorHook(new IndexUpdateProvider(provider, "async", false));
hook.processCommit(before, after, CommitInfo.EMPTY);
assertTrue(((ContextAwareCallback) provider.callback).getIndexingContext().isAsync());
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class IndexUpdateTest method contextAwareCallback.
@Test
public void contextAwareCallback() throws Exception {
NodeState before = builder.getNodeState();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null);
NodeState after = builder.getNodeState();
CallbackCapturingProvider provider = new CallbackCapturingProvider();
EditorHook hook = new EditorHook(new IndexUpdateProvider(provider));
CommitInfo info = new CommitInfo("foo", "bar");
NodeState indexed = hook.processCommit(before, after, info);
assertNotNull(provider.callback);
assertThat(provider.callback, instanceOf(ContextAwareCallback.class));
ContextAwareCallback contextualCallback = (ContextAwareCallback) provider.callback;
IndexingContext context = contextualCallback.getIndexingContext();
assertNotNull(context);
assertEquals("/oak:index/rootIndex", context.getIndexPath());
assertTrue(context.isReindexing());
assertFalse(context.isAsync());
assertSame(info, context.getCommitInfo());
before = indexed;
builder = indexed.builder();
builder.child("a").setProperty("foo", "bar");
after = builder.getNodeState();
hook.processCommit(before, after, info);
assertFalse(((ContextAwareCallback) provider.callback).getIndexingContext().isReindexing());
}
Aggregations