You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dr...@apache.org on 2016/08/25 16:42:44 UTC

incubator-unomi git commit: UNOMI-39 - clear goals and past events when anonymized. Send event when anonymous flag is switched. Use uptodate proile in session

Repository: incubator-unomi
Updated Branches:
  refs/heads/master 6f46c9238 -> b2cb9ee0d


UNOMI-39 - clear goals and past events when anonymized. Send event when anonymous flag is switched. Use uptodate proile in session


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

Branch: refs/heads/master
Commit: b2cb9ee0dd55b5566d0e7770f5744f9c0d50c733
Parents: 6f46c92
Author: Thomas Draier <dr...@apache.org>
Authored: Thu Aug 25 18:42:34 2016 +0200
Committer: Thomas Draier <dr...@apache.org>
Committed: Thu Aug 25 18:42:34 2016 +0200

----------------------------------------------------------------------
 .../apache/unomi/privacy/internal/PrivacyServiceImpl.java   | 8 ++++++++
 wab/src/main/java/org/apache/unomi/web/ContextServlet.java  | 9 +++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/b2cb9ee0/extensions/privacy-extension/services/src/main/java/org/apache/unomi/privacy/internal/PrivacyServiceImpl.java
----------------------------------------------------------------------
diff --git a/extensions/privacy-extension/services/src/main/java/org/apache/unomi/privacy/internal/PrivacyServiceImpl.java b/extensions/privacy-extension/services/src/main/java/org/apache/unomi/privacy/internal/PrivacyServiceImpl.java
index ef2f03b..ce97f52 100644
--- a/extensions/privacy-extension/services/src/main/java/org/apache/unomi/privacy/internal/PrivacyServiceImpl.java
+++ b/extensions/privacy-extension/services/src/main/java/org/apache/unomi/privacy/internal/PrivacyServiceImpl.java
@@ -144,6 +144,14 @@ public class PrivacyServiceImpl implements PrivacyService {
             return false;
         }
         profile.getSystemProperties().put("requireAnonymousProfile", anonymous);
+        if (anonymous) {
+            profile.getSystemProperties().remove("goals");
+            profile.getSystemProperties().remove("pastEvents");
+        }
+        Event profileUpdated = new Event("profileUpdated", null, profile, null, null, profile, new Date());
+        profileUpdated.setPersistent(false);
+        eventService.send(profileUpdated);
+
         profileService.save(profile);
         return true;
     }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/b2cb9ee0/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
----------------------------------------------------------------------
diff --git a/wab/src/main/java/org/apache/unomi/web/ContextServlet.java b/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
index c8987b6..2d536d9 100644
--- a/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
+++ b/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
@@ -182,9 +182,9 @@ public class ContextServlet extends HttpServlet {
                         // User does not want to browse anonymously, use the real profile. Check that session contains the current profile.
                         sessionProfile = profile;
                         if (!session.getProfileId().equals(sessionProfile.getItemId())) {
-                            session.setProfile(sessionProfile);
                             changes = EventService.SESSION_UPDATED;
                         }
+                        session.setProfile(sessionProfile);
                     }
                 }
             }
@@ -295,7 +295,8 @@ public class ContextServlet extends HttpServlet {
         if(contextRequest.getEvents() != null && !(profile instanceof Persona)) {
             for (Event event : contextRequest.getEvents()){
                 if(event.getEventType() != null) {
-                    Event eventToSend = new Event(event.getEventType(), session, session.getProfile(), contextRequest.getSource().getScope(), event.getSource(), event.getTarget(), event.getProperties(), timestamp);
+                    Profile sessionProfile = session.getProfile();
+                    Event eventToSend = new Event(event.getEventType(), session, sessionProfile, contextRequest.getSource().getScope(), event.getSource(), event.getTarget(), event.getProperties(), timestamp);
                     if (!eventService.isEventAllowed(event, thirdPartyId)) {
                         logger.debug("Event is not allowed : {}", event.getEventType());
                         continue;
@@ -304,6 +305,10 @@ public class ContextServlet extends HttpServlet {
                         logger.debug("Profile is filtering event type {}", event.getEventType());
                         continue;
                     }
+                    if (sessionProfile.isAnonymousProfile()) {
+                        // Do not keep track of profile in event
+                        event.setProfileId(null);
+                    }
 
                     event.getAttributes().put(Event.HTTP_REQUEST_ATTRIBUTE, request);
                     event.getAttributes().put(Event.HTTP_RESPONSE_ATTRIBUTE, response);