jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1311715 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/
Date Tue, 10 Apr 2012 13:30:07 GMT
Author: mduerig
Date: Tue Apr 10 13:30:06 2012
New Revision: 1311715

URL: http://svn.apache.org/viewvc?rev=1311715&view=rev
Log:
OAK-15: Clean up oak-jcr
remove reference to MicroKernel

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java?rev=1311715&r1=1311714&r2=1311715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
Tue Apr 10 13:30:06 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.core;
 
+import org.apache.jackrabbit.mk.MicroKernelFactory;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.model.NodeState;
 import org.apache.jackrabbit.mk.model.NodeStateEditor;
@@ -60,7 +61,18 @@ public class ConnectionImpl implements C
     }
 
     static Connection createWorkspaceConnection(SimpleCredentials credentials,
-            String workspace, MicroKernel microKernel, String revision) throws NoSuchWorkspaceException
{
+            String workspace, boolean create, String microKernelUrl, String revision)
+            throws NoSuchWorkspaceException {
+
+        MicroKernel microKernel = MicroKernelFactory.getInstance(microKernelUrl);
+
+        // FIXME: workspace must be done elsewhere...
+        if (create) {
+            String headRev = microKernel.getHeadRevision();
+            if (!microKernel.nodeExists('/' + workspace, headRev)) {
+                microKernel.commit("/", "+ \"" + workspace + "\" : {}", headRev, null);
+            }
+        }
 
         NodeStore store = new KernelNodeStore(microKernel); // TODO: pass revision?
         NodeState wspRoot = store.getRoot().getChildNode(workspace);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java?rev=1311715&r1=1311714&r2=1311715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
Tue Apr 10 13:30:06 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.Connection;
 import org.apache.jackrabbit.oak.api.RepositoryService;
 import org.slf4j.Logger;
@@ -40,20 +39,16 @@ public class TmpRepositoryService implem
     // TODO: retrieve default wsp-name from configuration
     private static final String DEFAULT_WORKSPACE_NAME = "default";
 
-    private final MicroKernel mk;
+    private final String microKernelUrl;
 
-    public TmpRepositoryService(MicroKernel mk) {
-        this.mk = mk;
-
-        // FIXME: default mk-setup must be done elsewhere...
-        String headRev = mk.getHeadRevision();
-        if (!mk.nodeExists('/' + DEFAULT_WORKSPACE_NAME, headRev)) {
-            mk.commit("/", "+ \"" + DEFAULT_WORKSPACE_NAME + "\" : {}", headRev, null);
-        }
+    public TmpRepositoryService(String microKernelUrl) {
+        this.microKernelUrl = microKernelUrl;
     }
 
     @Override
-    public Connection login(Object credentials, String workspaceName) throws LoginException,
NoSuchWorkspaceException {
+    public Connection login(Object credentials, String workspaceName)
+            throws LoginException, NoSuchWorkspaceException {
+
         // TODO: add proper implementation
         // TODO  - authentication against configurable spi-authentication
         // TODO  - validation of workspace name (including access rights for the given 'user')
@@ -71,7 +66,9 @@ public class TmpRepositoryService implem
         final String revision = getRevision(credentials);
 
         if (sc != null) {
-            return ConnectionImpl.createWorkspaceConnection(sc, wspName, mk, revision);
+            return ConnectionImpl.createWorkspaceConnection(
+                    sc, wspName, wspName.equals(DEFAULT_WORKSPACE_NAME),
+                    microKernelUrl, getRevision(credentials));
         } else {
             throw new LoginException("login failed...");
         }
@@ -79,11 +76,11 @@ public class TmpRepositoryService implem
 
     /**
      * @param credentials The credentials object used for authentication.
-     * @return The microkernal revision. If the give credentials don't specify
-     * a specific revision number the current head revision is returned.
+     * @return The microkernel revision or {@code null} if the give credentials doesn't
+     * specify a specific revision number.
      */
     private String getRevision(Object credentials) {
         // TODO: define if/how desired revision can be passed in by the credentials object.
-        return mk.getHeadRevision();
+        return null;
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java?rev=1311715&r1=1311714&r2=1311715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
Tue Apr 10 13:30:06 2012
@@ -19,8 +19,6 @@
 
 package org.apache.jackrabbit.oak.jcr;
 
-import org.apache.jackrabbit.mk.MicroKernelFactory;
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.RepositoryService;
 import org.apache.jackrabbit.oak.core.TmpRepositoryService;
 import org.apache.jackrabbit.oak.jcr.configuration.RepositoryConfiguration;
@@ -45,12 +43,12 @@ public class GlobalContext {
     private final Map<Class<?>, Object> instances = new HashMap<Class<?>,
Object>();
     
     public GlobalContext(RepositoryConfiguration repositoryConfiguration) throws RepositoryException
{
-        this(MicroKernelFactory.getInstance(repositoryConfiguration.getMicrokernelUrl()));
+        this(repositoryConfiguration.getMicrokernelUrl());
         put(RepositoryConfiguration.class, repositoryConfiguration);
     }
 
-    public GlobalContext(MicroKernel mk) {
-        RepositoryService repositoryService = new TmpRepositoryService(mk);
+    public GlobalContext(String microKernelUrl) {
+        RepositoryService repositoryService = new TmpRepositoryService(microKernelUrl);
         put(RepositoryService.class, repositoryService);
         put(Repository.class, new RepositoryImpl(this));
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1311715&r1=1311714&r2=1311715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
Tue Apr 10 13:30:06 2012
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.oak.jcr;
 
 import org.apache.jackrabbit.commons.SimpleValueFactory;
-import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.api.Connection;
 import org.apache.jackrabbit.oak.api.RepositoryService;
 import org.slf4j.Logger;
@@ -48,7 +47,7 @@ public class RepositoryImpl implements R
      * newly constructed Oak repository.
      */
     public RepositoryImpl() {
-        this(new GlobalContext(new MicroKernelImpl()));
+        context = null; // fixme this(new GlobalContext(new MicroKernelImpl()));
     }
 
     public RepositoryImpl(GlobalContext context) {



Mime
View raw message