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 2020/04/06 16:25:21 UTC
[unomi] branch master updated: Unomi 307 enable profile's sessions
and events deletion (#146)
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/master by this push:
new 3711465 Unomi 307 enable profile's sessions and events deletion (#146)
3711465 is described below
commit 3711465bb145a1e8f8510f6ae76a9c65daa55fe8
Author: nlevitsky <59...@users.noreply.github.com>
AuthorDate: Mon Apr 6 19:25:14 2020 +0300
Unomi 307 enable profile's sessions and events deletion (#146)
* feat(EventService) - add method to remove all profile's events
* feat(ProfileService) - add method to remove all profile's sessions
* feat(PrivacyService) - on profile deletion - add an option to also delete it's sessions and events
Co-authored-by: nlevitsky <Pitzek1305>
---
.../main/java/org/apache/unomi/api/services/EventService.java | 7 +++++++
.../java/org/apache/unomi/api/services/PrivacyService.java | 3 ++-
.../java/org/apache/unomi/api/services/ProfileService.java | 7 +++++++
.../org/apache/unomi/privacy/rest/PrivacyServiceEndPoint.java | 9 ++++++---
.../org/apache/unomi/privacy/internal/PrivacyServiceImpl.java | 9 +++++++--
.../apache/unomi/services/impl/events/EventServiceImpl.java | 10 ++++++++++
.../unomi/services/impl/profiles/ProfileServiceImpl.java | 10 ++++++++++
7 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/api/src/main/java/org/apache/unomi/api/services/EventService.java b/api/src/main/java/org/apache/unomi/api/services/EventService.java
index 84c1ef5..6060481 100644
--- a/api/src/main/java/org/apache/unomi/api/services/EventService.java
+++ b/api/src/main/java/org/apache/unomi/api/services/EventService.java
@@ -142,4 +142,11 @@ public interface EventService {
* @return {@code true} if the event has already been raised, {@code false} otherwise
*/
boolean hasEventAlreadyBeenRaised(Event event, boolean session);
+
+ /**
+ * Removes all events of the specified profile
+ *
+ * @param profileId identifier of the profile that we want to remove it's events
+ */
+ void removeProfileEvents(String profileId);
}
diff --git a/api/src/main/java/org/apache/unomi/api/services/PrivacyService.java b/api/src/main/java/org/apache/unomi/api/services/PrivacyService.java
index d860b7c..35f11be 100644
--- a/api/src/main/java/org/apache/unomi/api/services/PrivacyService.java
+++ b/api/src/main/java/org/apache/unomi/api/services/PrivacyService.java
@@ -66,9 +66,10 @@ public interface PrivacyService {
* This method will perform two operations, first it will call the anonymizeBrowsingData method on the
* specified profile, and then it will delete the profile from the persistence service.
* @param profileId the identifier of the profile
+ * @param purgeData flag that indicates whether to purge the profile's data
* @return true if the operation was successful, false otherwise
*/
- Boolean deleteProfileData(String profileId);
+ Boolean deleteProfileData(String profileId,boolean purgeData);
/**
* Controls the activation/deactivation of anonymous browsing. This method will simply set a system
diff --git a/api/src/main/java/org/apache/unomi/api/services/ProfileService.java b/api/src/main/java/org/apache/unomi/api/services/ProfileService.java
index 35ebfd1..21c0333 100644
--- a/api/src/main/java/org/apache/unomi/api/services/ProfileService.java
+++ b/api/src/main/java/org/apache/unomi/api/services/ProfileService.java
@@ -167,6 +167,13 @@ public interface ProfileService {
PartialList<Session> findProfileSessions(String profileId);
/**
+ * Removes all sessions of the specified profile
+ *
+ * @param profileId identifier of the profile that we want to remove it's sessions
+ */
+ void removeProfileSessions(String profileId);
+
+ /**
* Checks whether the specified profile and/or session satisfy the specified condition.
*
* @param condition the condition we're testing against which might or might not have profile- or session-specific sub-conditions
diff --git a/extensions/privacy-extension/rest/src/main/java/org/apache/unomi/privacy/rest/PrivacyServiceEndPoint.java b/extensions/privacy-extension/rest/src/main/java/org/apache/unomi/privacy/rest/PrivacyServiceEndPoint.java
index 5e9e1b6..40b1160 100644
--- a/extensions/privacy-extension/rest/src/main/java/org/apache/unomi/privacy/rest/PrivacyServiceEndPoint.java
+++ b/extensions/privacy-extension/rest/src/main/java/org/apache/unomi/privacy/rest/PrivacyServiceEndPoint.java
@@ -55,9 +55,12 @@ public class PrivacyServiceEndPoint {
@DELETE
@Path("/profiles/{profileId}")
- public Response deleteProfileData(@PathParam("profileId") String profileId, @QueryParam("withData") @DefaultValue("false") boolean withData) {
- if (withData) {
- privacyService.deleteProfileData(profileId);
+ public Response deleteProfileData(@PathParam("profileId") String profileId, @QueryParam("withData") @DefaultValue("false") boolean withData,
+ @QueryParam("purgeAll") @DefaultValue("false") boolean purgeAll) {
+ if (purgeAll) {
+ privacyService.deleteProfileData(profileId,true);
+ } else if (withData) {
+ privacyService.deleteProfileData(profileId,false);
} else {
privacyService.deleteProfile(profileId);
}
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 d4db874..1675e11 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
@@ -145,8 +145,13 @@ public class PrivacyServiceImpl implements PrivacyService {
}
@Override
- public Boolean deleteProfileData(String profileId) {
- anonymizeBrowsingData(profileId);
+ public Boolean deleteProfileData(String profileId,boolean purgeData) {
+ if (purgeData) {
+ eventService.removeProfileEvents(profileId);
+ profileService.removeProfileSessions(profileId);
+ } else {
+ anonymizeBrowsingData(profileId);
+ }
profileService.delete(profileId, false);
return true;
}
diff --git a/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
index 2a1a092..d0bdb51 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
@@ -324,4 +324,14 @@ public class EventServiceImpl implements EventService {
eventListeners.remove(eventListenerService);
}
}
+
+ public void removeProfileEvents(String profileId){
+ Condition profileCondition = new Condition();
+ profileCondition.setConditionType(definitionsService.getConditionType("eventPropertyCondition"));
+ profileCondition.setParameter("propertyName", "profileId");
+ profileCondition.setParameter("comparisonOperator", "equals");
+ profileCondition.setParameter("propertyValue", profileId);
+
+ persistenceService.removeByQuery(profileCondition,Event.class);
+ }
}
diff --git a/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
index 94fb5c5..c0269ed 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
@@ -749,6 +749,16 @@ public class ProfileServiceImpl implements ProfileService, SynchronousBundleList
return persistenceService.query("profileId", profileId, "timeStamp:desc", Session.class, 0, 50);
}
+ public void removeProfileSessions(String profileId) {
+ Condition profileCondition = new Condition();
+ profileCondition.setConditionType(definitionsService.getConditionType("sessionPropertyCondition"));
+ profileCondition.setParameter("propertyName", "profileId");
+ profileCondition.setParameter("comparisonOperator", "equals");
+ profileCondition.setParameter("propertyValue", profileId);
+
+ persistenceService.removeByQuery(profileCondition,Session.class);
+ }
+
@Override
public boolean matchCondition(Condition condition, Profile profile, Session session) {
ParserHelper.resolveConditionType(definitionsService, condition);