jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1367532 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Date Tue, 31 Jul 2012 13:18:39 GMT
Author: angela
Date: Tue Jul 31 13:18:39 2012
New Revision: 1367532

URL: http://svn.apache.org/viewvc?rev=1367532&view=rev
Log:
OAK-213 : Misleading exception message in NodeImpl#getParent

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java

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=1367532&r1=1367531&r2=1367532&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
Tue Jul 31 13:18:39 2012
@@ -27,6 +27,7 @@ import java.util.UUID;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
+import javax.jcr.AccessDeniedException;
 import javax.jcr.Binary;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.Item;
@@ -111,16 +112,20 @@ public class NodeImpl extends ItemImpl<N
     public Node getParent() throws RepositoryException {
         checkStatus();
 
-        return sessionDelegate.perform(new SessionOperation<NodeImpl>() {
-            @Override
-            public NodeImpl perform() throws RepositoryException {
-                NodeDelegate parent = dlg.getParent();
-                if (parent == null) {
-                    throw new ItemNotFoundException("Root has no parent");
+        if (dlg.isRoot()) {
+            throw new ItemNotFoundException("Root has no parent");
+        } else {
+            return sessionDelegate.perform(new SessionOperation<NodeImpl>() {
+                @Override
+                public NodeImpl perform() throws RepositoryException {
+                    NodeDelegate parent = dlg.getParent();
+                    if (parent == null) {
+                        throw new AccessDeniedException();
+                    }
+                    return new NodeImpl(parent);
                 }
-                return new NodeImpl(parent);
-            }
-        });
+            });
+        }
     }
 
     /**



Mime
View raw message