Merge "Continue addressing technical debt for ONAP-XACML"
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / controller / ActionPolicyController.java
index c8b7a96..a556bee 100644 (file)
@@ -26,12 +26,15 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.xml.bind.JAXBElement;
 
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.rest.adapter.PolicyRestAdapter;
 import org.onap.policy.rest.jpa.PolicyEntity;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
@@ -48,8 +51,6 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
 
 @Controller
 @RequestMapping({ "/" })
@@ -77,7 +78,7 @@ public class ActionPolicyController extends RestrictedBaseController {
             PolicyType policy = (PolicyType) policyData;
             policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
             String policyNameValue = policyAdapter.getPolicyName()
-                    .substring(policyAdapter.getPolicyName().indexOf("_") + 1);
+                    .substring(policyAdapter.getPolicyName().indexOf('_') + 1);
             policyAdapter.setPolicyName(policyNameValue);
             String description = "";
             try {
@@ -166,8 +167,9 @@ public class ActionPolicyController extends RestrictedBaseController {
                                             AttributeValueType attributeValue = (AttributeValueType) attributeAssignmentExpression
                                                     .getExpression().getValue();
                                             if (attributeID.equals(PERFORMER_ATTRIBUTEID)) {
-                                                for (String key : performer.keySet()) {
-                                                    String keyValue = performer.get(key);
+                                                for ( Entry<String, String> entry: performer.entrySet()) {
+                                                       String key = entry.getKey();
+                                                    String keyValue = entry.getValue();
                                                     if (keyValue.equals(attributeValue.getContent().get(0))) {
                                                         policyAdapter.setActionPerformer(key);
                                                     }
@@ -210,7 +212,7 @@ public class ActionPolicyController extends RestrictedBaseController {
             if (LOGGER.isDebugEnabled()) {
                 LOGGER.debug("Prepopulating Compound rule algorithm: " + index);
             }
-            Map<String, String> rule = new HashMap<String, String>();
+            Map<String, String> rule = new HashMap<>();
             for (String key : PolicyController.getDropDownMap().keySet()) {
                 String keyValue = PolicyController.getDropDownMap().get(key);
                 if (keyValue.equals(actionApply.getFunctionId())) {
@@ -231,14 +233,13 @@ public class ActionPolicyController extends RestrictedBaseController {
     }
 
     private void prePopulateRuleAlgorithms(int index, ApplyType actionApply, List<JAXBElement<?>> jaxbActionTypes) {
-        Map<String, String> ruleMap = new HashMap<String, String>();
+        Map<String, String> ruleMap = new HashMap<>();
         ruleMap.put("id", "A" + (index + 1));
         // Populate combo box
         Map<String, String> dropDownMap = PolicyController.getDropDownMap();
-        for (String key : dropDownMap.keySet()) {
-            String keyValue = dropDownMap.get(key);
-            if (keyValue.equals(actionApply.getFunctionId())) {
-                ruleMap.put("dynamicRuleAlgorithmCombo", key);
+        for ( Entry<String, String> entry : dropDownMap.entrySet()) {
+            if (entry.getValue().equals(actionApply.getFunctionId())) {
+                ruleMap.put("dynamicRuleAlgorithmCombo", entry.getKey());
             }
         }
         // Populate the key and value fields
@@ -257,7 +258,7 @@ public class ActionPolicyController extends RestrictedBaseController {
             ruleMap.put("dynamicRuleAlgorithmField2", attributeValue);
         }
         // Rule Attribute added as value
-        else if (((jaxbActionTypes.get(0).getValue()) instanceof AttributeValueType)) {
+        else if ((jaxbActionTypes.get(0).getValue()) instanceof AttributeValueType) {
             AttributeValueType actionConditionAttributeValue = (AttributeValueType) jaxbActionTypes.get(0).getValue();
             String attributeValue = (String) actionConditionAttributeValue.getContent().get(0);
             ruleMap.put("dynamicRuleAlgorithmField2", attributeValue);