From oak-commits-return-1346-apmail-jackrabbit-oak-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Fri Aug 10 15:54:02 2012 Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A7CB0D5B6 for ; Fri, 10 Aug 2012 15:54:02 +0000 (UTC) Received: (qmail 16983 invoked by uid 500); 10 Aug 2012 15:54:02 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 16958 invoked by uid 500); 10 Aug 2012 15:54:02 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 16948 invoked by uid 99); 10 Aug 2012 15:54:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2012 15:54:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2012 15:53:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7383023888FD; Fri, 10 Aug 2012 15:53:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1371751 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java Date: Fri, 10 Aug 2012 15:53:15 -0000 To: oak-commits@jackrabbit.apache.org From: angela@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120810155315.7383023888FD@eris.apache.org> Author: angela Date: Fri Aug 10 15:53:15 2012 New Revision: 1371751 URL: http://svn.apache.org/viewvc?rev=1371751&view=rev Log: OAK-51 : Implement JCR Access Control Management (work in progress) Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java 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=1371751&r1=1371750&r2=1371751&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 Fri Aug 10 15:53:15 2012 @@ -116,7 +116,7 @@ public class TreeImpl implements Tree, P @Override public Tree getParent() { - if (parent != null && canRead(parent.getPath())) { + if (parent != null && canRead(parent)) { return parent; } else { return null; @@ -125,7 +125,7 @@ public class TreeImpl implements Tree, P @Override public PropertyState getProperty(String name) { - if (canReadProperty(buildChildPath(name))) { + if (canReadProperty(name)) { return internalGetProperty(name); } else { return null; @@ -135,7 +135,7 @@ public class TreeImpl implements Tree, P @Override public Status getPropertyStatus(String name) { // TODO: see OAK-212 - if (!canReadProperty(buildChildPath(name))) { + if (!canReadProperty(name)) { return null; } @@ -199,7 +199,7 @@ public class TreeImpl implements Tree, P @Override public boolean apply(PropertyState propertyState) { if (propertyState != null) { - return canReadProperty(buildChildPath(propertyState.getName())); + return canReadProperty(propertyState.getName()); } else { return false; } @@ -209,8 +209,9 @@ public class TreeImpl implements Tree, P @Override public TreeImpl getChild(String name) { - if (canRead(buildChildPath(name))) { - return internalGetChild(name); + TreeImpl child = internalGetChild(name); + if (child != null && canRead(child)) { + return child; } else { return null; } @@ -268,7 +269,7 @@ public class TreeImpl implements Tree, P @Override public boolean apply(Tree tree) { if (tree != null) { - return canRead(tree.getPath()); + return canRead(tree); } else { return false; } @@ -403,18 +404,14 @@ public class TreeImpl implements Tree, P */ @CheckForNull TreeImpl getTree(String path) { - TreeImpl tree = null; - if (canRead(buildChildPath(path))) { - TreeImpl child = this; - for (String name : elements(path)) { - child = child.internalGetChild(name); - if (child == null) { - return null; - } + TreeImpl child = this; + for (String name : elements(path)) { + child = child.internalGetChild(name); + if (child == null) { + return null; } - tree = child; } - return tree; + return (canRead(child)) ? child : null; } //------------------------------------------------------------< private >--- @@ -450,20 +447,17 @@ public class TreeImpl implements Tree, P } } - private String buildChildPath(String relPath) { - StringBuilder sb = new StringBuilder(); - buildPath(sb); - sb.append('/'); - sb.append(relPath); - return sb.toString(); + private boolean canRead(Tree tree) { + // FIXME: special handling for access control item and version content + return root.getPermissions().canRead(tree.getPath(), false); } - private boolean canRead(String path) { - return root.getPermissions().canRead(path, false); - } + private boolean canReadProperty(String name) { + StringBuilder path = new StringBuilder(); + path.append(getPath()).append(name); - private boolean canReadProperty(String path) { - return root.getPermissions().canRead(path, true); + // FIXME: special handling for access control item and version content + return root.getPermissions().canRead(path.toString(), true); } private static boolean isSame(NodeState state1, NodeState state2) {