diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/OnboardingFunctions.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/OnboardingFunctions.java index c8de42955..aabe12af4 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/OnboardingFunctions.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/OnboardingFunctions.java @@ -39,11 +39,15 @@ public class OnboardingFunctions { public static final String SEND_MAIL_REGISTRATION_REQUEST_ACTIVITY_NAME = "SendMailRegistrationRequest"; public static final String SEND_MAIL_REGISTRATION_APPROVE_ACTIVITY_NAME = "SendMailRegistrationApprove"; public static final String SEND_MAIL_ONBOARDING_APPROVE_ACTIVITY_NAME = "SendMailOnboardingApprove"; - @Inject - OnboardingService service; - @Inject - ObjectMapper objectMapper; + private final OnboardingService service; + + private final ObjectMapper objectMapper; + + public OnboardingFunctions(OnboardingService service, ObjectMapper objectMapper) { + this.service = service; + this.objectMapper = objectMapper; + } private static final TaskOptions optionsRetry; diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java index 172628fe0..682b4e391 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java @@ -42,11 +42,14 @@ public class ContractServiceDefault implements ContractService { private static final Logger log = LoggerFactory.getLogger(ContractServiceDefault.class); public static final String PDF_FORMAT_FILENAME = "%s.pdf"; - @Inject - AzureStorageConfig azureStorageConfig; + private final AzureStorageConfig azureStorageConfig; - @Inject - AzureBlobClient azureBlobClient; + private final AzureBlobClient azureBlobClient; + + public ContractServiceDefault(AzureStorageConfig azureStorageConfig, AzureBlobClient azureBlobClient) { + this.azureStorageConfig = azureStorageConfig; + this.azureBlobClient = azureBlobClient; + } /** * Creates a PDF contract document from a given contract template file and institution data. diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/NotificationServiceDefault.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/NotificationServiceDefault.java index 278c587bc..8f493eacb 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/NotificationServiceDefault.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/NotificationServiceDefault.java @@ -31,17 +31,17 @@ public class NotificationServiceDefault implements NotificationService { private static final Logger log = LoggerFactory.getLogger(NotificationServiceDefault.class); - final private MailTemplatePlaceholdersConfig templatePlaceholdersConfig; - final private MailTemplatePathConfig templatePathConfig; - final private AzureBlobClient azureBlobClient; - final private ObjectMapper objectMapper; - final private ContractService contractService; - final private String senderMail; - final private Boolean destinationMailTest; - final private String destinationMailTestAddress; - - final private String notificationAdminMail; - final private Mailer mailer; + private final MailTemplatePlaceholdersConfig templatePlaceholdersConfig; + private final MailTemplatePathConfig templatePathConfig; + private final AzureBlobClient azureBlobClient; + private final ObjectMapper objectMapper; + private final ContractService contractService; + private final String senderMail; + private final Boolean destinationMailTest; + private final String destinationMailTestAddress; + + private final String notificationAdminMail; + private final Mailer mailer; public NotificationServiceDefault(MailTemplatePlaceholdersConfig templatePlaceholdersConfig, MailTemplatePathConfig templatePathConfig, AzureBlobClient azureBlobClient, ObjectMapper objectMapper, Mailer mailer, ContractService contractService, @@ -158,7 +158,7 @@ private void sendMailWithFile(List destinationMail, String templateName, log.info("End of sending mail to {}, with subject {}", destinationMail, subject); } catch (Exception e) { - log.error(ERROR_DURING_SEND_MAIL + ":" + e.getMessage()); + log.error(String.format("%s: %s", ERROR_DURING_SEND_MAIL, e.getMessage())); throw new GenericOnboardingException(ERROR_DURING_SEND_MAIL.getMessage()); } } diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/OnboardingService.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/OnboardingService.java index 4fb0a55de..ecdc8f93b 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/OnboardingService.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/OnboardingService.java @@ -36,6 +36,8 @@ public class OnboardingService { public static final String USERS_FIELD_LIST = "fiscalCode,familyName,name"; public static final String TOKEN_DOES_NOT_EXISTS_FOR_ONBOARDING_S = "Token does not exists for onboarding %s"; + public static final String loggedUserName = "example"; + public static final String loggedUserSurname = "example"; @RestClient @Inject @@ -119,7 +121,7 @@ public void sendMailRegistration(Onboarding onboarding) { Product product = productService.getProduct(onboarding.getProductId()); notificationService.sendMailRegistration(onboarding.getInstitution().getDescription(), - onboarding.getInstitution().getDigitalAddress(), "example", "example", + onboarding.getInstitution().getDigitalAddress(), loggedUserName, loggedUserSurname, product.getTitle()); } @@ -131,7 +133,7 @@ public void sendMailRegistrationWithContract(Onboarding onboarding) { Product product = productService.getProduct(onboarding.getProductId()); notificationService.sendMailRegistrationWithContract(onboarding.getOnboardingId(), - onboarding.getInstitution().getDigitalAddress(), "example", "example", + onboarding.getInstitution().getDigitalAddress(), loggedUserName, loggedUserSurname, product.getTitle(), token.getId().toHexString()); } @@ -155,7 +157,7 @@ public void sendMailRegistrationApprove(Onboarding onboarding) { Product product = productService.getProduct(onboarding.getProductId()); notificationService.sendMailRegistrationApprove(onboarding.getInstitution().getDescription(), - "example", "example", product.getTitle(), token.getId().toHexString()); + loggedUserName, loggedUserSurname, product.getTitle(), token.getId().toHexString()); } @@ -166,7 +168,7 @@ public void sendMailOnboardingApprove(Onboarding onboarding) { Product product = productService.getProduct(onboarding.getProductId()); notificationService.sendMailOnboardingApprove(onboarding.getInstitution().getDescription(), - "example", "example", product.getTitle(), token.getId().toHexString()); + loggedUserName, loggedUserSurname, product.getTitle(), token.getId().toHexString()); } }