jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1368881 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/ oak-core/src/test/java/org/apache/jackrabbit/oak/query/ oak-jcr/src/test/java/org/a...
Date Fri, 03 Aug 2012 10:46:46 GMT
Author: alexparvulescu
Date: Fri Aug  3 10:46:45 2012
New Revision: 1368881

URL: http://svn.apache.org/viewvc?rev=1368881&view=rev
Log:
OAK-224 Allow the ContentRepositoryImpl to receive a CommitEditor in the constructor

Added:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTestUtils.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java?rev=1368881&r1=1368880&r2=1368881&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
Fri Aug  3 10:46:45 2012
@@ -16,8 +16,7 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collections;
 
 import javax.annotation.Nonnull;
 import javax.jcr.Credentials;
@@ -32,18 +31,11 @@ import org.apache.jackrabbit.oak.api.Con
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
-import org.apache.jackrabbit.oak.plugins.lucene.LuceneEditor;
-import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
-import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
-import org.apache.jackrabbit.oak.plugins.type.DefaultTypeEditor;
-import org.apache.jackrabbit.oak.plugins.type.TypeValidatorProvider;
-import org.apache.jackrabbit.oak.plugins.value.ConflictValidatorProvider;
 import org.apache.jackrabbit.oak.query.QueryEngineImpl;
 import org.apache.jackrabbit.oak.security.authentication.LoginContextProviderImpl;
 import org.apache.jackrabbit.oak.security.authorization.AccessControlContextImpl;
 import org.apache.jackrabbit.oak.spi.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
-import org.apache.jackrabbit.oak.spi.commit.CompositeEditor;
 import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
 import org.apache.jackrabbit.oak.spi.commit.ValidatingEditor;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
@@ -75,33 +67,47 @@ public class ContentRepositoryImpl imple
      * test cases only.
      */
     public ContentRepositoryImpl() {
-        this(new MicroKernelImpl(), null, createDefaultValidatorProvider());
+        this(new MicroKernelImpl(), null, new ValidatingEditor(
+                new CompositeValidatorProvider(
+                        Collections.<ValidatorProvider> emptyList())));
         // this(new IndexWrapper(new MicroKernelImpl()), null, null);
     }
 
     /**
+     * Utility constructor, intended to be used within test cases only.
+     * 
+     * Creates an Oak repository instance based on the given, already
+     * initialized components.
+     * 
+     * @param microKernel
+     *            underlying kernel instance
+     * @param indexProvider
+     *            index provider
+     * @param validatorProvider
+     *            the validation provider
+     */
+    public ContentRepositoryImpl(MicroKernel microKernel,
+            QueryIndexProvider indexProvider,
+            ValidatorProvider validatorProvider) {
+        this(microKernel, indexProvider, new ValidatingEditor(
+                validatorProvider != null ? validatorProvider
+                        : new CompositeValidatorProvider(
+                                Collections.<ValidatorProvider> emptyList())));
+    }
+
+    /**
      * Creates an Oak repository instance based on the given, already
      * initialized components.
      *
      * @param microKernel underlying kernel instance
      * @param indexProvider index provider
-     * @param validatorProvider the validation provider
+     * @param commitEditor the commit editor
      */
     public ContentRepositoryImpl(MicroKernel microKernel, QueryIndexProvider indexProvider,
-            ValidatorProvider validatorProvider) {
-
-        if (validatorProvider == null) {
-            validatorProvider = createDefaultValidatorProvider();
-        }
-
+            CommitEditor commitEditor) {
 
         nodeStore = new KernelNodeStore(microKernel);
- 
-        List<CommitEditor> editors = new ArrayList<CommitEditor>();
-        editors.add(new DefaultTypeEditor());
-        editors.add(new ValidatingEditor(validatorProvider));
-        editors.add(new LuceneEditor());
-        nodeStore.setEditor(new CompositeEditor(editors));
+        nodeStore.setEditor(commitEditor);
 
         QueryIndexProvider qip = (indexProvider == null) ? getDefaultIndexProvider(microKernel)
: indexProvider;
         queryEngine = new QueryEngineImpl(nodeStore, microKernel, qip);
@@ -118,15 +124,6 @@ public class ContentRepositoryImpl imple
                 null, null);
     }
 
-    private static ValidatorProvider createDefaultValidatorProvider() {
-        List<ValidatorProvider> providers = new ArrayList<ValidatorProvider>();
-        providers.add(new NameValidatorProvider());
-        providers.add(new NamespaceValidatorProvider());
-        providers.add(new TypeValidatorProvider());
-        providers.add(new ConflictValidatorProvider());
-        return new CompositeValidatorProvider(providers);
-    }
-
     private static QueryIndexProvider getDefaultIndexProvider(MicroKernel mk) {
         return Indexer.getInstance(mk);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java?rev=1368881&r1=1368880&r2=1368881&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
Fri Aug  3 10:46:45 2012
@@ -21,6 +21,8 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.createIndexNode;
 
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.jcr.GuestCredentials;
 
@@ -34,6 +36,16 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
+import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.type.DefaultTypeEditor;
+import org.apache.jackrabbit.oak.plugins.type.TypeValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.value.ConflictValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
+import org.apache.jackrabbit.oak.spi.commit.CompositeEditor;
+import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.ValidatingEditor;
+import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.junit.Before;
 
 /**
@@ -54,7 +66,8 @@ public abstract class AbstractLuceneQuer
     @Before
     public void before() throws Exception {
         repository = new ContentRepositoryImpl(new MicroKernelImpl(),
-                new LuceneIndexProvider(DEFAULT_INDEX_HOME), null);
+                new LuceneIndexProvider(DEFAULT_INDEX_HOME),
+                buildDefaultCommitEditor());
         session = repository.login(new GuestCredentials(), null);
         cleanupIndexNode();
 
@@ -63,6 +76,23 @@ public abstract class AbstractLuceneQuer
 
     }
 
+    private static CommitEditor buildDefaultCommitEditor() {
+        List<CommitEditor> editors = new ArrayList<CommitEditor>();
+        editors.add(new DefaultTypeEditor());
+        editors.add(new ValidatingEditor(createDefaultValidatorProvider()));
+        editors.add(new LuceneEditor());
+        return new CompositeEditor(editors);
+    }
+
+    private static ValidatorProvider createDefaultValidatorProvider() {
+        List<ValidatorProvider> providers = new ArrayList<ValidatorProvider>();
+        providers.add(new NameValidatorProvider());
+        providers.add(new NamespaceValidatorProvider());
+        providers.add(new TypeValidatorProvider());
+        providers.add(new ConflictValidatorProvider());
+        return new CompositeValidatorProvider(providers);
+    }
+
     /**
      * Recreates an empty index node, ready to be used in tests
      * 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1368881&r1=1368880&r2=1368881&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
Fri Aug  3 10:46:45 2012
@@ -22,6 +22,9 @@ import org.apache.jackrabbit.oak.api.Con
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
+import org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexProvider;
+import org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils;
+import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 
 import javax.jcr.GuestCredentials;
 
@@ -38,7 +41,7 @@ public abstract class AbstractQueryTest 
 
     {
         mk = new IndexWrapper(new MicroKernelImpl());
-        rep = new ContentRepositoryImpl(mk, null, null);
+        rep = new ContentRepositoryImpl(mk, null, (ValidatorProvider) null);
         try {
             session = rep.login(new GuestCredentials(), "default");
             vf = session.getCoreValueFactory();

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java?rev=1368881&r1=1368880&r2=1368881&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
Fri Aug  3 10:46:45 2012
@@ -16,9 +16,12 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import static org.apache.jackrabbit.oak.jcr.RepositoryTestUtils.buildDefaultCommitEditor;
+
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.junit.After;
 
@@ -62,8 +65,9 @@ public abstract class AbstractRepository
     protected Repository getRepository() throws RepositoryException {
         if (repository == null) {
             executor = Executors.newScheduledThreadPool(1);
-            repository =
-                    new RepositoryImpl(new ContentRepositoryImpl(), executor);
+            repository = new RepositoryImpl(new ContentRepositoryImpl(
+                    new MicroKernelImpl(), null, buildDefaultCommitEditor()),
+                    executor);
         }
         return repository;
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java?rev=1368881&r1=1368880&r2=1368881&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
Fri Aug  3 10:46:45 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import static org.apache.jackrabbit.oak.jcr.RepositoryTestUtils.buildDefaultCommitEditor;
+
 import java.io.IOException;
 import java.security.Principal;
 import java.util.Properties;
@@ -48,7 +50,7 @@ public class OakRepositoryStub extends R
         super(settings);
 
         MicroKernel microkernel = new MicroKernelImpl("target/mk-tck-" + System.currentTimeMillis());
-        ContentRepository contentRepository = new ContentRepositoryImpl(microkernel, null,
null);
+        ContentRepository contentRepository = new ContentRepositoryImpl(microkernel, null,
buildDefaultCommitEditor());
         repository = new RepositoryImpl(contentRepository, Executors.newScheduledThreadPool(1));
 
         Session session = repository.login(superuser);
@@ -60,6 +62,7 @@ public class OakRepositoryStub extends R
         }
     }
 
+
     /**
      * Returns the configured repository instance.
      * 

Added: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTestUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTestUtils.java?rev=1368881&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTestUtils.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTestUtils.java
Fri Aug  3 10:46:45 2012
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.jcr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jackrabbit.oak.plugins.lucene.LuceneEditor;
+import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.type.DefaultTypeEditor;
+import org.apache.jackrabbit.oak.plugins.type.TypeValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.value.ConflictValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
+import org.apache.jackrabbit.oak.spi.commit.CompositeEditor;
+import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.ValidatingEditor;
+import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
+
+public class RepositoryTestUtils {
+
+    public static CommitEditor buildDefaultCommitEditor() {
+        List<CommitEditor> editors = new ArrayList<CommitEditor>();
+        editors.add(new DefaultTypeEditor());
+        editors.add(new ValidatingEditor(createDefaultValidatorProvider()));
+        editors.add(new LuceneEditor());
+        return new CompositeEditor(editors);
+    }
+
+    private static ValidatorProvider createDefaultValidatorProvider() {
+        List<ValidatorProvider> providers = new ArrayList<ValidatorProvider>();
+        providers.add(new NameValidatorProvider());
+        providers.add(new NamespaceValidatorProvider());
+        providers.add(new TypeValidatorProvider());
+        providers.add(new ConflictValidatorProvider());
+        return new CompositeValidatorProvider(providers);
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTestUtils.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java?rev=1368881&r1=1368880&r2=1368881&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java Fri
Aug  3 10:46:45 2012
@@ -17,11 +17,12 @@
 package org.apache.jackrabbit.oak.run;
 
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.Executors;
 
 import javax.jcr.Repository;
-import javax.servlet.Servlet;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
@@ -29,6 +30,17 @@ import org.apache.jackrabbit.oak.api.Con
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.http.OakServlet;
 import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
+import org.apache.jackrabbit.oak.plugins.lucene.LuceneEditor;
+import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.type.DefaultTypeEditor;
+import org.apache.jackrabbit.oak.plugins.type.TypeValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.value.ConflictValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
+import org.apache.jackrabbit.oak.spi.commit.CompositeEditor;
+import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.ValidatingEditor;
+import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.webdav.jcr.JCRWebdavServerServlet;
 import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet;
 import org.eclipse.jetty.server.Server;
@@ -132,7 +144,7 @@ public class Main {
 
         private void addServlets(MicroKernel kernel, String path) {
             ContentRepository repository =
-                    new ContentRepositoryImpl(kernel, null, null);
+                    new ContentRepositoryImpl(kernel, null, buildDefaultCommitEditor());
 
             ServletHolder oak =
                     new ServletHolder(new OakServlet(repository));
@@ -172,6 +184,23 @@ public class Main {
             context.addServlet(davex, path + "/davex/*");
         }
 
+        private static CommitEditor buildDefaultCommitEditor() {
+            List<CommitEditor> editors = new ArrayList<CommitEditor>();
+            editors.add(new DefaultTypeEditor());
+            editors.add(new ValidatingEditor(createDefaultValidatorProvider()));
+            editors.add(new LuceneEditor());
+            return new CompositeEditor(editors);
+        }
+
+        private static ValidatorProvider createDefaultValidatorProvider() {
+            List<ValidatorProvider> providers = new ArrayList<ValidatorProvider>();
+            providers.add(new NameValidatorProvider());
+            providers.add(new NamespaceValidatorProvider());
+            providers.add(new TypeValidatorProvider());
+            providers.add(new ConflictValidatorProvider());
+            return new CompositeValidatorProvider(providers);
+        }
+
     }
 
 }



Mime
View raw message