Use try-with-resources
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / admin / PolicyNotificationMail.java
index a4e4762..36e94c2 100644 (file)
@@ -108,12 +108,15 @@ 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.substring(0, policyFileName.indexOf('/'));
                        policyFileName = policyFileName.replace("/", File.separator);
                }
                if(policyFileName.contains("\\")){
-                       policyFileName = policyFileName.substring(0, policyFileName.indexOf("\\"));
+                       policyFileName = policyFileName.substring(0, policyFileName.indexOf('\\'));
                        policyFileName = policyFileName.replace("\\", "\\\\");
                }
                
@@ -122,7 +125,12 @@ public class PolicyNotificationMail{
                boolean sendFlag = false;
                SimpleBindings params = new SimpleBindings();
                params.put("policyFileName", policyFileName);
-               List<Object> watchList = policyNotificationDao.getDataByQuery(query, params);
+               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;