summaryrefslogtreecommitdiffstats
path: root/ONAP-REST
diff options
context:
space:
mode:
authorrb7147 <rb7147@att.com>2018-07-18 12:50:06 -0400
committerrb7147 <rb7147@att.com>2018-07-24 14:16:12 -0400
commit95524c8ef8be0d41de8bb2b918f320e464ebb897 (patch)
treed3b5cdf4ebd9b42aff5e48e54cfd45f353c89f52 /ONAP-REST
parent9bfa1d61dc77973f85a42174b199d4c744265521 (diff)
Decision BlackList Guard Enhancements
While creating a decision Bl Guard Policy we are allowing to add Blacklist entries through file upload for bulk from GUI. Issue-ID: POLICY-901 Change-Id: I4031fd4a96937b9facc330cecf72777d701d4678 Signed-off-by: rb7147 <rb7147@att.com>
Diffstat (limited to 'ONAP-REST')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java21
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ReturnBlackList.java51
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java33
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ReturnBlackListTest.java41
4 files changed, 132 insertions, 14 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
index a9daf1732..e815fe2b9 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
@@ -127,6 +127,9 @@ public class PolicyRestAdapter {
private String actionDictUrl = null;
private String actionDictMethod = null;
private YAMLParams yamlparams;
+ private List<String> blackListEntries;
+ private List<String> appendBlackListEntries;
+ private String blackListEntryType;
//Rainy Day Decision
private RainyDayParams rainyday;
@@ -907,4 +910,22 @@ public class PolicyRestAdapter {
public void setFaultDatas(ClosedLoopFaultTrapDatas faultDatas) {
this.faultDatas = faultDatas;
}
+ public List<String> getAppendBlackListEntries() {
+ return appendBlackListEntries;
+ }
+ public void setAppendBlackListEntries(List<String> appendBlackListEntries) {
+ this.appendBlackListEntries = appendBlackListEntries;
+ }
+ public List<String> getBlackListEntries() {
+ return blackListEntries;
+ }
+ public void setBlackListEntries(List<String> blackListEntries) {
+ this.blackListEntries = blackListEntries;
+ }
+ public String getBlackListEntryType() {
+ return blackListEntryType;
+ }
+ public void setBlackListEntryType(String blackListEntryType) {
+ this.blackListEntryType = blackListEntryType;
+ }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ReturnBlackList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ReturnBlackList.java
new file mode 100644
index 000000000..6ecf1b5e4
--- /dev/null
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ReturnBlackList.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.adapter;
+
+public class ReturnBlackList {
+ private boolean entryCheck;
+ private int actionValue;
+ private String entryValue;
+
+ public boolean isEntryCheck() {
+ return entryCheck;
+ }
+
+ public void setEntryCheck(boolean entryCheck) {
+ this.entryCheck = entryCheck;
+ }
+
+ public int getActionValue() {
+ return actionValue;
+ }
+
+ public void setActionValue(int actionValue) {
+ this.actionValue = actionValue;
+ }
+
+ public String getEntryValue() {
+ return entryValue;
+ }
+
+ public void setEntryValue(String entryValue) {
+ this.entryValue = entryValue;
+ }
+}
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 50985b12d..0478f5f95 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
@@ -940,20 +940,25 @@ public class PolicyValidation {
responseString.append("Guard Params <b>Time Units</b> is Required" + HTML_ITALICS_LNBREAK);
valid = false;
}
- }else if("GUARD_BL_YAML".equals(policyData.getRuleProvider())){
- if(policyData.getYamlparams().getBlackList()==null || policyData.getYamlparams().getBlackList().isEmpty()){
- responseString.append(" Guard Params <b>BlackList</b> is Required " + HTML_ITALICS_LNBREAK);
- valid = false;
- }else{
- for(String blackList: policyData.getYamlparams().getBlackList()){
- if(blackList==null || !(SUCCESS.equals(PolicyUtils.policySpecialCharValidator(blackList)))){
- responseString.append(" Guard Params <b>BlackList</b> Should be valid String" + HTML_ITALICS_LNBREAK);
- valid = false;
- break;
- }
- }
- }
- }
+ } else if ("GUARD_BL_YAML".equals(policyData.getRuleProvider())
+ && "Use Manual Entry".equals(policyData.getBlackListEntryType())) {
+ if (policyData.getYamlparams().getBlackList() == null
+ || policyData.getYamlparams().getBlackList().isEmpty()) {
+ responseString
+ .append(" Guard Params <b>BlackList</b> is Required " + HTML_ITALICS_LNBREAK);
+ valid = false;
+ } else {
+ for (String blackList : policyData.getYamlparams().getBlackList()) {
+ if (blackList == null
+ || !(SUCCESS.equals(PolicyUtils.policySpecialCharValidator(blackList)))) {
+ responseString.append(" Guard Params <b>BlackList</b> Should be valid String"
+ + HTML_ITALICS_LNBREAK);
+ valid = false;
+ break;
+ }
+ }
+ }
+ }
}
}
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ReturnBlackListTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ReturnBlackListTest.java
new file mode 100644
index 000000000..e8f6684b1
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ReturnBlackListTest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.adapter;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class ReturnBlackListTest {
+
+ @Test
+ public void testReturnBlackList() {
+ ReturnBlackList list = new ReturnBlackList();
+ list.setActionValue(1);
+ list.setEntryCheck(true);
+ list.setEntryValue("Test");
+
+ assertTrue(1 == list.getActionValue());
+ assertTrue(list.isEntryCheck());
+ assertTrue("Test".equals(list.getEntryValue()));
+ }
+
+}