summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/main/java/org
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2018-07-25 14:12:20 +0000
committerGerrit Code Review <gerrit@onap.org>2018-07-25 14:12:20 +0000
commit7957dd169d09ff5fcfdfc0384e8ed7d3534d3dc0 (patch)
treea4fe47a1cbb37860bcef5d90d6bfc3cada04287b /ONAP-PAP-REST/src/main/java/org
parenta5ccc101707216e8ffc07773c17799c60360863f (diff)
parent95524c8ef8be0d41de8bb2b918f320e464ebb897 (diff)
Merge "Decision BlackList Guard Enhancements"
Diffstat (limited to 'ONAP-PAP-REST/src/main/java/org')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java16
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java12
2 files changed, 25 insertions, 3 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
index 56c23ac2c..c8c540c34 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
@@ -167,7 +167,9 @@ public class DecisionPolicy extends Policy {
if(policyAdapter.getRuleProvider().equals(GUARD_YAML) || policyAdapter.getRuleProvider().equals(GUARD_BL_YAML)){
Map<String, String> yamlParams = new HashMap<>();
- yamlParams.put(DESCRIPTION, (policyAdapter.getPolicyDescription()!=null)? policyAdapter.getPolicyDescription(): "YAML Guard Policy");
+ String blackListEntryType = policyAdapter.getBlackListEntryType() !=null ? policyAdapter.getBlackListEntryType(): "Use Manual Entry";
+ String description = policyAdapter.getPolicyDescription() != null? policyAdapter.getPolicyDescription(): "YAML Guard Policy";
+ yamlParams.put(DESCRIPTION, description + "@blEntry@" + blackListEntryType + "@blEntry@");
String fileName = policyAdapter.getNewFileName();
String name = fileName.substring(fileName.lastIndexOf('\\') + 1, fileName.length());
if ((name == null) || ("".equals(name))) {
@@ -295,6 +297,16 @@ public class DecisionPolicy extends Policy {
blackList.add(blackListString);
}
}
+ if(yamlParams.containsKey("appendBlackList")){
+ String appendBlackListString = yamlParams.get("appendBlackList");
+ List<String> appendBlackList = null;
+ if(appendBlackListString!=null && !appendBlackListString.trim().isEmpty()){
+ appendBlackList = Arrays.asList(appendBlackListString.split(","));
+ for(int i=0; i<appendBlackList.size();i++){
+ blackList.remove(appendBlackList.get(i));
+ }
+ }
+ }
File templateFile;
Path xacmlTemplatePath;
ClassLoader classLoader = getClass().getClassLoader();
@@ -781,7 +793,7 @@ public class DecisionPolicy extends Policy {
}
public String getFunctionDefinitionId(String key){
- FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "short_name", key);
+ FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "shortname", key);
if(object != null){
return object.getXacmlid();
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
index f7ef1a097..a6cda5e68 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * 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.
@@ -416,6 +416,16 @@ public class PolicyCreation extends AbstractPolicyCreation{
String blackList = StringUtils.join(policyData.getYamlparams().getBlackList(), ",");
attributeMap.put("blackList", blackList);
}
+ if(DecisionPolicy.GUARD_BL_YAML.equals(policyData.getRuleProvider()) && "Use File Upload".equals(policyData.getBlackListEntryType())){
+ if(policyData.getBlackListEntries() != null && !policyData.getBlackListEntries().isEmpty()){
+ String blackList = StringUtils.join(policyData.getBlackListEntries(), ",");
+ attributeMap.put("blackList", blackList);
+ }
+ if(policyData.getAppendBlackListEntries() != null && !policyData.getAppendBlackListEntries().isEmpty()){
+ String blackList = StringUtils.join(policyData.getAppendBlackListEntries(), ",");
+ attributeMap.put("appendBlackList", blackList);
+ }
+ }
if(policyData.getYamlparams().getTargets()!=null){
String targets = StringUtils.join(policyData.getYamlparams().getTargets(),",");
attributeMap.put("targets", targets);