Repository: curator Updated Branches: refs/heads/CURATOR-348 [created] 027dee39b
validateCreate() should be taking a path argument. The class field "path" was hiding this so I renamed that as well. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/027dee39 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/027dee39 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/027dee39 Branch: refs/heads/CURATOR-348 Commit: 027dee39bbda546af07dc30622fa28e29cbfc9bc Parents: 9e400bc Author: randgalt <[email protected]> Authored: Tue Sep 6 10:50:28 2016 -0500 Committer: randgalt <[email protected]> Committed: Tue Sep 6 10:50:28 2016 -0500 ---------------------------------------------------------------------- .../curator/framework/imps/CreateBuilderImpl.java | 2 +- .../imps/CuratorMultiTransactionImpl.java | 2 +- .../apache/curator/framework/schema/Schema.java | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/027dee39/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java index 34009b1..d7126dc 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java @@ -487,7 +487,7 @@ class CreateBuilderImpl implements CreateBuilder, BackgroundOperation<PathAndByt final String adjustedPath = adjustPath(client.fixForNamespace(givenPath, createMode.isSequential())); List<ACL> aclList = acling.getAclList(adjustedPath); - client.getSchemaSet().getSchema(givenPath).validateCreate(createMode, data, aclList); + client.getSchemaSet().getSchema(givenPath).validateCreate(createMode, givenPath, data, aclList); String returnPath = null; if ( backgrounding.inBackground() ) http://git-wip-us.apache.org/repos/asf/curator/blob/027dee39/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java index 4b4d473..40eb4a2 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java @@ -129,7 +129,7 @@ public class CuratorMultiTransactionImpl implements { CreateRequest createRequest = (CreateRequest)curatorOp.get().toRequestRecord(); CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags(), CreateMode.PERSISTENT); - schema.validateCreate(createMode, createRequest.getData(), createRequest.getAcl()); + schema.validateCreate(createMode, createRequest.getPath(), createRequest.getData(), createRequest.getAcl()); } else if ( (curatorOp.get().getType() == ZooDefs.OpCode.delete) || (curatorOp.get().getType() == ZooDefs.OpCode.deleteContainer) ) { http://git-wip-us.apache.org/repos/asf/curator/blob/027dee39/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java index 6d4d09e..ce128e9 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java @@ -34,7 +34,7 @@ public class Schema { private final String name; private final Pattern pathRegex; - private final String path; + private final String fixedPath; private final String documentation; private final SchemaValidator schemaValidator; private final Allowance ephemeral; @@ -107,7 +107,7 @@ public class Schema { Preconditions.checkNotNull((pathRegex != null) || (path != null), "pathRegex and path cannot both be null"); this.pathRegex = pathRegex; - this.path = fixPath(path); + this.fixedPath = fixPath(path); this.metadata = ImmutableMap.copyOf(Preconditions.checkNotNull(metadata, "metadata cannot be null")); this.name = Preconditions.checkNotNull(name, "name cannot be null"); this.documentation = Preconditions.checkNotNull(documentation, "documentation cannot be null"); @@ -167,11 +167,12 @@ public class Schema * Validate that this schema's create mode setting matches and that the data is valid * * @param mode CreateMode being used + * @param path the znode full path * @param data data being set * @param acl the creation acls * @throws SchemaViolation if schema's create mode setting does not match or data is invalid */ - public void validateCreate(CreateMode mode, byte[] data, List<ACL> acl) + public void validateCreate(CreateMode mode, String path, byte[] data, List<ACL> acl) { if ( mode.isEphemeral() && (ephemeral == Allowance.CANNOT) ) { @@ -226,7 +227,7 @@ public class Schema */ public String getRawPath() { - return (path != null) ? path : pathRegex.pattern(); + return (fixedPath != null) ? fixedPath : pathRegex.pattern(); } public Map<String, String> getMetadata() @@ -241,7 +242,7 @@ public class Schema public String getPath() { - return path; + return fixedPath; } public String getDocumentation() @@ -294,7 +295,7 @@ public class Schema { return false; } - return path.equals(schema.path); + return fixedPath.equals(schema.fixedPath); } @@ -303,7 +304,7 @@ public class Schema public int hashCode() { int result = pathRegex.hashCode(); - result = 31 * result + path.hashCode(); + result = 31 * result + fixedPath.hashCode(); return result; } @@ -313,7 +314,7 @@ public class Schema return "Schema{" + "name='" + name + '\'' + ", pathRegex=" + pathRegex + - ", path='" + path + '\'' + + ", path='" + fixedPath + '\'' + ", documentation='" + documentation + '\'' + ", dataValidator=" + schemaValidator + ", ephemeral=" + ephemeral +
