@Nullable @Override public CommitHook apply(@Nullable EditorProvider input) { return new EditorHook(input); } })).processCommit(before, after, info);
@Test public void requiredTypeIsUndefined() throws CommitFailedException { EditorHook hook = new EditorHook(new TypeEditorProvider()); NodeState root = INITIAL_CONTENT; NodeBuilder builder = root.builder(); NodeState before = builder.getNodeState(); builder.setProperty("any", "title"); NodeState after = builder.getNodeState(); hook.processCommit(before, after, CommitInfo.EMPTY); builder.setProperty("any", 134.34, Type.DOUBLE); hook.processCommit(after, builder.getNodeState(), CommitInfo.EMPTY); }
private NodeState commitAndDump(NodeState before, NodeState after) throws CommitFailedException, IOException { NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY); tracker.update(indexed); dumpIndexDir(); return indexed; }
private void commit() throws Exception { root = HOOK.processCommit(rootBuilder.getBaseState(), rootBuilder.getNodeState(), EMPTY); rootBuilder = root.builder(); }
@Nullable @Override public CommitHook apply(@Nullable EditorProvider input) { return new EditorHook(input); } })).processCommit(before, after, info);
@Test public void ignoreHidden() throws CommitFailedException { EditorHook hook = new EditorHook(new TypeEditorProvider()); NodeState root = INITIAL_CONTENT; NodeBuilder builder = root.builder(); NodeState before = builder.getNodeState(); builder.child(":hidden"); NodeState after = builder.getNodeState(); hook.processCommit(before, after, CommitInfo.EMPTY); before = after; builder.child(":hidden").setProperty("prop", "value"); after = builder.getNodeState(); hook.processCommit(before, after, CommitInfo.EMPTY); before = after; builder.getChildNode(":hidden").remove(); after = builder.getNodeState(); hook.processCommit(before, after, CommitInfo.EMPTY); }
private void commit() throws Exception { root = HOOK.processCommit(rootBuilder.getBaseState(), rootBuilder.getNodeState(), EMPTY); rootBuilder = root.builder(); }
@Nullable @Override public CommitHook apply(@Nullable EditorProvider input) { return new EditorHook(input); } })).processCommit(before, after, info);
@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()); }
private void commit() throws Exception { root = HOOK.processCommit(rootBuilder.getBaseState(), rootBuilder.getNodeState(), EMPTY); rootBuilder = root.builder(); }
/** * Turns all currently tracked editors to an editor commit hook and * associates that hook with the repository to be created. This way * a sequence of {@code with()} calls that alternates between editors * and other commit hooks will have all the editors in the correct * order while still being able to leverage the performance gains of * multiple editors iterating over the changes simultaneously. */ private void withEditorHook() { if (!editorProviders.isEmpty()) { commitHooks.add(new EditorHook( CompositeEditorProvider.compose(editorProviders))); editorProviders = newArrayList(); } }
@Test public void shouldNotReindexAsyncIndexInSyncMode() throws Exception{ String indexPath = "/oak:index/rootIndex"; CallbackCapturingProvider provider = new CallbackCapturingProvider(); IndexUpdateProvider indexUpdate = new IndexUpdateProvider(provider); EditorHook hook = new EditorHook(indexUpdate); NodeState before = builder.getNodeState(); NodeBuilder idx = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null); idx.setProperty("async", asList("async", "sync"), Type.STRINGS); builder.child("a").setProperty("foo", "abc"); NodeState after = builder.getNodeState(); NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY); assertFalse(provider.getContext(indexPath).isReindexing()); }
private void commit() throws Exception { root = HOOK.processCommit(rootBuilder.getBaseState(), rootBuilder.getNodeState(), EMPTY); rootBuilder = root.builder(); }
/** * Turns all currently tracked editors to an editor commit hook and * associates that hook with the repository to be created. This way * a sequence of {@code with()} calls that alternates between editors * and other commit hooks will have all the editors in the correct * order while still being able to leverage the performance gains of * multiple editors iterating over the changes simultaneously. */ private void withEditorHook() { if (!editorProviders.isEmpty()) { commitHooks.add(new EditorHook( CompositeEditorProvider.compose(editorProviders))); editorProviders = newArrayList(); } }
private NodeState getFooIndexNodeState() throws CommitFailedException { NodeState root = INITIAL_CONTENT; // Add index definition NodeBuilder builder = root.builder(); NodeBuilder index = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "fooIndex", true, false, ImmutableSet.of("foo"), null); builder.child("a").setProperty("foo", "abc"); NodeState after = builder.getNodeState(); EditorHook hook = new EditorHook( new IndexUpdateProvider(new PropertyIndexEditorProvider())); NodeState indexed = hook.processCommit(EMPTY_NODE, after, CommitInfo.EMPTY); return indexed.getChildNode("oak:index").getChildNode("fooIndex"); }
private void commit() throws Exception { root = HOOK.processCommit(rootBuilder.getBaseState(), rootBuilder.getNodeState(), EMPTY); rootBuilder = root.builder(); }
/** * Turns all currently tracked editors to an editor commit hook and * associates that hook with the repository to be created. This way * a sequence of {@code with()} calls that alternates between editors * and other commit hooks will have all the editors in the correct * order while still being able to leverage the performance gains of * multiple editors iterating over the changes simultaneously. */ private void withEditorHook() { if (!editorProviders.isEmpty()) { commitHooks.add(new EditorHook( CompositeEditorProvider.compose(editorProviders))); editorProviders = newArrayList(); } }
@Test public void addNamedPropertyWithBadRequiredType() { EditorHook hook = new EditorHook(new TypeEditorProvider()); NodeState root = INITIAL_CONTENT; NodeBuilder builder = root.builder(); NodeState before = builder.getNodeState(); NodeBuilder testNode = builder.child("testNode"); testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME); testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES); testNode.setProperty("jcr:title", true); try { hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY); fail(); } catch (CommitFailedException e) { assertTrue(e.isConstraintViolation()); } }
private NodeState doAsyncIndex(NodeState current, String childName, String fooValue) throws CommitFailedException { //Have some stuff to be indexed NodeBuilder builder = current.builder(); builder.child(childName).setProperty("foo", fooValue); NodeState after = builder.getNodeState(); return asyncHook.processCommit(current, after, newCommitInfo()); }
private static CommitHook createHook(@Nonnull IndexEditorProvider indexEditor) { return new CompositeHook( ResetCommitAttributeHook.INSTANCE, new EditorHook(new IndexUpdateProvider(indexEditor))); }