aboutsummaryrefslogtreecommitdiffstats
path: root/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components
diff options
context:
space:
mode:
Diffstat (limited to 'ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components')
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java14
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/AutoPushPolicy.java4
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java2
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java2
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java2
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java12
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java4
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java2
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateNewMicroSerivceModel.java12
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java39
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java2
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java20
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java4
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java17
14 files changed, 72 insertions, 64 deletions
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java
index aee2b3886..63fa04210 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java
@@ -89,12 +89,12 @@ public class ActionPolicy extends Policy {
public static boolean isAttribute = false;
- List<String> dynamicLabelRuleAlgorithms = new LinkedList<String>();
- List<String> dynamicFieldFunctionRuleAlgorithms = new LinkedList<String>();
- List<String> dynamicFieldOneRuleAlgorithms = new LinkedList<String>();
- List<String> dynamicFieldTwoRuleAlgorithms = new LinkedList<String>();
+ List<String> dynamicLabelRuleAlgorithms = new LinkedList<>();
+ List<String> dynamicFieldFunctionRuleAlgorithms = new LinkedList<>();
+ List<String> dynamicFieldOneRuleAlgorithms = new LinkedList<>();
+ List<String> dynamicFieldTwoRuleAlgorithms = new LinkedList<>();
- protected Map<String, String> dropDownMap = new HashMap<String, String>();
+ protected Map<String, String> dropDownMap = new HashMap<>();
public ActionPolicy() {
@@ -108,7 +108,7 @@ public class ActionPolicy extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
@@ -490,7 +490,7 @@ public class ActionPolicy extends Policy {
LOGGER.error("Exception Occured"+e);
}
Map<Datatype, List<FunctionDefinition>> functionMap = jpaUtils.getFunctionDatatypeMap();
- Map<String, String> dropDownMap = new HashMap<String, String>();
+ Map<String, String> dropDownMap = new HashMap<>();
for (Datatype id : functionMap.keySet()) {
List<FunctionDefinition> functionDefinitions = (List<FunctionDefinition>) functionMap
.get(id);
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/AutoPushPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/AutoPushPolicy.java
index 4d4859349..b9ed78ef6 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/AutoPushPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/AutoPushPolicy.java
@@ -72,7 +72,7 @@ public class AutoPushPolicy {
* @param papEngine
*/
public Set<StdPDPGroup> checkGroupsToPush(String policyToCreateUpdate, PAPPolicyEngine papEngine) {
- Set<StdPDPGroup> changedGroups= new HashSet<StdPDPGroup>();
+ Set<StdPDPGroup> changedGroups= new HashSet<>();
// Check if the file has been modified. then re-load the properties file.
newModified = propFile.lastModified();
try {
@@ -135,7 +135,7 @@ public class AutoPushPolicy {
StdPDPPolicy policy = new StdPDPPolicy(policyId, true, policyName, null);
//Get the current policies from the Group and Add the new one
Set<PDPPolicy> currentPoliciesInGroup = pdpGroup.getPolicies();
- Set<PDPPolicy> policies = new HashSet<PDPPolicy>();
+ Set<PDPPolicy> policies = new HashSet<>();
if(policy!=null){
policies.add(policy);
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
index 264602a1d..1281bd083 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
@@ -116,7 +116,7 @@ public class ClosedLoopPolicy extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java
index cab76b9e5..0cf9c6546 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java
@@ -236,7 +236,7 @@ public class ConfigPolicy extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java
index 2f122647d..078ba1040 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java
@@ -45,7 +45,7 @@ public class CreateBRMSRuleTemplate {
public CreateBRMSRuleTemplate() {}
public Map<String, String> addRule(String rule, String ruleName, String description, String userID) {
- Map<String,String> responseMap = new HashMap<String,String>();
+ Map<String,String> responseMap = new HashMap<>();
if(rule!=null && !PolicyUtils.brmsRawValidate(rule).contains("[ERR")){
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(ruleName, "ruleName", BRMSParamTemplate.class);
if(duplicateData!=null && !duplicateData.isEmpty()){
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java
index 0aaf1b1d2..535b2edd3 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java
@@ -40,6 +40,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -93,13 +94,14 @@ public class CreateBrmsParamPolicy extends Policy {
public String expandConfigBody(String ruleContents, Map<String, String> brmsParamBody) {
- Set<String> keySet= new HashSet<String>();
+ Set<String> keySet= new HashSet<>();
Map<String,String> copyMap=new HashMap<>();
copyMap.putAll(brmsParamBody);
copyMap.put("policyName", policyName.substring(0, policyName.replace(".xml", "").lastIndexOf(".")));
copyMap.put("policyScope", policyAdapter.getDomainDir());
copyMap.put("policyVersion",policyAdapter.getHighestVersion().toString());
+ copyMap.put("unique", ("p"+policyName+UUID.randomUUID().toString()).replaceAll("[^A-Za-z0-9]", ""));
//Finding all the keys in the Map data-structure.
keySet= copyMap.keySet();
@@ -179,7 +181,7 @@ public class CreateBrmsParamPolicy extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
@@ -195,7 +197,7 @@ public class CreateBrmsParamPolicy extends Policy {
Boolean dbIsUpdated = true;
- successMap = new HashMap<String, String>();
+ successMap = new HashMap<>();
if (dbIsUpdated) {
successMap = createPolicy(newPolicyPath,getCorrectPolicyDataObject());
} else {
@@ -253,7 +255,7 @@ public class CreateBrmsParamPolicy extends Policy {
}
protected Map<String, String> findType(String rule) {
- Map<String, String> mapFieldType= new HashMap<String,String>();
+ Map<String, String> mapFieldType= new HashMap<>();
if(rule!=null){
try {
String params = "";
@@ -658,7 +660,7 @@ public class CreateBrmsParamPolicy extends Policy {
// Adding Dependencies.
if(policyAdapter.getBrmsDependency()!=null){
BRMSDictionaryController brmsDicitonaryController = new BRMSDictionaryController();
- ArrayList<String> dependencies = new ArrayList<String>();
+ ArrayList<String> dependencies = new ArrayList<>();
StringBuilder key = new StringBuilder();
for(String dependencyName: policyAdapter.getBrmsDependency()){
dependencies.add(brmsDicitonaryController.getDependencyDataByID(dependencyName).getDependency());
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java
index dfd647c6e..350bbc4ff 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java
@@ -117,7 +117,7 @@ public class CreateBrmsRawPolicy extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
@@ -405,7 +405,7 @@ public class CreateBrmsRawPolicy extends Policy {
// Adding Dependencies.
if(policyAdapter.getBrmsDependency()!=null){
BRMSDictionaryController brmsDicitonaryController = new BRMSDictionaryController();
- ArrayList<String> dependencies = new ArrayList<String>();
+ ArrayList<String> dependencies = new ArrayList<>();
StringBuilder key = new StringBuilder();
for(String dependencyName: policyAdapter.getBrmsDependency()){
dependencies.add(brmsDicitonaryController.getDependencyDataByID(dependencyName).getDependency());
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java
index dcb2a93d4..a16ab9a79 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java
@@ -101,7 +101,7 @@ public class CreateClosedLoopPerformanceMetrics extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateNewMicroSerivceModel.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateNewMicroSerivceModel.java
index c1740ae30..30a95f901 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateNewMicroSerivceModel.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateNewMicroSerivceModel.java
@@ -58,7 +58,7 @@ import com.att.research.xacml.util.XACMLProperties;
public class CreateNewMicroSerivceModel {
private static final Logger logger = FlexLogger.getLogger(CreateNewMicroSerivceModel.class);
private MicroServiceModels newModel = null;
- private HashMap<String,MSAttributeObject > classMap = new HashMap<String,MSAttributeObject>();
+ private HashMap<String,MSAttributeObject > classMap = new HashMap<>();
/*
* These are the parameters needed for DB access from the PAP
@@ -85,7 +85,7 @@ public class CreateNewMicroSerivceModel {
this.newModel.setUserCreatedBy(userInfo);
String cleanUpFile = null;
- HashMap<String, MSAttributeObject> tempMap = new HashMap<String, MSAttributeObject>();
+ HashMap<String, MSAttributeObject> tempMap = new HashMap<>();
//Need to delete the file
if (importFile.contains(".zip")){
extractFolder(randomID + ".zip");
@@ -118,7 +118,7 @@ public class CreateNewMicroSerivceModel {
private List<File> listModelFiles(String directoryName) {
File directory = new File(directoryName);
- List<File> resultList = new ArrayList<File>();
+ List<File> resultList = new ArrayList<>();
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile()) {
@@ -185,7 +185,7 @@ public class CreateNewMicroSerivceModel {
public Map<String, String> addValuesToNewModel() {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
MSAttributeObject mainClass = null;
ArrayList<String> dependency = null;
String subAttribute = null;
@@ -227,13 +227,13 @@ public class CreateNewMicroSerivceModel {
@SuppressWarnings("resource")
public Map<String, String> saveImportService(){
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
Connection con = null;
Statement st = null;
ResultSet rs = null;
String modelName = this.newModel.getModelName();
- String imported_by = "API";////////////////////////////////////////////
+ String imported_by = "API";
String version = this.newModel.getVersion();
String insertQuery = null;
int ID = 0;
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java
index e5a114ba8..8d2617ce2 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java
@@ -88,13 +88,13 @@ public class DecisionPolicy extends Policy {
private static final String XACMLTEMPLATE = "Decision_GuardPolicyTemplate.xml";
- List<String> dynamicLabelRuleAlgorithms = new LinkedList<String>();
- List<String> dynamicFieldComboRuleAlgorithms = new LinkedList<String>();
- List<String> dynamicFieldOneRuleAlgorithms = new LinkedList<String>();
- List<String> dynamicFieldTwoRuleAlgorithms = new LinkedList<String>();
- List<String> dataTypeList = new LinkedList<String>();
+ List<String> dynamicLabelRuleAlgorithms = new LinkedList<>();
+ List<String> dynamicFieldComboRuleAlgorithms = new LinkedList<>();
+ List<String> dynamicFieldOneRuleAlgorithms = new LinkedList<>();
+ List<String> dynamicFieldTwoRuleAlgorithms = new LinkedList<>();
+ List<String> dataTypeList = new LinkedList<>();
- protected Map<String, String> dropDownMap = new HashMap<String, String>();
+ protected Map<String, String> dropDownMap = new HashMap<>();
public DecisionPolicy() {
@@ -108,7 +108,7 @@ public class DecisionPolicy extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
@@ -153,7 +153,7 @@ public class DecisionPolicy extends Policy {
policyName = policyAdapter.getNewFileName();
if(policyAdapter.getRuleProvider().equals(GUARD_YAML)){
- Map<String, String> yamlParams = new HashMap<String, String>();
+ Map<String, String> yamlParams = new HashMap<>();
yamlParams.put("description", (policyAdapter.getPolicyDescription()!=null)? policyAdapter.getPolicyDescription(): "YAML Guard Policy");
String fileName = policyAdapter.getNewFileName();
String name = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length());
@@ -191,7 +191,7 @@ public class DecisionPolicy extends Policy {
Map<String, String> dynamicFieldComponentAttributes = policyAdapter.getDynamicFieldConfigAttributes();
if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFProvider)){
- dynamicFieldComponentAttributes = new HashMap<String,String>();
+ dynamicFieldComponentAttributes = new HashMap<>();
}
// If there is any dynamic field attributes create the matches here
@@ -214,7 +214,7 @@ public class DecisionPolicy extends Policy {
//dynamicVariableList = policyAdapter.getDynamicVariableList();
if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals(AAFProvider)){
- dynamicFieldDecisionSettings = new HashMap<String,String>();
+ dynamicFieldDecisionSettings = new HashMap<>();
}
// settings are dynamic so check how many rows are added and add all
@@ -240,11 +240,12 @@ public class DecisionPolicy extends Policy {
ControlLoopGuardBuilder builder = ControlLoopGuardBuilder.Factory.buildControlLoopGuard(new Guard());
GuardPolicy policy1 = new GuardPolicy((policyAdapter.getUuid()!=null? policyAdapter.getUuid(): UUID.randomUUID().toString()) ,yamlParams.get("PolicyName"), yamlParams.get("description"), yamlParams.get("actor"), yamlParams.get("recipe"));
builder = builder.addGuardPolicy(policy1);
- Map<String, String> time_in_range = new HashMap<String, String>();
+ Map<String, String> time_in_range = new HashMap<>();
time_in_range.put("arg2", yamlParams.get("guardActiveStart"));
time_in_range.put("arg3", yamlParams.get("guardActiveEnd"));
- Constraint cons = new Constraint(Integer.parseInt(yamlParams.get("limit")), yamlParams.get("timeWindow"), time_in_range);
- builder = builder.addLimitConstraint(policy1.id, cons);
+ Constraint cons = new Constraint(Integer.parseInt(yamlParams.get("limit")), yamlParams.get("timeWindow"));
+ cons.setTime_in_range(time_in_range);
+ builder = builder.addLimitConstraint(policy1.getId(), cons);
// Build the specification
Results results = builder.buildSpecification();
// YAML TO XACML
@@ -257,12 +258,12 @@ public class DecisionPolicy extends Policy {
yamlSpecs.put("PolicyName", yamlParams.get("PolicyName"));
yamlSpecs.put("description", yamlParams.get("description"));
yamlSpecs.put("ECOMPName", yamlParams.get("ECOMPName"));
- yamlSpecs.put("actor", yamlGuardObject.guards.getFirst().actor);
- yamlSpecs.put("recipe", yamlGuardObject.guards.getFirst().recipe);
- yamlSpecs.put("limit", yamlGuardObject.guards.getFirst().limit_constraints.getFirst().num.toString());
- yamlSpecs.put("timeWindow", yamlGuardObject.guards.getFirst().limit_constraints.getFirst().duration);
- yamlSpecs.put("guardActiveStart", yamlGuardObject.guards.getFirst().limit_constraints.getFirst().time_in_range.get("arg2"));
- yamlSpecs.put("guardActiveEnd", yamlGuardObject.guards.getFirst().limit_constraints.getFirst().time_in_range.get("arg3"));
+ yamlSpecs.put("actor", ((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getActor());
+ yamlSpecs.put("recipe", ((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getRecipe());
+ yamlSpecs.put("limit", ((LinkedList<Constraint>)((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getLimit_constraints()).getFirst().getNum().toString());
+ yamlSpecs.put("timeWindow", ((LinkedList<Constraint>)((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getLimit_constraints()).getFirst().getDuration());
+ yamlSpecs.put("guardActiveStart", ((LinkedList<Constraint>)((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getLimit_constraints()).getFirst().getTime_in_range().get("arg2"));
+ yamlSpecs.put("guardActiveEnd", ((LinkedList<Constraint>)((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getLimit_constraints()).getFirst().getTime_in_range().get("arg3"));
String xacmlPolicyContent = SafePolicyBuilder.generateXacmlGuard(xacmlTemplateContent,yamlSpecs);
// Convert the Policy into Stream input to Policy Adapter.
Object policy = XACMLPolicyScanner.readPolicy(new ByteArrayInputStream(xacmlPolicyContent.getBytes(StandardCharsets.UTF_8)));
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java
index 9e590732c..b4b1a410e 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java
@@ -138,7 +138,7 @@ public class FirewallConfigPolicy extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
index 736069d00..5fc4370e1 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
@@ -76,8 +76,8 @@ public class MicroServiceConfigPolicy extends Policy {
private static String papDbUrl = null;
private static String papDbUser = null;
private static String papDbPassword = null;
- private static Map<String, String> mapAttribute = new HashMap<String,String>();
- private static Map<String, String> matchMap = new HashMap<String,String>();
+ private static Map<String, String> mapAttribute = new HashMap<>();
+ private static Map<String, String> matchMap = new HashMap<>();
public MicroServiceConfigPolicy() {
super();
@@ -105,7 +105,7 @@ public class MicroServiceConfigPolicy extends Policy {
@Override
public Map<String, String> savePolicies() throws Exception {
- Map<String, String> successMap = new HashMap<String,String>();
+ Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
successMap.put("EXISTS", "This Policy already exist on the PAP");
return successMap;
@@ -188,7 +188,7 @@ public class MicroServiceConfigPolicy extends Policy {
matching = getValueFromDictionary(policyAdapter.getServiceType() + "-v" + jsonVersion);
}
- matchMap = new HashMap<String,String>();
+ matchMap = new HashMap<>();
if (matching != null && !matching.isEmpty()){
matchMap = Splitter.on(",").withKeyValueSeparator("=").split(matching);
if(policyAdapter.getJsonBody() != null){
@@ -372,9 +372,15 @@ public class MicroServiceConfigPolicy extends Policy {
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "MicroServiceModels", "Exception querying MicroServiceModels");
} finally {
try{
- if (con!=null) con.close();
- if (rs!=null) rs.close();
- if (st!=null) st.close();
+ if (con!=null){
+ con.close();
+ }
+ if (rs!=null){
+ rs.close();
+ }
+ if (st!=null){
+ st.close();
+ }
} catch (Exception ex){
LOGGER.error("Exception Occured While Closing the Database Connection"+ex);
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
index 743883b01..48431fe93 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
@@ -118,7 +118,7 @@ public abstract class Policy {
public static String ACTION_HOME = null;
public static String CONFIG_URL = null;
- protected Map<String, String> performer = new HashMap<String, String>();
+ protected Map<String, String> performer = new HashMap<>();
private static String actionHome = null;
private static String configHome = null;
@@ -287,7 +287,7 @@ public abstract class Policy {
//create policy once all the validations are completed
protected Map<String, String> createPolicy(final Path policyPath, final Object policyData) {
- Map<String, String> success = new HashMap<String, String>();
+ Map<String, String> success = new HashMap<>();
//
// Is the root a PolicySet or Policy?
//
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java
index eaceb6575..51fcb3d09 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java
@@ -213,7 +213,7 @@ public class PolicyDBDao {
*/
private List<?> getRemotePolicyDBDaoList(){
logger.debug("getRemotePolicyDBDaoList() as getRemotePolicyDBDaoList() called");
- List<?> policyDBDaoEntityList = new LinkedList<Object>();
+ List<?> policyDBDaoEntityList = new LinkedList<>();
EntityManager em = emf.createEntityManager();
startTransactionSynced(em, 1000);
try{
@@ -375,7 +375,6 @@ public class PolicyDBDao {
em.close();
} catch(Exception e2){
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "COULD NOT CREATE DATABASELOCK ROW. WILL TRY ONE MORE TIME");
- e2.printStackTrace();
}
em = null;
em = emf.createEntityManager();
@@ -446,7 +445,7 @@ public class PolicyDBDao {
}
public void notifyOthers(long entityId, String entityType, String newGroupId){
logger.debug("notifyOthers(long entityId, String entityType, long newGroupId) as notifyOthers("+entityId+","+entityType+","+newGroupId+") called");
- LinkedList<Thread> notifyThreads = new LinkedList<Thread>();
+ LinkedList<Thread> notifyThreads = new LinkedList<>();
//we're going to run notiftions in parellel threads to speed things up
for(Object obj : otherServers){
@@ -855,7 +854,7 @@ public class PolicyDBDao {
//this must always be true since we don't explicitly know when a delete is occuring
boolean didUpdate = true;
HashMap<String,PDPPolicy> currentPolicySet = new HashMap<String,PDPPolicy>(oldPdpGroup.getPolicies().size());
- HashSet<PDPPolicy> newPolicySet = new HashSet<PDPPolicy>();
+ HashSet<PDPPolicy> newPolicySet = new HashSet<>();
for(PDPPolicy pdpPolicy : oldPdpGroup.getPolicies()){
currentPolicySet.put(pdpPolicy.getId(), pdpPolicy);
}
@@ -1127,7 +1126,7 @@ public class PolicyDBDao {
Properties propertyFileProperties = new Properties();
String groupList = "";
String defaultGroup = "";
- HashSet<String> currentGroupPaths = new HashSet<String>();
+ HashSet<String> currentGroupPaths = new HashSet<>();
for(Object o : groups){
GroupEntity group = (GroupEntity)o;
Path groupPath = Paths.get(pdpsPath.toString(), group.getGroupId());
@@ -1663,7 +1662,7 @@ public class PolicyDBDao {
getPolicyEntitiesQuery.setParameter("deleted", false);
policyEntityList = getPolicyEntitiesQuery.getResultList();
} catch(Exception e){
- policyEntityList = new LinkedList<PolicyEntity>();
+ policyEntityList = new LinkedList<>();
}
for (PolicyEntity policy: policyEntityList){
@@ -1971,7 +1970,7 @@ public class PolicyDBDao {
}
String gitPath = getGitPath();
- ArrayList<String> gitPathParts = new ArrayList<String>();
+ ArrayList<String> gitPathParts = new ArrayList<>();
Iterator<?> gitPathIterator = Paths.get(gitPath).iterator();
while(gitPathIterator.hasNext()){
gitPathParts.add(gitPathIterator.next().toString());
@@ -2528,7 +2527,7 @@ public class PolicyDBDao {
getGroups.setParameter("pid", existingPolicy.getPolicyId());
groups = getGroups.getResultList();
}catch(Exception e){
- groups = new LinkedList<GroupEntity>();
+ groups = new LinkedList<>();
}
for(Object o : groups){
GroupEntity group = (GroupEntity)o;
@@ -3104,7 +3103,7 @@ public class PolicyDBDao {
PolicyLogger.error("We cannot get the group from the papEngine to delete policies");
} else {
- Set<String> newPolicySet = new HashSet<String>(group.getPolicies().size());
+ Set<String> newPolicySet = new HashSet<>(group.getPolicies().size());
//a multiple of n runtime is faster than n^2, so I am using a hashset to do the comparison
for(PDPPolicy pol: group.getPolicies()){
newPolicySet.add(pol.getId());