You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2012/03/27 17:00:43 UTC

svn commit: r1305860 - in /jackrabbit/oak/trunk: oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/test/java/org/a...

Author: angela
Date: Tue Mar 27 15:00:42 2012
New Revision: 1305860

URL: http://svn.apache.org/viewvc?rev=1305860&view=rev
Log:
OAK-15 : Clean up oak-jcr

- move login to oak-core (work in progress)
- remove workspace mgt from oak-jcr (-> should go to oak-core)

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/AuthenticationService.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/AuthenticationServiceImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/SessionInfoImpl.java
Removed:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionFactory.java
Modified:
    jackrabbit/oak/trunk/oak-core/pom.xml
    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
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/pom.xml?rev=1305860&r1=1305859&r2=1305860&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-core/pom.xml Tue Mar 27 15:00:42 2012
@@ -48,7 +48,27 @@
       <optional>true</optional>
     </dependency>
 
-    <!--Test Dependencies-->
+    <!-- TODO: review
+         currently using credentials and some exceptions from JCR API -->
+    <dependency>
+      <groupId>javax.jcr</groupId>
+      <artifactId>jcr</artifactId>
+      <version>2.0</version>
+    </dependency>
+
+    <!-- Logging -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.6.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>jcl-over-slf4j</artifactId>
+      <version>1.6.4</version>
+    </dependency>
+
+    <!-- Test Dependencies -->
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/AuthenticationService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/AuthenticationService.java?rev=1305860&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/AuthenticationService.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/AuthenticationService.java Tue Mar 27 15:00:42 2012
@@ -0,0 +1,37 @@
+/*
+ * 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.api;
+
+import javax.jcr.NoSuchWorkspaceException;
+import javax.security.auth.login.LoginException;
+
+/**
+ * AuthenticationService... TODO: WORK IN PROGRESS
+ */
+public interface AuthenticationService {
+
+    /**
+     *
+     * @param credentials
+     * @param workspaceName
+     * @return
+     * @throws javax.security.auth.login.LoginException
+     * @throws javax.jcr.NoSuchWorkspaceException
+     */
+    SessionInfo login(Object credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException;
+
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java?rev=1305860&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java Tue Mar 27 15:00:42 2012
@@ -0,0 +1,77 @@
+/*
+ * 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.api;
+
+/**
+ * The {@code SessionInfo} TODO... describe how obtained, when disposed, used for communication with oak-api, identification, authorization....
+ */
+public interface SessionInfo {
+
+    /**
+     * Return the user ID to be exposed on the JCR Session object. It refers
+     * to the ID of the user associated with the Credentials passed to the
+     * repository login.
+     *
+     * @return the user ID such as exposed on the JCR Session object.
+     */
+    String getUserID();
+
+    /**
+     * Returns the attribute names associated with this instance.
+     *
+     * @return The attribute names with that instance or an empty array if
+     * no attributes are present.
+     */
+    String[] getAttributeNames();
+
+    /**
+     * Returns the attribute with the given name or {@code null} if no attribute
+     * with that {@code attributeName} exists.
+     *
+     * @param attributeName The attribute name.
+     * @return The attribute or {@code null}.
+     */
+    Object getAttribute(String attributeName);
+
+    /**
+     * Returns the current revision the associated session is operating on.
+     * Upon creation of a given {@code SessionInfo} instance the initial
+     * revision is always set to the head revision. Upon successful commit
+     * of changes the revision is reset to match the latest state.
+     *
+     * TODO: define how the desired initial revision is passed to the oak-api / mk
+     * TODO: define how and when the revision is updated (would a setRevision required? and who would use it?)
+     * TODO: define default value (head-revision?)
+     *
+     * @return the revision.
+     */
+    String getRevision();
+
+    /**
+     * The immutable name of the workspace this instance has been created for.
+     *
+     * @return name of the workspace this instance has been created for.
+     */
+    String getWorkspaceName();
+
+    /**
+     * Dispose this instance of {@code SessionInfo} as the associated
+     * JCR Session instance was logged out. This method allows an implementation
+     * to free any resources that may possibly be associated with this instance.
+     */
+    void dispose();
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/AuthenticationServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/AuthenticationServiceImpl.java?rev=1305860&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/AuthenticationServiceImpl.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/AuthenticationServiceImpl.java Tue Mar 27 15:00:42 2012
@@ -0,0 +1,89 @@
+/*
+ * 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.api.impl;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.AuthenticationService;
+import org.apache.jackrabbit.oak.api.SessionInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.GuestCredentials;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.SimpleCredentials;
+import javax.security.auth.login.LoginException;
+
+/**
+ * AuthenticationServiceImpl...
+ */
+public class AuthenticationServiceImpl implements AuthenticationService {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(AuthenticationServiceImpl.class);
+
+    // TODO: retrieve default wsp-name from configuration
+    private static final String DEFAULT_WORKSPACE_NAME = "default";
+
+    private final MicroKernel mk;
+
+    public AuthenticationServiceImpl(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);
+        }
+    }
+
+    @Override
+    public SessionInfo 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')
+
+        final SimpleCredentials sc;
+        if (credentials == null || credentials instanceof GuestCredentials) {
+            sc = new SimpleCredentials("anonymous", new char[0]);
+        } else if (credentials instanceof SimpleCredentials) {
+            sc = (SimpleCredentials) credentials;
+        } else {
+            sc = null;
+        }
+
+        final String wspName = (workspaceName == null) ? DEFAULT_WORKSPACE_NAME : workspaceName;
+        final String revision = getRevision(credentials);
+
+        if (sc != null) {
+            return new SessionInfoImpl(sc, wspName, revision);
+        } else {
+            throw new LoginException("login failed...");
+        }
+    }
+
+    /**
+     * @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.
+     */
+    private String getRevision(Object credentials) {
+        // TODO: define if/how desired revision can be passed in by the credentials object.
+        return mk.getHeadRevision();
+    }
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/SessionInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/SessionInfoImpl.java?rev=1305860&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/SessionInfoImpl.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/SessionInfoImpl.java Tue Mar 27 15:00:42 2012
@@ -0,0 +1,83 @@
+/*
+ * 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.api.impl;
+
+import org.apache.jackrabbit.oak.api.SessionInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.SimpleCredentials;
+
+/**
+ * SessionInfoImpl...
+ */
+public class SessionInfoImpl implements SessionInfo {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(SessionInfoImpl.class);
+
+    private final SimpleCredentials sc;
+    private final String workspaceName;
+
+    private String revision;
+
+    SessionInfoImpl(SimpleCredentials sc, String workspaceName, String revision) {
+        this.sc = sc;
+        this.workspaceName = workspaceName;
+        this.revision = revision;
+    }
+
+    @Override
+    public String getUserID() {
+        return sc.getUserID();
+    }
+
+    @Override
+    public String[] getAttributeNames() {
+        return sc.getAttributeNames();
+    }
+
+    @Override
+    public Object getAttribute(String attributeName) {
+        return sc.getAttribute(attributeName);
+    }
+
+    @Override
+    public String getRevision() {
+        return revision;
+    }
+
+    @Override
+    public String getWorkspaceName() {
+        return workspaceName;
+    }
+
+    @Override
+    public void dispose() {
+        // TODO
+
+    }
+
+    //--------------------------------------------------------------------------
+    // TODO: tmp solution as long as oak-jcr still writes to MK directly
+    public void setRevision(String revision) {
+        this.revision = revision;
+    }
+
+}
\ 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=1305860&r1=1305859&r2=1305860&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 Mar 27 15:00:42 2012
@@ -21,6 +21,8 @@ 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.AuthenticationService;
+import org.apache.jackrabbit.oak.api.impl.AuthenticationServiceImpl;
 import org.apache.jackrabbit.oak.jcr.configuration.RepositoryConfiguration;
 import org.apache.jackrabbit.oak.jcr.util.Unchecked;
 
@@ -34,6 +36,7 @@ import static java.text.MessageFormat.fo
 /**
  * Poor man's dependency injection
  * todo: OAK-17: replace by some more sophisticated mechanism
+ * todo: OAK-20: remove usages of mk on oak-jcr
  * This class implements a poor man's dependency injection mechanism.
  * It should be replaced by a more sophisticated mechanism for compile
  * time dependency injection mechanism.
@@ -42,10 +45,12 @@ public class GlobalContext {
     private final Map<Class<?>, Object> instances = new HashMap<Class<?>, Object>();
     
     public GlobalContext(RepositoryConfiguration repositoryConfiguration) throws RepositoryException {
+        MicroKernel mk = MicroKernelFactory.getInstance(repositoryConfiguration.getMicrokernelUrl());
+        AuthenticationService authenticationService = new AuthenticationServiceImpl(mk);
         put(RepositoryConfiguration.class, repositoryConfiguration);
-        put(MicroKernel.class, MicroKernelFactory.getInstance(repositoryConfiguration.getMicrokernelUrl()));
+        put(AuthenticationService.class, authenticationService);
+        put(MicroKernel.class, mk);
         put(Repository.class, new RepositoryImpl(this));
-        put(SessionFactory.class, SessionImpl.FACTORY);
     }
 
     public <T> T getInstance(Class<T> forClass) {

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=1305860&r1=1305859&r2=1305860&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 Mar 27 15:00:42 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import org.apache.jackrabbit.oak.api.AuthenticationService;
+import org.apache.jackrabbit.oak.api.SessionInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -24,6 +26,7 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
+import javax.security.auth.login.LoginException;
 
 /**
  * {@code RepositoryImpl}...
@@ -85,8 +88,14 @@ public class RepositoryImpl implements R
     public Session login(Credentials credentials, String workspaceName) throws RepositoryException {
         // TODO: needs complete refactoring
 
-        SessionFactory sessionFactory = context.getInstance(SessionFactory.class);
-        return sessionFactory.createSession(context, credentials, workspaceName);
+        AuthenticationService authentication = context.getInstance(AuthenticationService.class);
+        try {
+            SessionInfo sessionInfo = authentication.login(credentials, workspaceName);
+            return new SessionImpl(context, sessionInfo);
+        } catch (LoginException e) {
+            throw new javax.jcr.LoginException(e.getMessage());
+        }
+
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1305860&r1=1305859&r2=1305860&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java Tue Mar 27 15:00:42 2012
@@ -30,7 +30,7 @@ public interface SessionContext<T extend
     GlobalContext getGlobalContext();
     String getWorkspaceName();
     MicroKernel getMicrokernel();
-    String getRevision();
+    String getRevision(); // TODO: this should be superfluous if SessionInfo is used for communication
     ValueFactory getValueFactory();
     NodeStateProvider getNodeStateProvider();
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1305860&r1=1305859&r2=1305860&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java Tue Mar 27 15:00:42 2012
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.jcr;
 
 import org.apache.jackrabbit.commons.AbstractSession;
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.SessionInfo;
 import org.apache.jackrabbit.oak.jcr.state.NodeStateProvider;
 import org.apache.jackrabbit.oak.jcr.state.TransientNodeState;
 import org.apache.jackrabbit.oak.jcr.state.TransientSpace;
@@ -30,8 +31,6 @@ import javax.jcr.Credentials;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.Item;
 import javax.jcr.ItemNotFoundException;
-import javax.jcr.LoginException;
-import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
@@ -57,94 +56,29 @@ public class SessionImpl extends Abstrac
 
     private final Repository repository;
     private final Workspace workspace;
+    private final SessionInfo sessionInfo;
     private final ValueFactory valueFactory;
 
     private final GlobalContext globalContext;
-    private final String workspaceName;
-    private final MicroKernel microKernel;
     private final TransientSpace transientSpace;
     private final NodeStateProvider nodeStateProvider;
 
-    private String revision;
+    private String revision; // TODO: revision should be kept with sessionINFO and adjusted upon calls on oak-core API
     private boolean isAlive = true;
 
-    public static final SessionFactory FACTORY = new SessionFactory() {
-        @Override
-        public Session createSession(GlobalContext globalContext, Credentials credentials,
-                String workspaceName) throws LoginException, NoSuchWorkspaceException {
-
-            MicroKernel microKernel = globalContext.getInstance(MicroKernel.class);
-            String revision = microKernel.getHeadRevision();
-
-            if (workspaceName == null) {
-                workspaceName = WorkspaceImpl.DEFAULT_WORKSPACE_NAME;
-            }
-
-            if (!microKernel.nodeExists('/' + workspaceName, revision)) {
-                if (WorkspaceImpl.DEFAULT_WORKSPACE_NAME.equals(workspaceName)) {
-                    WorkspaceImpl.createWorkspace(microKernel, workspaceName);
-                    revision = microKernel.getHeadRevision();
-                }
-                else {
-                    throw new NoSuchWorkspaceException(workspaceName);
-                }
-            }
+    private final SessionContext<SessionImpl> sessionContext = new Context();
 
-            return new SessionImpl(globalContext, workspaceName, revision);
-        }
-    };
-
-    private final SessionContext<SessionImpl> sessionContext = new SessionContext<SessionImpl>() {
-
-        @Override
-        public SessionImpl getSession() {
-            return SessionImpl.this;
-        }
-
-        @Override
-        public GlobalContext getGlobalContext() {
-            return globalContext;
-        }
-
-        @Override
-        public String getWorkspaceName() {
-            return workspaceName;
-        }
-
-        @Override
-        public MicroKernel getMicrokernel() {
-            return microKernel;
-        }
-
-        @Override
-        public String getRevision() {
-            return revision;
-        }
-
-        @Override
-        public ValueFactory getValueFactory() {
-            return valueFactory;
-        }
-
-        @Override
-        public NodeStateProvider getNodeStateProvider() {
-            return nodeStateProvider;
-        }
-    };
-
-    private SessionImpl(GlobalContext globalContext, String workspaceName,
-            String revision) {
+    SessionImpl(GlobalContext globalContext, SessionInfo sessionInfo) {
 
         this.globalContext = globalContext;
-        this.workspaceName = workspaceName;
-        this.revision = revision;
+        this.sessionInfo = sessionInfo;
+        this.revision = sessionInfo.getRevision();
 
         valueFactory = new ValueFactoryImpl();
         repository = new RepositoryAdaptor(globalContext.getInstance(Repository.class), valueFactory);
         workspace = new WorkspaceImpl(sessionContext);
 
-        microKernel = globalContext.getInstance(MicroKernel.class);
-        transientSpace = new TransientSpace(workspaceName, microKernel, revision);
+        transientSpace = new TransientSpace(sessionContext.getWorkspaceName(), sessionContext.getMicrokernel(), revision);
         nodeStateProvider = new NodeStateProvider(sessionContext, transientSpace);
     }
 
@@ -158,19 +92,17 @@ public class SessionImpl extends Abstrac
 
     @Override
     public String getUserID() {
-        // TODO
-        return null;
+        return sessionInfo.getUserID();
     }
 
     @Override
     public String[] getAttributeNames() {
-        // TODO
-        return null;    }
+        return sessionInfo.getAttributeNames();
+    }
 
     @Override
     public Object getAttribute(String name) {
-        // TODO
-        return null;
+        return sessionInfo.getAttribute(name);
     }
 
     @Override
@@ -200,7 +132,7 @@ public class SessionImpl extends Abstrac
     @Override
     public Node getRootNode() throws RepositoryException {
         checkIsAlive();
-        return NodeImpl.create(sessionContext, Path.create(workspaceName));
+        return NodeImpl.create(sessionContext, Path.create(sessionContext.getWorkspaceName()));
     }
 
     @Override
@@ -220,12 +152,12 @@ public class SessionImpl extends Abstrac
 
     @Override
     public Node getNode(String absPath) throws RepositoryException {
-        return NodeImpl.create(sessionContext, Path.create(workspaceName, absPath));
+        return NodeImpl.create(sessionContext, Path.create(sessionContext.getWorkspaceName(), absPath));
     }
 
     @Override
     public boolean nodeExists(String absPath) throws RepositoryException {
-        Path path = Path.create(workspaceName, absPath);
+        Path path = Path.create(sessionContext.getWorkspaceName(), absPath);
         return path.isRoot() || NodeImpl.exist(sessionContext, path);
     }
 
@@ -235,12 +167,12 @@ public class SessionImpl extends Abstrac
             throw new ItemNotFoundException(absPath);
         }
 
-        return PropertyImpl.create(sessionContext, Path.create(workspaceName, absPath));
+        return PropertyImpl.create(sessionContext, Path.create(sessionContext.getWorkspaceName(), absPath));
     }
 
     @Override
     public boolean propertyExists(String absPath) throws RepositoryException {
-        Path path = Path.create(workspaceName, absPath);
+        Path path = Path.create(sessionContext.getWorkspaceName(), absPath);
         return !path.isRoot() && PropertyImpl.exist(sessionContext, path);
     }
 
@@ -265,13 +197,13 @@ public class SessionImpl extends Abstrac
     @Override
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
         checkIsAlive();
-        Path sourcePath = Path.create(workspaceName, srcAbsPath);
+        Path sourcePath = Path.create(sessionContext.getWorkspaceName(), srcAbsPath);
         TransientNodeState sourceParent = nodeStateProvider.getNodeState(sourcePath.getParent());
         if (sourceParent == null) {
             throw new PathNotFoundException(srcAbsPath);
         }
 
-        sourceParent.move(sourcePath.getName(), Path.create(workspaceName, destAbsPath));
+        sourceParent.move(sourcePath.getName(), Path.create(sessionContext.getWorkspaceName(), destAbsPath));
     }
 
     //------------------------------------------------------------< state >---
@@ -296,7 +228,7 @@ public class SessionImpl extends Abstrac
         return transientSpace.isDirty();
     }
 
-    //------------------------------------------------------------< Lifecycle >---
+    //----------------------------------------------------------< Lifecycle >---
 
     @Override
     public boolean isLive() {
@@ -313,9 +245,11 @@ public class SessionImpl extends Abstrac
 
         isAlive = false;
         // TODO
+
+        sessionInfo.dispose();
     }
 
-    //------------------------------------------------------------< Import / Export >---
+    //----------------------------------------------------< Import / Export >---
 
     @Override
     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws RepositoryException {
@@ -363,7 +297,7 @@ public class SessionImpl extends Abstrac
         }
     }
 
-    //------------------------------------------------------------< AccessControl >---
+    //------------------------------------------------------< AccessControl >---
 
     @Override
     public boolean hasPermission(String absPath, String actions) throws RepositoryException {
@@ -399,14 +333,14 @@ public class SessionImpl extends Abstrac
         return null;
     }
 
-    //------------------------------------------------------------< Retention >---
+    //----------------------------------------------------------< Retention >---
 
     @Override
     public RetentionManager getRetentionManager() throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Retention Management is not supported.");
     }
 
-    //------------------------------------------------------------< check methods >---
+    //--------------------------------------------------------------------------
 
     /**
      * Performs a sanity check on this session.
@@ -519,4 +453,43 @@ public class SessionImpl extends Abstrac
         }
     }
 
+    //--------------------------------------------------------------------------
+
+    private class Context implements SessionContext<SessionImpl> {
+
+        @Override
+        public SessionImpl getSession() {
+            return SessionImpl.this;
+        }
+
+        @Override
+        public GlobalContext getGlobalContext() {
+            return globalContext;
+        }
+
+        @Override
+        public String getWorkspaceName() {
+            return sessionInfo.getWorkspaceName();
+        }
+
+        @Override
+        public MicroKernel getMicrokernel() {
+            return globalContext.getInstance(MicroKernel.class);
+        }
+
+        @Override
+        public String getRevision() {
+            return revision;
+        }
+
+        @Override
+        public ValueFactory getValueFactory() {
+            return valueFactory;
+        }
+
+        @Override
+        public NodeStateProvider getNodeStateProvider() {
+            return nodeStateProvider;
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1305860&r1=1305859&r2=1305860&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java Tue Mar 27 15:00:42 2012
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.mk.model.ChildNodeEntry;
-import org.apache.jackrabbit.oak.kernel.KernelNodeState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
@@ -27,7 +24,6 @@ import javax.jcr.NamespaceRegistry;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Workspace;
 import javax.jcr.lock.LockManager;
 import javax.jcr.nodetype.NodeTypeManager;
@@ -37,14 +33,11 @@ import javax.jcr.version.Version;
 import javax.jcr.version.VersionManager;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * {@code WorkspaceImpl}...
  */
 public class WorkspaceImpl implements Workspace {
-    public static final String DEFAULT_WORKSPACE_NAME = "default";
 
     /**
      * logger instance
@@ -76,8 +69,8 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath) throws RepositoryException {
-        getOakSession().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        getSessionImpl().checkIsAlive();
 
         // TODO -> SPI
 
@@ -86,8 +79,8 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public void clone(String srcWorkspace, String srcAbsPath, String destAbsPath, boolean removeExisting) throws RepositoryException {
-        getOakSession().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        getSessionImpl().checkIsAlive();
 
         // TODO -> SPI
 
@@ -96,8 +89,8 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
-        getOakSession().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        getSessionImpl().checkIsAlive();
 
         // TODO -> SPI
 
@@ -110,8 +103,8 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public LockManager getLockManager() throws RepositoryException {
-        getOakSession().checkIsAlive();
-        getOakSession().checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
+        getSessionImpl().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
 
         // TODO
         return null;
@@ -119,7 +112,7 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public QueryManager getQueryManager() throws RepositoryException {
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkIsAlive();
 
         // TODO
         return null;
@@ -127,7 +120,7 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkIsAlive();
 
         // TODO
         return null;
@@ -135,50 +128,43 @@ public class WorkspaceImpl implements Wo
 
     @Override
     public NodeTypeManager getNodeTypeManager() throws RepositoryException {
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkIsAlive();
 
         // TODO
-        throw new UnsupportedRepositoryOperationException();
+        return null;
     }
 
     @Override
     public ObservationManager getObservationManager() throws RepositoryException {
-        getOakSession().checkSupportedOption(Repository.OPTION_OBSERVATION_SUPPORTED);
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.OPTION_OBSERVATION_SUPPORTED);
+        getSessionImpl().checkIsAlive();
 
         // TODO
-        throw new UnsupportedRepositoryOperationException();
+        return null;
     }
 
     @Override
     public VersionManager getVersionManager() throws RepositoryException {
-        getOakSession().checkIsAlive();
-        getOakSession().checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
+        getSessionImpl().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
 
         // TODO
-        throw new UnsupportedRepositoryOperationException();
+        return null;
     }
 
     @Override
     public String[] getAccessibleWorkspaceNames() throws RepositoryException {
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkIsAlive();
 
-        MicroKernel microKernel = sessionContext.getMicrokernel();
-        String revision = sessionContext.getRevision();
-        KernelNodeState rootState = new KernelNodeState(microKernel, "/", revision);
-        List<String> workspaces = new ArrayList<String>();
-        for (ChildNodeEntry entry : rootState.getChildNodeEntries(0, -1)) {
-            workspaces.add(entry.getName());
-        }
-
-        return workspaces.toArray(new String[workspaces.size()]);
+        // TODO -> SPI
+        return null;
     }
 
     @SuppressWarnings("deprecation")
     @Override
     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws RepositoryException {
-        getOakSession().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        getSessionImpl().checkIsAlive();
 
         // TODO
         return null;
@@ -187,47 +173,38 @@ public class WorkspaceImpl implements Wo
     @SuppressWarnings("deprecation")
     @Override
     public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException {
-        getOakSession().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        getOakSession().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
+        getSessionImpl().checkIsAlive();
 
         // TODO -> SPI
     }
 
     @Override
     public void createWorkspace(String name) throws RepositoryException {
-        getOakSession().checkIsAlive();
-        getOakSession().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        getSessionImpl().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
 
-        createWorkspace(sessionContext.getMicrokernel(), name);
+        // TODO -> SPI
     }
 
     @Override
     public void createWorkspace(String name, String srcWorkspace) throws RepositoryException {
-        getOakSession().checkIsAlive();
-        getOakSession().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        getSessionImpl().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
 
         // TODO -> SPI
     }
 
     @Override
     public void deleteWorkspace(String name) throws RepositoryException {
-        getOakSession().checkIsAlive();
-        getOakSession().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        getSessionImpl().checkIsAlive();
+        getSessionImpl().checkSupportedOption(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
 
-        MicroKernel microKernel = sessionContext.getMicrokernel();
-        String revision = microKernel.getHeadRevision();
-        microKernel.commit("/", "- \"" + name + '\"', revision, null);
+        // TODO -> SPI
     }
 
     //------------------------------------------------------------< private >---
-
-    private SessionImpl getOakSession() {
+    private SessionImpl getSessionImpl() {
         return sessionContext.getSession();
     }
-
-    static void createWorkspace(MicroKernel microKernel,String name) {
-        String revision = microKernel.getHeadRevision();
-        microKernel.commit("/", "+ \"" + name + "\" : {}", revision, null);
-    }
-
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1305860&r1=1305859&r2=1305860&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java Tue Mar 27 15:00:42 2012
@@ -114,51 +114,6 @@ public class RepositoryTest extends Abst
         assertNotNull(getSession());
     }
 
-    @Test(expected = NoSuchWorkspaceException.class)
-    public void loginInvalidWorkspace() throws RepositoryException {
-        Repository repository = getRepository();
-        repository.login("invalid");
-    }
-
-    @Test
-    public void getWorkspaceNames() throws RepositoryException {
-        String[] workspaces = getSession().getWorkspace().getAccessibleWorkspaceNames();
-
-        Set<String> names = new HashSet<String>() {{
-            add("default");
-        }};
-
-        assertTrue(asList(workspaces).containsAll(names));
-        assertTrue(names.containsAll(asList(workspaces)));
-    }
-
-    @Test
-    public void createDeleteWorkspace() throws RepositoryException {
-        getSession().getWorkspace().createWorkspace("new");
-
-        Session session2 = getRepository().login();
-        try {
-            String[] workspaces = session2.getWorkspace().getAccessibleWorkspaceNames();
-            assertTrue(asList(workspaces).contains("new"));
-            Session session3 = getRepository().login("new");
-            assertEquals("new", session3.getWorkspace().getName());
-            session3.logout();
-            session2.getWorkspace().deleteWorkspace("new");
-        }
-        finally {
-            session2.logout();
-        }
-
-        Session session4 = getRepository().login();
-        try {
-            String[] workspaces = session4.getWorkspace().getAccessibleWorkspaceNames();
-            assertFalse(asList(workspaces).contains("new"));
-        }
-        finally {
-            session4.logout();
-        }
-    }
-
     @Test
     public void getRoot() throws RepositoryException {
         Node root = getSession().getRootNode();



Re: svn commit: r1305860 - in /jackrabbit/oak/trunk: oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/test/java/o...

Posted by Michael Dürig <md...@apache.org>.

On 28.3.12 7:50, Angela Schreiber wrote:
>>> +
>>> + /**
>>> + * Returns the current revision the associated session is operating on.
>>> + * Upon creation of a given {@code SessionInfo} instance the initial
>>> + * revision is always set to the head revision. Upon successful commit
>>> + * of changes the revision is reset to match the latest state.
>>> + *
>>> + * TODO: define how the desired initial revision is passed to the
>>> oak-api / mk
>>> + * TODO: define how and when the revision is updated (would a
>>> setRevision required? and who would use it?)
>>
>> I wouldn't add support for setting the revision through the API. This
>> should only happen as a result of some higher level API like save() and
>> refresh() and possibly others.
>
> ok. glad to hear... that was my impression as well, but i would
> be open in case there was some compelling reason for having it.

So would I. But having it there from begin with will lead people to do 
all sorts of "funny things" with.

> regarding defining the revision
> upon initial login, that could be achieved by an attribute on the
> credentials.... but that's definitely not a first prio issue to solve.

That's my thinking too. So let's just keep this in the back of our minds 
(aka todos in the code).

Michael

Re: svn commit: r1305860 - in /jackrabbit/oak/trunk: oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/test/java/o...

Posted by Angela Schreiber <an...@adobe.com>.
hi michi

thanks for commenting. very much appreciated.

> I added the removed tests back and marked them as ignored. I think we
> should keep them for the time being until we have the same coverage from
> another test suite. We can then decide what to do with them.

thanks... that's obviously better (but i was in a hurry).

>> Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java
>> URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java?rev=1305860&view=auto
>> ==============================================================================
> [...]
>
>> +
>> +    /**
>> +     * Returns the current revision the associated session is operating on.
>> +     * Upon creation of a given {@code SessionInfo} instance the initial
>> +     * revision is always set to the head revision. Upon successful commit
>> +     * of changes the revision is reset to match the latest state.
>> +     *
>> +     * TODO: define how the desired initial revision is passed to the oak-api / mk
>> +     * TODO: define how and when the revision is updated (would a setRevision required? and who would use it?)
>
> I wouldn't add support for setting the revision through the API. This
> should only happen as a result of some higher level API like save() and
> refresh() and possibly others.

ok. glad to hear... that was my impression as well, but i would
be open in case there was some compelling reason for having it.

>
>> +     * TODO: define default value (head-revision?)

> The head revision seem like the correct default value to me.

fine with me.
i will clean up the TODOs in that case. regarding defining the revision
upon initial login, that could be achieved by an attribute on the
credentials.... but that's definitely not a first prio issue to solve.

kind regards
angela

Re: svn commit: r1305860 - in /jackrabbit/oak/trunk: oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/api/impl/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/test/java/org/a...

Posted by Michael Dürig <md...@apache.org>.

On 27.3.12 16:00, angela@apache.org wrote:
> Author: angela
> Date: Tue Mar 27 15:00:42 2012
> New Revision: 1305860
>
> URL: http://svn.apache.org/viewvc?rev=1305860&view=rev
> Log:
> OAK-15 : Clean up oak-jcr
>
> - move login to oak-core (work in progress)
> - remove workspace mgt from oak-jcr (->  should go to oak-core)

This looks pretty good to me and takes the direction I initially intended.

[...]

> Modified:
[...]
>      jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

I added the removed tests back and marked them as ignored. I think we 
should keep them for the time being until we have the same coverage from 
another test suite. We can then decide what to do with them.

> Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java
> URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/SessionInfo.java?rev=1305860&view=auto
> ==============================================================================
[...]

> +
> +    /**
> +     * Returns the current revision the associated session is operating on.
> +     * Upon creation of a given {@code SessionInfo} instance the initial
> +     * revision is always set to the head revision. Upon successful commit
> +     * of changes the revision is reset to match the latest state.
> +     *
> +     * TODO: define how the desired initial revision is passed to the oak-api / mk
> +     * TODO: define how and when the revision is updated (would a setRevision required? and who would use it?)

I wouldn't add support for setting the revision through the API. This 
should only happen as a result of some higher level API like save() and 
refresh() and possibly others.

> +     * TODO: define default value (head-revision?)

The head revision seem like the correct default value to me.

Michael