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 7fda2a3 UNOMI-374 Merge profile without sessions (#193)
7fda2a3 is described below
commit 7fda2a305962eb0d28ce47dddefb3f56bfe6b688
Author: giladw <[email protected]>
AuthorDate: Tue Sep 22 11:48:26 2020 +0300
UNOMI-374 Merge profile without sessions (#193)
* feat(DATA_3381-merging-monthly-indices): remove itemsMonthlyIndexed f…
(#39)
* feat(DATA_3381-merging-monthly-indices): remove itemsMonthlyIndexed from
blueprint, put it in config instead
* feat(DATA_3381-merging-monthly-indices): sending none if monthlyIndex
should contain nothing
* Revert "feat(DATA_3381-merging-monthly-indices): remove
itemsMonthlyIndexed f… (#39)"
This reverts commit b309e61b67ec0c3ed116c725d6c471ce4e60b3e0.
* check for session is null in mergePofilesPropertyAction
Co-authored-by: liatiusim <[email protected]>
Co-authored-by: Shir Bromberg <[email protected]>
Co-authored-by: amitco1 <[email protected]>
---
.../actions/MergeProfilesOnPropertyAction.java | 39 +++++++++++++---------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git
a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
index da92a24..e8c975b 100644
---
a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
+++
b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
@@ -96,7 +96,7 @@ public class MergeProfilesOnPropertyAction implements
ActionExecutor {
} else {
// Create a new profile
profile = new Profile(UUID.randomUUID().toString());
- profile.setProperty("firstVisit",
currentSession.getTimeStamp());
+ profile.setProperty("firstVisit", event.getTimeStamp());
profile.getSystemProperties().put(mergeProfilePropertyName,
mergeProfilePropertyValue);
}
@@ -109,9 +109,10 @@ public class MergeProfilesOnPropertyAction implements
ActionExecutor {
event.setProfileId(profile.getItemId());
event.setProfile(profile);
- currentSession.setProfile(profile);
-
- eventService.send(new Event("sessionReassigned", currentSession,
profile, event.getScope(), event, currentSession, event.getTimeStamp()));
+ if (currentSession != null) {
+ currentSession.setProfile(profile);
+ eventService.send(new Event("sessionReassigned",
currentSession, profile, event.getScope(), event, currentSession,
event.getTimeStamp()));
+ }
return EventService.PROFILE_UPDATED + EventService.SESSION_UPDATED;
} else {
@@ -139,7 +140,7 @@ public class MergeProfilesOnPropertyAction implements
ActionExecutor {
HttpServletResponse httpServletResponse =
(HttpServletResponse) event.getAttributes().get(Event.HTTP_RESPONSE_ATTRIBUTE);
// we still send back the current profile cookie. It will be
changed on the next request to the ContextServlet.
// The current profile will be deleted only then because we
cannot delete it right now (too soon)
- sendProfileCookie(currentSession.getProfile(),
httpServletResponse,
+ sendProfileCookie(profile, httpServletResponse,
profileIdCookieName, profileIdCookieDomain,
profileIdCookieMaxAgeInSeconds);
final String masterProfileId = masterProfile.getItemId();
@@ -147,16 +148,19 @@ public class MergeProfilesOnPropertyAction implements
ActionExecutor {
event.setProfileId(masterProfileId);
event.setProfile(masterProfile);
- currentSession.setProfile(masterProfile);
- if (privacyService.isRequireAnonymousBrowsing(profile)) {
-
privacyService.setRequireAnonymousBrowsing(masterProfileId, true,
event.getScope());
- }
-
final Boolean anonymousBrowsing =
privacyService.isRequireAnonymousBrowsing(masterProfileId);
- if (anonymousBrowsing) {
-
currentSession.setProfile(privacyService.getAnonymousProfile(masterProfile));
- event.setProfileId(null);
- persistenceService.save(event);
+
+ if (currentSession != null){
+ currentSession.setProfile(masterProfile);
+ if (privacyService.isRequireAnonymousBrowsing(profile)) {
+
privacyService.setRequireAnonymousBrowsing(masterProfileId, true,
event.getScope());
+ }
+
+ if (anonymousBrowsing) {
+
currentSession.setProfile(privacyService.getAnonymousProfile(masterProfile));
+ event.setProfileId(null);
+ persistenceService.save(event);
+ }
}
event.getActionPostExecutors().add(new ActionPostExecutor() {
@@ -167,9 +171,12 @@ public class MergeProfilesOnPropertyAction implements
ActionExecutor {
String profileId = profile.getItemId();
if (!StringUtils.equals(profileId,
masterProfileId)) {
List<Session> sessions =
persistenceService.query("profileId", profileId, null, Session.class);
- if (masterProfileId.equals(profileId) &&
!sessions.contains(currentSession)) {
- sessions.add(currentSession);
+ if (currentSession != null){
+ if (masterProfileId.equals(profileId)
&& !sessions.contains(currentSession)) {
+ sessions.add(currentSession);
+ }
}
+
for (Session session : sessions) {
persistenceService.update(session.getItemId(), session.getTimeStamp(),
Session.class, "profileId", anonymousBrowsing ? null : masterProfileId);
}