You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by js...@apache.org on 2023/07/20 16:24:38 UTC
[unomi] branch UNOMI-785-fix-npe created (now a804a830c)
This is an automated email from the ASF dual-hosted git repository.
jsinovassinnaik pushed a change to branch UNOMI-785-fix-npe
in repository https://gitbox.apache.org/repos/asf/unomi.git
at a804a830c UNOMI-785 : create new profile in case session profile not existing anymore
This branch includes the following new commits:
new a804a830c UNOMI-785 : create new profile in case session profile not existing anymore
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[unomi] 01/01: UNOMI-785 : create new profile in case session profile not existing anymore
Posted by js...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jsinovassinnaik pushed a commit to branch UNOMI-785-fix-npe
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit a804a830c05601601b25f6496a7d7ade91fddad6
Author: jsinovassin <js...@jahia.com>
AuthorDate: Thu Jul 20 18:24:30 2023 +0200
UNOMI-785 : create new profile in case session profile not existing anymore
---
.../unomi/rest/endpoints/ContextJsonEndpoint.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
index a7ebea0da..7ac46970c 100644
--- a/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
@@ -50,14 +50,7 @@ import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
@WebService
@Consumes(MediaType.APPLICATION_JSON)
@@ -232,7 +225,14 @@ public class ContextJsonEndpoint {
// Session user has been switched, profile id in cookie is not up to date
// We must reload the profile with the session ID as some properties could be missing from the session profile
// #personalIdentifier
- profile = profileService.load(sessionProfile.getItemId());
+ Profile persistedProfile = profileService.load(sessionProfile.getItemId());
+ if (persistedProfile == null){
+ logger.error("Profile with id {} in session {} not existing anymore in profile index. A new profile will be created", sessionProfile.getItemId(), sessionProfile.getItemId());
+ profile = createNewProfile(null, timestamp);
+ profileCreated = true;
+ } else {
+ profile = persistedProfile;
+ }
}
// Handle anonymous situation