Repository: incubator-unomi
Updated Branches:
  refs/heads/master d4d6306b2 -> 361596c66


UNOMI-39 : anonymize browsing data removes all sensitive data


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

Branch: refs/heads/master
Commit: 361596c66c5172f2f9e63866063f35ea43e243f6
Parents: d4d6306
Author: Thomas Draier <[email protected]>
Authored: Mon Jul 11 15:11:21 2016 +0200
Committer: Thomas Draier <[email protected]>
Committed: Mon Jul 11 15:11:21 2016 +0200

----------------------------------------------------------------------
 .../privacy/internal/PrivacyServiceImpl.java    | 39 +++++++++-----------
 1 file changed, 17 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/361596c6/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 c885dc9..bd73131 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
@@ -89,28 +89,23 @@ public class PrivacyServiceImpl implements PrivacyService {
 
     @Override
     public String anonymizeBrowsingData(String profileId) {
-//        Profile profile = profileService.load(profileId);
-//        if (profile == null) {
-//            return profileId;
-//        }
-//        Profile newProfile = new Profile(UUID.randomUUID().toString());
-//        // first we copy all the profile data to the new Profile
-//        newProfile.setMergedWith(profile.getMergedWith());
-//        newProfile.setProperties(profile.getProperties());
-//        newProfile.setScores(profile.getScores());
-//        newProfile.setSegments(profile.getSegments());
-//        newProfile.setSystemProperties(profile.getSystemProperties());
-//        newProfile.setScope(profile.getScope());
-//        profileService.save(newProfile);
-//        // then we clear the old profile of all data
-//        profile.setMergedWith(null);
-//        profile.setProperties(new HashMap<String, Object>());
-//        profile.setScores(new HashMap<String, Integer>());
-//        profile.setSegments(new HashSet<String>());
-//        profile.setSystemProperties(new HashMap<String, Object>());
-//        profile.setScope(null);
-//        profileService.save(profile);
-        return null;
+        Profile profile = profileService.load(profileId);
+        if (profile == null) {
+            return profileId;
+        }
+
+        List<Session> sessions = profileService.getProfileSessions(profileId, 
null, 0, -1, null).getList();
+        for (Session session : sessions) {
+            Profile newProfile = getAnonymousProfile();
+            session.setProfile(newProfile);
+            persistenceService.save(session);
+            List<Event> events = 
eventService.searchEvents(session.getItemId(), new String[0], null, 0, -1, 
null).getList();
+            for (Event event : events) {
+                persistenceService.update(event.getItemId(), 
event.getTimeStamp(), Event.class, "profileId", newProfile.getItemId());
+            }
+        }
+
+        return profileId;
     }
 
     @Override

Reply via email to