Upgraded the latest ONAP SDK
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / controller / DecisionPolicyController.java
index 45369ce..8427797 100644 (file)
@@ -36,7 +36,7 @@ import org.onap.policy.rest.adapter.PolicyRestAdapter;
 import org.onap.policy.rest.adapter.RainyDayParams;
 import org.onap.policy.rest.adapter.YAMLParams;
 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;
 
@@ -82,7 +82,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
                        Object policyData = policyAdapter.getPolicyData();
                        PolicyType policy = (PolicyType) policyData;
                        policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
-                       String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("_") + 1);
+                       String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf('_') + 1);
                        policyAdapter.setPolicyName(policyNameValue);
                        String description = "";
                        try{
@@ -120,6 +120,9 @@ public class DecisionPolicyController extends RestrictedBaseController {
                                                                                //
                                                                                AttributeValueType attributeValue = match.getAttributeValue();
                                                                                String value = (String) attributeValue.getContent().get(0);
+                                        if(value!=null){
+                                            value = value.replaceAll("\\(\\?i\\)", "");
+                                        }
                                                                                AttributeDesignatorType designator = match.getAttributeDesignator();
                                                                                String attributeId = designator.getAttributeId();
                                                                                // First match in the target is OnapName, so set that value.
@@ -203,13 +206,13 @@ public class DecisionPolicyController extends RestrictedBaseController {
                                                                        YAMLParams yamlParams = new YAMLParams();
                                                                        for(int i=0; i<attributeList.size() ; i++){
                                                                                Map<String, String> map = (Map<String,String>)attributeList.get(i);
-                                                                               if(map.get("key").equals("actor")){
+                                                                               if("actor".equals(map.get("key"))){
                                                                                        yamlParams.setActor(map.get("value"));
-                                                                               }else if(map.get("key").equals("recipe")){
+                                                                               }else if("recipe".equals(map.get("key"))){
                                                                                        yamlParams.setRecipe(map.get("value"));
-                                                                               }else if(map.get("key").equals("targets")){
+                                                                               }else if("target".equals(map.get("key"))){
                                                                                        yamlParams.setTargets(Arrays.asList(map.get("value").split("\\|")));
-                                                                               }else if(map.get("key").equals("clname")){
+                                                                               }else if("clname".equals(map.get("key"))){
                                                                                        yamlParams.setClname(map.get("value"));
                                                                                }
                                                                        }