Search in sources :

Example 6 with EditorProvider

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

the class PrivateStoreValidatorProviderTest method testValidatorServiceRegistered.

@Test
public void testValidatorServiceRegistered() {
    // test service registration, there should be a service for the PrivateStoreValidatorProvider
    MountInfoProvider mountInfoProvider = createMountInfoProvider("/content/readonly");
    context.registerService(MountInfoProvider.class, mountInfoProvider);
    registerValidatorProvider(privateStoreValidatorProvider, true);
    EditorProvider validator = context.getService(EditorProvider.class);
    assertNotNull("No PrivateStoreValidatorProvider available!", validator);
    assertTrue(validator instanceof PrivateStoreValidatorProvider);
    assertTrue(((PrivateStoreValidatorProvider) validator).isFailOnDetection());
    MockOsgi.deactivate(privateStoreValidatorProvider, context.bundleContext());
    assertNull(context.getService(EditorProvider.class));
}
Also used : MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) EditorProvider(org.apache.jackrabbit.oak.spi.commit.EditorProvider) Test(org.junit.Test)

Example 7 with EditorProvider

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

the class VersionHook method processCommit.

@Nonnull
@Override
public NodeState processCommit(NodeState before, NodeState after, CommitInfo info) throws CommitFailedException {
    Set<String> existingVersionables = newHashSet();
    List<EditorProvider> providers = newArrayList();
    providers.add(new VersionEditorProvider());
    providers.add(new VersionableCollector.Provider(existingVersionables));
    providers.add(new OrphanedVersionCleaner.Provider(existingVersionables));
    return compose(transform(providers, new Function<EditorProvider, CommitHook>() {

        @Nullable
        @Override
        public CommitHook apply(@Nullable EditorProvider input) {
            return new EditorHook(input);
        }
    })).processCommit(before, after, info);
}
Also used : CommitHook(org.apache.jackrabbit.oak.spi.commit.CommitHook) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) EditorProvider(org.apache.jackrabbit.oak.spi.commit.EditorProvider) Nullable(javax.annotation.Nullable) Nonnull(javax.annotation.Nonnull)

Example 8 with EditorProvider

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

the class DocumentBundlingTest method recreatedBundledNode2.

@Test
public void recreatedBundledNode2() throws Exception {
    NodeBuilder builder = store.getRoot().builder();
    NodeBuilder fileNode = newNode("nt:file");
    fileNode.child("jcr:content").setProperty("jcr:data", "foo");
    builder.child("test").setChildNode("book.jpg", fileNode.getNodeState());
    merge(builder);
    builder = store.getRoot().builder();
    builder.child("a");
    //In this case we recreate the node in CommitHook
    store.merge(builder, new EditorHook(new EditorProvider() {

        @Override
        public Editor getRootEditor(NodeState before, NodeState after, NodeBuilder builder, CommitInfo info) throws CommitFailedException {
            return new BookRecreatingEditor(builder);
        }
    }), CommitInfo.EMPTY);
}
Also used : DocumentNodeState(org.apache.jackrabbit.oak.plugins.document.DocumentNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AbstractNodeState(org.apache.jackrabbit.oak.spi.state.AbstractNodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) EditorProvider(org.apache.jackrabbit.oak.spi.commit.EditorProvider) Test(org.junit.Test)

Example 9 with EditorProvider

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

the class PrivateStoreValidatorProviderTest method testValidatorServiceNotRegistered.

@Test
public void testValidatorServiceNotRegistered() {
    // test service registration, for default mount there should be no service for the validator provider
    MountInfoProvider mountInfoProvider = createMountInfoProvider();
    context.registerService(MountInfoProvider.class, mountInfoProvider);
    registerValidatorProvider(privateStoreValidatorProvider, true);
    EditorProvider validator = context.getService(EditorProvider.class);
    assertNull("No PrivateStoreValidatorProvider should be registered for default mounts!", validator);
}
Also used : MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) EditorProvider(org.apache.jackrabbit.oak.spi.commit.EditorProvider) Test(org.junit.Test)

Aggregations

EditorProvider (org.apache.jackrabbit.oak.spi.commit.EditorProvider)9 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)6 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)4 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)4 Test (org.junit.Test)4 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)3 AnnotatingConflictHandler (org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler)3 ConflictHook (org.apache.jackrabbit.oak.plugins.commit.ConflictHook)3 ConflictValidatorProvider (org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)3 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)3 CompositeHook (org.apache.jackrabbit.oak.spi.commit.CompositeHook)3 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)3 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)2 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)2 Editor (org.apache.jackrabbit.oak.spi.commit.Editor)2 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)2 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 DocumentNodeState (org.apache.jackrabbit.oak.plugins.document.DocumentNodeState)1 IndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider)1