UNOMI-47 : Once per profile handled in the mailing action, because event 
updatedProfile is not persisted


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/d1d0bb39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/d1d0bb39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/d1d0bb39

Branch: refs/heads/master
Commit: d1d0bb39c39d6fddd3e0406b1ad210ece2cebc97
Parents: 2d58c95
Author: Abdelkader Midani <[email protected]>
Authored: Thu Aug 4 02:51:09 2016 +0200
Committer: Quentin Lamerand <[email protected]>
Committed: Thu Aug 4 19:02:12 2016 +0200

----------------------------------------------------------------------
 .../unomi/plugins/mail/actions/SendMailAction.java | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/d1d0bb39/plugins/mail/src/main/java/org/apache/unomi/plugins/mail/actions/SendMailAction.java
----------------------------------------------------------------------
diff --git 
a/plugins/mail/src/main/java/org/apache/unomi/plugins/mail/actions/SendMailAction.java
 
b/plugins/mail/src/main/java/org/apache/unomi/plugins/mail/actions/SendMailAction.java
index 278418d..fc8b85a 100644
--- 
a/plugins/mail/src/main/java/org/apache/unomi/plugins/mail/actions/SendMailAction.java
+++ 
b/plugins/mail/src/main/java/org/apache/unomi/plugins/mail/actions/SendMailAction.java
@@ -88,18 +88,23 @@ public class SendMailAction implements ActionExecutor {
             if(notifyOnce.booleanValue() && notifTypeAck > 0){
                 logger.info("Notification "+notifType+" already sent for the 
profile "+event.getProfileId());
                 return EventService.NO_CHANGE;
+            }else{
+                ((HashMap) profileNotif.get(notifType) ).put(notifTypeId, 
notifTypeAck+1);
             }
         } else {
-            Map notification = profileNotif!=null?profileNotif:new HashMap();
-            notification.put(notifType, 
notification.get(notifType)!=null?notification.get(notifType):new HashMap());
-            Integer notifTypeAck = (Integer) ((HashMap) 
notification.get(notifType) ).get(notifTypeId);
+            if(profileNotif == null){
+                profileNotif = new HashMap();
+            }
+            profileNotif.put(notifType, 
profileNotif.get(notifType)!=null?profileNotif.get(notifType):new HashMap());
+            Integer notifTypeAck = (Integer) ((HashMap) 
profileNotif.get(notifType) ).get(notifTypeId);
             if(notifTypeAck == null){
-                ((HashMap) notification.get(notifType) ).put(notifTypeId, 1);
+                ((HashMap) profileNotif.get(notifType) ).put(notifTypeId, 1);
             }
-            event.getProfile().getSystemProperties().put("notificationAck", 
notification);
-            persistenceService.update(event.getProfile().getItemId(), null, 
Profile.class, "systemProperties", event.getProfile().getSystemProperties());
         }
 
+        event.getProfile().getSystemProperties().put("notificationAck", 
profileNotif);
+        persistenceService.update(event.getProfile().getItemId(), null, 
Profile.class, "systemProperties", event.getProfile().getSystemProperties());
+
         ST stringTemplate = new ST(template);
         stringTemplate.add("profile", event.getProfile());
         stringTemplate.add("event", event);

Reply via email to