diff options
author | Michael Mokry <mm117s@att.com> | 2018-09-10 15:23:15 -0500 |
---|---|---|
committer | Michael Mokry <mm117s@att.com> | 2018-09-11 10:31:26 -0500 |
commit | e957a1d9a9fa6bd0f9f8348d1e864c09cfe2cb92 (patch) | |
tree | a09024bc2c7e6a3b69affd95de9352c7d4d5c468 /ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java | |
parent | 1134bd40da28d3833a0dd4f821e75ec938f6061f (diff) |
New min/max Guard Policy
Made changes to support Guard policy create/update and other policy manager
functions including deletePolicy and pushPolicy.
Includes changes for new Guard policy support using GUI and API (Rest and Java Client)
Made changes to address Jim's comments
Made changes to address Liam's comments
Change-Id: I133fe1fd9287ea77ea41a2788de90c7642c36b6a
Issue-ID: POLICY-1038
Signed-off-by: Mike Mokry <mm117s@att.com>
Diffstat (limited to 'ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java')
-rw-r--r-- | ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java | 64 |
1 files changed, 45 insertions, 19 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 |