jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1465618 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java
Date Mon, 08 Apr 2013 12:52:44 GMT
Author: jukka
Date: Mon Apr  8 12:52:44 2013
New Revision: 1465618

URL: http://svn.apache.org/r1465618
Log:
OAK-708: SecureNodeState#getChildNodeCount and #getPropertyCount: don't respect read permissions

Patch by Antonio Sanso

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java?rev=1465618&r1=1465617&r2=1465618&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java
Mon Apr  8 12:52:44 2013
@@ -41,7 +41,6 @@ import org.apache.jackrabbit.oak.spi.sta
  * SecureNodeState...
  *
  * TODO: clarify if HIDDEN items should be filtered by this NodeState implementation
- * TODO: add proper implementation for getPropertyCount and getChildrenCount
  * TODO: clarify usage of ReadStatus in getChildNodeEntries
  * TODO: add proper equals/hashcode implementation
  * TODO: should be package-private
@@ -61,6 +60,8 @@ public class SecureNodeState extends Abs
     private final PermissionProvider permissionProvider;
 
     private ReadStatus readStatus;
+    private long childNodeCount = -1;
+    private long propertyCount = -1;
 
     public SecureNodeState(@Nonnull NodeState rootState,
                            @Nonnull PermissionProvider permissionProvider,
@@ -99,8 +100,10 @@ public class SecureNodeState extends Abs
 
     @Override
     public long getPropertyCount() {
-        // TODO: make sure cnt respects read permissions (OAK-708)
-        return state.getPropertyCount();
+        if (propertyCount == -1){
+            propertyCount = super.getPropertyCount();
+        }
+        return propertyCount;
     }
 
     @Nonnull
@@ -136,8 +139,10 @@ public class SecureNodeState extends Abs
 
     @Override
     public long getChildNodeCount() {
-        // TODO: make sure cnt respects read permissions (OAK-708)
-        return state.getChildNodeCount();
+        if (childNodeCount == -1) {
+            childNodeCount = super.getChildNodeCount();
+        }
+        return childNodeCount;
     }
 
     @Override



Mime
View raw message