diff --git a/.github/workflows/release_open_api.yml b/.github/workflows/release_open_api.yml index 0d3aed43e..cf755171a 100644 --- a/.github/workflows/release_open_api.yml +++ b/.github/workflows/release_open_api.yml @@ -12,6 +12,7 @@ jobs: swagger_conflict_update: runs-on: ubuntu-20.04 permissions: write-all + secrets: inherit name: Swagger Detect Conflict and Update steps: - id: swagger-conflict-update diff --git a/Dockerfile.new b/Dockerfile.new index ba66fea15..8f8f2be17 100644 --- a/Dockerfile.new +++ b/Dockerfile.new @@ -2,7 +2,21 @@ FROM maven:3-eclipse-temurin-17@sha256:0d328fa6843bb26b60cf44d69833f241ffe96218f COPY . . -RUN mvn clean package -DskipTests=true +RUN echo "\n" \ + "\n" \ + "\n" \ + "\${repositoryOnboarding}\n" \ + "\${repoLogin}\n" \ + "\${repoPwd}\n" \ + "\n" \ + "\n" \ + "\n" > settings.xml + +ARG REPO_ONBOARDING +ARG REPO_USERNAME +ARG REPO_PASSWORD + +RUN mvn --global-settings settings.xml -DrepositoryOnboarding=${REPO_ONBOARDING} -DrepoLogin=${REPO_USERNAME} -DrepoPwd=${REPO_PASSWORD} clean package -DskipTests=true FROM openjdk:17-jdk@sha256:528707081fdb9562eb819128a9f85ae7fe000e2fbaeaf9f87662e7b3f38cb7d8 AS runtime diff --git a/app/src/main/resources/config/core-config.properties b/app/src/main/resources/config/core-config.properties index 13911ca3e..2aa620369 100644 --- a/app/src/main/resources/config/core-config.properties +++ b/app/src/main/resources/config/core-config.properties @@ -51,3 +51,7 @@ scheduler.threads.max-number=${THREADS_SCHEDULE_MAX_NUMBER:1} scheduler.fixed-delay.delay=${SCHEDULER_FIXED_DELAY:20000} scheduler.regenerate-kafka-queue-config.name=${SCHEDULER_REGENERATE_KAFKA_QUEUE_CONFIG_NAME:KafkaScheduler} scheduler.regenerate-kafka-queue.enabled=${SCHEDULER_REGENERATE_KAFKA_QUEUE_ENABLED:false} + +mscore.blob-storage.container-product=${PRODUCT_STORAGE_CONTAINER:selc-d-product} +mscore.blob-storage.filepath-product = products.json +mscore.blob-storage.connection-string-product = ${BLOB_STORAGE_CONN_STRING:UseDevelopmentStorage=true;} \ No newline at end of file diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index 5bb6d8f05..ba458cb92 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -2367,7 +2367,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/BulkInstitutions" } @@ -2481,7 +2481,7 @@ "204" : { "description" : "No Content", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/RelationshipsManagement" } @@ -2618,7 +2618,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/OnboardingInfoResponse" } @@ -2725,7 +2725,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "type" : "array", "items" : { @@ -2791,7 +2791,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "type" : "string", "format" : "byte" @@ -2844,7 +2844,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "type" : "array", "items" : { @@ -2909,7 +2909,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "type" : "array", "items" : { @@ -3356,7 +3356,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/PaginatedTokenResponse" } @@ -3429,7 +3429,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/TokenListResponse" } @@ -3490,7 +3490,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/TokenResource" } @@ -3544,7 +3544,7 @@ "204" : { "description" : "No Content", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/OnboardedUsersResponse" } @@ -3597,7 +3597,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/RelationshipResult" } @@ -3836,7 +3836,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/UsersNotificationResponse" } @@ -3907,7 +3907,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/UserResponse" } @@ -4147,7 +4147,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/OnboardingInfoResponse" } @@ -4293,7 +4293,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/UserProductsResponse" } diff --git a/connector-api/pom.xml b/connector-api/pom.xml index 51d41e0e9..23741e641 100644 --- a/connector-api/pom.xml +++ b/connector-api/pom.xml @@ -34,6 +34,19 @@ it.pagopa.selfcare selc-commons-base + + it.pagopa.selfcare + onboarding-sdk-product + 0.1.9 + + + + selfcare-onboarding + Selfcare Onboarding SDK + https://maven.pkg.github.com/pagopa/selfcare-onboarding + + + diff --git a/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/ProductConnector.java b/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/ProductConnector.java deleted file mode 100644 index 5531d2cb9..000000000 --- a/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/ProductConnector.java +++ /dev/null @@ -1,10 +0,0 @@ -package it.pagopa.selfcare.mscore.api; - - -import it.pagopa.selfcare.mscore.model.product.Product; - -public interface ProductConnector { - Product getProductById(String productId); - - Product getProductValidById(String productId); -} diff --git a/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/CoreConfig.java b/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/CoreConfig.java index ef1e2ad8b..1410c5bc6 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/CoreConfig.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/CoreConfig.java @@ -23,4 +23,12 @@ public class CoreConfig { private Integer onboardingExpiringDate; private boolean infoCamereEnable; private boolean enableSendDelegationMail; + private BlobStorage blobStorage; + + @Data + public static class BlobStorage { + private String containerProduct; + private String filepathProduct; + private String connectionStringProduct; + } } diff --git a/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/UserConnectorImpl.java b/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/UserConnectorImpl.java index 609e6a78e..f52f551b3 100644 --- a/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/UserConnectorImpl.java +++ b/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/UserConnectorImpl.java @@ -8,7 +8,6 @@ import it.pagopa.selfcare.mscore.connector.dao.model.inner.UserBindingEntity; import it.pagopa.selfcare.mscore.connector.dao.model.mapper.UserEntityMapper; import it.pagopa.selfcare.mscore.connector.dao.model.mapper.UserInstitutionAggregationMapper; -import it.pagopa.selfcare.mscore.connector.rest.client.ProductsRestClient; import it.pagopa.selfcare.mscore.constant.Env; import it.pagopa.selfcare.mscore.constant.RelationshipState; import it.pagopa.selfcare.mscore.exception.InvalidRequestException; @@ -19,10 +18,11 @@ import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct; import it.pagopa.selfcare.mscore.model.onboarding.OnboardedUser; import it.pagopa.selfcare.mscore.model.onboarding.Token; -import it.pagopa.selfcare.mscore.model.product.Product; -import it.pagopa.selfcare.mscore.model.product.ProductRoleInfo; import it.pagopa.selfcare.mscore.model.user.UserBinding; import it.pagopa.selfcare.mscore.model.user.UserInfo; +import it.pagopa.selfcare.product.entity.Product; +import it.pagopa.selfcare.product.entity.ProductRoleInfo; +import it.pagopa.selfcare.product.service.ProductService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.PageRequest; @@ -65,7 +65,7 @@ public class UserConnectorImpl implements UserConnector { private final MongoOperations mongoOperations; - private final ProductsRestClient productRestClient; + private final ProductService productService; /** @@ -370,8 +370,8 @@ public List getUserInfo(String userId, String instit private void checkRoles(String productId, PartyRole role, String productRole) { if (StringUtils.hasText(productRole)) { Assert.notNull(role, ROLE_IS_NULL.getMessage()); - Product product = productRestClient.getProductById(productId, null); - ProductRoleInfo productRoleInfo = product.getRoleMappings().get(role); + Product product = productService.getProduct(productId); + ProductRoleInfo productRoleInfo = product.getRoleMappings().get(it.pagopa.selfcare.onboarding.common.PartyRole.valueOf(role.name())); if (productRoleInfo == null) { throw new InvalidRequestException(ROLE_NOT_FOUND.getMessage(), ROLE_NOT_FOUND.getCode()); } diff --git a/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/UserConnectorImplTest.java b/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/UserConnectorImplTest.java index aae33bf27..0c9f0a6ff 100644 --- a/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/UserConnectorImplTest.java +++ b/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/UserConnectorImplTest.java @@ -10,7 +10,6 @@ import it.pagopa.selfcare.mscore.connector.dao.model.inner.OnboardingEntity; import it.pagopa.selfcare.mscore.connector.dao.model.inner.UserBindingEntity; import it.pagopa.selfcare.mscore.connector.dao.model.mapper.*; -import it.pagopa.selfcare.mscore.connector.rest.client.ProductsRestClient; import it.pagopa.selfcare.mscore.constant.Env; import it.pagopa.selfcare.mscore.constant.RelationshipState; import it.pagopa.selfcare.mscore.exception.ResourceNotFoundException; @@ -22,9 +21,11 @@ import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct; import it.pagopa.selfcare.mscore.model.onboarding.OnboardedUser; import it.pagopa.selfcare.mscore.model.onboarding.Token; -import it.pagopa.selfcare.mscore.model.product.Product; -import it.pagopa.selfcare.mscore.model.product.ProductRoleInfo; import it.pagopa.selfcare.mscore.model.user.UserBinding; +import it.pagopa.selfcare.product.entity.Product; +import it.pagopa.selfcare.product.entity.ProductRole; +import it.pagopa.selfcare.product.entity.ProductRoleInfo; +import it.pagopa.selfcare.product.service.ProductService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -62,7 +63,7 @@ class UserConnectorImplTest { private UserEntityMapper userMapper = new UserEntityMapperImpl(); @Mock - private ProductsRestClient productsRestClient; + private ProductService productService; @Spy private OnboardedProductMapper productMapper = new OnboardedProductMapperImpl(); @@ -220,15 +221,15 @@ void findAndUpdateStateByInstitutionAndProduct() { when(userRepository.findAndModify(any(), any(), any(), any())) .thenReturn(new UserEntity()); Product product = mock(Product.class); - EnumMap map = mock(EnumMap.class); + EnumMap map = mock(EnumMap.class); ProductRoleInfo productRoleInfo = mock(ProductRoleInfo.class); - ProductRoleInfo.ProductRole productRole = mock(ProductRoleInfo.ProductRole.class); + ProductRole productRole = mock(ProductRole.class); when(productRole.getCode()).thenReturn("productRole"); when(productRoleInfo.getRoles()).thenReturn(List.of(productRole)); - when(map.get(PartyRole.DELEGATE)).thenReturn(productRoleInfo); + when(map.get(it.pagopa.selfcare.onboarding.common.PartyRole.DELEGATE)).thenReturn(productRoleInfo); when(product.getRoleMappings()).thenReturn(map); - when(productsRestClient.getProductById(anyString(), any())).thenReturn(product); + when(productService.getProduct(anyString())).thenReturn(product); Assertions.assertDoesNotThrow(() -> userConnectorImpl.findAndUpdateStateWithOptionalFilter("42", "42", "productId", PartyRole.DELEGATE, "productRole", RelationshipState.PENDING)); } @@ -253,7 +254,7 @@ void findAndUpdateStateWithoutFilter() { Product product = mock(Product.class); EnumMap map = mock(EnumMap.class); ProductRoleInfo productRoleInfo = mock(ProductRoleInfo.class); - ProductRoleInfo.ProductRole productRole = mock(ProductRoleInfo.ProductRole.class); + ProductRole productRole = mock(ProductRole.class); Assertions.assertDoesNotThrow(() -> userConnectorImpl.findAndUpdateStateWithOptionalFilter("42", null, null, null, null, RelationshipState.PENDING)); } diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/ProductConnectorImpl.java b/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/ProductConnectorImpl.java deleted file mode 100644 index 635c29d16..000000000 --- a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/ProductConnectorImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package it.pagopa.selfcare.mscore.connector.rest; - -import it.pagopa.selfcare.commons.base.logging.LogUtils; -import it.pagopa.selfcare.mscore.api.ProductConnector; -import it.pagopa.selfcare.mscore.connector.rest.client.ProductsRestClient; -import it.pagopa.selfcare.mscore.model.product.Product; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -@Slf4j -@Service -public class ProductConnectorImpl implements ProductConnector { - - private final ProductsRestClient restClient; - - public ProductConnectorImpl(ProductsRestClient productsRestClient) { - this.restClient = productsRestClient; - } - - @Override - public Product getProductById(String productId) { - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getProductById productId = {}", productId); - Assert.hasText(productId, "A productId is required"); - Product result = restClient.getProductById(productId, null); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getProductById result = {}", result); - return result; - } - - @Override - public Product getProductValidById(String productId) { - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getProductValidById productId = {}", productId); - Assert.hasText(productId, "A productId is required"); - Product result = restClient.getProductValid(productId); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getProductValidById result = {}", result); - return result; - } -} diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/client/ProductsRestClient.java b/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/client/ProductsRestClient.java deleted file mode 100644 index 6eb64b48a..000000000 --- a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/client/ProductsRestClient.java +++ /dev/null @@ -1,25 +0,0 @@ -package it.pagopa.selfcare.mscore.connector.rest.client; - -import it.pagopa.selfcare.commons.base.utils.InstitutionType; -import it.pagopa.selfcare.mscore.model.product.Product; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -@FeignClient(name = "${rest-client.products.serviceCode}", url = "${rest-client.products.base-url}") -public interface ProductsRestClient{ - - @GetMapping(value = "${rest-client.products.getProduct.path}", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - Product getProductById(@PathVariable("id") String id, - @RequestParam(value = "institutionType", required = false) InstitutionType institutionType); - - - @GetMapping(value = "${rest-client.products.getProductValid.path}", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - Product getProductValid(@PathVariable("id") String id); - -} diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/config/ProductRestClientConfig.java b/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/config/ProductRestClientConfig.java deleted file mode 100644 index b66010d7d..000000000 --- a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/config/ProductRestClientConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package it.pagopa.selfcare.mscore.connector.rest.config; - -import it.pagopa.selfcare.commons.connector.rest.config.RestClientBaseConfig; -import it.pagopa.selfcare.mscore.connector.rest.client.ProductsRestClient; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@Import(RestClientBaseConfig.class) -@EnableFeignClients(clients = ProductsRestClient.class) -@PropertySource("classpath:config/products-rest-client.properties") -public class ProductRestClientConfig { -} diff --git a/connector/rest/src/main/resources/config/products-rest-client.properties b/connector/rest/src/main/resources/config/products-rest-client.properties deleted file mode 100644 index 0311cb3a1..000000000 --- a/connector/rest/src/main/resources/config/products-rest-client.properties +++ /dev/null @@ -1,8 +0,0 @@ -rest-client.products.serviceCode=products -rest-client.products.base-url=${MS_PRODUCT_URL} -rest-client.products.getProduct.path=/products/{id} -rest-client.products.getProductValid.path=/products/{id}/valid -feign.client.config.products.requestInterceptors[0]=it.pagopa.selfcare.commons.connector.rest.interceptor.AuthorizationHeaderInterceptor -feign.client.config.products.connectTimeout=${MS_PRODUCT_REST_CLIENT_CONNECT_TIMEOUT:${REST_CLIENT_CONNECT_TIMEOUT:5000}} -feign.client.config.products.readTimeout=${MS_PRODUCT_REST_CLIENT_READ_TIMEOUT:${REST_CLIENT_READ_TIMEOUT:5000}} -feign.client.config.products.loggerLevel=${MS_PRODUCT_REST_CLIENT_LOGGER_LEVEL:${REST_CLIENT_LOGGER_LEVEL:FULL}} \ No newline at end of file diff --git a/connector/rest/src/test/java/it/pagopa/selfcare/mscore/connector/rest/ProductConnectorImplTest.java b/connector/rest/src/test/java/it/pagopa/selfcare/mscore/connector/rest/ProductConnectorImplTest.java deleted file mode 100644 index 191b625bc..000000000 --- a/connector/rest/src/test/java/it/pagopa/selfcare/mscore/connector/rest/ProductConnectorImplTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package it.pagopa.selfcare.mscore.connector.rest; - -import it.pagopa.selfcare.mscore.connector.rest.client.ProductsRestClient; -import it.pagopa.selfcare.mscore.model.product.Product; -import it.pagopa.selfcare.mscore.model.product.ProductStatus; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.mockito.Mockito.*; - -@ContextConfiguration(classes = {ProductConnectorImpl.class}) -@ExtendWith(SpringExtension.class) -class ProductConnectorImplTest { - @Autowired - private ProductConnectorImpl productConnectorImpl; - - @MockBean - private ProductsRestClient productsRestClient; - - /** - * Method under test: {@link ProductConnectorImpl#getProductById(String)} - */ - @Test - void testGetProductById() { - Product product = dummyProduct(); - when(productsRestClient.getProductById(any(), any())).thenReturn(product); - assertSame(product, productConnectorImpl.getProductById("42")); - verify(productsRestClient).getProductById(any(), any()); - } - - @Test - void testGetProductValid() { - Product product = dummyProduct(); - when(productsRestClient.getProductValid(any())).thenReturn(product); - assertSame(product, productConnectorImpl.getProductValidById("42")); - verify(productsRestClient).getProductValid(any()); - } - - private Product dummyProduct(){ - Product product = new Product(); - product.setContractTemplatePath("Contract Template Path"); - product.setContractTemplateVersion("1.0.2"); - product.setId("42"); - product.setParentId("42"); - product.setRoleMappings(null); - product.setStatus(ProductStatus.ACTIVE); - product.setTitle("Dr"); - return product; - } -} - diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/MailNotificationServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/MailNotificationServiceImpl.java index c7e813e60..509c9e6e0 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/MailNotificationServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/MailNotificationServiceImpl.java @@ -2,12 +2,12 @@ import it.pagopa.selfcare.mscore.api.EmailConnector; import it.pagopa.selfcare.mscore.api.InstitutionConnector; -import it.pagopa.selfcare.mscore.api.ProductConnector; import it.pagopa.selfcare.mscore.api.UserApiConnector; import it.pagopa.selfcare.mscore.config.CoreConfig; import it.pagopa.selfcare.mscore.core.util.MailParametersMapper; import it.pagopa.selfcare.mscore.model.institution.Institution; -import it.pagopa.selfcare.mscore.model.product.Product; +import it.pagopa.selfcare.product.entity.Product; +import it.pagopa.selfcare.product.service.ProductService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -24,17 +24,17 @@ public class MailNotificationServiceImpl implements MailNotificationService { private static final String MAIL_PARAMETER_LOG = "mailParameters: {}"; private static final String DESTINATION_MAIL_LOG = "destinationMails: {}"; private final InstitutionConnector institutionConnector; - private final UserApiConnector userApiConnector; - private final ProductConnector productConnector; + private final ProductService productService; private final UserNotificationService userNotificationService; private final EmailConnector emailConnector; private final MailParametersMapper mailParametersMapper; private final CoreConfig coreConfig; + private final UserApiConnector userApiConnector; public void sendMailForDelegation(String institutionName, String productId, String partnerId) { try { Map mailParameters; - Product product = productConnector.getProductById(productId); + Product product = productService.getProduct(productId); Institution partnerInstitution = institutionConnector.findById(partnerId); if(Objects.isNull(product) || Objects.isNull(partnerInstitution)) { log.error("create-delegation-email-notification :: Impossible to send email. Error: partner institution or product is null"); diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/OnboardingDao.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/OnboardingDao.java index 289b4c4f8..40e8dc93b 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/OnboardingDao.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/OnboardingDao.java @@ -15,6 +15,7 @@ import it.pagopa.selfcare.mscore.model.user.RelationshipInfo; import it.pagopa.selfcare.mscore.model.user.UserBinding; import it.pagopa.selfcare.mscore.model.user.UserToOnboard; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -27,17 +28,12 @@ @Service @Slf4j +@RequiredArgsConstructor public class OnboardingDao { private final InstitutionConnector institutionConnector; private final UserConnector userConnector; - public OnboardingDao(InstitutionConnector institutionConnector, - UserConnector userConnector) { - this.institutionConnector = institutionConnector; - this.userConnector = userConnector; - } - private OnboardedProduct updateUser(OnboardedUser onboardedUser, UserToOnboard user, Institution institution, OnboardingRequest request, String tokenId) { OnboardedProduct product = constructProduct(user, request, institution); product.setTokenId(tokenId); diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/OnboardingServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/OnboardingServiceImpl.java index 419576094..77e86365b 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/OnboardingServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/OnboardingServiceImpl.java @@ -3,7 +3,6 @@ import feign.FeignException; import it.pagopa.selfcare.commons.base.security.PartyRole; import it.pagopa.selfcare.mscore.api.InstitutionConnector; -import it.pagopa.selfcare.mscore.api.ProductConnector; import it.pagopa.selfcare.mscore.constant.CustomError; import it.pagopa.selfcare.mscore.constant.RelationshipState; import it.pagopa.selfcare.mscore.core.util.OnboardingInfoUtils; @@ -17,10 +16,12 @@ import it.pagopa.selfcare.mscore.model.institution.Institution; import it.pagopa.selfcare.mscore.model.institution.Onboarding; import it.pagopa.selfcare.mscore.model.onboarding.*; -import it.pagopa.selfcare.mscore.model.product.Product; import it.pagopa.selfcare.mscore.model.user.RelationshipInfo; import it.pagopa.selfcare.mscore.model.user.User; import it.pagopa.selfcare.mscore.model.user.UserToOnboard; +import it.pagopa.selfcare.product.entity.Product; +import it.pagopa.selfcare.product.service.ProductService; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -34,7 +35,11 @@ @Slf4j @Service +@RequiredArgsConstructor public class OnboardingServiceImpl implements OnboardingService { + protected static final String REQUIRED_ADDITIONAL_INFORMATIONS_MESSAGE = "AdditionalInformations is required"; + protected static final String REQUIRED_OTHER_NOTE_MESSAGE = "Other note is required"; + private final OnboardingDao onboardingDao; private final InstitutionService institutionService; private final UserService userService; @@ -45,30 +50,7 @@ public class OnboardingServiceImpl implements OnboardingService { private final MailNotificationService notificationService; private final UserNotificationService userNotificationService; private final InstitutionConnector institutionConnector; - private final ProductConnector productConnector; - - public OnboardingServiceImpl(OnboardingDao onboardingDao, - InstitutionService institutionService, - UserService userService, - UserRelationshipService userRelationshipService, - ContractService contractService, - UserEventService userEventService, - ContractEventNotificationService contractEventNotification, MailNotificationService notificationService, - UserNotificationService userNotificationService, - InstitutionConnector institutionConnector, - ProductConnector productConnector) { - this.onboardingDao = onboardingDao; - this.institutionService = institutionService; - this.userService = userService; - this.userRelationshipService = userRelationshipService; - this.userEventService = userEventService; - this.contractService = contractService; - this.contractEventNotification = contractEventNotification; - this.notificationService = notificationService; - this.userNotificationService = userNotificationService; - this.institutionConnector = institutionConnector; - this.productConnector = productConnector; - } + private final ProductService productService; @Override public void verifyOnboardingInfo(String externalId, String productId) { @@ -187,13 +169,14 @@ private TokenUser toTokenUser(UserToOnboard user) { public List onboardingUsers(OnboardingUsersRequest request, String loggedUserName, String loggedUserSurname) { + + Product product = Optional.ofNullable(productService.getProductIsValid(request.getProductId())) + .orElseThrow(() -> new InvalidRequestException("Product not found or is not valid!", "")); + Institution institution = institutionService.getInstitutions(request.getInstitutionTaxCode(), request.getInstitutionSubunitCode()).stream() .findFirst() .orElseThrow(() -> new InvalidRequestException("Institution not found!", "")); - Product product = Optional.ofNullable(productConnector.getProductValidById(request.getProductId())) - .orElseThrow(() -> new InvalidRequestException("Product not found or is not valid!", "")); - List roleLabels = request.getUsers().stream() .map(UserToOnboard::getRoleLabel).collect(Collectors.toList()); diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImpl.java index bbd07cf52..5a31daf99 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImpl.java @@ -5,16 +5,16 @@ import freemarker.template.Template; import it.pagopa.selfcare.mscore.api.FileStorageConnector; import it.pagopa.selfcare.mscore.api.NotificationServiceConnector; -import it.pagopa.selfcare.mscore.api.ProductConnector; import it.pagopa.selfcare.mscore.model.institution.Institution; import it.pagopa.selfcare.mscore.model.notification.MessageRequest; import it.pagopa.selfcare.mscore.model.notification.MultipleReceiverMessageRequest; import it.pagopa.selfcare.mscore.model.onboarding.MailTemplate; import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct; -import it.pagopa.selfcare.mscore.model.product.Product; -import it.pagopa.selfcare.mscore.model.product.ProductRoleInfo; import it.pagopa.selfcare.mscore.model.user.User; import it.pagopa.selfcare.mscore.model.user.UserBinding; +import it.pagopa.selfcare.product.entity.Product; +import it.pagopa.selfcare.product.entity.ProductRole; +import it.pagopa.selfcare.product.service.ProductService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.text.StringSubstitutor; @@ -56,7 +56,7 @@ public class UserNotificationServiceImpl implements UserNotificationService { private final Configuration freemarkerConfig; private final NotificationServiceConnector notificationConnector; - private final ProductConnector productsConnector; + private final ProductService productService; private final UserService userService; private final InstitutionService institutionService; @@ -184,12 +184,12 @@ private void sendRelationshipBasedNotification(String relationshipId, String use .findFirst().orElseThrow(); Assert.notNull(onboardedProduct.getProductId(), "A product Id is required"); Assert.notNull(institution.getDescription(), "An institution description is required"); - Product product = productsConnector.getProductById(onboardedProduct.getProductId()); + Product product = productService.getProduct(onboardedProduct.getProductId()); Assert.notNull(product.getTitle(), A_PRODUCT_TITLE_IS_REQUIRED); Optional roleLabel = product.getRoleMappings().values().stream() .flatMap(productRoleInfo -> productRoleInfo.getRoles().stream()) .filter(productRole -> productRole.getCode().equals(onboardedProduct.getProductRole())) - .map(ProductRoleInfo.ProductRole::getLabel) + .map(ProductRole::getLabel) .findAny(); Map dataModel = new HashMap<>(); diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/config/MsCoreConfig.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/config/MsCoreConfig.java new file mode 100644 index 000000000..238ffff26 --- /dev/null +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/config/MsCoreConfig.java @@ -0,0 +1,27 @@ +package it.pagopa.selfcare.mscore.core.config; + +import it.pagopa.selfcare.azurestorage.AzureBlobClient; +import it.pagopa.selfcare.azurestorage.AzureBlobClientDefault; +import it.pagopa.selfcare.mscore.config.CoreConfig; +import it.pagopa.selfcare.product.service.ProductService; +import it.pagopa.selfcare.product.service.ProductServiceCacheable; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@RequiredArgsConstructor +public class MsCoreConfig { + + private final CoreConfig config; + + @Bean + public ProductService productService(){ + AzureBlobClient azureBlobClient = new AzureBlobClientDefault(config.getBlobStorage().getConnectionStringProduct(), config.getBlobStorage().getContainerProduct()); + try{ + return new ProductServiceCacheable(azureBlobClient, config.getBlobStorage().getFilepathProduct()); + } catch(IllegalArgumentException e){ + throw new IllegalArgumentException("Found an issue when trying to serialize product json string!!"); + } + } +} diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtils.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtils.java index a86c7a469..04c86c499 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtils.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtils.java @@ -12,9 +12,9 @@ import it.pagopa.selfcare.mscore.model.institution.Institution; import it.pagopa.selfcare.mscore.model.institution.InstitutionUpdate; import it.pagopa.selfcare.mscore.model.institution.Onboarding; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardingRequest; +import it.pagopa.selfcare.mscore.model.onboarding.*; import it.pagopa.selfcare.mscore.model.user.UserToOnboard; +import it.pagopa.selfcare.product.entity.Product; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/MailNotificationServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/MailNotificationServiceImplTest.java index caba0e430..efc0b262f 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/MailNotificationServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/MailNotificationServiceImplTest.java @@ -2,7 +2,6 @@ import it.pagopa.selfcare.mscore.api.EmailConnector; import it.pagopa.selfcare.mscore.api.InstitutionConnector; -import it.pagopa.selfcare.mscore.api.ProductConnector; import it.pagopa.selfcare.mscore.api.UserApiConnector; import it.pagopa.selfcare.mscore.config.CoreConfig; import it.pagopa.selfcare.mscore.config.MailTemplateConfig; @@ -10,8 +9,9 @@ import it.pagopa.selfcare.mscore.model.CertifiedField; import it.pagopa.selfcare.mscore.model.institution.Institution; import it.pagopa.selfcare.mscore.model.institution.WorkContact; -import it.pagopa.selfcare.mscore.model.product.Product; import it.pagopa.selfcare.mscore.model.user.User; +import it.pagopa.selfcare.product.entity.Product; +import it.pagopa.selfcare.product.service.ProductService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -36,7 +36,7 @@ class MailNotificationServiceImplTest { private InstitutionConnector institutionConnector; @Mock - private ProductConnector productConnector; + private ProductService productService; @Mock private MailTemplateConfig mailTemplateConfig; @@ -86,7 +86,7 @@ void sendNotificationDelegationMail() { institution.setDigitalAddress("test@test.com"); List userEmails = List.of("userEmail"); - when(productConnector.getProductById(anyString())).thenReturn(product); + when(productService.getProduct(anyString())).thenReturn(product); when(institutionConnector.findById(anyString())).thenReturn(institution); when(userApiConnector.getUserEmails(institution.getId(), product.getId())).thenReturn(userEmails); when(coreConfig.isSendEmailToInstitution()).thenReturn(true); @@ -98,7 +98,7 @@ void sendNotificationDelegationMail() { void sendNotificationDelegationMailWithEmptyProduct() { Institution institution = new Institution(); institution.setDigitalAddress("test@test.com"); - when(productConnector.getProductById(anyString())).thenReturn(null); + when(productService.getProduct(anyString())).thenReturn(null); when(institutionConnector.findById(anyString())).thenReturn(institution); Assertions.assertDoesNotThrow(() -> notificationService.sendMailForDelegation("institutionName", "productId", "partnerId")); } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/OnboardingDaoTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/OnboardingDaoTest.java index 0ac32aca3..525d7e992 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/OnboardingDaoTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/OnboardingDaoTest.java @@ -2,7 +2,6 @@ import it.pagopa.selfcare.commons.base.security.PartyRole; import it.pagopa.selfcare.mscore.api.InstitutionConnector; -import it.pagopa.selfcare.mscore.api.ProductConnector; import it.pagopa.selfcare.mscore.api.TokenConnector; import it.pagopa.selfcare.mscore.api.UserConnector; import it.pagopa.selfcare.mscore.constant.Env; @@ -85,7 +84,6 @@ void testUpdateUserProductState2() { */ @Test void testUpdateUserProductState4() { - ProductConnector productConnector = mock(ProductConnector.class); OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedUser onboardedUser = new OnboardedUser(); @@ -138,7 +136,6 @@ void testUpdateUserProductState8() { */ @Test void testUpdateUserProductState9() { - ProductConnector productConnector = mock(ProductConnector.class); OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedUser onboardedUser = new OnboardedUser(); @@ -152,7 +149,6 @@ void testUpdateUserProductState9() { */ @Test void testUpdateUserProductState10() { - ProductConnector productConnector = mock(ProductConnector.class); OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedUser onboardedUser = new OnboardedUser(); @@ -197,7 +193,6 @@ void testUpdateUserProductState11() { @Test void testUpdateUserProductState12() { - ProductConnector productConnector = mock(ProductConnector.class); OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedUser onboardedUser = new OnboardedUser(); @@ -248,7 +243,7 @@ void testUpdateUserProductState13() { @Test void testUpdateUserProductState14() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedUser onboardedUser = new OnboardedUser(); @@ -262,7 +257,7 @@ void testUpdateUserProductState14() { */ @Test void testUpdateUserProductState15() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); UserBinding userBinding = new UserBinding(); @@ -282,7 +277,7 @@ void testUpdateUserProductState15() { */ @Test void testUpdateUserProductState17() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedProduct onboardedProduct = new OnboardedProduct(); @@ -317,7 +312,7 @@ void testUpdateUserProductState17() { */ @Test void testUpdateUserProductState18() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedProduct onboardedProduct = new OnboardedProduct(); @@ -366,20 +361,20 @@ void testUpdateUserProductState18() { @Test void testUpdateUserProductState19() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedProduct onboardedProduct = mock(OnboardedProduct.class); when(onboardedProduct.getRelationshipId()).thenReturn("42"); doNothing().when(onboardedProduct).setContract(any()); - doNothing().when(onboardedProduct).setCreatedAt( any()); + doNothing().when(onboardedProduct).setCreatedAt(any()); doNothing().when(onboardedProduct).setEnv(any()); doNothing().when(onboardedProduct).setProductId(any()); doNothing().when(onboardedProduct).setProductRole(any()); doNothing().when(onboardedProduct).setRelationshipId(any()); - doNothing().when(onboardedProduct).setRole( any()); - doNothing().when(onboardedProduct).setStatus( any()); + doNothing().when(onboardedProduct).setRole(any()); + doNothing().when(onboardedProduct).setStatus(any()); doNothing().when(onboardedProduct).setTokenId(any()); - doNothing().when(onboardedProduct).setUpdatedAt( any()); + doNothing().when(onboardedProduct).setUpdatedAt(any()); onboardedProduct.setContract("Contract"); onboardedProduct.setCreatedAt(null); onboardedProduct.setEnv(Env.ROOT); @@ -405,15 +400,15 @@ void testUpdateUserProductState19() { onboardingDao.updateUserProductState(onboardedUser, "foo", RelationshipState.PENDING); verify(onboardedProduct).getRelationshipId(); verify(onboardedProduct).setContract(any()); - verify(onboardedProduct).setCreatedAt( any()); + verify(onboardedProduct).setCreatedAt(any()); verify(onboardedProduct).setEnv(any()); verify(onboardedProduct).setProductId(any()); verify(onboardedProduct).setProductRole(any()); verify(onboardedProduct).setRelationshipId(any()); - verify(onboardedProduct).setRole( any()); - verify(onboardedProduct).setStatus( any()); + verify(onboardedProduct).setRole(any()); + verify(onboardedProduct).setStatus(any()); verify(onboardedProduct).setTokenId(any()); - verify(onboardedProduct).setUpdatedAt( any()); + verify(onboardedProduct).setUpdatedAt(any()); assertEquals(1, onboardedUser.getBindings().size()); } @@ -422,21 +417,21 @@ void testUpdateUserProductState19() { */ @Test void testUpdateUserProductState20() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedProduct onboardedProduct = mock(OnboardedProduct.class); when(onboardedProduct.getStatus()).thenReturn(RelationshipState.PENDING); when(onboardedProduct.getRelationshipId()).thenReturn("foo"); doNothing().when(onboardedProduct).setContract(any()); - doNothing().when(onboardedProduct).setCreatedAt( any()); + doNothing().when(onboardedProduct).setCreatedAt(any()); doNothing().when(onboardedProduct).setEnv(any()); doNothing().when(onboardedProduct).setProductId(any()); doNothing().when(onboardedProduct).setProductRole(any()); doNothing().when(onboardedProduct).setRelationshipId(any()); - doNothing().when(onboardedProduct).setRole( any()); - doNothing().when(onboardedProduct).setStatus( any()); + doNothing().when(onboardedProduct).setRole(any()); + doNothing().when(onboardedProduct).setStatus(any()); doNothing().when(onboardedProduct).setTokenId(any()); - doNothing().when(onboardedProduct).setUpdatedAt( any()); + doNothing().when(onboardedProduct).setUpdatedAt(any()); onboardedProduct.setContract("Contract"); onboardedProduct.setCreatedAt(null); onboardedProduct.setEnv(Env.ROOT); @@ -464,15 +459,15 @@ void testUpdateUserProductState20() { verify(onboardedProduct).getStatus(); verify(onboardedProduct, atLeast(1)).getRelationshipId(); verify(onboardedProduct).setContract(any()); - verify(onboardedProduct).setCreatedAt( any()); + verify(onboardedProduct).setCreatedAt(any()); verify(onboardedProduct).setEnv(any()); verify(onboardedProduct).setProductId(any()); verify(onboardedProduct).setProductRole(any()); verify(onboardedProduct).setRelationshipId(any()); - verify(onboardedProduct).setRole( any()); - verify(onboardedProduct).setStatus( any()); + verify(onboardedProduct).setRole(any()); + verify(onboardedProduct).setStatus(any()); verify(onboardedProduct).setTokenId(any()); - verify(onboardedProduct).setUpdatedAt( any()); + verify(onboardedProduct).setUpdatedAt(any()); } /** @@ -481,21 +476,21 @@ void testUpdateUserProductState20() { @Test void testUpdateUserProductState21() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedProduct onboardedProduct = mock(OnboardedProduct.class); when(onboardedProduct.getStatus()).thenReturn(RelationshipState.PENDING); when(onboardedProduct.getRelationshipId()).thenReturn("foo"); doNothing().when(onboardedProduct).setContract(any()); - doNothing().when(onboardedProduct).setCreatedAt( any()); + doNothing().when(onboardedProduct).setCreatedAt(any()); doNothing().when(onboardedProduct).setEnv(any()); doNothing().when(onboardedProduct).setProductId(any()); doNothing().when(onboardedProduct).setProductRole(any()); doNothing().when(onboardedProduct).setRelationshipId(any()); - doNothing().when(onboardedProduct).setRole( any()); - doNothing().when(onboardedProduct).setStatus( any()); + doNothing().when(onboardedProduct).setRole(any()); + doNothing().when(onboardedProduct).setStatus(any()); doNothing().when(onboardedProduct).setTokenId(any()); - doNothing().when(onboardedProduct).setUpdatedAt( any()); + doNothing().when(onboardedProduct).setUpdatedAt(any()); onboardedProduct.setContract("Contract"); onboardedProduct.setCreatedAt(null); onboardedProduct.setEnv(Env.ROOT); @@ -523,15 +518,15 @@ void testUpdateUserProductState21() { verify(onboardedProduct).getStatus(); verify(onboardedProduct, atLeast(1)).getRelationshipId(); verify(onboardedProduct).setContract(any()); - verify(onboardedProduct).setCreatedAt( any()); + verify(onboardedProduct).setCreatedAt(any()); verify(onboardedProduct).setEnv(any()); verify(onboardedProduct).setProductId(any()); verify(onboardedProduct).setProductRole(any()); verify(onboardedProduct).setRelationshipId(any()); - verify(onboardedProduct).setRole( any()); - verify(onboardedProduct).setStatus( any()); + verify(onboardedProduct).setRole(any()); + verify(onboardedProduct).setStatus(any()); verify(onboardedProduct).setTokenId(any()); - verify(onboardedProduct).setUpdatedAt( any()); + verify(onboardedProduct).setUpdatedAt(any()); } /** @@ -540,21 +535,21 @@ void testUpdateUserProductState21() { @Test void testUpdateUserProductState22() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); OnboardedProduct onboardedProduct = mock(OnboardedProduct.class); when(onboardedProduct.getStatus()).thenReturn(RelationshipState.PENDING); when(onboardedProduct.getRelationshipId()).thenReturn("foo"); doNothing().when(onboardedProduct).setContract(any()); - doNothing().when(onboardedProduct).setCreatedAt( any()); + doNothing().when(onboardedProduct).setCreatedAt(any()); doNothing().when(onboardedProduct).setEnv(any()); doNothing().when(onboardedProduct).setProductId(any()); doNothing().when(onboardedProduct).setProductRole(any()); doNothing().when(onboardedProduct).setRelationshipId(any()); - doNothing().when(onboardedProduct).setRole( any()); - doNothing().when(onboardedProduct).setStatus( any()); + doNothing().when(onboardedProduct).setRole(any()); + doNothing().when(onboardedProduct).setStatus(any()); doNothing().when(onboardedProduct).setTokenId(any()); - doNothing().when(onboardedProduct).setUpdatedAt( any()); + doNothing().when(onboardedProduct).setUpdatedAt(any()); onboardedProduct.setContract("Contract"); onboardedProduct.setCreatedAt(null); onboardedProduct.setEnv(Env.ROOT); @@ -582,15 +577,15 @@ void testUpdateUserProductState22() { verify(onboardedProduct).getStatus(); verify(onboardedProduct, atLeast(1)).getRelationshipId(); verify(onboardedProduct).setContract(any()); - verify(onboardedProduct).setCreatedAt( any()); + verify(onboardedProduct).setCreatedAt(any()); verify(onboardedProduct).setEnv(any()); verify(onboardedProduct).setProductId(any()); verify(onboardedProduct).setProductRole(any()); verify(onboardedProduct).setRelationshipId(any()); - verify(onboardedProduct).setRole( any()); - verify(onboardedProduct).setStatus( any()); + verify(onboardedProduct).setRole(any()); + verify(onboardedProduct).setStatus(any()); verify(onboardedProduct).setTokenId(any()); - verify(onboardedProduct).setUpdatedAt( any()); + verify(onboardedProduct).setUpdatedAt(any()); } /** @@ -671,7 +666,7 @@ void testOnboardOperatorAndDeleteSameRole() { */ @Test void testOnboardOperator2() { - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, null); assertTrue(onboardingDao.onboardOperator(new Institution(), "productId", List.of()).isEmpty()); } @@ -689,11 +684,11 @@ void testOnboardOperator5() { onboardedUser.setBindings(List.of(userBinding)); UserConnector userConnector = mock(UserConnector.class); doNothing().when(userConnector) - .findAndUpdate(any(), any(), any(),any(), + .findAndUpdate(any(), any(), any(), any(), any()); when(userConnector.findById(any())).thenReturn(onboardedUser); - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, userConnector); UserToOnboard userToOnboard = TestUtils.dummyUserToOnboard(); @@ -714,7 +709,7 @@ void testOnboardOperator5() { assertEquals(Env.ROOT, onboardedProduct.getEnv()); verify(userConnector).findById(any()); verify(userConnector).findAndUpdate(any(), any(), any(), - any(), any()); + any(), any()); } /** @@ -729,14 +724,14 @@ void testOnboardOperator6() { userBinding.setProducts(List.of(onboardedProduct)); onboardedUser.setBindings(List.of(userBinding)); UserConnector userConnector = mock(UserConnector.class); - doNothing().when(userConnector).findAndRemoveProduct(any(), any(),any()); + doNothing().when(userConnector).findAndRemoveProduct(any(), any(), any()); doThrow(new InvalidRequestException("An error occurred", "users to update: {}")).when(userConnector) - .findAndUpdate(any(), any(), any(),any(), + .findAndUpdate(any(), any(), any(), any(), any()); when(userConnector.findById(any())).thenReturn(onboardedUser); - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, userConnector); UserToOnboard userToOnboard = TestUtils.dummyUserToOnboard(); @@ -746,9 +741,9 @@ void testOnboardOperator6() { assertTrue(onboardingDao.onboardOperator(new Institution(), "42", userToOnboardList).isEmpty()); verify(userConnector).findById(any()); - verify(userConnector, times(2)).findAndRemoveProduct(any(), any(),any()); + verify(userConnector, times(2)).findAndRemoveProduct(any(), any(), any()); verify(userConnector).findAndUpdate(any(), any(), any(), - any(), any()); + any(), any()); } /** @@ -764,13 +759,13 @@ void testOnboardOperator7() { onboardedUser.setBindings(List.of(userBinding)); UserConnector userConnector = mock(UserConnector.class); doThrow(new InvalidRequestException("An error occurred", "can not onboard operators")).when(userConnector) - .findAndRemoveProduct(any(), any(),any()); + .findAndRemoveProduct(any(), any(), any()); doThrow(new InvalidRequestException("An error occurred", "users to update: {}")).when(userConnector) - .findAndUpdate(any(), any(), any(),any(), + .findAndUpdate(any(), any(), any(), any(), any()); when(userConnector.findById(any())).thenReturn(onboardedUser); - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, userConnector); UserToOnboard userToOnboard = TestUtils.dummyUserToOnboard(); @@ -781,9 +776,9 @@ void testOnboardOperator7() { assertThrows(InvalidRequestException.class, () -> onboardingDao.onboardOperator(new Institution(), "42", userToOnboardList)); verify(userConnector).findById(any()); - verify(userConnector).findAndRemoveProduct(any(), any(),any()); + verify(userConnector).findAndRemoveProduct(any(), any(), any()); verify(userConnector).findAndUpdate(any(), any(), any(), - any(), any()); + any(), any()); } /** @@ -796,13 +791,13 @@ void testOnboardOperator8() { when(onboardedUser.getId()).thenThrow(new ResourceNotFoundException("An error occurred", "Code")); UserConnector userConnector = mock(UserConnector.class); when(userConnector.findAndCreate(any(), any())).thenReturn(new OnboardedUser()); - doNothing().when(userConnector).findAndRemoveProduct(any(), any(),any()); + doNothing().when(userConnector).findAndRemoveProduct(any(), any(), any()); doThrow(new InvalidRequestException("An error occurred", "users to update: {}")).when(userConnector) - .findAndUpdate(any(), any(), any(),any(), + .findAndUpdate(any(), any(), any(), any(), any()); when(userConnector.findById(any())).thenReturn(onboardedUser); - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, userConnector); UserToOnboard userToOnboard = new UserToOnboard(); @@ -840,18 +835,18 @@ void testOnboardOperator8() { */ @Test void testOnboardOperator9() { - OnboardedUser onboardedUser = mock(OnboardedUser.class); + OnboardedUser onboardedUser = mock(OnboardedUser.class); when(onboardedUser.getId()).thenThrow(new ResourceNotFoundException("An error occurred", "Code")); UserConnector userConnector = mock(UserConnector.class); when(userConnector.findAndCreate(any(), any())) .thenThrow(new InvalidRequestException("An error occurred", "users to update: {}")); - doNothing().when(userConnector).findAndRemoveProduct(any(), any(),any()); + doNothing().when(userConnector).findAndRemoveProduct(any(), any(), any()); doThrow(new InvalidRequestException("An error occurred", "users to update: {}")).when(userConnector) - .findAndUpdate(any(), any(), any(),any(), + .findAndUpdate(any(), any(), any(), any(), any()); when(userConnector.findById(any())).thenReturn(onboardedUser); - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, userConnector); UserToOnboard userToOnboard = new UserToOnboard(); @@ -878,17 +873,17 @@ void testOnboardOperator9() { */ @Test void testOnboardOperator10() { - OnboardedUser onboardedUser = mock(OnboardedUser.class); + OnboardedUser onboardedUser = mock(OnboardedUser.class); when(onboardedUser.getId()).thenThrow(new ResourceNotFoundException("An error occurred", "Code")); UserConnector userConnector = mock(UserConnector.class); when(userConnector.findAndCreate(any(), any())).thenReturn(new OnboardedUser()); - doNothing().when(userConnector).findAndRemoveProduct(any(), any(),any()); + doNothing().when(userConnector).findAndRemoveProduct(any(), any(), any()); doThrow(new InvalidRequestException("An error occurred", "users to update: {}")).when(userConnector) - .findAndUpdate(any(), any(), any(),any(), + .findAndUpdate(any(), any(), any(), any(), any()); when(userConnector.findById(any())).thenReturn(onboardedUser); - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, userConnector); UserToOnboard userToOnboard = new UserToOnboard(); @@ -943,13 +938,13 @@ void testOnboardOperator11() { when(onboardedUser.getId()).thenReturn("42"); UserConnector userConnector = mock(UserConnector.class); when(userConnector.findAndCreate(any(), any())).thenReturn(new OnboardedUser()); - doNothing().when(userConnector).findAndRemoveProduct(any(), any(),any()); + doNothing().when(userConnector).findAndRemoveProduct(any(), any(), any()); doThrow(new InvalidRequestException("An error occurred", "users to update: {}")).when(userConnector) - .findAndUpdate(any(), any(), any(),any(), + .findAndUpdate(any(), any(), any(), any(), any()); when(userConnector.findById(any())).thenReturn(onboardedUser); - ProductConnector productConnector = mock(ProductConnector.class); + OnboardingDao onboardingDao = new OnboardingDao(null, userConnector); UserToOnboard userToOnboard = mock(UserToOnboard.class); when(userToOnboard.getRole()).thenReturn(PartyRole.MANAGER); @@ -961,7 +956,7 @@ void testOnboardOperator11() { doNothing().when(userToOnboard).setId(any()); doNothing().when(userToOnboard).setName(any()); doNothing().when(userToOnboard).setProductRole(any()); - doNothing().when(userToOnboard).setRole( any()); + doNothing().when(userToOnboard).setRole(any()); doNothing().when(userToOnboard).setSurname(any()); doNothing().when(userToOnboard).setTaxCode(any()); userToOnboard.setEmail("prof.einstein@example.org"); @@ -978,9 +973,9 @@ void testOnboardOperator11() { assertTrue(onboardingDao.onboardOperator(new Institution(), "42", userToOnboardList).isEmpty()); verify(userConnector).findById(any()); - verify(userConnector).findAndRemoveProduct(any(), any(),any()); + verify(userConnector).findAndRemoveProduct(any(), any(), any()); verify(userConnector).findAndUpdate(any(), any(), any(), - any(), any()); + any(), any()); verify(onboardedUser).getId(); verify(userToOnboard).getRole(); verify(userToOnboard, atLeast(1)).getEnv(); @@ -991,7 +986,7 @@ void testOnboardOperator11() { verify(userToOnboard).setId(any()); verify(userToOnboard).setName(any()); verify(userToOnboard).setProductRole(any()); - verify(userToOnboard).setRole( any()); + verify(userToOnboard).setRole(any()); verify(userToOnboard).setSurname(any()); verify(userToOnboard).setTaxCode(any()); } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/OnboardingServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/OnboardingServiceImplTest.java index 38eaffb38..e449508f7 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/OnboardingServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/OnboardingServiceImplTest.java @@ -3,7 +3,7 @@ import feign.FeignException; import it.pagopa.selfcare.commons.base.security.PartyRole; import it.pagopa.selfcare.mscore.api.InstitutionConnector; -import it.pagopa.selfcare.mscore.api.ProductConnector; +import it.pagopa.selfcare.mscore.constant.CustomError; import it.pagopa.selfcare.mscore.constant.Env; import it.pagopa.selfcare.mscore.constant.RelationshipState; import it.pagopa.selfcare.mscore.constant.TokenType; @@ -19,10 +19,11 @@ import it.pagopa.selfcare.mscore.model.institution.InstitutionUpdate; import it.pagopa.selfcare.mscore.model.institution.Onboarding; import it.pagopa.selfcare.mscore.model.onboarding.*; -import it.pagopa.selfcare.mscore.model.product.Product; import it.pagopa.selfcare.mscore.model.user.RelationshipInfo; import it.pagopa.selfcare.mscore.model.user.User; import it.pagopa.selfcare.mscore.model.user.UserToOnboard; +import it.pagopa.selfcare.product.entity.Product; +import it.pagopa.selfcare.product.service.ProductService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -79,7 +80,7 @@ class OnboardingServiceImplTest { private InstitutionConnector institutionConnector; @Mock - private ProductConnector productConnector; + private ProductService productService; @Mock private UserNotificationService userNotificationService; @@ -253,6 +254,7 @@ void testGetOnboardingInfoWithTwoParameters() { void onboardingUsers_shouldThrowExceptionIfInstitutionNotFound() { OnboardingUsersRequest request = new OnboardingUsersRequest(); request.setInstitutionTaxCode("taxCode"); + when(productService.getProductIsValid(request.getProductId())).thenReturn(new Product()); when(institutionService.getInstitutions(request.getInstitutionTaxCode(), null)).thenReturn(List.of()); assertThrows(InvalidRequestException.class, () -> onboardingServiceImpl.onboardingUsers(request, null, null)); } @@ -265,8 +267,8 @@ void onboardingUsers_shouldThrowExceptionIfProductIsNotValid() { OnboardingUsersRequest request = new OnboardingUsersRequest(); request.setInstitutionTaxCode("taxCode"); request.setProductId("productId"); - when(institutionService.getInstitutions(request.getInstitutionTaxCode(), null)).thenReturn(List.of(new Institution())); - when(productConnector.getProductValidById(request.getProductId())).thenReturn(null); + + when(productService.getProductIsValid(request.getProductId())).thenReturn(null); assertThrows(InvalidRequestException.class, () -> onboardingServiceImpl.onboardingUsers(request, null, null)); } @@ -283,7 +285,7 @@ void onboardingUsers_whenUserExistsOnRegistry() { request.setUsers(List.of(userToOnboard)); when(institutionService.getInstitutions(request.getInstitutionTaxCode(), null)).thenReturn(List.of(new Institution())); - when(productConnector.getProductValidById(request.getProductId())).thenReturn(new Product()); + when(productService.getProductIsValid(request.getProductId())).thenReturn(new it.pagopa.selfcare.product.entity.Product()); when(userService.retrieveUserFromUserRegistryByFiscalCode(userToOnboard.getTaxCode())).thenReturn(new User()); when(userService.persistWorksContractToUserRegistry(any(), any(), any())).thenReturn(new User()); @@ -304,7 +306,7 @@ void onboardingUsers_whenUserExistsOnRegistryAndSendMailIsFalse() { request.setUsers(List.of(userToOnboard)); when(institutionService.getInstitutions(request.getInstitutionTaxCode(), null)).thenReturn(List.of(new Institution())); - when(productConnector.getProductValidById(request.getProductId())).thenReturn(new Product()); + when(productService.getProductIsValid(request.getProductId())).thenReturn(new Product()); when(userService.retrieveUserFromUserRegistryByFiscalCode(userToOnboard.getTaxCode())).thenReturn(new User()); when(userService.persistWorksContractToUserRegistry(any(), any(), any())).thenReturn(new User()); @@ -332,7 +334,7 @@ void onboardingUsers_whenUserNotExistsOnRegistry() { Institution institution = new Institution(); institution.setId("example"); when(institutionService.getInstitutions(request.getInstitutionTaxCode(), null)).thenReturn(List.of(institution)); - when(productConnector.getProductValidById(request.getProductId())).thenReturn(new Product()); + when(productService.getProductIsValid(request.getProductId())).thenReturn(new it.pagopa.selfcare.product.entity.Product()); when(userService.retrieveUserFromUserRegistryByFiscalCode(userToOnboard.getTaxCode())).thenThrow(FeignException.NotFound.class); when(userService.persistUserRegistry(any(), any(), any(), any(),any())).thenReturn(user); diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImplTest.java index 8e7edf689..339f0775c 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImplTest.java @@ -4,19 +4,20 @@ import com.fasterxml.jackson.databind.ObjectMapper; import freemarker.template.Configuration; import freemarker.template.Template; -import it.pagopa.selfcare.commons.base.security.PartyRole; import it.pagopa.selfcare.mscore.api.FileStorageConnector; import it.pagopa.selfcare.mscore.api.NotificationServiceConnector; -import it.pagopa.selfcare.mscore.api.ProductConnector; import it.pagopa.selfcare.mscore.model.CertifiedField; import it.pagopa.selfcare.mscore.model.institution.Institution; import it.pagopa.selfcare.mscore.model.institution.WorkContact; import it.pagopa.selfcare.mscore.model.onboarding.MailTemplate; import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct; -import it.pagopa.selfcare.mscore.model.product.Product; -import it.pagopa.selfcare.mscore.model.product.ProductRoleInfo; import it.pagopa.selfcare.mscore.model.user.User; import it.pagopa.selfcare.mscore.model.user.UserBinding; +import it.pagopa.selfcare.onboarding.common.PartyRole; +import it.pagopa.selfcare.product.entity.Product; +import it.pagopa.selfcare.product.entity.ProductRole; +import it.pagopa.selfcare.product.entity.ProductRoleInfo; +import it.pagopa.selfcare.product.service.ProductService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -30,7 +31,8 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -47,7 +49,7 @@ class UserNotificationServiceImplTest { private NotificationServiceConnector notificationConnector; @Mock - private ProductConnector productsConnector; + private ProductService productService; @Mock private UserService userService; @@ -158,8 +160,8 @@ void sendDeletedUserNotification(){ product.setTitle("id"); EnumMap map = new EnumMap<>(PartyRole.class); ProductRoleInfo productRoleInfo = new ProductRoleInfo(); - List productRoles = new ArrayList<>(); - ProductRoleInfo.ProductRole productRole = new ProductRoleInfo.ProductRole(); + List productRoles = new ArrayList<>(); + ProductRole productRole = new ProductRole(); productRole.setLabel("MANAGER"); productRole.setCode("MANAGER"); productRoles.add(productRole); @@ -168,7 +170,7 @@ void sendDeletedUserNotification(){ product.setRoleMappings(map); - when(productsConnector.getProductById(any())).thenReturn(product); + when(productService.getProduct(any())).thenReturn(product); assertThrows(MailPreparationException.class, () -> userNotificationService.sendDeletedUserNotification("id","userid",userBinding, "name","surname")); } @@ -210,8 +212,8 @@ void sendActivatedUserNotification(){ product.setTitle("id"); EnumMap map = new EnumMap<>(PartyRole.class); ProductRoleInfo productRoleInfo = new ProductRoleInfo(); - List productRoles = new ArrayList<>(); - ProductRoleInfo.ProductRole productRole = new ProductRoleInfo.ProductRole(); + List productRoles = new ArrayList<>(); + ProductRole productRole = new ProductRole(); productRole.setLabel("MANAGER"); productRole.setCode("MANAGER"); productRoles.add(productRole); @@ -220,7 +222,7 @@ void sendActivatedUserNotification(){ product.setRoleMappings(map); - when(productsConnector.getProductById(any())).thenReturn(product); + when(productService.getProduct(any())).thenReturn(product); assertThrows(MailPreparationException.class, () -> userNotificationService.sendActivatedUserNotification("id","userid",userBinding,"name","surname")); } @@ -263,8 +265,8 @@ void sendSuspendedUserNotification() throws JsonProcessingException { product.setTitle("id"); EnumMap map = new EnumMap<>(PartyRole.class); ProductRoleInfo productRoleInfo = new ProductRoleInfo(); - List productRoles = new ArrayList<>(); - ProductRoleInfo.ProductRole productRole = new ProductRoleInfo.ProductRole(); + List productRoles = new ArrayList<>(); + ProductRole productRole = new ProductRole(); productRole.setLabel("MANAGER"); productRole.setCode("MANAGER"); productRoles.add(productRole); @@ -273,7 +275,7 @@ void sendSuspendedUserNotification() throws JsonProcessingException { product.setRoleMappings(map); - when(productsConnector.getProductById(any())).thenReturn(product); + when(productService.getProduct(any())).thenReturn(product); assertThrows(MailPreparationException.class, () -> userNotificationService.sendSuspendedUserNotification("id","userid",userBinding, "name","surname")); } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtilsTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtilsTest.java index 6ffe33e24..6442cb604 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtilsTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtilsTest.java @@ -13,6 +13,7 @@ import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct; import it.pagopa.selfcare.mscore.model.onboarding.OnboardingRequest; import it.pagopa.selfcare.mscore.model.user.UserToOnboard; +import it.pagopa.selfcare.product.entity.Product; import org.junit.jupiter.api.Test; import java.util.ArrayList; diff --git a/helm/pnpg/templates/deployment.yaml b/helm/pnpg/templates/deployment.yaml index 9ebf2d255..6b1149dd0 100644 --- a/helm/pnpg/templates/deployment.yaml +++ b/helm/pnpg/templates/deployment.yaml @@ -48,6 +48,8 @@ spec: name: contracts-storage - secretRef: name: event-secrets + - secretRef: + name: product-storage - secretRef: name: mail - configMapRef: diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 1304219f8..07ec99d57 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -52,6 +52,8 @@ spec: name: mail - secretRef: name: geotaxonomy-secrets + - secretRef: + name: product-storage - configMapRef: name: jwt - configMapRef: diff --git a/infra/container_apps/env/dev-pnpg/terraform.tfvars b/infra/container_apps/env/dev-pnpg/terraform.tfvars index af2f0897b..a8b68337c 100644 --- a/infra/container_apps/env/dev-pnpg/terraform.tfvars +++ b/infra/container_apps/env/dev-pnpg/terraform.tfvars @@ -174,10 +174,6 @@ app_settings = [ name = "USERVICE_PARTY_REGISTRY_PROXY_URL" value = "https://selc-d-pnpg-party-reg-proxy-ca.victoriousfield-e39534b8.westeurope.azurecontainerapps.io" }, - { - name = "MS_PRODUCT_URL" - value = "https://selc-d-pnpg-product-ca.victoriousfield-e39534b8.westeurope.azurecontainerapps.io" - }, { name = "USERVICE_USER_REGISTRY_URL" value = "https://api.uat.pdv.pagopa.it/user-registry/v1" @@ -185,6 +181,10 @@ app_settings = [ { name = "SELFCARE_USER_URL" value = "https://selc-d-pnpg-user-ms-ca.victoriousfield-e39534b8.westeurope.azurecontainerapps.io" + }, + { + name = "PRODUCT_STORAGE_CONTAINER" + value = "selc-d-product" } ] diff --git a/infra/container_apps/env/dev/terraform.tfvars b/infra/container_apps/env/dev/terraform.tfvars index e3be3f91d..d96689f3f 100644 --- a/infra/container_apps/env/dev/terraform.tfvars +++ b/infra/container_apps/env/dev/terraform.tfvars @@ -194,10 +194,6 @@ app_settings = [ name = "USERVICE_PARTY_REGISTRY_PROXY_URL" value = "https://selc-d-party-reg-proxy-ca.politewater-9af33050.westeurope.azurecontainerapps.io" }, - { - name = "MS_PRODUCT_URL" - value = "https://selc-d-product-ca.politewater-9af33050.westeurope.azurecontainerapps.io" - }, { name = "USERVICE_USER_REGISTRY_URL" value = "https://api.uat.pdv.pagopa.it/user-registry/v1" @@ -205,6 +201,10 @@ app_settings = [ { name = "SELFCARE_USER_URL" value = "https://selc-d-user-ms-ca.politewater-9af33050.westeurope.azurecontainerapps.io" + }, + { + name = "PRODUCT_STORAGE_CONTAINER" + value = "selc-d-product" } ] diff --git a/infra/container_apps/env/prod-pnpg/terraform.tfvars b/infra/container_apps/env/prod-pnpg/terraform.tfvars index 509572257..be6122436 100644 --- a/infra/container_apps/env/prod-pnpg/terraform.tfvars +++ b/infra/container_apps/env/prod-pnpg/terraform.tfvars @@ -169,10 +169,6 @@ app_settings = [ name = "USERVICE_PARTY_REGISTRY_PROXY_URL" value = "https://selc-p-pnpg-party-reg-proxy-ca.calmmoss-0be48755.westeurope.azurecontainerapps.io" }, - { - name = "MS_PRODUCT_URL" - value = "https://selc-p-pnpg-product-ca.calmmoss-0be48755.westeurope.azurecontainerapps.io" - }, { name = "USERVICE_USER_REGISTRY_URL" value = "https://api.pdv.pagopa.it/user-registry/v1" @@ -180,6 +176,10 @@ app_settings = [ { name = "SELFCARE_USER_URL" value = "https://selc-p-pnpg-user-ms-ca.calmmoss-0be48755.westeurope.azurecontainerapps.io" + }, + { + name = "PRODUCT_STORAGE_CONTAINER" + value = "selc-p-product" } ] diff --git a/infra/container_apps/env/prod/terraform.tfvars b/infra/container_apps/env/prod/terraform.tfvars index 11b38a801..75b197cc6 100644 --- a/infra/container_apps/env/prod/terraform.tfvars +++ b/infra/container_apps/env/prod/terraform.tfvars @@ -182,10 +182,6 @@ app_settings = [ name = "USERVICE_PARTY_REGISTRY_PROXY_URL" value = "https://selc-p-party-reg-proxy-ca.greensand-62fc96da.westeurope.azurecontainerapps.io" }, - { - name = "MS_PRODUCT_URL" - value = "https://selc-p-product-ca.greensand-62fc96da.westeurope.azurecontainerapps.io" - }, { name = "USERVICE_USER_REGISTRY_URL" value = "https://api.pdv.pagopa.it/user-registry/v1" @@ -193,6 +189,10 @@ app_settings = [ { name = "SELFCARE_USER_URL" value = "https://selc-p-user-ms-ca.greensand-62fc96da.westeurope.azurecontainerapps.io" + }, + { + name = "PRODUCT_STORAGE_CONTAINER" + value = "selc-p-product" } ] diff --git a/infra/container_apps/env/uat-pnpg/terraform.tfvars b/infra/container_apps/env/uat-pnpg/terraform.tfvars index 1160b9249..cca7d8f3d 100644 --- a/infra/container_apps/env/uat-pnpg/terraform.tfvars +++ b/infra/container_apps/env/uat-pnpg/terraform.tfvars @@ -162,10 +162,6 @@ app_settings = [ name = "USERVICE_PARTY_REGISTRY_PROXY_URL" value = "https://selc-u-pnpg-party-reg-proxy-ca.orangeground-0bd2d4dc.westeurope.azurecontainerapps.io" }, - { - name = "MS_PRODUCT_URL" - value = "https://uat01.pnpg.internal.uat.selfcare.pagopa.it/ms-product/v1" - }, { name = "USERVICE_USER_REGISTRY_URL" value = "https://api.uat.pdv.pagopa.it/user-registry/v1" @@ -173,6 +169,10 @@ app_settings = [ { name = "SELFCARE_USER_URL" value = "https://selc-u-pnpg-user-ms-ca.orangeground-0bd2d4dc.westeurope.azurecontainerapps.io" + }, + { + name = "PRODUCT_STORAGE_CONTAINER" + value = "selc-u-product" } ] diff --git a/infra/container_apps/env/uat/terraform.tfvars b/infra/container_apps/env/uat/terraform.tfvars index 9e2e6d829..08c1c1f41 100644 --- a/infra/container_apps/env/uat/terraform.tfvars +++ b/infra/container_apps/env/uat/terraform.tfvars @@ -173,10 +173,6 @@ app_settings = [ name = "USERVICE_PARTY_REGISTRY_PROXY_URL" value = "https://selc-u-party-reg-proxy-ca.proudglacier-20652b81.westeurope.azurecontainerapps.io" }, - { - name = "MS_PRODUCT_URL" - value = "https://selc-u-product-ca.proudglacier-20652b81.westeurope.azurecontainerapps.io" - }, { name = "USERVICE_USER_REGISTRY_URL" value = "https://api.uat.pdv.pagopa.it/user-registry/v1" @@ -184,6 +180,10 @@ app_settings = [ { name = "SELFCARE_USER_URL" value = "https://selc-u-user-ms-ca.proudglacier-20652b81.westeurope.azurecontainerapps.io" + }, + { + name = "PRODUCT_STORAGE_CONTAINER" + value = "selc-u-product" } ] diff --git a/pom.xml b/pom.xml index 06dd3a274..4a5aa1312 100644 --- a/pom.xml +++ b/pom.xml @@ -202,6 +202,11 @@ https://pkgs.dev.azure.com/pagopaspa/selfcare-platform-app-projects/_packaging/selfcare-platform/maven/v1 + + selfcare-onboarding + Selfcare Onboarding SDK + https://maven.pkg.github.com/pagopa/selfcare-onboarding + \ No newline at end of file diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/DelegationController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/DelegationController.java index 4c3316ec0..b9ebf61f6 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/DelegationController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/DelegationController.java @@ -54,7 +54,7 @@ public DelegationController(DelegationService delegationService, */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.delegation.create}", notes = "${swagger.mscore.delegation.create}") - @PostMapping + @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createDelegation(@RequestBody @Valid DelegationRequest delegation) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_DELEGATION_ERROR); Delegation saved = delegationService.createDelegation(delegationMapper.toDelegation(delegation)); @@ -73,7 +73,7 @@ public ResponseEntity createDelegation(@RequestBody @Valid D */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.delegation.createFromTaxCode}", notes = "${swagger.mscore.delegation.createFromTaxCode}") - @PostMapping("/from-taxcode") + @PostMapping(value = "/from-taxcode", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createDelegationFromInstitutionsTaxCode(@RequestBody @Valid DelegationRequestFromTaxcode delegation) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_DELEGATION_ERROR); Delegation saved = delegationService.createDelegationFromInstitutionsTaxCode(delegationMapper.toDelegation(delegation)); @@ -93,7 +93,7 @@ public ResponseEntity createDelegationFromInstitutionsTaxCod */ @Tags({@Tag(name = "external-v2"), @Tag(name = "support"), @Tag(name = "Delegation")}) @ApiOperation(value = "${swagger.mscore.institutions.delegations}", notes = "${swagger.mscore.institutions.delegations}") - @GetMapping() + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getDelegations(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @RequestParam(name = "institutionId", required = false) String institutionId, @ApiParam("${swagger.mscore.institutions.model.institutionId}") diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ExternalController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ExternalController.java index 8d2516ac1..413ccc43b 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ExternalController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ExternalController.java @@ -76,7 +76,7 @@ public ExternalController(ExternalService externalService, InstitutionResourceMa */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value ="${swagger.mscore.external.institution}", notes = "${swagger.mscore.external.institution}") - @GetMapping("/{externalId}") + @GetMapping(value = "/{externalId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getByExternalId(@ApiParam("${swagger.mscore.institutions.model.externalId}") @PathVariable("externalId") String externalId) { CustomExceptionMessage.setCustomMessage(GET_INSTITUTION_BY_EXTERNAL_ID_ERROR); @@ -98,7 +98,7 @@ public ResponseEntity getByExternalId(@ApiParam("${swagger. */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.external.institution.manager}", notes = "${swagger.mscore.external.institution.manager}") - @GetMapping(value = "/{externalId}/products/{productId}/manager") + @GetMapping(value = "/{externalId}/products/{productId}/manager", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getManagerInstitutionByExternalId(@ApiParam("${swagger.mscore.institutions.model.externalId}") @PathVariable("externalId") String externalId, @ApiParam("${swagger.mscore.institutions.model.productId}") @@ -122,7 +122,7 @@ public ResponseEntity getManagerInstitutionByExterna */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.external.institution.billing}", notes = "${swagger.mscore.external.institution.billing}") - @GetMapping(value = "/{externalId}/products/{productId}/billing") + @GetMapping(value = "/{externalId}/products/{productId}/billing", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getBillingInstitutionByExternalId(@ApiParam("${swagger.mscore.institutions.model.externalId}") @PathVariable("externalId") String externalId, @ApiParam("${swagger.mscore.institutions.model.productId}") @@ -146,7 +146,7 @@ public ResponseEntity getBillingInstitutionByExterna */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.external.institution.products}", notes = "${swagger.mscore.external.institution.products}") - @GetMapping(value = "/{externalId}/products") + @GetMapping(value = "/{externalId}/products", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity retrieveInstitutionProductsByExternalId(@ApiParam("${swagger.mscore.institutions.model.externalId}") @PathVariable("externalId") String externalId, @RequestParam(value = "states", required = false) List states) { @@ -166,7 +166,7 @@ public ResponseEntity retrieveInstitutionProductsByExternalId */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.external.geotaxonomies}", notes = "${swagger.mscore.external.geotaxonomies}") - @GetMapping(value = "/{externalId}/geotaxonomies") + @GetMapping(value = "/{externalId}/geotaxonomies", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> retrieveInstitutionGeoTaxonomiesByExternalId(@ApiParam("${swagger.mscore.institutions.model.externalId}") @PathVariable("externalId") String externalId) { CustomExceptionMessage.setCustomMessage(RETRIEVE_GEO_TAXONOMIES_ERROR); @@ -190,7 +190,7 @@ public ResponseEntity> retrieveInstitutionGeoTaxonomi */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.external.institution.relationships}", notes = "${swagger.mscore.external.institution.relationships}") - @GetMapping(value = "/{externalId}/relationships") + @GetMapping(value = "/{externalId}/relationships", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getUserInstitutionRelationshipsByExternalId(@ApiParam("${swagger.mscore.institutions.model.externalId}") @PathVariable("externalId") String externalId, @RequestParam(value = "personId", required = false) String personId, @RequestParam(value = "roles", required = false) List roles, @@ -215,7 +215,7 @@ public ResponseEntity> getUserInstitutionRelationshipsB */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.PG.create}", notes = "${swagger.mscore.institution.PG.create}") - @PostMapping(value = "/pn-pg") + @PostMapping(value = "/pn-pg", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createPnPgInstitution(@RequestBody @Valid CreatePnPgInstitutionRequest request) { CustomExceptionMessage.setCustomMessage(CREATE_INSTITUTION_ERROR); Institution saved = externalService.createPnPgInstitution(request.getTaxId(), request.getDescription()); @@ -233,7 +233,7 @@ public ResponseEntity createPnPgInstitution(@RequestBod */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution}", notes = "${swagger.mscore.institution}") - @GetMapping(value = "") + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> retrieveInstitutionByIds(@ApiParam("${swagger.mscore.institutions.model.internalIds}") @RequestParam("ids") List ids) { CustomExceptionMessage.setCustomMessage(GET_INSTITUTION_BY_ID_ERROR); diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java index 06a41da04..3f3aa81ee 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java @@ -78,7 +78,7 @@ public InstitutionController(InstitutionService institutionService, @Tags({@Tag(name = "support"), @Tag(name = "external-v2"), @Tag(name = "Institution")}) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institutions}", notes = "${swagger.mscore.institutions}") - @GetMapping + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getInstitutions(@ApiParam("${swagger.mscore.institutions.model.taxCode}") @RequestParam(value = "taxCode", required = false) String taxCode, @ApiParam("${swagger.mscore.institutions.model.subunitCode}") @@ -115,7 +115,7 @@ public ResponseEntity getInstitutions(@ApiParam("${swagger */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.create.from-ipa}", notes = "${swagger.mscore.institution.create.from-ipa}") - @PostMapping(value = "/from-ipa") + @PostMapping(value = "/from-ipa", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createInstitutionFromIpa(@RequestBody @Valid InstitutionFromIpaPost institutionFromIpaPost) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR); @@ -144,7 +144,7 @@ public ResponseEntity createInstitutionFromIpa(@RequestBody */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.create.from-anac}", notes = "${swagger.mscore.institution.create.from-anac}") - @PostMapping(value = "/from-anac") + @PostMapping(value = "/from-anac", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createInstitutionFromAnac(@RequestBody @Valid InstitutionRequest institution) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR); Institution saved = institutionService.createInstitutionFromAnac(InstitutionMapperCustom.toInstitution(institution, null)); @@ -163,7 +163,7 @@ public ResponseEntity createInstitutionFromAnac(@RequestBod */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.create.from-ivass}", notes = "${swagger.mscore.institution.create.from-ivass}") - @PostMapping(value = "/from-ivass") + @PostMapping(value = "/from-ivass", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createInstitutionFromIvass(@RequestBody @Valid InstitutionRequest institution) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR); Institution saved = institutionService.createInstitutionFromIvass(InstitutionMapperCustom.toInstitution(institution, null)); @@ -182,7 +182,7 @@ public ResponseEntity createInstitutionFromIvass(@RequestBo */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.create.from-pda}", notes = "${swagger.mscore.institution.create.from-ipa}") - @PostMapping(value = "/from-pda") + @PostMapping(value = "/from-pda", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createInstitutionFromPda(@RequestBody @Valid PdaInstitutionRequest institutionRequest) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR); @@ -202,7 +202,7 @@ public ResponseEntity createInstitutionFromPda(@RequestBody */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.create.from-infocamere}", notes = "${swagger.mscore.institution.create.from-infocamere}") - @PostMapping(value = "/from-infocamere") + @PostMapping(value = "/from-infocamere", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createInstitutionFromInfocamere(@RequestBody @Valid InstitutionRequest institutionRequest) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR); @@ -223,7 +223,7 @@ public ResponseEntity createInstitutionFromInfocamere(@Requ @Deprecated @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.PA.create}", notes = "${swagger.mscore.institution.PA.create}") - @PostMapping(value = "/{externalId}") + @PostMapping(value = "/{externalId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createInstitutionByExternalId(@ApiParam("${swagger.mscore.institutions.model.externalId}") @PathVariable("externalId") String externalId) { @@ -243,7 +243,7 @@ public ResponseEntity createInstitutionByExternalId(@ApiPar */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.create}", notes = "${swagger.mscore.institution.create}") - @PostMapping + @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createInstitution(@RequestBody @Valid InstitutionRequest institution) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR); Institution saved = institutionService.createInstitution(InstitutionMapperCustom.toInstitution(institution, null)); @@ -263,7 +263,7 @@ public ResponseEntity createInstitution(@RequestBody @Valid @Deprecated @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution.create}", notes = "${swagger.mscore.institution.create}") - @PostMapping(value = "/insert/{externalId}") + @PostMapping(value = "/insert/{externalId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createInstitutionRaw(@ApiParam("${swagger.mscore.institutions.model.externalId}") @PathVariable("externalId") String externalId, @RequestBody @Valid InstitutionRequest institution) { @@ -284,7 +284,7 @@ public ResponseEntity createInstitutionRaw(@ApiParam("${swa */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.institution.PG.create}", notes = "${swagger.mscore.institution.PG.create}") - @PostMapping(value = "/pg") + @PostMapping(value = "/pg", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createPgInstitution(@RequestBody @Valid CreatePgInstitutionRequest request, Authentication authentication) { CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR); @@ -304,7 +304,7 @@ public ResponseEntity createPgInstitution(@RequestBody @Val */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution.products}", notes = "${swagger.mscore.institution.products}") - @GetMapping(value = "/{id}/products") + @GetMapping(value = "/{id}/products", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity retrieveInstitutionProducts(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @PathVariable("id") String institutionId, @ApiParam("${swagger.mscore.institutions.model.relationshipState}") @@ -327,7 +327,7 @@ public ResponseEntity retrieveInstitutionProducts(@ApiParam(" */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution.update}", notes = "${swagger.mscore.institution.update}") - @PutMapping(value = "/{id}") + @PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity updateInstitution(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @PathVariable("id") String institutionId, @RequestBody InstitutionPut institutionPut, @@ -351,7 +351,7 @@ public ResponseEntity updateInstitution(@ApiParam("${swagge */ @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "${swagger.mscore.onboarding.users}", notes = "${swagger.mscore.onboarding.users}") - @PostMapping(value = "/{id}/onboarding") + @PostMapping(value = "/{id}/onboarding", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity onboardingInstitution(@RequestBody @Valid InstitutionOnboardingRequest request, @PathVariable("id") String id) { CustomExceptionMessage.setCustomMessage(GenericError.ONBOARDING_OPERATION_ERROR); @@ -374,7 +374,7 @@ public ResponseEntity onboardingInstitution(@RequestBody @V */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution.geotaxonomies}", notes = "${swagger.mscore.institution.geotaxonomies}") - @GetMapping(value = "/{id}/geotaxonomies") + @GetMapping(value = "/{id}/geotaxonomies", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> retrieveInstitutionGeoTaxonomies(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @PathVariable("id") String id) { @@ -395,7 +395,7 @@ public ResponseEntity> retrieveInstitutionGeoTaxonomi @Tags({@Tag(name = "external-v2"), @Tag(name = "Institution")}) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution}", notes = "${swagger.mscore.institution}") - @GetMapping(value = "/{id}") + @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity retrieveInstitutionById(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @PathVariable("id") String id) { CustomExceptionMessage.setCustomMessage(GenericError.GET_INSTITUTION_BY_ID_ERROR); @@ -418,7 +418,7 @@ public ResponseEntity retrieveInstitutionById(@ApiParam("${ */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution.relationships}", notes = "${swagger.mscore.institution.relationships}") - @GetMapping(value = "/{id}/relationships") + @GetMapping(value = "/{id}/relationships", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getUserInstitutionRelationships(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @PathVariable("id") String institutionId, @RequestParam(value = "personId", required = false) String personId, @@ -447,7 +447,7 @@ public ResponseEntity> getUserInstitutionRelationships( @Tags({@Tag(name = "external-v2"), @Tag(name = "Institution")}) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution.info}", notes = "${swagger.mscore.institution.info}") - @GetMapping(value = "/{institutionId}/onboardings") + @GetMapping(value = "/{institutionId}/onboardings", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getOnboardingsInstitution(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @PathVariable("institutionId") String institutionId, @RequestParam(value = "productId", required = false) String productId) { @@ -470,7 +470,7 @@ public ResponseEntity getOnboardingsInstitution(@ApiParam(" */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institutions.valid}", notes = "${swagger.mscore.institutions.valid}") - @PostMapping(value = "/onboarded/{productId}") + @PostMapping(value = "/onboarded/{productId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getValidInstitutionToOnboard(@RequestBody List institutions, @PathVariable(value = "productId") String productId) { List validInstitutions = institutionService.retrieveInstitutionByExternalIds(InstitutionMapperCustom.toValidInstitutions(institutions), productId); @@ -488,7 +488,7 @@ public ResponseEntity> getValidInstitutionToOnboard(@ */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institutions.updateCreatedAt}", notes = "${swagger.mscore.institutions.updateCreatedAt}") - @PutMapping(value = "/{institutionId}/createdAt") + @PutMapping(value = "/{institutionId}/createdAt", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity updateCreatedAt(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @PathVariable("institutionId") String institutionId, @Valid @RequestBody CreatedAtRequest createdAtRequest) { @@ -514,7 +514,7 @@ public ResponseEntity updateCreatedAt(@ApiParam("${swagger.mscore.institut */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institutions.findFromProduct}", notes = "${swagger.mscore.institutions.findFromProduct}") - @GetMapping(value = "/products/{productId}") + @GetMapping(value = "/products/{productId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity findFromProduct(@ApiParam("${swagger.mscore.institutions.model.productId}") @PathVariable(value = "productId") String productId, @ApiParam("${swagger.mscore.page.number}") @@ -534,7 +534,7 @@ public ResponseEntity findFromProduct(@ApiPar return ResponseEntity.ok().body(institutionListResponse); } - @GetMapping(value = "/{productId}/brokers/{institutionType}") + @GetMapping(value = "/{productId}/brokers/{institutionType}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institutions.brokers}", notes = "${swagger.mscore.institutions.getInstitutionBrokers}") public Collection getInstitutionBrokers(@ApiParam("${swagger.mscore.institutions.model.productId}") @@ -553,7 +553,7 @@ public Collection getInstitutionBrokers(@ApiParam("${swagger.msc } @Tags({@Tag(name = "support"), @Tag(name = "Institution")}) - @GetMapping(value = "/{institutionId}/users") + @GetMapping(value = "/{institutionId}/users", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "", notes = "${swagger.mscore.institutions.api.getInstitutionUsers}") public List getInstitutionUsers(@ApiParam("${swagger.mscore.institutions.model.id}") diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ManagementController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ManagementController.java index 35eea8b99..71cd391ee 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ManagementController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ManagementController.java @@ -6,7 +6,6 @@ import it.pagopa.selfcare.commons.base.security.PartyRole; import it.pagopa.selfcare.mscore.constant.RelationshipState; import it.pagopa.selfcare.mscore.core.InstitutionService; -import it.pagopa.selfcare.mscore.core.UserService; import it.pagopa.selfcare.mscore.model.institution.Institution; import it.pagopa.selfcare.mscore.model.user.RelationshipInfo; import it.pagopa.selfcare.mscore.web.model.institution.BulkInstitutions; @@ -17,6 +16,7 @@ import it.pagopa.selfcare.mscore.web.util.CustomExceptionMessage; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -40,7 +40,7 @@ public ManagementController(InstitutionService institutionService) { @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.institution}", notes = "${swagger.mscore.institution}") - @PostMapping(value = "/bulk/institutions") + @PostMapping(value = "/bulk/institutions", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity retrieveInstitutionByIds(@ApiParam("${swagger.mscore.institutions.model.internalIds}") @RequestBody @Valid BulkPartiesSeed bulkPartiesSeed) { CustomExceptionMessage.setCustomMessage(GET_INSTITUTION_BY_ID_ERROR); @@ -55,7 +55,7 @@ public ResponseEntity retrieveInstitutionByIds(@ApiParam("${sw @Deprecated(since = "1.0-SNAPSHOT") @ResponseStatus(HttpStatus.NO_CONTENT) @ApiOperation(value = "${swagger.mscore.relationships.get}", notes = "${swagger.mscore.relationships.get}") - @GetMapping(value = "/relationships") + @GetMapping(value = "/relationships", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getInstitutionRelationships(@RequestParam(value = "from", required = false) String userId, @RequestParam(value = "to", required = false) String institutionId, @RequestParam(value = "roles", required = false) List roles, diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/OnboardingController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/OnboardingController.java index c5892fa41..1ed160b67 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/OnboardingController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/OnboardingController.java @@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.*; @@ -130,7 +131,7 @@ public ResponseEntity verifyOnboardingInfoByFilters(@ApiParam("${swagger.m */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.onboarding.info}", notes = "${swagger.mscore.onboarding.info}") - @GetMapping(value = "/info") + @GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity onboardingInfo(@ApiParam("${swagger.mscore.institutions.model.institutionId}") @RequestParam(value = "institutionId", required = false) String institutionId, @ApiParam("${swagger.mscore.institutions.model.externalId}") @@ -157,7 +158,7 @@ public ResponseEntity onboardingInfo(@ApiParam("${swagge */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.onboarding.operator}", notes = "${swagger.mscore.onboarding.operator}") - @PostMapping(value = "/operators") + @PostMapping(value = "/operators", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> onboardingInstitutionOperators(@RequestBody @Valid OnboardingInstitutionOperatorsRequest request, Authentication authentication) { CustomExceptionMessage.setCustomMessage(GenericError.ONBOARDING_OPERATORS_ERROR); @@ -177,7 +178,7 @@ public ResponseEntity> onboardingInstitutionOperators(@ */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.onboarding.subdelegates}", notes = "${swagger.mscore.onboarding.subdelegates}") - @PostMapping(value = "/subdelegates") + @PostMapping(value = "/subdelegates", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> onboardingInstitutionSubDelegate(@RequestBody @Valid OnboardingInstitutionOperatorsRequest request, Authentication authentication) { CustomExceptionMessage.setCustomMessage(GenericError.ONBOARDING_SUBDELEGATES_ERROR); @@ -198,7 +199,7 @@ public ResponseEntity> onboardingInstitutionSubDelegate @ResponseStatus(HttpStatus.OK) @Tags({@Tag(name = "support"), @Tag(name = "Onboarding")}) @ApiOperation(value = "${swagger.mscore.onboarding.users}", notes = "${swagger.mscore.onboarding.users}") - @PostMapping(value = "/users") + @PostMapping(value = "/users", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> onboardingInstitutionUsers(@RequestBody @Valid OnboardingInstitutionUsersRequest request, Authentication authentication) { CustomExceptionMessage.setCustomMessage(GenericError.ONBOARDING_SUBDELEGATES_ERROR); @@ -217,7 +218,7 @@ public ResponseEntity> onboardingInstitutionUsers(@Requ */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.onboarding.relationship.document}", notes = "${swagger.mscore.onboarding.relationship.document}") - @GetMapping(value = "/relationship/{relationshipId}/document") + @GetMapping(value = "/relationship/{relationshipId}/document", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getOnboardingDocument(@ApiParam("${swagger.mscore.relationship.relationshipId}") @PathVariable("relationshipId") String relationshipId) { CustomExceptionMessage.setCustomMessage(GenericError.GETTING_ONBOARDING_INFO_ERROR); diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/QueueNotificationController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/QueueNotificationController.java index 30416173c..20a5473f8 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/QueueNotificationController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/QueueNotificationController.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -29,7 +30,7 @@ public QueueNotificationController(QueueNotificationService queueNotificationSer this.userMapper = userMapper; } @ApiOperation(value = "", notes = "${swagger.ms-core.notification-event.api.start}") - @PostMapping(value = "/contracts") + @PostMapping(value = "/contracts", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public void resendContracts(@RequestParam(name = "size", required = false) Optional size, @RequestParam(name = "productsFilter") List productsFilter){ @@ -38,7 +39,7 @@ public void resendContracts(@RequestParam(name = "size", required = false) Optio queueNotificationService.sendContracts(size, productsFilter); } @ApiOperation(value = "", notes = "Function to send a specific onboarding using institutionId and tokenId ") - @PutMapping(value = "/contracts") + @PutMapping(value = "/contracts", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public void resendContractsByInstitutionIdAndTokenId(@RequestParam(name = "tokenId") String tokenId, @RequestParam(name = "institutionId") String institutionId){ @@ -48,7 +49,7 @@ public void resendContractsByInstitutionIdAndTokenId(@RequestParam(name = "token } @ApiOperation(value = "", notes = "${swagger.ms-core.notification-event.api.start.users}") - @PostMapping(value = "/users") + @PostMapping(value = "/users", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public void resendUsers(@RequestParam(name = "size", required = false)Optional size, @RequestParam(name = "page", required = false)Optional page, diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/TokenController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/TokenController.java index 80538661e..08a220129 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/TokenController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/TokenController.java @@ -16,6 +16,7 @@ import it.pagopa.selfcare.mscore.web.model.token.TokenResource; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -47,7 +48,7 @@ public TokenController(TokenService tokenService, TokenMapper tokenMapper) { */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.token.api.getToken}") - @GetMapping(value = "/tokens/token") + @GetMapping(value = "/tokens/token", produces = MediaType.APPLICATION_JSON_VALUE) public TokenResource getToken(@ApiParam("${swagger.mscore.institution.model.id}")@RequestParam(value = "institutionId")String institutionId, @ApiParam("${swagger.mscore.product.model.id}")@RequestParam(value = "productId")String productId){ log.trace("getToken start"); @@ -72,7 +73,7 @@ public TokenResource getToken(@ApiParam("${swagger.mscore.institution.model.id}" @Tags({@Tag(name = "external-v2"), @Tag(name = "Token")}) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.tokens.findFromProduct}", notes = "${swagger.mscore.tokens.findFromProduct}") - @GetMapping(value = "/tokens/products/{productId}") + @GetMapping(value = "/tokens/products/{productId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity findFromProduct(@ApiParam("${swagger.mscore.institutions.model.productId}") @PathVariable(value = "productId") String productId, @ApiParam("${swagger.mscore.page.number}") @@ -105,7 +106,7 @@ public ResponseEntity findFromProduct(@ApiParam("${swagger.ms @Tag(name = "Token") @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.tokens.getAll}", notes = "${swagger.mscore.tokens.getAll}") - @GetMapping(value = "/tokens") + @GetMapping(value = "/tokens", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getAllTokens(@ApiParam("${swagger.mscore.token.model.states}") @RequestParam(value = "states", defaultValue = "ACTIVE,DELETED") List states, @ApiParam("${swagger.mscore.page.number}") diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/UserController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/UserController.java index 6aed3636d..f84ffb4c7 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/UserController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/UserController.java @@ -28,6 +28,7 @@ import it.pagopa.selfcare.mscore.web.util.CustomExceptionMessage; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.*; @@ -134,7 +135,7 @@ public ResponseEntity deleteRelationship(@ApiParam("${swagger.mscore.relat */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.relationships}", notes = "${swagger.mscore.relationships}") - @GetMapping("/relationships/{relationshipId}") + @GetMapping(value = "/relationships/{relationshipId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getRelationship(@ApiParam("${swagger.mscore.relationship.relationshipId}") @PathVariable("relationshipId") String relationshipId) { log.info("Getting relationship {}", relationshipId); @@ -156,7 +157,7 @@ public ResponseEntity getRelationship(@ApiParam("${swagger.m */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.onboarding.info}", notes = "${swagger.mscore.onboarding.info}") - @GetMapping(value = "/users/{userId}/institution-products") + @GetMapping(value = "/users/{userId}/institution-products", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getInstitutionProductsInfo(@ApiParam("${swagger.mscore.relationship.relationshipId}") @PathVariable("userId") String userId, @ApiParam("${swagger.mscore.institutions.model.institutionId}") @@ -183,7 +184,7 @@ public ResponseEntity getInstitutionProductsInfo(@ApiPar */ @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.users.products}", notes = "${swagger.mscore.users.products}") - @GetMapping(value = "/users/{userId}/products") + @GetMapping(value = "/users/{userId}/products", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getUserProductsInfo(@ApiParam("${swagger.mscore.relationship.relationshipId}") @PathVariable("userId") String userId, @ApiParam("${swagger.mscore.institutions.model.institutionId}") @@ -245,7 +246,7 @@ public ResponseEntity deleteProducts(@ApiParam("${swagger.mscore.relations @Tags({@Tag(name = "support"), @Tag(name = "external-v2"), @Tag(name = "Persons")}) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "${swagger.mscore.users}", notes = "${swagger.mscore.users}") - @GetMapping(value = "/users/{id}") + @GetMapping(value = "/users/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getUserInfo(@ApiParam("${swagger.mscore.users.userId}") @PathVariable("id") String userId, @ApiParam("${swagger.mscore.institutions.model.productId}") @@ -292,7 +293,7 @@ public ResponseEntity updateUser(@ApiParam("${swagger.mscore.users.userId} * * Code: 404, Message: Not found, DataType: Problem */ @ApiOperation(value = "", notes = "${swagger.mscore.api.users.findAll}") - @GetMapping(value = "/users") + @GetMapping(value = "/users", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public ResponseEntity getUsers(@RequestParam(name = "size", required = false, defaultValue = "100") Optional size, @RequestParam(name = "page", required = false, defaultValue = "0") Optional page, @@ -340,7 +341,7 @@ public ResponseEntity getUsers(@RequestParam(name = " @Tag(name = "support") @ResponseStatus(HttpStatus.NO_CONTENT) @ApiOperation(value = "${swagger.mscore.api.users.updateUserStatus}", notes = "${swagger.mscore.api.users.updateUserStatus}") - @PutMapping(value = "/users/{id}/status") + @PutMapping(value = "/users/{id}/status", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity updateUserStatus(@ApiParam(value = "${swagger.mscore.users.userId}", required = true) @PathVariable(value = "id") String userId, @ApiParam(value = "${swagger.mscore.institutions.model.institutionId}") @RequestParam(value = "institutionId", required = false) String institutionId, @ApiParam(value = "${swagger.mscore.institutions.model.productId}") @RequestParam(value = "productId", required = false) String productId, @@ -364,7 +365,7 @@ public ResponseEntity updateUserStatus(@ApiParam(value = "${swagger.mscore */ @ResponseStatus(HttpStatus.NO_CONTENT) @ApiOperation(value = "${swagger.mscore.api.users.getOnboardedUsers}", notes = "${swagger.mscore.api.users.getOnboardedUsers}") - @GetMapping(value = "/onboarded-users") + @GetMapping(value = "/onboarded-users", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getOnboardedUsers(@ApiParam(value = "${swagger.mscore.users.userIds}", required = true) @RequestParam(value = "ids") List userIds) { log.debug("getOnboardedUsers - userIds: {}", userIds);