jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1507339 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/aut...
Date Fri, 26 Jul 2013 14:52:53 GMT
Author: angela
Date: Fri Jul 26 14:52:53 2013
New Revision: 1507339

URL: http://svn.apache.org/r1507339
Log:
OAK-212: Tree#getPropertyStatus requires tree to exist

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/ReadPropertyTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java?rev=1507339&r1=1507338&r2=1507339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
Fri Jul 26 14:52:53 2013
@@ -18,22 +18,8 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.indexOf;
-import static org.apache.jackrabbit.oak.api.Tree.Status.EXISTING;
-import static org.apache.jackrabbit.oak.api.Tree.Status.MODIFIED;
-import static org.apache.jackrabbit.oak.api.Tree.Status.NEW;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
-import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
-
 import java.util.Collections;
 import java.util.Set;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
@@ -50,6 +36,19 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.indexOf;
+import static org.apache.jackrabbit.oak.api.Tree.Status.EXISTING;
+import static org.apache.jackrabbit.oak.api.Tree.Status.MODIFIED;
+import static org.apache.jackrabbit.oak.api.Tree.Status.NEW;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
+import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
+
 public class MutableTree extends AbstractTree {
 
     /**
@@ -135,8 +134,12 @@ public class MutableTree extends Abstrac
 
     @Override
     public Status getPropertyStatus(String name) {
-        // TODO: see OAK-212
-        Status nodeStatus = getStatus();
+        // make sure we don't expose information about a non-accessible property
+        if (!hasProperty(name)) {
+            return null;
+        }
+        // get status of this tree without checking for it's existence
+        Status nodeStatus = super.getStatus();
         if (nodeStatus == NEW) {
             return (super.hasProperty(name)) ? NEW : null;
         }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java?rev=1507339&r1=1507338&r2=1507339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java
Fri Jul 26 14:52:53 2013
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.oak.securi
 import java.util.List;
 
 import com.google.common.collect.ImmutableList;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConstants;
@@ -28,6 +30,7 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 public class TreeTest extends AbstractOakCoreTest {
@@ -118,7 +121,16 @@ public class TreeTest extends AbstractOa
 
     @Test
     public void testGetPropertyStatus() throws Exception {
-        // TODO
+        setupPermission("/a", testPrincipal, false, PrivilegeConstants.REP_READ_NODES);
+
+        testRoot.refresh();
+        Tree a = testRoot.getTree("/a");
+        assertFalse(a.exists());
+
+        PropertyState p = a.getProperty(JcrConstants.JCR_PRIMARYTYPE);
+        assertNotNull(p);
+        assertEquals(Tree.Status.EXISTING, a.getPropertyStatus(JcrConstants.JCR_PRIMARYTYPE));
+
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/ReadPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/ReadPropertyTest.java?rev=1507339&r1=1507338&r2=1507339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/ReadPropertyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/ReadPropertyTest.java
Fri Jul 26 14:52:53 2013
@@ -107,4 +107,21 @@ public class ReadPropertyTest extends Ab
             assertEquals(pPath, p.getPath());
         }
     }
+
+    @Test
+    public void testGetStatus() throws Exception {
+        deny(path, privilegesFromName(PrivilegeConstants.JCR_READ));
+        allow(path, privilegesFromName(PrivilegeConstants.REP_READ_PROPERTIES));
+
+        List<String> propertyPaths = new ArrayList<String>();
+        propertyPaths.add(childPPath);
+        propertyPaths.add(childchildPPath);
+        propertyPaths.add(path + "/jcr:primaryType");
+
+        for (String pPath : propertyPaths) {
+            Property p = testSession.getProperty(pPath);
+            assertFalse(p.isModified());
+            assertFalse(p.isNew());
+        }
+    }
 }
\ No newline at end of file



Mime
View raw message