From 8e78cb3a99b03af8d4d8c79bcd59fbf151c9141b Mon Sep 17 00:00:00 2001 From: Manuel Rafeli Date: Fri, 23 Aug 2024 09:43:46 +0200 Subject: [PATCH] hotfix: nullpointer when retrieve WorkContracts on retrievemail method (#178) --- .github/workflows/swagger_detect_quarkus_ms.yml | 2 +- apps/user-group-ms/app/src/main/docs/openapi.json | 2 +- .../selfcare/user/service/UserNotificationServiceImpl.java | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/swagger_detect_quarkus_ms.yml b/.github/workflows/swagger_detect_quarkus_ms.yml index f625f505..88a9889b 100644 --- a/.github/workflows/swagger_detect_quarkus_ms.yml +++ b/.github/workflows/swagger_detect_quarkus_ms.yml @@ -1,4 +1,4 @@ -name: Swagger Detect Conflict and Update Onboarding MS +name: Swagger Detect Conflict and Update on: pull_request: branches: diff --git a/apps/user-group-ms/app/src/main/docs/openapi.json b/apps/user-group-ms/app/src/main/docs/openapi.json index 57768303..b31f374b 100644 --- a/apps/user-group-ms/app/src/main/docs/openapi.json +++ b/apps/user-group-ms/app/src/main/docs/openapi.json @@ -26,7 +26,7 @@ "paths" : { "/v1/user-groups" : { "get" : { - "tags" : [ "UserGroup", "external-v2", "support", "support-pnpg" ], + "tags" : [ "UserGroup", "external-pnpg", "external-v2", "support", "support-pnpg" ], "summary" : "getUserGroups", "description" : "Service that allows to get a list of UserGroup entities", "operationId" : "getUserGroupsUsingGET", diff --git a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserNotificationServiceImpl.java b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserNotificationServiceImpl.java index e1a12d83..180c8f32 100644 --- a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserNotificationServiceImpl.java +++ b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserNotificationServiceImpl.java @@ -192,7 +192,9 @@ private StringWriter getContent(String templateName, Map dataMod } private static String retrieveMail(UserResource user, UserInstitution institution) { - WorkContactResource certEmail = user.getWorkContacts().getOrDefault(institution.getUserMailUuid(), null); + WorkContactResource certEmail = Optional.ofNullable(user.getWorkContacts()) + .map(wc -> wc.getOrDefault(institution.getUserMailUuid(), null)) + .orElse(null); String email; if (certEmail == null || certEmail.getEmail() == null || StringUtils.isBlank(certEmail.getEmail().getValue())) { throw new InvalidRequestException("Missing mail for userId: " + user.getId());