jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1344776 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ oak-core/src/test/java/org/apache/jackrabbit/oak/core/ oak-core/src/test/resources/org/a...
Date Thu, 31 May 2012 15:34:30 GMT
Author: mduerig
Date: Thu May 31 15:34:29 2012
New Revision: 1344776

URL: http://svn.apache.org/viewvc?rev=1344776&view=rev
Log:
OAK-118: Implement workspace handling
- removing half baked support for multiple workspaces as noted on the last comment of the
issue

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElement.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.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=1344776&r1=1344775&r2=1344776&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
Thu May 31 15:34:29 2012
@@ -34,7 +34,6 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.ValidatingCommitHook;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -96,18 +95,13 @@ public class ContentRepositoryImpl imple
         // TODO: use configurable context provider
         loginContextProvider = new LoginContextProviderImpl(this);
 
-        // FIXME: workspace setup must be done elsewhere...
-        NodeState root = nodeStore.getRoot();
-
-        NodeState wspNode = root.getChildNode(DEFAULT_WORKSPACE_NAME);
-
         // FIXME: depends on CoreValue's name mangling
         String ntUnstructured = "nam:nt:unstructured";
 
-        if (wspNode == null) {
-            microKernel.commit("/", "+\"" + DEFAULT_WORKSPACE_NAME + "\":{}" + "^\"" + DEFAULT_WORKSPACE_NAME
-                    + "/jcr:primaryType\":\"" + ntUnstructured + "\" ", null, null);
-        }
+        // FIXME: workspace setup must be done elsewhere...
+        microKernel.commit("/",
+                "^\"jcr:primaryType\":\"" + ntUnstructured + "\" ",
+                null, null);
     }
 
     private static QueryIndexProvider getDefaultIndexProvider(MicroKernel mk) {
@@ -121,8 +115,8 @@ public class ContentRepositoryImpl imple
             workspaceName = DEFAULT_WORKSPACE_NAME;
         }
 
-        NodeState wspRoot = nodeStore.getRoot().getChildNode(workspaceName);
-        if (wspRoot == null) {
+        // TODO: support multiple workspaces. See OAK-118
+        if (!DEFAULT_WORKSPACE_NAME.equals(workspaceName)) {
             throw new NoSuchWorkspaceException(workspaceName);
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Thu May 31 15:34:29 2012
@@ -22,7 +22,6 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateBuilder;
@@ -44,7 +43,7 @@ public class RootImpl implements Root {
     static final Logger log = LoggerFactory.getLogger(RootImpl.class);
 
     /**
-     * Number of {@link #setWorkspaceRootState(NodeState)} calls for which changes
+     * Number of {@link #setCurrentRootState} calls for which changes
      * are kept in memory.
      */
     private static final int PURGE_LIMIT = 100;
@@ -52,20 +51,17 @@ public class RootImpl implements Root {
     /** The underlying store to which this root belongs */
     private final NodeStore store;
 
-    /** The name of the workspace we are operating on */
-    private final String workspaceName;
+    /** Current branch this root operates on */
+    private NodeStoreBranch branch;
 
     /** Actual root element of the {@code Tree} */
     private TreeImpl root;
 
-    /** Current branch this root operates on */
-    private NodeStoreBranch branch;
-
-    /** Lazily initialised builder for the root node state of this workspace */
-    private NodeStateBuilder workspaceBuilder;
+    /** Current root node state if changed */
+    private NodeState currentRootState;
 
     /**
-     * Number of {@link #setWorkspaceRootState(NodeState)} occurred so since the lase
+     * Number of {@link #setCurrentRootState} occurred so since the lase
      * purge.
      */
     private int modCount;
@@ -94,10 +90,11 @@ public class RootImpl implements Root {
      * New instance bases on a given {@link NodeStore} and a workspace
      * @param store  node store
      * @param workspaceName  name of the workspace
+     * TODO: add support for multiple workspaces. See OAK-118
      */
+    @SuppressWarnings("UnusedParameters")
     public RootImpl(NodeStore store, String workspaceName) {
         this.store = store;
-        this.workspaceName = workspaceName;
         branch = store.branch();
         root = TreeImpl.createRoot(this);
     }
@@ -116,13 +113,11 @@ public class RootImpl implements Root {
 
         String destName = getName(destPath);
         if (source.moveTo(destParent, destName)) {
-            branch.move(
-                PathUtils.concat(workspaceName, sourcePath),
-                PathUtils.concat(workspaceName, destPath));
-
-            return true;
+            currentRootState = null;
+            return branch.move(sourcePath, destPath);
         }
         else {
+            currentRootState = null;
             return false;
         }
     }
@@ -130,9 +125,7 @@ public class RootImpl implements Root {
     @Override
     public boolean copy(String sourcePath, String destPath) {
         purgePendingChanges();
-        return branch.copy(
-            PathUtils.concat(workspaceName, sourcePath),
-            PathUtils.concat(workspaceName, destPath));
+        return branch.copy(sourcePath, destPath);
     }
 
     @Override
@@ -143,8 +136,9 @@ public class RootImpl implements Root {
     @Override
     public void rebase() {
         purgePendingChanges();
-        NodeState base = getWorkspaceBaseState();
-        NodeState head = getWorkspaceRootState();
+        NodeState base = getBaseState();
+        NodeState head = getCurrentRootState();
+        currentRootState = null;
         branch = store.branch();
         root = TreeImpl.createRoot(this);
         merge(base, head, getRoot());
@@ -152,7 +146,7 @@ public class RootImpl implements Root {
 
     @Override
     public void refresh() {
-        workspaceBuilder = null;
+        currentRootState = null;
         branch = store.branch();
         root = TreeImpl.createRoot(this);
     }
@@ -167,7 +161,7 @@ public class RootImpl implements Root {
 
     @Override
     public boolean hasPendingChanges() {
-        return !getWorkspaceBaseState().equals(getWorkspaceRootState());
+        return !getBaseState().equals(getCurrentRootState());
     }
 
     /**
@@ -181,31 +175,24 @@ public class RootImpl implements Root {
     }
 
     /**
-     * Returns the current root node state of the workspace
+     * Returns the current root node state
      * @return root node state
      */
     @Nonnull
-    public NodeState getWorkspaceRootState() {
-        if (workspaceBuilder == null) {
-            NodeState workspaceRootState = branch.getRoot().getChildNode(workspaceName);
-            assert workspaceRootState != null;
-            return workspaceRootState;
-        }
-        else {
-            return workspaceBuilder.getNodeState();
+    public NodeState getCurrentRootState() {
+        if (currentRootState == null) {
+            currentRootState = branch.getRoot();
         }
+        return currentRootState;
     }
 
     /**
-     * Returns the node state of the workspace from which
-     * the current branch was created.
+     * Returns the node state from which the current branch was created.
      * @return base node state
      */
     @Nonnull
-    public NodeState getWorkspaceBaseState() {
-        NodeState workspaceBaseState = branch.getBase().getChildNode(workspaceName);
-        assert workspaceBaseState != null;
-        return workspaceBaseState;
+    public NodeState getBaseState() {
+        return branch.getBase();
     }
 
     /**
@@ -222,12 +209,12 @@ public class RootImpl implements Root {
     }
 
     /**
-     * Set the node state of the current workspace
+     * Set the current root node state
      *
-     * @param nodeState  node state representing the modified workspace
+     * @param nodeState  node state representing the modified root state
      */
-    public void setWorkspaceRootState(NodeState nodeState) {
-        getWorkspaceBuilder().setNode(workspaceName, nodeState);
+    public void setCurrentRootState(NodeState nodeState) {
+        currentRootState = nodeState;
         modCount++;
         if (needsPurging()) {
             purgePendingChanges();
@@ -239,9 +226,9 @@ public class RootImpl implements Root {
      * All registered {@link PurgeListener}s are notified.
      */
     public void purgePendingChanges() {
-        if (workspaceBuilder != null) {
-            branch.setRoot(workspaceBuilder.getNodeState());
-            workspaceBuilder = null;
+        if (currentRootState != null) {
+            branch.setRoot(currentRootState);
+            currentRootState = null;
             notifyListeners();
         }
     }
@@ -259,6 +246,13 @@ public class RootImpl implements Root {
         store.compare(before, after, diffHandler);
     }
 
+    //------------------------------------------------------------< internal >---
+
+    // FIXME remove
+    NodeStore getNodeStore() {
+        return store;
+    }
+
     //------------------------------------------------------------< private >---
 
     // TODO better way to determine purge limit
@@ -272,18 +266,6 @@ public class RootImpl implements Root {
         }
     }
 
-    /**
-     * Lazily initialise the {@code NodeStateBuilder} associated with the
-     * root node of the current workspace.
-     * @return
-     */
-    private synchronized NodeStateBuilder getWorkspaceBuilder() {
-        if (workspaceBuilder == null) {
-            workspaceBuilder = getBuilder(branch.getRoot());
-        }
-        return workspaceBuilder;
-    }
-
     private void notifyListeners() {
         List<PurgeListener> purgeListeners = this.purgePurgeListeners;
         this.purgePurgeListeners = new ArrayList<PurgeListener>();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Thu May 31 15:34:29 2012
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.util.It
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
+import javax.jcr.PropertyType;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -71,19 +72,19 @@ public class TreeImpl implements Tree, P
         return new TreeImpl(root, null, "") {
             @Override
             protected NodeState getBaseState() {
-                return root.getWorkspaceBaseState();
+                return root.getBaseState();
             }
 
             @Override
             protected NodeState getNodeState() {
                 return nodeStateBuilder == null
-                    ? root.getWorkspaceRootState()
+                    ? root.getCurrentRootState()
                     : nodeStateBuilder.getNodeState();
             }
 
             @Override
             protected void updateParentState(NodeState childState) {
-                root.setWorkspaceRootState(childState);
+                root.setCurrentRootState(childState);
             }
         };
     }
@@ -112,7 +113,35 @@ public class TreeImpl implements Tree, P
 
     @Override
     public PropertyState getProperty(String name) {
-        return getNodeState().getProperty(name);
+        PropertyState propertyState = getNodeState().getProperty(name);
+        // FIXME find a better way to default jcr:primaryType
+        if (propertyState == null && "jcr:primaryType".equals(name)) {
+            propertyState = new PropertyState() {
+                @Override
+                public String getName() {
+                    return "jcr:primaryType";
+                }
+
+                @Override
+                public boolean isArray() {
+                    return false;
+                }
+
+                @Nonnull
+                @Override
+                public CoreValue getValue() {
+                    return root.getNodeStore().getValueFactory().createValue("nt:unstructured",
PropertyType.NAME);
+                }
+
+                @Nonnull
+                @Override
+                public Iterable<CoreValue> getValues() {
+                    throw new IllegalStateException();
+                }
+            };
+        }
+
+        return propertyState;
     }
 
     @Override
@@ -361,7 +390,6 @@ public class TreeImpl implements Tree, P
     @Nonnull
     protected NodeState getNodeState() {
         if (nodeStateBuilder == null) {
-            parent.getNodeState().getChildNode(name);
             NodeState nodeState = parent.getNodeState().getChildNode(name);
             assert nodeState != null;
             return nodeState;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElement.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElement.java?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElement.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElement.java
Thu May 31 15:34:29 2012
@@ -22,7 +22,6 @@ import org.apache.jackrabbit.mk.json.Jso
 import org.apache.jackrabbit.mk.json.JsopTokenizer;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.kernel.CoreValueMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.query.Query;
@@ -59,12 +58,7 @@ abstract class AstElement {
      * @return the absolute path
      */
     protected String getAbsolutePath(String path) {
-        String workspaceName = query.getWorkspaceName();
-        if (PathUtils.denotesRoot(workspaceName)) {
-            return path;
-        }
-        String p = PathUtils.relativize("/", path);
-        return PathUtils.concat("/", workspaceName, p);
+        return path;
     }
 
     /**
@@ -75,15 +69,7 @@ abstract class AstElement {
      * @return the session local path, or null if not within this workspace
      */
     protected String getLocalPath(String path) {
-        String workspaceName = query.getWorkspaceName();
-        if (PathUtils.denotesRoot(workspaceName)) {
-            return path;
-        }
-        String prefix = PathUtils.concat("/", workspaceName);
-        if (path.startsWith(prefix)) {
-            return PathUtils.concat("/", PathUtils.relativize(prefix, path));
-        }
-        return null;
+        return path;
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
Thu May 31 15:34:29 2012
@@ -80,13 +80,13 @@ public class RootImplFuzzIT {
         MicroKernel mk1 = new MicroKernelImpl("./target/mk1/" + random.nextInt());
         store1 = new KernelNodeStore(mk1);
         vf = store1.getValueFactory();
-        mk1.commit("", "+\"/test\":{} +\"/test/root\":{}", mk1.getHeadRevision(), "");
-        root1 = new RootImpl(store1, "test");
+        mk1.commit("", "+\"/root\":{}", mk1.getHeadRevision(), "");
+        root1 = new RootImpl(store1, null);
 
         MicroKernel mk2 = new MicroKernelImpl("./target/mk2/" + random.nextInt());
         store2 = new KernelNodeStore(mk2);
-        mk2.commit("", "+\"/test\":{} +\"/test/root\":{}", mk2.getHeadRevision(), "");
-        root2 = new RootImpl(store2, "test");
+        mk2.commit("", "+\"/root\":{}", mk2.getHeadRevision(), "");
+        root2 = new RootImpl(store2, null);
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
Thu May 31 15:34:29 2012
@@ -44,16 +44,14 @@ public class RootImplTest extends Abstra
 
     @Override
     protected NodeState createInitialState(MicroKernel microKernel) {
-        String jsop =
-                "+\"test\":{\"a\":1,\"b\":2,\"c\":3,"
-                        + "\"x\":{},\"y\":{},\"z\":{}}";
+        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{}";
         microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
-        return store.getRoot().getChildNode("test");
+        return store.getRoot();
     }
 
     @Test
     public void getChild() {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         Tree child = tree.getChild("any");
@@ -98,7 +96,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void getProperties() {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         Map<String, CoreValue> expectedProperties = new HashMap<String, CoreValue>();
@@ -121,7 +119,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void addChild() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         assertFalse(tree.hasChild("new"));
@@ -141,7 +139,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void addExistingChild() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         assertFalse(tree.hasChild("new"));
@@ -158,7 +156,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void removeChild() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         assertTrue(tree.hasChild("x"));
@@ -173,7 +171,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void setProperty() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         assertFalse(tree.hasProperty("new"));
@@ -195,7 +193,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void removeProperty() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         assertTrue(tree.hasProperty("a"));
@@ -210,7 +208,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void move() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         Tree y = tree.getChild("y");
@@ -230,7 +228,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void move2() {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree r = root.getTree("");
         Tree x = r.getChild("x");
         Tree y = r.getChild("y");
@@ -244,7 +242,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void rename() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         assertTrue(tree.hasChild("x"));
@@ -261,7 +259,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void copy() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         Tree y = tree.getChild("y");
@@ -281,7 +279,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void deepCopy() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         Tree y = tree.getChild("y");
@@ -306,7 +304,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void getChildrenCount() {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         assertEquals(3, tree.getChildrenCount());
@@ -323,7 +321,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void getPropertyCount() {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         assertEquals(3, tree.getPropertyCount());
@@ -344,7 +342,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void addAndRemoveProperty() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         tree.setProperty("P0", valueFactory.createValue("V1"));
@@ -360,7 +358,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void nodeStatus() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         tree.addChild("new");
@@ -389,7 +387,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void propertyStatus() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
         CoreValue value1 = valueFactory.createValue("V1");
         CoreValue value2 = valueFactory.createValue("V2");
@@ -416,7 +414,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void noTransitiveModifiedStatus() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
         tree.addChild("one").addChild("two");
         root.commit();
@@ -429,8 +427,8 @@ public class RootImplTest extends Abstra
 
     @Test
     public void rebase() throws CommitFailedException {
-        RootImpl root1 = new RootImpl(store, "test");
-        RootImpl root2 = new RootImpl(store, "test");
+        RootImpl root1 = new RootImpl(store, null);
+        RootImpl root2 = new RootImpl(store, null);
 
         checkEqual(root1.getTree("/"), root2.getTree("/"));
 
@@ -453,7 +451,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void largeChildList() throws CommitFailedException {
-        RootImpl root = new RootImpl(store, "test");
+        RootImpl root = new RootImpl(store, null);
         Tree tree = root.getTree("/");
 
         Set<String> added = new HashSet<String>();

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
Thu May 31 15:34:29 2012
@@ -26,14 +26,14 @@
 select * from [nt:base] as p inner join [nt:base] as p on ischildnode(p, p) where p.[jcr:path]
= '/'
 java.lang.IllegalArgumentException: Two selectors with the same name: p
 
-commit /default + "test": { "a": { "id": "10" }, "b": { "id" : "20" }}
+commit / + "test": { "a": { "id": "10" }, "b": { "id" : "20" }}
 commit /jcr:system/indexes + "property:id": {}
 
 explain select * from [nt:base] where id = '10'
 nt:base AS nt:base /* propertyIndex "id [10..10]" */
 
 select * from [nt:base] where id = '10'
-/default/test/a
+/test/a
 
 select [jcr:path], * from [nt:base] where id = '10'
 /test/a, null
@@ -41,64 +41,68 @@ select [jcr:path], * from [nt:base] wher
 explain select * from [nt:base] where id > '10'
 nt:base AS nt:base /* traverse "//*" */
 
-commit /default - "test"
+commit / - "test"
 commit /jcr:system/indexes - "property:id"
 
 # other tests
 
-commit /default + "test": { "jcr:resource": {}, "resource": { "x" : {}}}
+commit / + "test": { "jcr:resource": {}, "resource": { "x" : {}}}
 
 select * from [nt:base] where id = -1
 
 explain select * from [nt:base] as b where ischildnode(b, '/test')
-nt:base AS b /* traverse "/default/test/*" */
+nt:base AS b /* traverse "/test/*" */
 
 explain select * from [nt:base] as b where isdescendantnode(b, '/test')
-nt:base AS b /* traverse "/default/test//*" */
+nt:base AS b /* traverse "/test//*" */
 
 select * from [nt:base] as b where ischildnode(b, '/test')
-/default/test/jcr:resource
-/default/test/resource
+/test/jcr:resource
+/test/resource
 
 select * from [nt:base] as b where issamenode(b, '/test')
-/default/test
+/test
 
 select * from [nt:base] where name() = 'resource'
-/default/test/resource
+/test/resource
 
 select * from [nt:base] as b where localname(b) = 'resource'
-/default/test/jcr:resource
-/default/test/resource
+/test/jcr:resource
+/test/resource
 
 select * from [nt:base] as x where isdescendantnode(x, '/')
-/default/test
-/default/test/jcr:resource
-/default/test/resource
-/default/test/resource/x
+/
+/jcr:system
+/jcr:system/indexes
+/test
+/test/jcr:resource
+/test/resource
+/test/resource/x
 
-commit /default - "test"
+commit / - "test"
 
-commit /default + "parents": { "p0": {"id": "0"}, "p1": {"id": "1"}, "p2": {"id": "2"}}
-commit /default + "children": { "c1": {"p": "1"}, "c2": {"p": "1"}, "c3": {"p": "2"}, "c4":
{"p": "3"}}
+commit / + "parents": { "p0": {"id": "0"}, "p1": {"id": "1"}, "p2": {"id": "2"}}
+commit / + "children": { "c1": {"p": "1"}, "c2": {"p": "1"}, "c3": {"p": "2"}, "c4": {"p":
"3"}}
 
 # relative property
 select * from [nt:base] where [c1/p] = '1'
-/default/children
+/children
 
 select * from [nt:base] as p where p.[jcr:path] = '/parents'
-/default/parents
+/parents
 
 select * from [nt:base] as p inner join [nt:base] as p2 on ischildnode(p2, p) where p.[jcr:path]
= '/'
-/default, /default/children
-/default, /default/parents
+/, /children
+/, /jcr:system
+/, /parents
 
 select * from [nt:base] as p inner join [nt:base] as p2 on isdescendantnode(p2, p) where
p.[jcr:path] = '/parents'
-/default/parents, /default/parents/p0
-/default/parents, /default/parents/p1
-/default/parents, /default/parents/p2
+/parents, /parents/p0
+/parents, /parents/p1
+/parents, /parents/p2
 
 select * from [nt:base] as p inner join [nt:base] as p2 on issamenode(p2, p) where p.[jcr:path]
= '/parents'
-/default/parents, /default/parents
+/parents, /parents
 
 select id from [nt:base] where id is not null
 0
@@ -111,82 +115,79 @@ select id from [nt:base] where id is not
 0
 
 select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where p.id is
not null
-/default/children/c1, /default/parents/p1
-/default/children/c2, /default/parents/p1
-/default/children/c3, /default/parents/p2
-null, /default/parents/p0
+/children/c1, /parents/p1
+/children/c2, /parents/p1
+/children/c3, /parents/p2
+null, /parents/p0
 
 select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not
null
-/default/parents/p0, null
-/default/parents/p1, /default/children/c1
-/default/parents/p1, /default/children/c2
-/default/parents/p2, /default/children/c3
+/parents/p0, null
+/parents/p1, /children/c1
+/parents/p1, /children/c2
+/parents/p2, /children/c3
 
 select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not
null and c.p is null
-/default/parents/p0, null
+/parents/p0, null
 
 select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not
null and c.p is not null
-/default/parents/p1, /default/children/c1
-/default/parents/p1, /default/children/c2
-/default/parents/p2, /default/children/c3
+/parents/p1, /children/c1
+/parents/p1, /children/c2
+/parents/p2, /children/c3
 
 select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
-/default/parents/p1, /default/children/c1
-/default/parents/p1, /default/children/c2
-/default/parents/p2, /default/children/c3
+/parents/p1, /children/c1
+/parents/p1, /children/c2
+/parents/p2, /children/c3
 
 explain select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
 nt:base AS p /* traverse "//*" */ INNER JOIN nt:base AS c /* traverse "//*" */
 
-commit /default - "parents"
-commit /default - "children"
+commit / - "parents"
+commit / - "children"
 
-commit /default + "test": { "hello": { "x": "1" }, "world": { "x": "2" } }
-commit /default + "test2": { "id":"1", "x": "2" }
+commit / + "test": { "hello": { "x": "1" }, "world": { "x": "2" } }
+commit / + "test2": { "id":"1", "x": "2" }
 
 select * from [nt:base]
 /
-/default
-/default/test
-/default/test/hello
-/default/test/world
-/default/test2
 /jcr:system
 /jcr:system/indexes
+/test
+/test/hello
+/test/world
+/test2
 
 select * from [nt:base] where id = '1'
-/default/test2
+/test2
 
 select * from [nt:base] where id = '1' and x = '2'
-/default/test2
+/test2
 
 select * from [nt:base] where id = '1' or x = '2'
-/default/test/world
-/default/test2
+/test/world
+/test2
 
 select * from [nt:base] where not (id = '1' or x = '2')
 /
-/default
-/default/test
-/default/test/hello
 /jcr:system
 /jcr:system/indexes
+/test
+/test/hello
 
 select * from [nt:base] where x is null
 /
-/default
-/default/test
 /jcr:system
 /jcr:system/indexes
+/test
 
-commit /default - "test"
-commit /default - "test2"
+commit / - "test"
+commit / - "test2"
 
-commit /default + "test": { "name": "hello" }
-commit /default + "test2": { "name": "World!" }
-commit /default + "test3": { "name": "Hallo" }
-commit /default + "test4": { "name": "10%" }
-commit /default + "test5": { "name": "10 percent" }
+commit / + "test": { "name": "hello" }
+commit / + "test2": { "name": "World!" }
+commit / + "test3": { "name": "Hallo" }
+commit / + "test4": { "name": "10%" }
+commit / + "test5": { "name": "10 percent" }
 
 select name from [nt:base] order by upper(name)
 10 percent
@@ -197,38 +198,37 @@ World!
 null
 null
 null
-null
 
 select * from [nt:base] where length(name) = 5
-/default/test
-/default/test3
+/test
+/test3
 
 select * from [nt:base] where upper(name) = 'HELLO'
-/default/test
+/test
 
 select * from [nt:base] where lower(name) = 'world!'
-/default/test2
+/test2
 
 select * from [nt:base] where name like 'W%'
-/default/test2
+/test2
 
 select * from [nt:base] where name like '%o_%'
-/default/test2
+/test2
 
 select * from [nt:base] where name like '__llo'
-/default/test
-/default/test3
+/test
+/test3
 
 select * from [nt:base] where upper(name) like 'H_LLO'
-/default/test
-/default/test3
+/test
+/test3
 
 select * from [nt:base] where upper(name) like 'H\_LLO'
 
 select * from [nt:base] where upper(name) like '10%'
-/default/test4
-/default/test5
+/test4
+/test5
 
 select * from [nt:base] where upper(name) like '10\%'
-/default/test4
+/test4
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
Thu May 31 15:34:29 2012
@@ -53,6 +53,9 @@ public class PropertyDelegate extends It
 
     PropertyDelegate(SessionDelegate sessionDelegate, Tree parent, PropertyState propertyState)
{
         super(sessionDelegate);
+
+        assert parent != null;
+        assert propertyState != null;
         this.parent = parent;
         this.propertyState = propertyState;
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
Thu May 31 15:34:29 2012
@@ -356,7 +356,6 @@ public class SessionDelegate {
 
     @CheckForNull
     NodeDelegate findByJcrUuid(String id) {
-
         try {
             Map<String, CoreValue> bindings = Collections.singletonMap("id", getValueFactory().getCoreValueFactory()
                     .createValue(id));
@@ -367,13 +366,11 @@ public class SessionDelegate {
             String path = null;
 
             for (ResultRow rr : result.getRows()) {
-                String tmppath = PathUtils.concat("/", PathUtils.relativize('/' + getWorkspaceName(),
rr.getPath()));
-
                 if (path != null) {
-                    log.error("multiple results for identifier lookup: " + path + " vs. "
+ tmppath);
+                    log.error("multiple results for identifier lookup: " + path + " vs. "
+ rr.getPath());
                     return null;
                 } else {
-                    path = tmppath;
+                    path = rr.getPath();
                 }
             }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java?rev=1344776&r1=1344775&r2=1344776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
Thu May 31 15:34:29 2012
@@ -18,16 +18,6 @@
  */
 package org.apache.jackrabbit.oak.jcr.query;
 
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import javax.annotation.CheckForNull;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.RowIterator;
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.RowIteratorAdapter;
 import org.apache.jackrabbit.oak.api.CoreValue;
@@ -38,6 +28,16 @@ import org.apache.jackrabbit.oak.jcr.Nod
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
 import org.apache.jackrabbit.oak.jcr.SessionDelegate;
 
+import javax.annotation.CheckForNull;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.RowIterator;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
 /**
  * The implementation of the corresponding JCR interface.
  */
@@ -53,7 +53,7 @@ public class QueryResultImpl implements 
 
         // TODO the path currently contains the workspace name
         // TODO filter in oak-core once we support workspaces there
-        pathFilter = "/" + sessionDelegate.getWorkspaceName();
+        pathFilter = "/";
     }
 
     @Override



Mime
View raw message