summaryrefslogtreecommitdiffstats
path: root/ONAP-REST/src/main/java/org
diff options
context:
space:
mode:
authorMichael Mokry <mm117s@att.com>2018-09-10 15:23:15 -0500
committerMichael Mokry <mm117s@att.com>2018-09-11 10:31:26 -0500
commite957a1d9a9fa6bd0f9f8348d1e864c09cfe2cb92 (patch)
treea09024bc2c7e6a3b69affd95de9352c7d4d5c468 /ONAP-REST/src/main/java/org
parent1134bd40da28d3833a0dd4f821e75ec938f6061f (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')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/YAMLParams.java21
-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
3 files changed, 70 insertions, 21 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/YAMLParams.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/YAMLParams.java
index ec43a19f2..c7063b86e 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/YAMLParams.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/YAMLParams.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@ public class YAMLParams {
private String recipe;
private String clname;
private String limit;
+ private String min;
+ private String max;
private String timeWindow;
private String timeUnits;
private String guardActiveStart;
@@ -52,6 +54,23 @@ public class YAMLParams {
public void setLimit(String limit) {
this.limit = limit;
}
+
+ public String getMin() {
+ return min;
+ }
+
+ public void setMin(String min) {
+ this.min = min;
+ }
+
+ public String getMax() {
+ return max;
+ }
+
+ public void setMax(String max) {
+ this.max = max;
+ }
+
public String getTimeWindow() {
return timeWindow;
}
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<>();