This is an automated email from the ASF dual-hosted git repository.

jsinovassinnaik pushed a commit to branch UNOMI-660-fix-origineventids-property
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to 
refs/heads/UNOMI-660-fix-origineventids-property by this push:
     new 0fbc6aa27 feedbacks
0fbc6aa27 is described below

commit 0fbc6aa2711ffcba6c8c76c0a3d70ce2ad6f90fd
Author: jsinovassin <[email protected]>
AuthorDate: Fri Sep 2 17:18:33 2022 +0200

    feedbacks
---
 .../apache/unomi/rest/service/impl/RestServiceUtilsImpl.java   |  8 ++------
 .../main/java/org/apache/unomi/utils/EventsRequestContext.java | 10 ++++++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git 
a/rest/src/main/java/org/apache/unomi/rest/service/impl/RestServiceUtilsImpl.java
 
b/rest/src/main/java/org/apache/unomi/rest/service/impl/RestServiceUtilsImpl.java
index c7f2e24a2..ace630b3f 100644
--- 
a/rest/src/main/java/org/apache/unomi/rest/service/impl/RestServiceUtilsImpl.java
+++ 
b/rest/src/main/java/org/apache/unomi/rest/service/impl/RestServiceUtilsImpl.java
@@ -186,6 +186,7 @@ public class RestServiceUtilsImpl implements 
RestServiceUtils {
 
                     Session session = new Session(sessionId, sessionProfile, 
timestamp, scope);
                     eventsRequestContext.setSession(session);
+                    eventsRequestContext.setNewSession(true);
                     
eventsRequestContext.addChanges(EventService.SESSION_UPDATED);
                     Event event = new Event("sessionCreated", 
eventsRequestContext.getSession(), eventsRequestContext.getProfile(),
                             scope, null, eventsRequestContext.getSession(), 
null, timestamp, false);
@@ -238,11 +239,6 @@ public class RestServiceUtilsImpl implements 
RestServiceUtils {
             // set Total items on context
             eventsRequestContext.setTotalItems(events.size());
 
-            boolean toStoreEventIdsInSession = false;
-            if (eventsRequestContext.getSession() != null
-                    && 
profileService.loadSession(eventsRequestContext.getSession().getItemId(), null) 
== null) {
-                toStoreEventIdsInSession= true;
-            }
             for (Event event : events) {
                 
eventsRequestContext.setProcessedItems(eventsRequestContext.getProcessedItems() 
+ 1);
 
@@ -278,7 +274,7 @@ public class RestServiceUtilsImpl implements 
RestServiceUtils {
                     if ((eventsRequestContext.getChanges() & 
EventService.PROFILE_UPDATED) == EventService.PROFILE_UPDATED) {
                         
eventsRequestContext.setProfile(eventToSend.getProfile());
                     }
-                    if(toStoreEventIdsInSession){
+                    if (eventsRequestContext.isNewSession()) {
                         
eventsRequestContext.getSession().getOriginEventIds().add(eventToSend.getItemId());
                         
eventsRequestContext.getSession().getOriginEventTypes().add(eventToSend.getEventType());
                     }
diff --git 
a/rest/src/main/java/org/apache/unomi/utils/EventsRequestContext.java 
b/rest/src/main/java/org/apache/unomi/utils/EventsRequestContext.java
index 188f42da2..679887568 100644
--- a/rest/src/main/java/org/apache/unomi/utils/EventsRequestContext.java
+++ b/rest/src/main/java/org/apache/unomi/utils/EventsRequestContext.java
@@ -35,6 +35,8 @@ public class EventsRequestContext {
     private Date timestamp;
     private Profile profile;
     private Session session;
+
+    private boolean newSession = false;
     private HttpServletRequest request;
     private HttpServletResponse response;
     private int changes;
@@ -79,6 +81,14 @@ public class EventsRequestContext {
         this.session = session;
     }
 
+    public boolean isNewSession() {
+        return newSession;
+    }
+
+    public void setNewSession(boolean newSession) {
+        this.newSession = newSession;
+    }
+
     public int getChanges() {
         return changes;
     }

Reply via email to