Upgraded the latest ONAP SDK
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / admin / PolicyNotificationMail.java
index bf89c01..67d9c88 100644 (file)
@@ -30,6 +30,7 @@ import java.util.Properties;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
+import javax.script.SimpleBindings;
 
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
@@ -107,6 +108,9 @@ public class PolicyNotificationMail{
                }
                String policyFileName = entityItem.getPolicyName();
                String checkPolicyName = policyName;
+               if(checkPolicyName.endsWith(".xml") || checkPolicyName.contains(".")){
+                       checkPolicyName = checkPolicyName.substring(0, checkPolicyName.indexOf("."));
+               }
                if(policyFileName.contains("/")){
                        policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
                        policyFileName = policyFileName.replace("/", File.separator);
@@ -116,9 +120,17 @@ public class PolicyNotificationMail{
                        policyFileName = policyFileName.replace("\\", "\\\\");
                }
                
-               String query = "from WatchPolicyNotificationTable where policyName like'" +policyFileName+"%'";
+               policyFileName += "%";
+               String query = "from WatchPolicyNotificationTable where policyName like:policyFileName";
                boolean sendFlag = false;
-               List<Object> watchList = policyNotificationDao.getDataByQuery(query);
+               SimpleBindings params = new SimpleBindings();
+               params.put("policyFileName", policyFileName);
+               List<Object> watchList = null;
+               if(PolicyController.isjUnit()){
+                       watchList = policyNotificationDao.getDataByQuery(query, null);
+               }else{
+                       watchList = policyNotificationDao.getDataByQuery(query, params);
+               }
                if(watchList != null && !watchList.isEmpty()){
                        for(Object watch : watchList){
                                WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;