Fixed the Policy API issues and Bugfixes
[policy/engine.git] / ECOMP-PAP-REST / src / main / java / org / openecomp / policy / pap / xacml / rest / components / CreateBrmsRawPolicy.java
index dfd647c..a0f13ec 100644 (file)
@@ -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;
@@ -131,13 +131,9 @@ public class CreateBrmsRawPolicy extends Policy {
                Path newPolicyPath = null;
                newPolicyPath = Paths.get(policyAdapter.getNewFileName());
                
-               Boolean dbIsUpdated = true;
-
-               successMap = new HashMap<String, String>();
-               if (dbIsUpdated) {
-                       successMap = createPolicy(newPolicyPath,
-                                       getCorrectPolicyDataObject());
-               } else {
+               successMap = createPolicy(newPolicyPath, getCorrectPolicyDataObject());
+               if (successMap == null) {
+                       successMap = new HashMap<>();
                        PolicyLogger.error("Failed to Update the Database Dictionary Tables.");
                        successMap.put("error", "DB UPDATE");
                }
@@ -405,7 +401,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());