aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-REST
diff options
context:
space:
mode:
authorMichael Mokry <mm117s@att.com>2018-06-08 08:53:44 -0500
committerMichael Mokry <mm117s@att.com>2018-06-08 09:02:50 -0500
commit7b9a19e6c101fd834404774a40be51645992cdd5 (patch)
tree224845804a36606e83092a3d9271bdbd68230e95 /ONAP-REST
parente1bec1e7a8e3be989a81507eee81909314550693 (diff)
Fixed Model Content Validation for API
This fixes the validation of the content of the model to include validating parent nodes that are required based on the yaml. Prior to this we were only validating required child nodes and in some cases this was causing failures to create a policy. Change-Id: I2bbef4a671cfc7af8b55b3b3c6454b8cea3a88c9 Issue-ID: POLICY-799 Signed-off-by: Michael Mokry <mm117s@att.com>
Diffstat (limited to 'ONAP-REST')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
index 2e685d423..50985b12d 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
@@ -1085,9 +1085,11 @@ public class PolicyValidation {
final JsonNode value = field.getValue();
if (value.isContainerNode() && !value.isArray()) {
+ jsonRequestMap.put(key, "containerNode");
pullModelJsonKeyPairs(value); // RECURSIVE CALL
} else if (value.isArray()) {
try {
+ jsonRequestMap.put(key, "array");
String stringValue = StringUtils.replaceEach(value.toString(), new String[]{"[", "]"}, new String[]{"",""});
ObjectMapper mapper = new ObjectMapper();
JsonNode newValue = mapper.readTree(stringValue);
@@ -1098,8 +1100,7 @@ public class PolicyValidation {
} else {
jsonRequestMap.put(key, value.toString().trim());
}
- }
-
+ }
}
private JsonObject stringToJsonObject(String value) {