Search in sources :

Example 6 with ConflictValidatorProvider

use of org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider in project sling by apache.

the class RepositoryTestHelper method createOakRepository.

public static Repository createOakRepository(NodeStore nodeStore) {
    DefaultWhiteboard whiteboard = new DefaultWhiteboard();
    final Oak oak = new Oak(nodeStore).with(new InitialContent()).with(JcrConflictHandler.createJcrConflictHandler()).with(new EditorHook(new VersionEditorProvider())).with(new OpenSecurityProvider()).with(new NamespaceEditorProvider()).with(new TypeEditorProvider()).with(new ConflictValidatorProvider()).with(//getDefaultWorkspace())
    "default").with(whiteboard);
    //        if (commitRateLimiter != null) {
    //            oak.with(commitRateLimiter);
    //        }
    final ContentRepository contentRepository = oak.createContentRepository();
    return new RepositoryImpl(contentRepository, whiteboard, new OpenSecurityProvider(), 1000, null);
}
Also used : InitialContent(org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent) NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Oak(org.apache.jackrabbit.oak.Oak) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) VersionEditorProvider(org.apache.jackrabbit.oak.plugins.version.VersionEditorProvider) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)

Example 7 with ConflictValidatorProvider

use of org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider in project sling by apache.

the class OakSlingRepositoryManager method acquireRepository.

@Override
protected Repository acquireRepository() {
    final BundleContext bundleContext = componentContext.getBundleContext();
    final Whiteboard whiteboard = new OsgiWhiteboard(bundleContext);
    this.indexProvider.start(whiteboard);
    this.indexEditorProvider.start(whiteboard);
    this.oakExecutorServiceReference = bundleContext.registerService(Executor.class.getName(), new Executor() {

        @Override
        public void execute(Runnable command) {
            threadPool.execute(command);
        }
    }, new Hashtable<String, Object>());
    final Oak oak = new Oak(nodeStore).withAsyncIndexing("async", 5);
    final Jcr jcr = new Jcr(oak, false).with(new InitialContent()).with(new ExtraSlingContent()).with(JcrConflictHandler.createJcrConflictHandler()).with(new VersionHook()).with(securityProvider).with(new NameValidatorProvider()).with(new NamespaceEditorProvider()).with(new TypeEditorProvider()).with(new ConflictValidatorProvider()).with(indexProvider).with(indexEditorProvider).with(getDefaultWorkspace()).with(whiteboard).withFastQueryResultSize(true).withObservationQueueLength(configuration.oak_observation_queue_length());
    if (commitRateLimiter != null) {
        jcr.with(commitRateLimiter);
    }
    jcr.createContentRepository();
    return new TcclWrappingJackrabbitRepository((JackrabbitRepository) jcr.createRepository());
}
Also used : NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) Hashtable(java.util.Hashtable) VersionHook(org.apache.jackrabbit.oak.plugins.version.VersionHook) NameValidatorProvider(org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider) InitialContent(org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent) Executor(java.util.concurrent.Executor) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) Oak(org.apache.jackrabbit.oak.Oak) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) BundleContext(org.osgi.framework.BundleContext)

Example 8 with ConflictValidatorProvider

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

the class AbstractSecurityTest method before.

@Before
public void before() throws Exception {
    Oak oak = new Oak().with(new InitialContent()).with(new VersionHook()).with(JcrConflictHandler.createJcrConflictHandler()).with(new NamespaceEditorProvider()).with(new ReferenceEditorProvider()).with(new ReferenceIndexProvider()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(new ConflictValidatorProvider()).with(getQueryEngineSettings()).with(getSecurityProvider());
    withEditors(oak);
    contentRepository = oak.createContentRepository();
    adminSession = login(getAdminCredentials());
    root = adminSession.getLatestRoot();
    Configuration.setConfiguration(getConfiguration());
}
Also used : NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) ReferenceIndexProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceIndexProvider) PropertyIndexProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) VersionHook(org.apache.jackrabbit.oak.plugins.version.VersionHook) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider) Before(org.junit.Before)

Example 9 with ConflictValidatorProvider

use of org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider 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(new ConflictHook(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) ConflictHook(org.apache.jackrabbit.oak.plugins.commit.ConflictHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider) Test(org.junit.Test)

Example 10 with ConflictValidatorProvider

use of org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider 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

ConflictValidatorProvider (org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)10 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)8 ConflictHook (org.apache.jackrabbit.oak.plugins.commit.ConflictHook)7 CompositeHook (org.apache.jackrabbit.oak.spi.commit.CompositeHook)7 AnnotatingConflictHandler (org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler)4 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)4 Test (org.junit.Test)4 OakBaseTest (org.apache.jackrabbit.oak.OakBaseTest)3 NamespaceEditorProvider (org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider)3 TypeEditorProvider (org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider)3 EditorProvider (org.apache.jackrabbit.oak.spi.commit.EditorProvider)3 Calendar (java.util.Calendar)2 Oak (org.apache.jackrabbit.oak.Oak)2 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)2 InitialContent (org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent)2 VersionHook (org.apache.jackrabbit.oak.plugins.version.VersionHook)2 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)2 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)2