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/07/31 15:18:39 UTC
svn commit: r1367532 -
/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
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);
- }
- });
+ });
+ }
}
/**