You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2017/10/13 15:07:33 UTC

incubator-unomi git commit: UNOMI-129 Restore session storage in setPropertyAction

Repository: incubator-unomi
Updated Branches:
  refs/heads/master 7c7462018 -> fe4d27b89


UNOMI-129 Restore session storage in setPropertyAction

Signed-off-by: Serge Huber <sh...@apache.org>


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

Branch: refs/heads/master
Commit: fe4d27b8931331610c7f920064d956ee2a540e92
Parents: 7c74620
Author: Serge Huber <sh...@apache.org>
Authored: Fri Oct 13 17:07:26 2017 +0200
Committer: Serge Huber <sh...@apache.org>
Committed: Fri Oct 13 17:07:26 2017 +0200

----------------------------------------------------------------------
 .../baseplugin/actions/SetPropertyAction.java   | 22 ++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/fe4d27b8/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
----------------------------------------------------------------------
diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
index 17517c8..8da3b0f 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
@@ -66,14 +66,24 @@ public class SetPropertyAction implements ActionExecutor {
             propertyValue = format.format(event.getTimeStamp());
         }
 
-        Map<String, Object> propertyToUpdate = new HashMap<>();
-        propertyToUpdate.put(propertyName, propertyValue);
+        if (storeInSession) {
+            // in the case of session storage we directly update the session
+            Object target =  event.getSession();
 
-        updateProfileProperties.setProperty(UpdateProfilePropertiesAction.PROPS_TO_UPDATE, propertyToUpdate);
-        int changes = eventService.send(updateProfileProperties);
+            if (PropertyHelper.setProperty(target, propertyName, propertyValue, (String) action.getParameterValues().get("setPropertyStrategy"))) {
+                return EventService.SESSION_UPDATED;
+            }
+        } else {
+            // in the case of profile storage we use the update profile properties event instead.
+            Map<String, Object> propertyToUpdate = new HashMap<>();
+            propertyToUpdate.put(propertyName, propertyValue);
+
+            updateProfileProperties.setProperty(UpdateProfilePropertiesAction.PROPS_TO_UPDATE, propertyToUpdate);
+            int changes = eventService.send(updateProfileProperties);
 
-        if ((changes & EventService.PROFILE_UPDATED) == EventService.PROFILE_UPDATED) {
-            return storeInSession ? EventService.SESSION_UPDATED : EventService.PROFILE_UPDATED;
+            if ((changes & EventService.PROFILE_UPDATED) == EventService.PROFILE_UPDATED) {
+                return EventService.PROFILE_UPDATED;
+            }
         }
 
         return EventService.NO_CHANGE;