From 877d3e686c76832d2f80d9de333b38bd4545ab7b Mon Sep 17 00:00:00 2001 From: flaminiaScarciofolo Date: Thu, 7 Nov 2024 15:28:57 +0100 Subject: [PATCH] [SELC-5923] import sdk enum instead of constant for productId --- .../selfcare/user/event/UserInstitutionCdcService.java | 6 +++--- .../selfcare/user/service/UserRegistryServiceImpl.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/user-cdc/src/main/java/it/pagopa/selfcare/user/event/UserInstitutionCdcService.java b/apps/user-cdc/src/main/java/it/pagopa/selfcare/user/event/UserInstitutionCdcService.java index c18cc34e..c0446487 100644 --- a/apps/user-cdc/src/main/java/it/pagopa/selfcare/user/event/UserInstitutionCdcService.java +++ b/apps/user-cdc/src/main/java/it/pagopa/selfcare/user/event/UserInstitutionCdcService.java @@ -41,6 +41,8 @@ import static com.mongodb.client.model.Projections.fields; import static com.mongodb.client.model.Projections.include; +import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD; +import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD_GARANTITO; import static it.pagopa.selfcare.user.UserUtils.mapPropsForTrackEvent; import static it.pagopa.selfcare.user.event.constant.CdcStartAtConstant.*; import static it.pagopa.selfcare.user.model.TrackEventInput.toTrackEventInput; @@ -57,8 +59,6 @@ public class UserInstitutionCdcService { private static final String COLLECTION_NAME = "userInstitutions"; private static final String OPERATION_NAME = "USER-CDC-UserInfoUpdate"; public static final String USERS_FIELD_LIST_WITHOUT_FISCAL_CODE = "name,familyName,email,workContacts"; - private static final String PROD_FD = "prod-fd"; - private static final String PROD_FD_GARANTITO = "prod-fd-garantito"; public static final String ERROR_DURING_SUBSCRIBE_COLLECTION_EXCEPTION_MESSAGE = "Error during subscribe collection, exception: {} , message: {}"; @@ -251,7 +251,7 @@ public void consumerToSendUserEventForFD(ChangeStreamDocument d userRegistryApi.findByIdUsingGET(USERS_FIELD_LIST_WITHOUT_FISCAL_CODE, userInstitutionChanged.getUserId()) .onFailure(this::checkIfIsRetryableException) .retry().withBackOff(Duration.ofSeconds(retryMinBackOff), Duration.ofSeconds(retryMaxBackOff)).atMost(maxRetry) - .onItem().transformToUni(userResource -> Uni.createFrom().item(UserUtils.retrieveFdProductIfItChanged(userInstitutionChanged.getProducts(), List.of(PROD_FD, PROD_FD_GARANTITO))) + .onItem().transformToUni(userResource -> Uni.createFrom().item(UserUtils.retrieveFdProductIfItChanged(userInstitutionChanged.getProducts(), List.of(PROD_FD.name(), PROD_FD_GARANTITO.name()))) .onItem().ifNotNull().transform(onboardedProduct -> notificationMapper.toFdUserNotificationToSend(userInstitutionChanged, onboardedProduct, userResource, evaluateType(onboardedProduct))) .onItem().ifNotNull().transformToUni(fdUserNotificationToSend -> { log.info("Sending message to EventHubFdRestClient ... "); diff --git a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserRegistryServiceImpl.java b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserRegistryServiceImpl.java index 426b38b3..c1ed463c 100644 --- a/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserRegistryServiceImpl.java +++ b/apps/user-ms/src/main/java/it/pagopa/selfcare/user/service/UserRegistryServiceImpl.java @@ -32,6 +32,8 @@ import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; +import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD; +import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD_GARANTITO; import static it.pagopa.selfcare.user.constant.CollectionUtil.MAIL_ID_PREFIX; @@ -40,8 +42,6 @@ @Slf4j public class UserRegistryServiceImpl implements UserRegistryService { private static final String USERS_FIELD_LIST_WITHOUT_FISCAL_CODE = "name,familyName,email,workContacts"; - public static final String PROD_FD_GARANTITO = "prod-fd-garantito"; - public static final String PROD_FD = "prod-fd"; private final UserInstitutionService userInstitutionService; private final UserMapper userMapper; @@ -153,7 +153,7 @@ private Uni checkProductAndSendFdUserNotification(UserInstituti } private boolean checkIfExistActiveFdProduct(OnboardedProduct product) { - return List.of(PROD_FD, PROD_FD_GARANTITO).contains(product.getProductId()) && OnboardedProductState.ACTIVE.equals(product.getStatus()); + return List.of(PROD_FD.name(), PROD_FD_GARANTITO.name()).contains(product.getProductId()) && OnboardedProductState.ACTIVE.equals(product.getStatus()); } private String retrieveOldMail(UserResource userResource, String userMailUuid) {