You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2016/05/04 17:54:52 UTC

curator git commit: must do schema validation on set acl

Repository: curator
Updated Branches:
  refs/heads/CURATOR-322 b889e3bce -> 726b03cf9


must do schema validation on set acl


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/726b03cf
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/726b03cf
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/726b03cf

Branch: refs/heads/CURATOR-322
Commit: 726b03cf986f7ac2fc61f3dd448b18cde40d3501
Parents: b889e3b
Author: randgalt <ra...@apache.org>
Authored: Wed May 4 12:54:46 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Wed May 4 12:54:46 2016 -0500

----------------------------------------------------------------------
 .../curator/framework/imps/SetACLBuilderImpl.java       | 12 +++++++-----
 .../curator/framework/schema/SchemaValidator.java       |  7 +++++++
 .../org/apache/curator/framework/schema/TestSchema.java |  2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/726b03cf/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
index 5ab353a..44adfe2 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
@@ -114,16 +114,18 @@ class SetACLBuilderImpl implements SetACLBuilder, BackgroundPathable<Stat>, Back
     @Override
     public Stat forPath(String path) throws Exception
     {
-        path = client.fixForNamespace(path);
+        String fixedPath = client.fixForNamespace(path);
+        List<ACL> aclList = acling.getAclList(fixedPath);
+        client.getSchemaSet().getSchema(path).validateGeneral(path, null, aclList);
 
         Stat        resultStat = null;
         if ( backgrounding.inBackground()  )
         {
-            client.processBackgroundOperation(new OperationAndData<String>(this, path, backgrounding.getCallback(), null, backgrounding.getContext(), null), null);
+            client.processBackgroundOperation(new OperationAndData<String>(this, fixedPath, backgrounding.getCallback(), null, backgrounding.getContext(), null), null);
         }
         else
         {
-            resultStat = pathInForeground(path);
+            resultStat = pathInForeground(fixedPath, aclList);
         }
         return resultStat;
     }
@@ -160,7 +162,7 @@ class SetACLBuilderImpl implements SetACLBuilder, BackgroundPathable<Stat>, Back
         }
     }
 
-    private Stat pathInForeground(final String path) throws Exception
+    private Stat pathInForeground(final String path, final List<ACL> aclList) throws Exception
     {
         TimeTrace   trace = client.getZookeeperClient().startTracer("SetACLBuilderImpl-Foreground");
         Stat        resultStat = RetryLoop.callWithRetry
@@ -171,7 +173,7 @@ class SetACLBuilderImpl implements SetACLBuilder, BackgroundPathable<Stat>, Back
                 @Override
                 public Stat call() throws Exception
                 {
-                    return client.getZooKeeper().setACL(path, acling.getAclList(path), version);
+                    return client.getZooKeeper().setACL(path, aclList, version);
                 }
             }
         );

http://git-wip-us.apache.org/repos/asf/curator/blob/726b03cf/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
index 560b8f8..a92720f 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
@@ -23,5 +23,12 @@ import java.util.List;
 
 public interface SchemaValidator
 {
+    /**
+     * @param schema the schema being validated
+     * @param path the path being operated on
+     * @param data data or null
+     * @param acl acls or null
+     * @return true if valid
+     */
     boolean isValid(Schema schema, String path, byte[] data, List<ACL> acl);
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/726b03cf/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
index e2a581b..78ecdf5 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
@@ -74,7 +74,7 @@ public class TestSchema extends BaseClassForTests
     }
 
     @Test
-    public void testDataValidator() throws Exception
+    public void testSchemaValidator() throws Exception
     {
         final SchemaValidator schemaValidator = new SchemaValidator()
         {