Add null check for additionalInfo to UserListingModel fromDataModel

This commit is contained in:
George Kalampokis 2020-12-03 14:07:45 +02:00
parent d4672f1e60
commit c18e3f8e3c
1 changed files with 7 additions and 5 deletions

View File

@ -105,11 +105,13 @@ public class UserListingModel implements DataModel<eu.eudat.data.entities.UserIn
this.lastloggedin = entity.getLastloggedin();
// this.additionalinfo = entity.getAdditionalinfo();
this.appRoles = entity.getUserRoles().stream().map(item -> item.getRole()).collect(Collectors.toList());
try {
Map<String, Object> additionalInfo = new ObjectMapper().readValue(entity.getAdditionalinfo(), HashMap.class);
this.avatarUrl = (String) additionalInfo.get("avatarUrl");
} catch (IOException e) {
logger.error(e.getMessage(), e);
if (entity.getAdditionalinfo() != null) {
try {
Map<String, Object> additionalInfo = new ObjectMapper().readValue(entity.getAdditionalinfo(), HashMap.class);
this.avatarUrl = (String) additionalInfo.get("avatarUrl");
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
return this;
}