jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1338197 - in /jackrabbit/oak/trunk: oak-it/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/
Date Mon, 14 May 2012 13:47:20 GMT
Author: reschke
Date: Mon May 14 13:47:20 2012
New Revision: 1338197

URL: http://svn.apache.org/viewvc?rev=1338197&view=rev
Log:
OAK-101: push identifier handling down to SessionDelegate and NodeDelegate

Modified:
    jackrabbit/oak/trunk/oak-it/jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.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/SessionImpl.java

Modified: jackrabbit/oak/trunk/oak-it/jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/pom.xml?rev=1338197&r1=1338196&r2=1338197&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/pom.xml Mon May 14 13:47:20 2012
@@ -44,9 +44,7 @@
             <property>
               <name>known.issues</name>
               <value>
-org.apache.jackrabbit.test.api.NodeReadMethodsTest#testGetPrimaryItem
 org.apache.jackrabbit.test.api.NodeReadMethodsTest#testGetUUID
-org.apache.jackrabbit.test.api.SessionReadMethodsTest#testGetNodeByUUIDFailure
 org.apache.jackrabbit.test.api.SessionReadMethodsTest#testGetNodeByUUID
 org.apache.jackrabbit.test.api.PathTest#testGetItem
 org.apache.jackrabbit.test.api.PathTest#testCreatePathValue

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1338197&r1=1338196&r2=1338197&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Mon May 14 13:47:20 2012
@@ -92,6 +92,11 @@ public class NodeDelegate extends ItemDe
         return "NodeDelegate[/" + tree.getPath() + ']';
     }
 
+    public String getIdentifier() {
+        // TODO for now the identifier is the OAK path
+        return getPath();
+    }
+
     /**
      * Determine whether this is the root node
      * @return  {@code true} iff this is the root node

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1338197&r1=1338196&r2=1338197&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Mon May 14 13:47:20 2012
@@ -493,8 +493,8 @@ public class NodeImpl extends ItemImpl i
     public String getUUID() throws RepositoryException {
         checkStatus();
 
-        if (hasProperty(Property.JCR_UUID) && isNodeType(NodeType.MIX_REFERENCEABLE))
{
-            return getProperty(Property.JCR_UUID).getString();
+        if (isNodeType(NodeType.MIX_REFERENCEABLE)) {
+            return getIdentifier();
         }
 
         throw new UnsupportedRepositoryOperationException("Node is not referenceable.");
@@ -503,13 +503,7 @@ public class NodeImpl extends ItemImpl i
     @Override
     public String getIdentifier() throws RepositoryException {
         checkStatus();
-
-        if (isNodeType(NodeType.MIX_REFERENCEABLE)) {
-            return getProperty(Property.JCR_UUID).getString();
-        } else {
-            // TODO
-            return dlg.getPath();
-        }
+        return dlg.getIdentifier();
     }
 
     @Override

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=1338197&r1=1338196&r2=1338197&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
Mon May 14 13:47:20 2012
@@ -111,6 +111,12 @@ public class SessionDelegate {
         return tree == null ? null : new NodeDelegate(this, tree);
     }
 
+    public NodeDelegate getNodeByIdentifier(String id) {
+        // TODO: for now the OAK path is the identifier
+        Tree tree = getTree(id);
+        return tree == null ? null : new NodeDelegate(this, tree);
+    }
+
     public ValueFactoryImpl getValueFactory() {
         return valueFactory;
     }

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=1338197&r1=1338196&r2=1338197&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
Mon May 14 13:47:20 2012
@@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
 
 import javax.jcr.Credentials;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
@@ -100,21 +101,18 @@ public class SessionImpl extends Abstrac
     }
 
     @Override
-    public Node getNodeByUUID(String uuid) throws RepositoryException {
-        ensureIsAlive();
-        throw new UnsupportedRepositoryOperationException("TODO: Session.getNodeByUUID");
+    public Node getNodeByUUID(String id) throws RepositoryException {
+        return getNodeByIdentifier(id);
     }
 
     @Override
     public Node getNodeByIdentifier(String id) throws RepositoryException {
         ensureIsAlive();
-        // TODO following line throws IndexOutOfBoundsException if id is empty
-        if (id.charAt(0) == '/') {
-            return getNode(id);
-        } else {
-            // TODO
-            throw new UnsupportedRepositoryOperationException("TODO: Session.getNodeByIdentifier");
+        NodeDelegate d = dlg.getNodeByIdentifier(id);
+        if (d == null) {
+            throw new ItemNotFoundException("Node with id " + id + " does not exist.");
         }
+        return new NodeImpl(d);
     }
 
     @Override



Mime
View raw message