diff --git a/CHANGELOG.md b/CHANGELOG.md
index 81349a8..a07c4ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [v2.5.5-SNAPSHOT] - 2024-04-16
+
+ - Bug #27218 fixed null pointer exception of parsing user from json
+
## [v2.5.4] - 2022-07-06
- Feature #23622 added Catalogue-Manager and Moderator roles
diff --git a/pom.xml b/pom.xml
index 56eccee..c97bb64 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.gcube.dvos
usermanagement-core
- 2.5.4
+ 2.5.5-SNAPSHOT
jar
User Management API
diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/impl/ws/LiferayWSUserManager.java b/src/main/java/org/gcube/vomanagement/usermanagement/impl/ws/LiferayWSUserManager.java
index a0c0cdb..659e82e 100644
--- a/src/main/java/org/gcube/vomanagement/usermanagement/impl/ws/LiferayWSUserManager.java
+++ b/src/main/java/org/gcube/vomanagement/usermanagement/impl/ws/LiferayWSUserManager.java
@@ -147,8 +147,12 @@ public class LiferayWSUserManager implements UserManager{
private GCubeUser mapLRUser(String json){
try{
if (json != null) {
+ logger.info("user json to be parsed: " , json);
JSONParser parser = new JSONParser();
JSONObject userJSON = (JSONObject)parser.parse(json);
+ if(userJSON!=null){
+ logger.info("parsed user json: " , userJSON.toString());
+ }
// TODO skip for now
List emails = new ArrayList();
// for (EmailAddress e : u.getEmailAddresses()) {
@@ -161,15 +165,17 @@ public class LiferayWSUserManager implements UserManager{
} catch (Exception e1) {
logger.warn("Failed to retrieve property " + USER_LOCATION_INDUSTRY_KEY, e1);
}
-
+ if(userJSON!=null){
+ logger.info("parsed user json: " , userJSON.toString());
+ }
// retrieve the contact id information (it is into the user json)
- long contactId = (long)userJSON.get("contactId");
-
- // retrieve contact json obj from contactId
- String jsonContact = getContactJson(contactId);
- JSONObject contactJSON = (JSONObject)parser.parse(jsonContact);
-
- return new GCubeUser(
+ String jsonContact;
+ JSONObject contactJSON;
+ try{
+ long contactId = (long)userJSON.get("contactId");
+ jsonContact = getContactJson(contactId);
+ contactJSON = (JSONObject)parser.parse(jsonContact);
+ return new GCubeUser(
(long)userJSON.get("userId"),
(String)userJSON.get("screenName"),
(String)userJSON.get("emailAddress"),
@@ -183,6 +189,23 @@ public class LiferayWSUserManager implements UserManager{
(String)userJSON.get("jobTitle"),
locationIndustry,
emails);
+ }catch (Exception e) {
+ logger.warn("Failed to retrieve property " + "contactId", e);
+ return new GCubeUser(
+ (long)userJSON.get("userId"),
+ (String)userJSON.get("screenName"),
+ (String)userJSON.get("emailAddress"),
+ (String)userJSON.get("firstName"),
+ (String)userJSON.get("middleName"),
+ (String)userJSON.get("lastName"),
+ buildFullName(userJSON),
+ (long)userJSON.get("createDate"),
+ getUserAvatarAbsoluteURL((String)userJSON.get("uuid"), (long)userJSON.get("portraitId")), // skip for now TODO getUserAvatarAbsoluteURL(u)
+ false,
+ (String)userJSON.get("jobTitle"),
+ locationIndustry,
+ emails);
+ }
}
}catch(Exception e){
logger.error("Exception while mapping the json user object to the GCubeUser java object", e);