Merge "Fix critical sonar for ONAP-PAP-REST"
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / components / CreateBrmsParamPolicy.java
index 047342a..5abe7ce 100644 (file)
@@ -38,6 +38,8 @@ import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import javax.script.SimpleBindings;
+
 import org.apache.commons.io.FilenameUtils;
 import org.onap.policy.common.logging.eelf.MessageCodes;
 import org.onap.policy.common.logging.eelf.PolicyLogger;
@@ -189,8 +191,10 @@ public class CreateBrmsParamPolicy extends Policy {
        private String getValueFromDictionary(String templateName){
                String ruleTemplate = null;
                CommonClassDaoImpl dbConnection = new CommonClassDaoImpl();
-               String queryString="from BRMSParamTemplate where param_template_name= '"+templateName+"'";
-               List<Object> result = dbConnection.getDataByQuery(queryString);
+               String queryString="from BRMSParamTemplate where param_template_name= :templateName";
+               SimpleBindings params = new SimpleBindings();
+               params.put("templateName", templateName);
+               List<Object> result = dbConnection.getDataByQuery(queryString, params);
                if(!result.isEmpty()){
                        BRMSParamTemplate template = (BRMSParamTemplate) result.get(0);
                        ruleTemplate = template.getRule();
@@ -227,6 +231,7 @@ public class CreateBrmsParamPolicy extends Policy {
                                                                line = line.split("\\/\\*")[0]
                                                                                + line.split("\\*\\/")[1].replace("*/", "");
                                                        } catch (Exception e) {
+                                                               LOGGER.debug(e);
                                                                line = line.split("\\/\\*")[0];
                                                        }
                                                } else {
@@ -238,6 +243,7 @@ public class CreateBrmsParamPolicy extends Policy {
                                                try {
                                                        line = line.split("\\*\\/")[1].replace("*/", "");
                                                } catch (Exception e) {
+                                                       LOGGER.debug(e);
                                                        line = "";
                                                }
                                        }
@@ -271,6 +277,7 @@ public class CreateBrmsParamPolicy extends Policy {
                                        try {
                                                nextComponent = components[i + 1];
                                        } catch (Exception e) {
+                                               LOGGER.debug(e);
                                                nextComponent = components[i];
                                        }
                                        //If the type is of type String then we add the UI Item and type to the map.