You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2016/03/28 05:13:30 UTC
incubator-ranger git commit: RANGER-882: fix inconsistent null check
in previous update
Repository: incubator-ranger
Updated Branches:
refs/heads/master 760fbdbae -> a0d63e751
RANGER-882: fix inconsistent null check in previous update
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/a0d63e75
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/a0d63e75
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/a0d63e75
Branch: refs/heads/master
Commit: a0d63e7518f7b6ab2f02ea416b1433ba80cf193b
Parents: 760fbdb
Author: Madhan Neethiraj <ma...@apache.org>
Authored: Sat Mar 26 01:31:45 2016 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Sun Mar 27 18:55:37 2016 -0700
----------------------------------------------------------------------
.../model/validation/RangerPolicyValidator.java | 74 ++++++++++----------
1 file changed, 38 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a0d63e75/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java b/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
index 5933a33..cab7006 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
@@ -606,46 +606,48 @@ public class RangerPolicyValidator extends RangerValidator {
for (Map.Entry<String, RangerPolicyResource> entry : resourceMap.entrySet()) {
String name = entry.getKey();
RangerPolicyResource policyResource = entry.getValue();
- if(policyResource != null && CollectionUtils.isNotEmpty(policyResource.getValues())){
- Set<String> resources = new HashSet<String>(policyResource.getValues());
- for (String aValue : resources) {
- if (StringUtils.isBlank(aValue)) {
- policyResource.getValues().remove(aValue);
+ if(policyResource != null) {
+ if(CollectionUtils.isNotEmpty(policyResource.getValues())) {
+ Set<String> resources = new HashSet<String>(policyResource.getValues());
+ for (String aValue : resources) {
+ if (StringUtils.isBlank(aValue)) {
+ policyResource.getValues().remove(aValue);
+ }
}
}
- }
- if(CollectionUtils.isEmpty(policyResource.getValues())){
- ValidationErrorCode error = ValidationErrorCode.POLICY_VALIDATION_ERR_MISSING_RESOURCE_LIST;
- if(LOG.isDebugEnabled()) {
- LOG.debug(String.format("Resource list was empty or contains null: value[%s], resource-name[%s], service-def-name[%s]", policyResource.getValues(), name, serviceDef.getName()));
+
+ if(CollectionUtils.isEmpty(policyResource.getValues())){
+ ValidationErrorCode error = ValidationErrorCode.POLICY_VALIDATION_ERR_MISSING_RESOURCE_LIST;
+ if(LOG.isDebugEnabled()) {
+ LOG.debug(String.format("Resource list was empty or contains null: value[%s], resource-name[%s], service-def-name[%s]", policyResource.getValues(), name, serviceDef.getName()));
+ }
+ failures.add(new ValidationFailureDetailsBuilder()
+ .field("resource-values")
+ .subField(name)
+ .isMissing()
+ .becauseOf(error.getMessage(name))
+ .errorCode(error.getErrorCode())
+ .build());
+ valid=false;
}
- failures.add(new ValidationFailureDetailsBuilder()
- .field("resource-values")
- .subField(name)
- .isMissing()
- .becauseOf(error.getMessage(name))
- .errorCode(error.getErrorCode())
- .build());
- valid=false;
- }
- if (validationRegExMap.containsKey(name) && policyResource != null && CollectionUtils.isNotEmpty(policyResource.getValues())) {
- String regEx = validationRegExMap.get(name);
- for (String aValue : policyResource.getValues()) {
- if (StringUtils.isBlank(aValue)) {
- LOG.debug("resource value was blank");
- } else if (!aValue.matches(regEx)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("Resource failed regex check: value[%s], resource-name[%s], regEx[%s], service-def-name[%s]", aValue, name, regEx, serviceDef.getName()));
+
+ if (validationRegExMap.containsKey(name) && CollectionUtils.isNotEmpty(policyResource.getValues())) {
+ String regEx = validationRegExMap.get(name);
+ for (String aValue : policyResource.getValues()) {
+ if (!aValue.matches(regEx)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(String.format("Resource failed regex check: value[%s], resource-name[%s], regEx[%s], service-def-name[%s]", aValue, name, regEx, serviceDef.getName()));
+ }
+ ValidationErrorCode error = ValidationErrorCode.POLICY_VALIDATION_ERR_INVALID_RESOURCE_VALUE_REGEX;
+ failures.add(new ValidationFailureDetailsBuilder()
+ .field("resource-values")
+ .subField(name)
+ .isSemanticallyIncorrect()
+ .becauseOf(error.getMessage(aValue, name))
+ .errorCode(error.getErrorCode())
+ .build());
+ valid = false;
}
- ValidationErrorCode error = ValidationErrorCode.POLICY_VALIDATION_ERR_INVALID_RESOURCE_VALUE_REGEX;
- failures.add(new ValidationFailureDetailsBuilder()
- .field("resource-values")
- .subField(name)
- .isSemanticallyIncorrect()
- .becauseOf(error.getMessage(aValue, name))
- .errorCode(error.getErrorCode())
- .build());
- valid = false;
}
}
}