aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-REST/src/main/java/org/onap/policy/rest/util
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-REST/src/main/java/org/onap/policy/rest/util')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java64
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java6
2 files changed, 50 insertions, 20 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 42f94cfa7..df4e4726d 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
@@ -900,48 +900,74 @@ public class PolicyValidation {
}
}
- if("GUARD_YAML".equals(policyData.getRuleProvider()) || "GUARD_BL_YAML".equals(policyData.getRuleProvider())){
- if(policyData.getYamlparams()==null){
+ if ("GUARD_YAML".equals(policyData.getRuleProvider())
+ || "GUARD_BL_YAML".equals(policyData.getRuleProvider())
+ || "GUARD_MIN_MAX".equals(policyData.getRuleProvider())) {
+ if (policyData.getYamlparams() == null) {
responseString.append("<b> Guard Params are Required </b>" + HTML_ITALICS_LNBREAK);
valid = false;
- }else{
- if(Strings.isNullOrEmpty(policyData.getYamlparams().getActor())){
+ } else {
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getActor())) {
responseString.append("Guard Params <b>Actor</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
}
- if(Strings.isNullOrEmpty(policyData.getYamlparams().getRecipe())){
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getRecipe())) {
responseString.append("Guard Params <b>Recipe</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
}
- if(Strings.isNullOrEmpty(policyData.getYamlparams().getGuardActiveStart())){
- responseString.append("Guard Params <b>Guard Active Start</b> is Required " + HTML_ITALICS_LNBREAK);
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getGuardActiveStart())) {
+ responseString.append(
+ "Guard Params <b>Guard Active Start</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
}
- if(Strings.isNullOrEmpty(policyData.getYamlparams().getGuardActiveEnd())){
- responseString.append("Guard Params <b>Guard Active End</b> is Required " + HTML_ITALICS_LNBREAK);
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getGuardActiveEnd())) {
+ responseString
+ .append("Guard Params <b>Guard Active End</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
}
- if("GUARD_YAML".equals(policyData.getRuleProvider())){
- if(Strings.isNullOrEmpty(policyData.getYamlparams().getLimit())){
+ if ("GUARD_YAML".equals(policyData.getRuleProvider())) {
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getLimit())) {
responseString.append(" Guard Params <b>Limit</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
- }else if(!PolicyUtils.isInteger(policyData.getYamlparams().getLimit())){
- responseString.append(" Guard Params <b>Limit</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+ } else if (!PolicyUtils.isInteger(policyData.getYamlparams().getLimit())) {
+ responseString
+ .append(" Guard Params <b>Limit</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+ valid = false;
+ }
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getTimeWindow())) {
+ responseString
+ .append("Guard Params <b>Time Window</b> is Required" + HTML_ITALICS_LNBREAK);
+ valid = false;
+ } else if (!PolicyUtils.isInteger(policyData.getYamlparams().getTimeWindow())) {
+ responseString.append(
+ " Guard Params <b>Time Window</b> Should be Integer " + HTML_ITALICS_LNBREAK);
valid = false;
}
- if(Strings.isNullOrEmpty(policyData.getYamlparams().getTimeWindow())){
- responseString.append("Guard Params <b>Time Window</b> is Required" + HTML_ITALICS_LNBREAK);
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getTimeUnits())) {
+ responseString
+ .append("Guard Params <b>Time Units</b> is Required" + HTML_ITALICS_LNBREAK);
+ valid = false;
+ }
+ } else if ("GUARD_MIN_MAX".equals(policyData.getRuleProvider())) {
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getMin())) {
+ responseString.append(" Guard Params <b>Min</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
- }else if(!PolicyUtils.isInteger(policyData.getYamlparams().getTimeWindow())){
- responseString.append(" Guard Params <b>Time Window</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+ } else if (!PolicyUtils.isInteger(policyData.getYamlparams().getMin())) {
+ responseString
+ .append(" Guard Params <b>Min</b> Should be Integer " + HTML_ITALICS_LNBREAK);
valid = false;
}
- if(Strings.isNullOrEmpty(policyData.getYamlparams().getTimeUnits())){
- responseString.append("Guard Params <b>Time Units</b> is Required" + HTML_ITALICS_LNBREAK);
+ if (Strings.isNullOrEmpty(policyData.getYamlparams().getMax())) {
+ responseString.append(" Guard Params <b>Max</b> is Required " + HTML_ITALICS_LNBREAK);
+ valid = false;
+ } else if (!PolicyUtils.isInteger(policyData.getYamlparams().getMax())) {
+ responseString
+ .append(" Guard Params <b>Max</b> Should be Integer " + HTML_ITALICS_LNBREAK);
valid = false;
}
} else if ("GUARD_BL_YAML".equals(policyData.getRuleProvider())
&& "Use Manual Entry".equals(policyData.getBlackListEntryType())) {
+
if (policyData.getYamlparams().getBlackList() == null
|| policyData.getYamlparams().getBlackList().isEmpty()) {
responseString
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
index 66628e2da..779c5227a 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
@@ -176,7 +176,8 @@ public class PolicyValidationRequestWrapper {
rainyday.setTreatmentTableChoices(treatmentsTableChoices);
policyData.setRainyday(rainyday);
- }else if("GUARD_YAML".equals(ruleProvider) || "GUARD_BL_YAML".equals(ruleProvider)) {
+ } else if ("GUARD_YAML".equals(ruleProvider) || "GUARD_BL_YAML".equals(ruleProvider)
+ || "GUARD_MIN_MAX".equals(ruleProvider)) {
// Set Matching attributes in YAMLParams in adapter
YAMLParams yamlparams = new YAMLParams();
@@ -191,6 +192,9 @@ public class PolicyValidationRequestWrapper {
yamlparams.setLimit(matching.get("limit"));
yamlparams.setTimeWindow(matching.get("timeWindow"));
yamlparams.setTimeUnits(matching.get("timeUnits"));
+ } else if ("GUARD_MIN_MAX".equals(ruleProvider)) {
+ yamlparams.setMin(matching.get("min"));
+ yamlparams.setMax(matching.get("max"));
}else{
List<String> blackList = new ArrayList<>();