- String policyFileName = entityItem.getPolicyName();
- String checkPolicyName = policyName;
- if(checkPolicyName.endsWith(".xml") || checkPolicyName.contains(".")){
- checkPolicyName = checkPolicyName.substring(0, checkPolicyName.indexOf('.'));
+ String checkPolicyName = findCheckPolicyName(policyName);
+
+ String policyFileName = findPolicyFileName(entityItem);
+ String query = "from WatchPolicyNotificationTable where policyName like:policyFileName";
+ List<Object> watchList = findWatchList(policyNotificationDao, policyFileName, query);
+ if (!watchList.isEmpty()) {
+ composeAndSendMail(mode, policyNotificationDao, subject, message, checkPolicyName, watchList);
+ }
+ }
+
+ private List<Object> findWatchList(CommonClassDao policyNotificationDao, String policyFileName, String query) {
+ SimpleBindings params = new SimpleBindings();
+ params.put("policyFileName", policyFileName);
+ List<Object> watchList;
+ if (PolicyController.isjUnit()) {
+ watchList = policyNotificationDao.getDataByQuery(query, null);
+ } else {
+ watchList = policyNotificationDao.getDataByQuery(query, params);
+ }
+
+ if (watchList == null || watchList.isEmpty()) {
+ policyLogger
+ .debug("List of policy being watched is either null or empty, hence return without sending mail");
+ watchList = new ArrayList<>();