From b6c41c273d2dca37d0711007d5a1063f4a9a3127 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Mon, 5 Feb 2024 18:59:19 +0100 Subject: [PATCH 01/88] NOD-690: wip --- .../node/cfg_sync/repository/model/Cache.java | 27 +++++++++++ src/main/resources/application.properties | 47 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java new file mode 100644 index 0000000..9f762a4 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java @@ -0,0 +1,27 @@ +package it.gov.pagopa.node.cfg_sync.repository.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.persistence.Table; +import java.io.Serializable; +import java.time.LocalDateTime; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Table +public class Cache implements Serializable { + + private String id; + + private LocalDateTime time; + + private byte[] cache; + + private String version; + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b2a394c..96d4332 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,6 +4,7 @@ info.application.name=@project.name@ info.application.version=@project.version@ info.application.description=@project.description@ info.properties.environment=${ENV:azure} + # Actuator management.endpoints.web.exposure.include=health,info management.endpoints.jmx.exposure.include=health,info @@ -11,15 +12,61 @@ management.info.env.enabled=true management.endpoint.health.probes.enabled=true management.health.livenessState.enabled=true management.health.readinessState.enabled=true + # Openapi springdoc.writer-with-order-by-keys=true springdoc.writer-with-default-pretty-printer=true + # Server server.servlet.context-path=/ server.port=8080 + # Logging logging.level.root=${DEFAULT_LOGGING_LEVEL:INFO} logging.level.it.gov.pagopa=${APP_LOGGING_LEVEL:INFO} + # CORS configuration cors.configuration=${CORS_CONFIGURATION:'{"origins": ["*"], "methods": ["*"]}'} + +# Functionality +app.update.nodo.oracle.nexi=${APP_UPDATE_NODO_ORACLE_NEXI:true} +app.update.nodo.postgre.nexi=${APP_UPDATE_NODO_POSTGRE_NEXI:true} +app.update.nodo.postgre.pagopa=${APP_UPDATE_NODO_POSTGRE_PAGOA:true} + +# DB +nodo.oracle.nexi.datasource.url=${NODO_ORACLE_NEXI_DB_CONFIG_URL} +nodo.oracle.nexi.datasource.username=${NODO_ORACLE_NEXI_DB_CONFIG_USER} +nodo.oracle.nexi.datasource.password=${NODO_ORACLE_NEXI_DB_CONFIG_PASSWORD} +nodo.oracle.nexi.datasource.driver-class-name=${NODO_ORACLE_NEXI_DB_CONFIG_DRIVER} +nodo.oracle.nexi.datasource.hikari.connection-test-query=${NODO_ORACLE_NEXI_HEALTHCHECK_QUERY:select 1} + +nodo.postgre.nexi.datasource.url=${NODO_POSTGRE_NEXI_DB_CONFIG_URL} +nodo.postgre.nexi.datasource.username=${NODO_POSTGRE_NEXI_DB_CONFIG_USER} +nodo.postgre.nexi.datasource.password=${NODO_POSTGRE_NEXI_DB_CONFIG_PASSWORD} +nodo.postgre.nexi.datasource.driver-class-name=${NODO_POSTGRE_NEXI_DB_CONFIG_DRIVER} +nodo.postgre.nexi.datasource.hikari.connection-test-query=${NODO_POSTGRE_NEXI_HEALTHCHECK_QUERY:select 1} + +nodo.postgre.pagopa.datasource.url=${NODO_POSTGRE_PAGOPA_DB_CONFIG_URL} +nodo.postgre.pagopa.datasource.username=${NODO_POSTGRE_PAGOPA_DB_CONFIG_USER} +nodo.postgre.pagopa.datasource.password=${NODO_POSTGRE_PAGOPA_DB_CONFIG_PASSWORD} +nodo.postgre.pagopa.datasource.driver-class-name=${NODO_POSTGRE_PAGOPA_DB_CONFIG_DRIVER} +nodo.postgre.pagopa.datasource.hikari.connection-test-query=${NODO_POSTGRE_PAGOPA_HEALTHCHECK_QUERY:select 1} + +# Api Config Cache configuration +service.api-config-cache.host=${API_CONFIG_CACHE_HOST} +service.api-config-cache.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} + +# DB +spring.datasource.url=${DB_CONFIG_URL} +spring.datasource.username=${DB_CONFIG_USER} +spring.datasource.password=${DB_CONFIG_PASSWORD} +spring.datasource.driver-class-name=${DB_CONFIG_DRIVER} +spring.datasource.hikari.maxLifetime=30000 +spring.datasource.hikari.keepaliveTime=30000 +spring.datasource.hikari.connection-test-query=${HEALTHCHECK_QUERY:select 1} +spring.jpa.show-sql=false +spring.jpa.open-in-view=false +spring.database.id=${DATABASE_ID} +spring.jpa.hibernate.ddl-auto=none +spring.jpa.generate-ddl=false From 3547363d4131e60fbe930a7b1af45d4f5bd924cc Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Thu, 8 Feb 2024 01:17:41 +0100 Subject: [PATCH 02/88] NOD-690: wip --- openapi/openapi.json | 141 +++++++++++++++++- .../cfg_sync/client/ApiConfigCacheClient.java | 18 +++ .../cfg_sync/client/StandInManagerClient.java | 19 +++ .../config/EventHubClientConfiguration.java | 82 ++++++++++ .../controller/SyncCacheController.java | 101 +++++++++++++ .../node/cfg_sync/model/RefreshResponse.java | 20 +++ .../cfg_sync/model/TargetRefreshEnum.java | 13 ++ .../repository/CacheNodoPNexiRepository.java | 8 + .../config/NodoONexiConfiguration.java | 72 +++++++++ .../config/NodoPagoPAPConfiguration.java | 76 ++++++++++ .../node/cfg_sync/repository/model/Cache.java | 27 +--- .../model/nexi/CacheNexiOracle.java | 32 ++++ .../repository/model/pagopa/CachePagoPA.java | 32 ++++ .../nexi/CacheNodoONexiRepository.java | 8 + .../pagopa/CacheNodoPagoPAPRepository.java | 8 + .../service/ApiConfigCacheService.java | 86 +++++++++++ .../node/cfg_sync/service/CacheService.java | 9 ++ .../cfg_sync/service/CacheServiceFactory.java | 32 ++++ .../cfg_sync/service/CommonCacheService.java | 44 ++++++ .../service/StandInManagerCacheService.java | 51 +++++++ .../gov/pagopa/node/cfg_sync/util/Utils.java | 27 ++++ 21 files changed, 878 insertions(+), 28 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/client/ApiConfigCacheClient.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/client/StandInManagerClient.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/controller/SyncCacheController.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/model/RefreshResponse.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/model/TargetRefreshEnum.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/CacheNodoPNexiRepository.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheService.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheServiceFactory.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/service/StandInManagerCacheService.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/util/Utils.java diff --git a/openapi/openapi.json b/openapi/openapi.json index 40f63b3..d0d4522 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,7 +1,7 @@ { "openapi" : "3.0.1", "info" : { - "title" : "job-manager", + "title" : "cfg-sync", "description" : "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService" : "https://www.pagopa.gov.it/", "version" : "0.0.0" @@ -10,8 +10,145 @@ "url" : "http://localhost", "description" : "Generated server url" } ], - "paths" : { }, + "paths" : { + "/sync/v1/{target}" : { + "get" : { + "tags" : [ "Cache" ], + "summary" : "Sync target v1 config", + "operationId" : "cache", + "parameters" : [ { + "name" : "target", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string", + "enum" : [ "CONFIG", "STANDIN" ] + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + }, + "content" : { + "application/json" : { } + } + }, + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + }, + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + } + }, + "403" : { + "description" : "Forbidden", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + } + }, + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + } + }, + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + }, + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + } + }, + "security" : [ { + "ApiKey" : [ ] + } ] + }, + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" + } + } ] + } + }, "components" : { + "schemas" : { + "ProblemJson" : { + "type" : "object", + "properties" : { + "title" : { + "type" : "string", + "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + }, + "status" : { + "maximum" : 600, + "minimum" : 100, + "type" : "integer", + "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format" : "int32", + "example" : 200 + }, + "detail" : { + "type" : "string", + "description" : "A human readable explanation specific to this occurrence of the problem.", + "example" : "There was an error processing the request" + } + } + } + }, "securitySchemes" : { "ApiKey" : { "type" : "apiKey", diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/client/ApiConfigCacheClient.java b/src/main/java/it/gov/pagopa/node/cfg_sync/client/ApiConfigCacheClient.java new file mode 100644 index 0000000..5a53457 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/client/ApiConfigCacheClient.java @@ -0,0 +1,18 @@ +package it.gov.pagopa.node.cfg_sync.client; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import feign.Response; +import org.springframework.stereotype.Service; + +@Service +public interface ApiConfigCacheClient { + + @RequestLine("GET /cache") + @Headers({ + "Ocp-Apim-Subscription-Key: {subscriptionKey}" + }) + Response getCache(@Param String subscriptionKey); + +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/client/StandInManagerClient.java b/src/main/java/it/gov/pagopa/node/cfg_sync/client/StandInManagerClient.java new file mode 100644 index 0000000..3cec05f --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/client/StandInManagerClient.java @@ -0,0 +1,19 @@ +package it.gov.pagopa.node.cfg_sync.client; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; +import feign.Response; +import org.springframework.stereotype.Service; + +@Service +public interface StandInManagerClient { + + @RequestLine("GET /cache/refresh") + @Headers({ + "Content-Type: application/json", + "Ocp-Apim-Subscription-Key: {subscriptionKey}" + }) + Response refresh(@Param String subscriptionKey); + +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java new file mode 100644 index 0000000..1dcd163 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java @@ -0,0 +1,82 @@ +//package it.gov.pagopa.node.cfg_sync.config; +// +//import com.azure.identity.DefaultAzureCredentialBuilder; +//import com.azure.messaging.eventhubs.EventHubClientBuilder; +//import com.azure.messaging.eventhubs.EventHubProducerClient; +//import com.azure.messaging.eventhubs.EventProcessorClient; +//import com.azure.messaging.eventhubs.EventProcessorClientBuilder; +//import com.azure.messaging.eventhubs.checkpointstore.blob.BlobCheckpointStore; +//import com.azure.messaging.eventhubs.models.ErrorContext; +//import com.azure.messaging.eventhubs.models.EventContext; +//import com.azure.storage.blob.BlobContainerAsyncClient; +//import com.azure.storage.blob.BlobContainerClientBuilder; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +// +//@Configuration +//public class EventHubClientConfiguration { +// +// private static final Logger LOGGER = LoggerFactory.getLogger(EventHubClientConfiguration.class); +// private static final String CONSUMER_GROUP = "$Default"; +// private static final String STORAGE_ACCOUNT_ENDPOINT = "https://pagopadapiconfigfesa.blob.core.windows.net/"; +// private static final String STORAGE_CONTAINER_NAME = "cfg-sync"; +// +// @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") +// private String ndpConnectionString; +// +// @Value("${nodo-dei-pagamenti-cache-rx-name}") +// private String ndpEventHubName; +// +// @Bean +// EventHubClientBuilder eventHubClientBuilder() { +// return new EventHubClientBuilder().credential(ndpConnectionString, ndpEventHubName, +// new DefaultAzureCredentialBuilder() +// .build()); +// } +// +// @Bean +// BlobContainerClientBuilder blobContainerClientBuilder() { +// return new BlobContainerClientBuilder().credential(new DefaultAzureCredentialBuilder() +// .build()) +// .endpoint(STORAGE_ACCOUNT_ENDPOINT) +// .containerName(STORAGE_CONTAINER_NAME); +// } +// +// @Bean +// BlobContainerAsyncClient blobContainerAsyncClient(BlobContainerClientBuilder blobContainerClientBuilder) { +// return blobContainerClientBuilder.buildAsyncClient(); +// } +// +// @Bean +// EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient blobContainerAsyncClient) { +// return new EventProcessorClientBuilder().credential(ndpConnectionString, ndpEventHubName, +// new DefaultAzureCredentialBuilder() +// .build()) +// .consumerGroup(CONSUMER_GROUP) +// .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) +// .processEvent(EventHubClientConfiguration::processEvent) +// .processError(EventHubClientConfiguration::processError); +// } +// +// @Bean +// EventProcessorClient eventProcessorClient(EventProcessorClientBuilder eventProcessorClientBuilder) { +// return eventProcessorClientBuilder.buildEventProcessorClient(); +// } +// +// public static void processEvent(EventContext eventContext) { +// LOGGER.info("Processing event from partition {} with sequence number {} with body: {}", +// eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), +// eventContext.getEventData().getBodyAsString()); +// } +// +// public static void processError(ErrorContext errorContext) { +// LOGGER.info("Error occurred in partition processor for partition {}, {}", +// errorContext.getPartitionContext().getPartitionId(), +// errorContext.getThrowable().getMessage(), +// errorContext.getThrowable()); +// } +// +//} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/controller/SyncCacheController.java b/src/main/java/it/gov/pagopa/node/cfg_sync/controller/SyncCacheController.java new file mode 100644 index 0000000..bed3563 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/controller/SyncCacheController.java @@ -0,0 +1,101 @@ +package it.gov.pagopa.node.cfg_sync.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import it.gov.pagopa.node.cfg_sync.model.ProblemJson; +import it.gov.pagopa.node.cfg_sync.model.RefreshResponse; +import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfg_sync.service.CacheServiceFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.UUID; + +@Slf4j +@RestController +@RequestMapping("/sync") +@Validated +public class SyncCacheController { + + @Autowired + private CacheServiceFactory cacheServiceFactory; + + + @Operation( + summary = "Sync target v1 config", + security = {@SecurityRequirement(name = "ApiKey")}, + tags = { + "Cache", + }) + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + description = "OK", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE + )), + @ApiResponse( + responseCode = "400", + description = "Bad Request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "401", + description = "Unauthorized", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "403", + description = "Forbidden", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "429", + description = "Too many requests", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "500", + description = "Service unavailable", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))) + }) + @GetMapping( + value = "/v1/{target}", + produces = {MediaType.APPLICATION_JSON_VALUE}) + public ResponseEntity cache(@PathVariable TargetRefreshEnum target) { + + log.debug("Sync {} configuration", target.label); + CacheServiceFactory.getService(target).syncCache(); + + String requestId = UUID.randomUUID().toString(); + ZonedDateTime timestamp = ZonedDateTime.now(); + + HttpHeaders responseHeaders = new HttpHeaders(); + responseHeaders.set("X-REQUEST-ID", requestId); + responseHeaders.set("X-CACHE-TIMESTAMP", DateTimeFormatter.ISO_DATE_TIME.format(timestamp)); + + return ResponseEntity.ok() + .headers(responseHeaders) + .body(RefreshResponse.builder().timestamp(timestamp).id(requestId).build()); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/model/RefreshResponse.java b/src/main/java/it/gov/pagopa/node/cfg_sync/model/RefreshResponse.java new file mode 100644 index 0000000..7a6ba86 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/model/RefreshResponse.java @@ -0,0 +1,20 @@ +package it.gov.pagopa.node.cfg_sync.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.*; + +import javax.validation.constraints.NotNull; +import java.time.ZonedDateTime; + +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class RefreshResponse { + + @NotNull private String id; +// @NotNull private String version; + @NotNull private ZonedDateTime timestamp; +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/model/TargetRefreshEnum.java b/src/main/java/it/gov/pagopa/node/cfg_sync/model/TargetRefreshEnum.java new file mode 100644 index 0000000..0e7eb46 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/model/TargetRefreshEnum.java @@ -0,0 +1,13 @@ +package it.gov.pagopa.node.cfg_sync.model; + +public enum TargetRefreshEnum { + + config("api-config-cache"), + standin("stand-in-manager"); + + public final String label; + + private TargetRefreshEnum(String label) { + this.label = label; + } +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/CacheNodoPNexiRepository.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/CacheNodoPNexiRepository.java new file mode 100644 index 0000000..8983557 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/CacheNodoPNexiRepository.java @@ -0,0 +1,8 @@ +//package it.gov.pagopa.node.cfg_sync.repository; +// +//import it.gov.pagopa.node.cfg_sync.repository.model.Cache; +//import org.springframework.data.jpa.repository.JpaRepository; +//import org.springframework.stereotype.Repository; +// +//@Repository +//public interface CacheNodoPNexiRepository extends JpaRepository { } diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java new file mode 100644 index 0000000..3fcb751 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java @@ -0,0 +1,72 @@ +package it.gov.pagopa.node.cfg_sync.repository.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.*; +import org.springframework.core.env.Environment; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; + +import javax.sql.DataSource; +import java.util.HashMap; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfg_sync.repository.CacheNodoONexiRepository", + entityManagerFactoryRef = "nodoNexiOEntityManager", + transactionManagerRef = "nodoNexiOTransactionManager" +) +public class NodoONexiConfiguration { + @Autowired + private Environment env; + + @Bean + public LocalContainerEntityManagerFactoryBean nodoNexiOEntityManager() { + LocalContainerEntityManagerFactoryBean em + = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(nodoNexiODataSource()); + em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.CacheNexiO"); + + HibernateJpaVendorAdapter vendorAdapter + = new HibernateJpaVendorAdapter(); + em.setJpaVendorAdapter(vendorAdapter); + HashMap properties = new HashMap<>(); + properties.put("hibernate.hbm2ddl.auto", + env.getProperty("hibernate.hbm2ddl.auto")); + properties.put("hibernate.dialect", + env.getProperty("hibernate.dialect")); + em.setJpaPropertyMap(properties); + + return em; + } + + @Bean + public DataSource nodoNexiODataSource() { + DriverManagerDataSource dataSource + = new DriverManagerDataSource(); + dataSource.setDriverClassName( + env.getProperty("db.nodo.nexi.oracle.datasource.driverClassName")); + dataSource.setUrl(env.getProperty("db.nodo.nexi.oracle.datasource.url")); + dataSource.setUsername(env.getProperty("db.nodo.nexi.oracle.datasource.username")); + dataSource.setPassword(env.getProperty("db.nodo.nexi.oracle.datasource.password")); + + return dataSource; + } + + @Bean + public PlatformTransactionManager nodoNexiOTransactionManager() { + JpaTransactionManager transactionManager + = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory( + nodoNexiOEntityManager().getObject()); + + return transactionManager; + } +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java new file mode 100644 index 0000000..c01da37 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java @@ -0,0 +1,76 @@ +package it.gov.pagopa.node.cfg_sync.repository.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.*; +import org.springframework.core.env.Environment; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; + +import javax.sql.DataSource; +import java.util.HashMap; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfg_sync.repository.CacheNodoPagoPAPRepository", + entityManagerFactoryRef = "nodoPagoPAPEntityManager", + transactionManagerRef = "nodoPagoPAPTransactionManager" +) +public class NodoPagoPAPConfiguration { + + @Autowired + private Environment env; + + @Bean + @Primary + public LocalContainerEntityManagerFactoryBean nodoPagoPAPEntityManager() { + LocalContainerEntityManagerFactoryBean em + = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(nodoPagoPAPDataSource()); + em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.CachePagoPAP"); + + HibernateJpaVendorAdapter vendorAdapter + = new HibernateJpaVendorAdapter(); + em.setJpaVendorAdapter(vendorAdapter); + HashMap properties = new HashMap<>(); + properties.put("hibernate.hbm2ddl.auto", + env.getProperty("hibernate.hbm2ddl.auto")); + properties.put("hibernate.dialect", + env.getProperty("hibernate.dialect")); + em.setJpaPropertyMap(properties); + + return em; + } + + @Primary + @Bean + public DataSource nodoPagoPAPDataSource() { + DriverManagerDataSource dataSource + = new DriverManagerDataSource(); + dataSource.setDriverClassName( + env.getProperty("db.nodo.pagopa.postgre.datasource.driverClassName")); + dataSource.setUrl(env.getProperty("db.nodo.pagopa.postgre.datasource.url")); + dataSource.setUsername(env.getProperty("db.nodo.pagopa.postgre.datasource.username")); + dataSource.setPassword(env.getProperty("db.nodo.pagopa.postgre.datasource.password")); + + return dataSource; + } + + @Primary + @Bean + public PlatformTransactionManager nodoPagoPAPTransactionManager() { + JpaTransactionManager transactionManager + = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory( + nodoPagoPAPEntityManager().getObject()); + + return transactionManager; + } +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java index 9f762a4..0cf1482 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java @@ -1,27 +1,2 @@ -package it.gov.pagopa.node.cfg_sync.repository.model; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.persistence.Table; -import java.io.Serializable; -import java.time.LocalDateTime; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Table -public class Cache implements Serializable { - - private String id; - - private LocalDateTime time; - - private byte[] cache; - - private String version; - +package it.gov.pagopa.node.cfg_sync.repository.model;public class Cache { } diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java new file mode 100644 index 0000000..a3ef499 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java @@ -0,0 +1,32 @@ +package it.gov.pagopa.node.cfg_sync.repository.nexi.model; + +import lombok.*; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.time.LocalDateTime; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Entity +@Table(name = "cache") +public class CacheNexiOracle implements Serializable { + + @Id + @Column(name="ID", columnDefinition = "VARCHAR", length = 20) + private String id; + + private LocalDateTime time; + + private byte[] cache; + + @Column(name="VERSION", columnDefinition = "VARCHAR", length = 32) + private String version; + +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java new file mode 100644 index 0000000..a5e51ce --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java @@ -0,0 +1,32 @@ +package it.gov.pagopa.node.cfg_sync.repository.pagopa.model; + +import lombok.*; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.time.LocalDateTime; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Entity +@Table(name = "cache") +public class CachePagoPA implements Serializable { + + @Id + @Column(name="ID", columnDefinition = "VARCHAR", length = 20) + private String id; + + private LocalDateTime time; + + private byte[] cache; + + @Column(name="VERSION", columnDefinition = "VARCHAR", length = 32) + private String version; + +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java new file mode 100644 index 0000000..af95ed3 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.node.cfg_sync.repository; + +import it.gov.pagopa.node.cfg_sync.repository.model.CacheNexiOracle; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CacheNodoONexiRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java new file mode 100644 index 0000000..04ef356 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.node.cfg_sync.repository; + +import it.gov.pagopa.node.cfg_sync.repository.model.CachePagoPA; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CacheNodoPagoPAPRepository extends JpaRepository { } diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java new file mode 100644 index 0000000..d27c9da --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java @@ -0,0 +1,86 @@ +package it.gov.pagopa.node.cfg_sync.service; + +import feign.Feign; +import feign.FeignException; +import feign.Response; +import it.gov.pagopa.node.cfg_sync.client.ApiConfigCacheClient; +import it.gov.pagopa.node.cfg_sync.exception.AppError; +import it.gov.pagopa.node.cfg_sync.exception.AppException; +import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfg_sync.repository.CacheNodoPagoPAPRepository; +import it.gov.pagopa.node.cfg_sync.repository.model.Cache; +import it.gov.pagopa.node.cfg_sync.repository.model.CachePagoPAP; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.io.IOException; +import java.time.ZonedDateTime; +import java.util.Collection; +import java.util.Map; + +@Component +@Slf4j +public class ApiConfigCacheService extends CommonCacheService implements CacheService { + + private static final String HEADER_CACHE_ID = "X-CACHE-ID"; + private static final String HEADER_CACHE_TIMESTAMP = "X-CACHE-TIMESTAMP"; + private static final String HEADER_CACHE_VERSION = "X-CACHE-VERSION"; + + private final ApiConfigCacheClient apiConfigCacheClient; + + @Value("${service.api-config-cache.enabled}") private boolean enabled; + @Value("${service.api-config-cache.subscriptionKey}") private String subscriptionKey; + + @Autowired + private CacheNodoPagoPAPRepository cacheNodoPagoPAPRepository; + + public ApiConfigCacheService(@Value("${service.api-config-cache.host}") String apiConfigCacheUrl) { + apiConfigCacheClient = Feign.builder().target(ApiConfigCacheClient.class, apiConfigCacheUrl); + } + + @Override + public TargetRefreshEnum getType() { + return TargetRefreshEnum.config; + } + + @Override + @Transactional("nodoPagoPAPTransactionManager") + public void syncCache() { + try { + if( !enabled ) { + throw new AppException(AppError.SERVICE_DISABLED, getType()); + } + log.debug("SyncService api-config-cache get cache"); + Response response = apiConfigCacheClient.getCache(subscriptionKey); + int httpResponseCode = response.status(); + if (httpResponseCode != HttpStatus.OK.value()) { + log.error("SyncService api-config-cache get cache error - result: httpStatusCode[{}]", httpResponseCode); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } + log.info("SyncService api-config-cache get cache successful"); + + Map> headers = response.headers(); + if( headers.isEmpty() ) { + log.error("SyncService api-config-cache get cache error - empty header"); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } + String cacheId = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_ID); + String cacheTimestamp = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_TIMESTAMP); + String cacheVersion = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_VERSION); + + CachePagoPAP cache = (CachePagoPAP) composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); + cacheNodoPagoPAPRepository.save(cache); + + } catch (FeignException.GatewayTimeout e) { + log.error("SyncService api-config-cache get cache error: Gateway timeout", e); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } catch (IOException e) { + log.error("SyncService api-config-cache get cache error", e); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } + } +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheService.java b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheService.java new file mode 100644 index 0000000..bb458a0 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheService.java @@ -0,0 +1,9 @@ +package it.gov.pagopa.node.cfg_sync.service; + +import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; + +public interface CacheService { + + TargetRefreshEnum getType(); + void syncCache(); +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheServiceFactory.java b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheServiceFactory.java new file mode 100644 index 0000000..ff842d1 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheServiceFactory.java @@ -0,0 +1,32 @@ +package it.gov.pagopa.node.cfg_sync.service; + +import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class CacheServiceFactory { + + @Autowired + private List services; + + private static final Map myServiceCache = new HashMap<>(); + + @PostConstruct + public void initMyServiceCache() { + for(CacheService service : services) { + myServiceCache.put(service.getType(), service); + } + } + + public static CacheService getService(TargetRefreshEnum target) { + CacheService service = myServiceCache.get(target); + if(service == null) throw new RuntimeException("Unknown service: " + target.label); + return service; + } +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java new file mode 100644 index 0000000..96fe949 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java @@ -0,0 +1,44 @@ +package it.gov.pagopa.node.cfg_sync.service; + +import it.gov.pagopa.node.cfg_sync.exception.AppError; +import it.gov.pagopa.node.cfg_sync.exception.AppException; +import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfg_sync.repository.model.Cache; +import it.gov.pagopa.node.cfg_sync.util.Utils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +@Slf4j +public class CommonCacheService { + + @Value("${app.trimCacheColumn}") + private boolean trimCacheColumn; + + protected Cache composeCache(String cacheId, LocalDateTime timestamp, String cacheVersion, byte[] cache) throws IOException { + String version = trimCacheColumn ? + (String) Utils.trimValueColumn(Cache.class, "version", cacheVersion) : cacheVersion; + + return Cache + .builder() + .id(cacheId) + .time(timestamp) + .version(version) + .cache(Utils.zipContent(cache)).build(); + } + + protected Object getHeaderParameter(TargetRefreshEnum target, Map> headers, String key) { + List valueList = headers.get(key).stream().toList(); + if(valueList.isEmpty()) { + log.error("SyncService {} get cache error - empty parameter '{}'", target, key); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } + return valueList.get(0); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/StandInManagerCacheService.java b/src/main/java/it/gov/pagopa/node/cfg_sync/service/StandInManagerCacheService.java new file mode 100644 index 0000000..e5e3aff --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/service/StandInManagerCacheService.java @@ -0,0 +1,51 @@ +package it.gov.pagopa.node.cfg_sync.service; + +import feign.Feign; +import feign.FeignException; +import it.gov.pagopa.node.cfg_sync.client.StandInManagerClient; +import it.gov.pagopa.node.cfg_sync.exception.AppError; +import it.gov.pagopa.node.cfg_sync.exception.AppException; +import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class StandInManagerCacheService extends CommonCacheService implements CacheService { + + @Value("${service.stand-in-manager.enabled}") private boolean enabled; + @Value("${service.stand-in-manager.subscriptionKey}") private String subscriptionKey; + + private final StandInManagerClient standInManagerClient; + + public StandInManagerCacheService(@Value("${service.stand-in-manager.host}") String standInManagerUrl) { + standInManagerClient = Feign.builder().target(StandInManagerClient.class, standInManagerUrl); + } + + @Override + public TargetRefreshEnum getType() { + return TargetRefreshEnum.standin; + } + + @Override + public void syncCache() { + try { + if( !enabled ) { + throw new AppException(AppError.SERVICE_DISABLED, getType()); + } + log.debug("SyncService stand-in-manager get cache"); +// Response response = standInManagerClient.refresh(subscriptionKey); +// int httpResponseCode = response.status(); +// if (httpResponseCode != HttpStatus.OK.value()) { +// log.error("SyncService stand-in-manager get cache error - result: httpStatusCode[{}]", httpResponseCode); +// } else { +// log.info("SyncService stand-in-manager get cache successful"); +// } + } catch (FeignException.GatewayTimeout e) { + log.error("SyncService stand-in-manager get cache error: Gateway timeout", e); + } catch (FeignException e) { + log.error("SyncService stand-in-manager get cache error", e); + } + } +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/util/Utils.java b/src/main/java/it/gov/pagopa/node/cfg_sync/util/Utils.java new file mode 100644 index 0000000..259bbf5 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/util/Utils.java @@ -0,0 +1,27 @@ +package it.gov.pagopa.node.cfg_sync.util; + +import javax.persistence.Column; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.zip.DeflaterOutputStream; + +public class Utils { + + public static byte[] zipContent(byte[] datas) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + DeflaterOutputStream dos = new DeflaterOutputStream(out); + dos.write(datas); + dos.close(); + return out.toByteArray(); + } + + public static Object trimValueColumn(Class clazz, String columnName, String value) { + try { + int length = clazz.getDeclaredField(columnName).getAnnotation(Column.class).length(); + return value.substring(0, length); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + +} From 377f02d1b4af5fe514f6e32e7d9c0aea11231e45 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Thu, 8 Feb 2024 01:18:33 +0100 Subject: [PATCH 03/88] NOD-690: wip --- .gitignore | 3 ++ helm/values-dev.yaml | 17 ++++++ helm/values-prod.yaml | 3 +- helm/values-uat.yaml | 2 + pom.xml | 52 ++++++++++++++++++- .../gov/pagopa/node/cfg_sync/Application.java | 29 ++++++++++- .../node/cfg_sync/exception/AppError.java | 6 ++- .../config/NodoONexiConfiguration.java | 4 +- .../config/NodoPagoPAPConfiguration.java | 4 +- .../node/cfg_sync/repository/model/Cache.java | 31 ++++++++++- .../model/nexi/CacheNexiOracle.java | 20 ++----- .../repository/model/pagopa/CachePagoPA.java | 20 ++----- .../nexi/CacheNodoONexiRepository.java | 4 +- .../pagopa/CacheNodoPagoPAPRepository.java | 4 +- .../service/ApiConfigCacheService.java | 9 ++-- .../cfg_sync/service/CommonCacheService.java | 7 +-- .../resources/application-local.properties | 36 +++++++++++++ src/main/resources/application.properties | 38 +++----------- 18 files changed, 203 insertions(+), 86 deletions(-) diff --git a/.gitignore b/.gitignore index 79d7c43..46a7764 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ hs_err_pid* # Helm /helm/charts/* **/.terraform/ + +# Others +**/.DS_Store diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 1894bc4..24c105c 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -67,6 +67,19 @@ microservice-chart: APP_LOGGING_LEVEL: 'DEBUG' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' + CACHET_TX_NAME: "nodo-dei-pagamenti-cache" + + NODO_ORACLE_NEXI_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + NODO_ORACLE_NEXI_DB_CONFIG_USER: "cfg" + NODO_ORACLE_NEXI_DB_CONFIG_DRIVER: "org.postgresql.Driver" + + NODO_POSTGRE_NEXI_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + NODO_POSTGRE_NEXI_DB_CONFIG_USER: "cfg" + NODO_POSTGRE_NEXI_DB_CONFIG_DRIVER: "org.postgresql.Driver" + + NODO_POSTGRE_PAGOPA_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + NODO_POSTGRE_PAGOPA_DB_CONFIG_USER: "cfg" + NODO_POSTGRE_PAGOPA_DB_CONFIG_DRIVER: "org.postgresql.Driver" OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" @@ -78,6 +91,10 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' + CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key" + NODO_ORACLE_NEXI_DB_CONFIG_PASSWORD: "oracle-db-cfg-password" + NODO_POSTGRE_NEXI_DB_CONFIG_PASSWORD: "postgresql-db-cfg-password" + NODO_POSTGRE_PAGOPA_DB_CONFIG_PASSWORD: "db-cfg-password" OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token keyvault: name: "pagopa-d-nodo-kv" diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 3ad73e0..4baba44 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -67,7 +67,7 @@ microservice-chart: APP_LOGGING_LEVEL: 'DEBUG' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - + CACHET_TX_NAME: "nodo-dei-pagamenti-cache" OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=prod" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" @@ -78,6 +78,7 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string' + CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key" OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token keyvault: name: "pagopa-d-nodo-kv" diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index b35bf0c..168b4a2 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -67,6 +67,7 @@ microservice-chart: APP_LOGGING_LEVEL: 'DEBUG' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' + CACHET_TX_NAME: "nodo-dei-pagamenti-cache" OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=uat" @@ -78,6 +79,7 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-u-connection-string' + CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key" OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token keyvault: name: "pagopa-d-nodo-kv" diff --git a/pom.xml b/pom.xml index 8760353..0d22ee5 100644 --- a/pom.xml +++ b/pom.xml @@ -20,8 +20,23 @@ 17 17 17 + 12.1 + 42.5.4 + 21.4.0.0 + + + + + + + + + + + + org.springframework.boot @@ -58,12 +73,22 @@ org.springframework.boot spring-boot-starter-data-jpa - org.springframework.data spring-data-jpa + + org.postgresql + postgresql + ${postgresql.version} + + + com.oracle.database.jdbc + ojdbc8 + ${oracle.version} + + org.springframework.boot spring-boot-starter-cache @@ -73,6 +98,31 @@ caffeine + + + + + + + + + io.github.openfeign + feign-core + ${feign-version} + + + + io.github.openfeign + feign-jackson + ${feign-version} + + + + io.github.openfeign + feign-mock + ${feign-version} + + org.springdoc diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java b/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java index 0b27ab2..b7f334e 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java @@ -1,13 +1,40 @@ package it.gov.pagopa.node.cfg_sync; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; +import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; @SpringBootApplication -public class Application { +@EnableAutoConfiguration(exclude = { + DataSourceAutoConfiguration.class, + DataSourceTransactionManagerAutoConfiguration.class, + HibernateJpaAutoConfiguration.class}) +@Slf4j +public class Application implements CommandLineRunner { + +// private final EventProcessorClient eventProcessorClient; +// +// public Application(EventProcessorClient eventProcessorClient) { +// this.eventProcessorClient = eventProcessorClient; +// } public static void main(String[] args) { SpringApplication.run(Application.class, args); } + @Override + public void run(String... args) throws Exception { +// eventProcessorClient.start(); +// // Wait for the processor client to be ready +// TimeUnit.SECONDS.sleep(10); +// +// log.info("Stopping and closing the processor"); +// eventProcessorClient.stop(); + } + } diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppError.java b/src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppError.java index d4c8c7e..42d0b1c 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppError.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppError.java @@ -7,7 +7,11 @@ @Getter public enum AppError { INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "Internal Server Error", - "Something was wrong"); + "Something was wrong"), + SERVICE_DISABLED( + HttpStatus.BAD_REQUEST, + "Target service disabled", + "Target service %s disabled"); public final HttpStatus httpStatus; public final String title; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java index 3fcb751..9b816d2 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java @@ -19,7 +19,7 @@ @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) }) @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfg_sync.repository.CacheNodoONexiRepository", + basePackages = "it.gov.pagopa.node.cfg_sync.repository.nexi", entityManagerFactoryRef = "nodoNexiOEntityManager", transactionManagerRef = "nodoNexiOTransactionManager" ) @@ -32,7 +32,7 @@ public LocalContainerEntityManagerFactoryBean nodoNexiOEntityManager() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(nodoNexiODataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.CacheNexiO"); + em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.nexi"); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java index c01da37..a0eb2d5 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java @@ -19,7 +19,7 @@ @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) }) @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfg_sync.repository.CacheNodoPagoPAPRepository", + basePackages = "it.gov.pagopa.node.cfg_sync.repository.pagopa", entityManagerFactoryRef = "nodoPagoPAPEntityManager", transactionManagerRef = "nodoPagoPAPTransactionManager" ) @@ -34,7 +34,7 @@ public LocalContainerEntityManagerFactoryBean nodoPagoPAPEntityManager() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(nodoPagoPAPDataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.CachePagoPAP"); + em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.pagopa"); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java index 0cf1482..fd9cc84 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java @@ -1,2 +1,31 @@ -package it.gov.pagopa.node.cfg_sync.repository.model;public class Cache { +package it.gov.pagopa.node.cfg_sync.repository.model; + +import antlr.ANTLRParser; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import java.io.Serializable; +import java.time.LocalDateTime; + + +@NoArgsConstructor +@AllArgsConstructor +@MappedSuperclass +public class Cache implements Serializable { + + @Id + @Column(name="ID", columnDefinition = "VARCHAR", length = 20) + private String id; + + private LocalDateTime time; + + private byte[] cache; + + @Column(name="VERSION", columnDefinition = "VARCHAR", length = 32) + private String version; + } diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java index a3ef499..1324ce1 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java @@ -1,6 +1,8 @@ -package it.gov.pagopa.node.cfg_sync.repository.nexi.model; +package it.gov.pagopa.node.cfg_sync.repository.model.nexi; +import it.gov.pagopa.node.cfg_sync.repository.model.Cache; import lombok.*; +import lombok.experimental.SuperBuilder; import javax.persistence.Column; import javax.persistence.Entity; @@ -11,22 +13,8 @@ @Getter @Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder @Entity @Table(name = "cache") -public class CacheNexiOracle implements Serializable { - - @Id - @Column(name="ID", columnDefinition = "VARCHAR", length = 20) - private String id; - - private LocalDateTime time; - - private byte[] cache; - - @Column(name="VERSION", columnDefinition = "VARCHAR", length = 32) - private String version; +public class CacheNexiOracle extends Cache { } diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java index a5e51ce..b84dc37 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java @@ -1,6 +1,8 @@ -package it.gov.pagopa.node.cfg_sync.repository.pagopa.model; +package it.gov.pagopa.node.cfg_sync.repository.model.pagopa; +import it.gov.pagopa.node.cfg_sync.repository.model.Cache; import lombok.*; +import lombok.experimental.SuperBuilder; import javax.persistence.Column; import javax.persistence.Entity; @@ -11,22 +13,8 @@ @Getter @Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder @Entity @Table(name = "cache") -public class CachePagoPA implements Serializable { - - @Id - @Column(name="ID", columnDefinition = "VARCHAR", length = 20) - private String id; - - private LocalDateTime time; - - private byte[] cache; - - @Column(name="VERSION", columnDefinition = "VARCHAR", length = 32) - private String version; +public class CachePagoPA extends Cache { } diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java index af95ed3..781315b 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java @@ -1,6 +1,6 @@ -package it.gov.pagopa.node.cfg_sync.repository; +package it.gov.pagopa.node.cfg_sync.repository.nexi; -import it.gov.pagopa.node.cfg_sync.repository.model.CacheNexiOracle; +import it.gov.pagopa.node.cfg_sync.repository.model.nexi.CacheNexiOracle; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java index 04ef356..30331f7 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java @@ -1,6 +1,6 @@ -package it.gov.pagopa.node.cfg_sync.repository; +package it.gov.pagopa.node.cfg_sync.repository.pagopa; -import it.gov.pagopa.node.cfg_sync.repository.model.CachePagoPA; +import it.gov.pagopa.node.cfg_sync.repository.model.pagopa.CachePagoPA; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java index d27c9da..812dccd 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java @@ -7,9 +7,9 @@ import it.gov.pagopa.node.cfg_sync.exception.AppError; import it.gov.pagopa.node.cfg_sync.exception.AppException; import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; -import it.gov.pagopa.node.cfg_sync.repository.CacheNodoPagoPAPRepository; import it.gov.pagopa.node.cfg_sync.repository.model.Cache; -import it.gov.pagopa.node.cfg_sync.repository.model.CachePagoPAP; +import it.gov.pagopa.node.cfg_sync.repository.model.pagopa.CachePagoPA; +import it.gov.pagopa.node.cfg_sync.repository.pagopa.CacheNodoPagoPAPRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -72,13 +72,14 @@ public void syncCache() { String cacheTimestamp = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_TIMESTAMP); String cacheVersion = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_VERSION); - CachePagoPAP cache = (CachePagoPAP) composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); + CachePagoPA cache = (CachePagoPA) composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); cacheNodoPagoPAPRepository.save(cache); } catch (FeignException.GatewayTimeout e) { log.error("SyncService api-config-cache get cache error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); - } catch (IOException e) { + } + catch (IOException e) { log.error("SyncService api-config-cache get cache error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java index 96fe949..292cb6b 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java @@ -24,12 +24,7 @@ protected Cache composeCache(String cacheId, LocalDateTime timestamp, String cac String version = trimCacheColumn ? (String) Utils.trimValueColumn(Cache.class, "version", cacheVersion) : cacheVersion; - return Cache - .builder() - .id(cacheId) - .time(timestamp) - .version(version) - .cache(Utils.zipContent(cache)).build(); + return new Cache(cacheId, timestamp, Utils.zipContent(cache), version); } protected Object getHeaderParameter(TargetRefreshEnum target, Map> headers, String key) { diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 1e89894..1d996ce 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -5,3 +5,39 @@ logging.level.root=INFO logging.level.it.gov.pagopa=DEBUG # CORS configuration cors.configuration={"origins": ["*"], "methods": ["*"]} + +# Functionality +app.update.nodo.oracle.nexi=true +app.update.nodo.postgre.nexi=true +app.update.nodo.postgre.pagopa=true +app.trimCacheColumn=true + +# Api Config Cache configuration +service.api-config-cache.enabled=false +service.api-config-cache.host=https://api.dev.platform.pagopa.it/api-config-cache/p/v1 +service.api-config-cache.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} + +# Stand-in Manager configuration +service.stand-in-manager.enabled=true +service.stand-in-manager.host=https://api.dev.platform.pagopa.it/technical-support/stand-in/api/v1 +service.stand-in-manager.subscriptionKey=${STAND-IN_MANAGER_SUBSCRIPTION_KEY} + +nodo-dei-pagamenti-cache-rx-connection-string=${NODO_CACHE_RX_CONNECTION_STRING} +nodo-dei-pagamenti-cache-rx-name=nodo-dei-pagamenti-cache + +stand-in-rx-connection-string=${STAND-IN-MANAGER_RX_CONNECTION_STRING} +stand-in-rx-name=nodo-dei-pagamenti-stand-in + +# DB +spring.sql.init.continue-on-error=true +spring.datasource.auto-commit=false + +db.nodo.pagopa.postgre.datasource.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg +db.nodo.pagopa.postgre.datasource.username=cfg +db.nodo.pagopa.postgre.datasource.password=${DB_NODO_PAGOPA_POSTGRE_PASSWORD} +db.nodo.pagopa.postgre.datasource.driverClassName=org.postgresql.Driver + +db.nodo.nexi.oracle.datasource.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg +db.nodo.nexi.oracle.datasource.username=cfg +db.nodo.nexi.oracle.datasource.password=${DB_NODO_NEXI_ORACLE_PASSWORD} +db.nodo.nexi.oracle.datasource.driverClassName=oracle.jdbc.driver.OracleDriver \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 96d4332..32d3677 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -33,40 +33,16 @@ cors.configuration=${CORS_CONFIGURATION:'{"origins": ["*"], "methods": ["*"]}'} app.update.nodo.oracle.nexi=${APP_UPDATE_NODO_ORACLE_NEXI:true} app.update.nodo.postgre.nexi=${APP_UPDATE_NODO_POSTGRE_NEXI:true} app.update.nodo.postgre.pagopa=${APP_UPDATE_NODO_POSTGRE_PAGOA:true} - -# DB -nodo.oracle.nexi.datasource.url=${NODO_ORACLE_NEXI_DB_CONFIG_URL} -nodo.oracle.nexi.datasource.username=${NODO_ORACLE_NEXI_DB_CONFIG_USER} -nodo.oracle.nexi.datasource.password=${NODO_ORACLE_NEXI_DB_CONFIG_PASSWORD} -nodo.oracle.nexi.datasource.driver-class-name=${NODO_ORACLE_NEXI_DB_CONFIG_DRIVER} -nodo.oracle.nexi.datasource.hikari.connection-test-query=${NODO_ORACLE_NEXI_HEALTHCHECK_QUERY:select 1} - -nodo.postgre.nexi.datasource.url=${NODO_POSTGRE_NEXI_DB_CONFIG_URL} -nodo.postgre.nexi.datasource.username=${NODO_POSTGRE_NEXI_DB_CONFIG_USER} -nodo.postgre.nexi.datasource.password=${NODO_POSTGRE_NEXI_DB_CONFIG_PASSWORD} -nodo.postgre.nexi.datasource.driver-class-name=${NODO_POSTGRE_NEXI_DB_CONFIG_DRIVER} -nodo.postgre.nexi.datasource.hikari.connection-test-query=${NODO_POSTGRE_NEXI_HEALTHCHECK_QUERY:select 1} - -nodo.postgre.pagopa.datasource.url=${NODO_POSTGRE_PAGOPA_DB_CONFIG_URL} -nodo.postgre.pagopa.datasource.username=${NODO_POSTGRE_PAGOPA_DB_CONFIG_USER} -nodo.postgre.pagopa.datasource.password=${NODO_POSTGRE_PAGOPA_DB_CONFIG_PASSWORD} -nodo.postgre.pagopa.datasource.driver-class-name=${NODO_POSTGRE_PAGOPA_DB_CONFIG_DRIVER} -nodo.postgre.pagopa.datasource.hikari.connection-test-query=${NODO_POSTGRE_PAGOPA_HEALTHCHECK_QUERY:select 1} +app.trimCacheColumn=${APP_TRIM_CACHE_COLUMN:true} # Api Config Cache configuration service.api-config-cache.host=${API_CONFIG_CACHE_HOST} service.api-config-cache.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} +#EventHub +nodo-dei-pagamenti-cache-rx-connection-string=${CACHE_RX_CONNECTION_STRING} +nodo-dei-pagamenti-cache-rx-name=${CACHET_RX_NAME:nodo-dei-pagamenti-cache} + # DB -spring.datasource.url=${DB_CONFIG_URL} -spring.datasource.username=${DB_CONFIG_USER} -spring.datasource.password=${DB_CONFIG_PASSWORD} -spring.datasource.driver-class-name=${DB_CONFIG_DRIVER} -spring.datasource.hikari.maxLifetime=30000 -spring.datasource.hikari.keepaliveTime=30000 -spring.datasource.hikari.connection-test-query=${HEALTHCHECK_QUERY:select 1} -spring.jpa.show-sql=false -spring.jpa.open-in-view=false -spring.database.id=${DATABASE_ID} -spring.jpa.hibernate.ddl-auto=none -spring.jpa.generate-ddl=false +spring.sql.init.continue-on-error=${APP_INIT_CONTINUE_ON_ERROR:false} +spring.datasource.auto-commit=${DATASOURCE_AUTO_COMMIT:false} From a3f386c02e6aec7494b673fb59e06fa2990dc8a6 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Thu, 8 Feb 2024 10:51:38 +0100 Subject: [PATCH 04/88] NOD-690: wip --- pom.xml | 28 +-- .../gov/pagopa/node/cfg_sync/Application.java | 72 ++++---- .../cfg_sync/EventHubClientApplication.java | 42 +++++ .../config/EventHubClientConfiguration.java | 162 +++++++++--------- .../EventHubProcessorClientConfiguration.java | 28 +++ .../node/cfg_sync/config/LoggingAspect.java | 2 +- .../config/MessageReceiveConfiguration.java | 53 ++++++ .../resources/application-local.properties | 2 +- 8 files changed, 266 insertions(+), 123 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/EventHubClientApplication.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubProcessorClientConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/config/MessageReceiveConfiguration.java diff --git a/pom.xml b/pom.xml index 0d22ee5..1127e43 100644 --- a/pom.xml +++ b/pom.xml @@ -25,17 +25,17 @@ 21.4.0.0 - - - - - - - - - - - + + + + com.azure.spring + spring-cloud-azure-dependencies + 4.5.0 + pom + import + + + @@ -98,11 +98,15 @@ caffeine - + + + com.azure.spring + spring-cloud-azure-starter-integration-eventhubs + diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java b/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java index b7f334e..f944f26 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java @@ -1,40 +1,52 @@ -package it.gov.pagopa.node.cfg_sync; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; - -@SpringBootApplication -@EnableAutoConfiguration(exclude = { - DataSourceAutoConfiguration.class, - DataSourceTransactionManagerAutoConfiguration.class, - HibernateJpaAutoConfiguration.class}) -@Slf4j -public class Application implements CommandLineRunner { - +//package it.gov.pagopa.node.cfg_sync; +// +//import com.azure.messaging.eventhubs.EventData; +//import com.azure.messaging.eventhubs.EventHubProducerClient; +//import com.azure.messaging.eventhubs.EventProcessorClient; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.boot.CommandLineRunner; +//import org.springframework.boot.SpringApplication; +//import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +//import org.springframework.boot.autoconfigure.SpringBootApplication; +//import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +//import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; +//import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; +// +//import java.util.Collections; +//import java.util.concurrent.TimeUnit; +// +//@SpringBootApplication +//@EnableAutoConfiguration(exclude = { +// DataSourceAutoConfiguration.class, +// DataSourceTransactionManagerAutoConfiguration.class, +// HibernateJpaAutoConfiguration.class}) +//@Slf4j +//public class Application implements CommandLineRunner { +// +//// private final EventHubProducerClient eventHubProducerClient; // private final EventProcessorClient eventProcessorClient; // -// public Application(EventProcessorClient eventProcessorClient) { +// public Application(//EventHubProducerClient eventHubProducerClient, +// EventProcessorClient eventProcessorClient) { +//// this.eventHubProducerClient = eventHubProducerClient; // this.eventProcessorClient = eventProcessorClient; // } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - - @Override - public void run(String... args) throws Exception { +// +// public static void main(String[] args) { +// SpringApplication.run(Application.class, args); +// } +// +// @Override +// public void run(String... args) throws Exception { // eventProcessorClient.start(); // // Wait for the processor client to be ready // TimeUnit.SECONDS.sleep(10); // +//// eventHubProducerClient.send(Collections.singletonList(new EventData("Hello World"))); +//// log.info("Successfully sent a message to Event Hubs."); +//// eventHubProducerClient.close(); // log.info("Stopping and closing the processor"); // eventProcessorClient.stop(); - } - -} +// } +// +//} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/EventHubClientApplication.java b/src/main/java/it/gov/pagopa/node/cfg_sync/EventHubClientApplication.java new file mode 100644 index 0000000..1033620 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/EventHubClientApplication.java @@ -0,0 +1,42 @@ +package it.gov.pagopa.node.cfg_sync; + +import com.azure.messaging.eventhubs.EventProcessorClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import java.util.concurrent.TimeUnit; + +@SpringBootApplication +public class EventHubClientApplication implements CommandLineRunner { + + private static final Logger LOGGER = LoggerFactory.getLogger(EventHubClientApplication.class); +// private final EventHubProducerClient eventHubProducerClient; + private final EventProcessorClient eventProcessorClient; + + public EventHubClientApplication(//EventHubProducerClient eventHubProducerClient, + EventProcessorClient eventProcessorClient) { +// this.eventHubProducerClient = eventHubProducerClient; + this.eventProcessorClient = eventProcessorClient; + } + + public static void main(String[] args) { + SpringApplication.run(EventHubClientApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + eventProcessorClient.start(); + // Wait for the processor client to be ready + TimeUnit.SECONDS.sleep(10); + +// eventHubProducerClient.send(Collections.singletonList(new EventData("Hello World"))); +// LOGGER.info("Successfully sent a message to Event Hubs."); +// eventHubProducerClient.close(); + LOGGER.info("Stopping and closing the processor"); + eventProcessorClient.stop(); + } + +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java index 1dcd163..a3c4aa1 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java @@ -1,82 +1,86 @@ -//package it.gov.pagopa.node.cfg_sync.config; -// -//import com.azure.identity.DefaultAzureCredentialBuilder; -//import com.azure.messaging.eventhubs.EventHubClientBuilder; -//import com.azure.messaging.eventhubs.EventHubProducerClient; -//import com.azure.messaging.eventhubs.EventProcessorClient; -//import com.azure.messaging.eventhubs.EventProcessorClientBuilder; -//import com.azure.messaging.eventhubs.checkpointstore.blob.BlobCheckpointStore; -//import com.azure.messaging.eventhubs.models.ErrorContext; -//import com.azure.messaging.eventhubs.models.EventContext; -//import com.azure.storage.blob.BlobContainerAsyncClient; -//import com.azure.storage.blob.BlobContainerClientBuilder; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Value; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -// -//@Configuration -//public class EventHubClientConfiguration { -// -// private static final Logger LOGGER = LoggerFactory.getLogger(EventHubClientConfiguration.class); -// private static final String CONSUMER_GROUP = "$Default"; -// private static final String STORAGE_ACCOUNT_ENDPOINT = "https://pagopadapiconfigfesa.blob.core.windows.net/"; -// private static final String STORAGE_CONTAINER_NAME = "cfg-sync"; -// -// @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") -// private String ndpConnectionString; -// -// @Value("${nodo-dei-pagamenti-cache-rx-name}") -// private String ndpEventHubName; -// -// @Bean -// EventHubClientBuilder eventHubClientBuilder() { -// return new EventHubClientBuilder().credential(ndpConnectionString, ndpEventHubName, -// new DefaultAzureCredentialBuilder() -// .build()); -// } -// -// @Bean -// BlobContainerClientBuilder blobContainerClientBuilder() { -// return new BlobContainerClientBuilder().credential(new DefaultAzureCredentialBuilder() -// .build()) -// .endpoint(STORAGE_ACCOUNT_ENDPOINT) -// .containerName(STORAGE_CONTAINER_NAME); -// } -// -// @Bean -// BlobContainerAsyncClient blobContainerAsyncClient(BlobContainerClientBuilder blobContainerClientBuilder) { -// return blobContainerClientBuilder.buildAsyncClient(); -// } -// +package it.gov.pagopa.node.cfg_sync.config; + +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.messaging.eventhubs.EventHubClientBuilder; +import com.azure.messaging.eventhubs.EventHubProducerClient; +import com.azure.messaging.eventhubs.EventProcessorClient; +import com.azure.messaging.eventhubs.EventProcessorClientBuilder; +import com.azure.messaging.eventhubs.checkpointstore.blob.BlobCheckpointStore; +import com.azure.messaging.eventhubs.models.ErrorContext; +import com.azure.messaging.eventhubs.models.EventContext; +import com.azure.storage.blob.BlobContainerAsyncClient; +import com.azure.storage.blob.BlobContainerClientBuilder; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@Slf4j +public class EventHubClientConfiguration { + + private static final String CONSUMER_GROUP = "$Default"; + private static final String STORAGE_ACCOUNT_ENDPOINT = ""; + private static final String STORAGE_CONTAINER_NAME = "prova"; + + @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") + private String nodoCacheRxConnectionString; + @Value("${nodo-dei-pagamenti-cache-rx-name}") + private String nodoCacheRxName; + + @Bean + EventHubClientBuilder eventHubClientBuilder() { + return new EventHubClientBuilder().credential(nodoCacheRxConnectionString, nodoCacheRxName, + new DefaultAzureCredentialBuilder() + .build()); + } + + @Bean + BlobContainerClientBuilder blobContainerClientBuilder() { + return new BlobContainerClientBuilder().credential(new DefaultAzureCredentialBuilder() + .build()) + .endpoint(STORAGE_ACCOUNT_ENDPOINT) + .containerName(STORAGE_CONTAINER_NAME); + } + + @Bean + BlobContainerAsyncClient blobContainerAsyncClient(BlobContainerClientBuilder blobContainerClientBuilder) { + return blobContainerClientBuilder.buildAsyncClient(); + } + + @Bean + EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient blobContainerAsyncClient) { + return new EventProcessorClientBuilder().credential(nodoCacheRxConnectionString, nodoCacheRxName, + new DefaultAzureCredentialBuilder() + .build()) + .consumerGroup(CONSUMER_GROUP) + .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) + .processEvent(EventHubClientConfiguration::processEvent) + .processError(EventHubClientConfiguration::processError); + } + // @Bean -// EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient blobContainerAsyncClient) { -// return new EventProcessorClientBuilder().credential(ndpConnectionString, ndpEventHubName, -// new DefaultAzureCredentialBuilder() -// .build()) -// .consumerGroup(CONSUMER_GROUP) -// .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) -// .processEvent(EventHubClientConfiguration::processEvent) -// .processError(EventHubClientConfiguration::processError); -// } +// EventHubProducerClient eventHubProducerClient(EventHubClientBuilder eventHubClientBuilder) { +// return eventHubClientBuilder.buildProducerClient(); // -// @Bean -// EventProcessorClient eventProcessorClient(EventProcessorClientBuilder eventProcessorClientBuilder) { -// return eventProcessorClientBuilder.buildEventProcessorClient(); // } -// -// public static void processEvent(EventContext eventContext) { -// LOGGER.info("Processing event from partition {} with sequence number {} with body: {}", -// eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), -// eventContext.getEventData().getBodyAsString()); -// } -// -// public static void processError(ErrorContext errorContext) { -// LOGGER.info("Error occurred in partition processor for partition {}, {}", -// errorContext.getPartitionContext().getPartitionId(), -// errorContext.getThrowable().getMessage(), -// errorContext.getThrowable()); -// } -// -//} + + @Bean + EventProcessorClient eventProcessorClient(EventProcessorClientBuilder eventProcessorClientBuilder) { + return eventProcessorClientBuilder.buildEventProcessorClient(); + } + + public static void processEvent(EventContext eventContext) { + log.info("Processing event from partition {} with sequence number {} with body: {}", + eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), + eventContext.getEventData().getBodyAsString()); + } + + public static void processError(ErrorContext errorContext) { + log.info("Error occurred in partition processor for partition {}, {}", + errorContext.getPartitionContext().getPartitionId(), + errorContext.getThrowable().getMessage(), + errorContext.getThrowable()); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubProcessorClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubProcessorClientConfiguration.java new file mode 100644 index 0000000..39bbabe --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubProcessorClientConfiguration.java @@ -0,0 +1,28 @@ +package it.gov.pagopa.node.cfg_sync.config; + +import com.azure.spring.cloud.service.eventhubs.consumer.EventHubsErrorHandler; +import com.azure.spring.cloud.service.eventhubs.consumer.EventHubsRecordMessageListener; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@Slf4j +public class EventHubProcessorClientConfiguration { + + @Bean + EventHubsRecordMessageListener processEvent() { + return eventContext->log.info("Processing event from partition {} with sequence number {} with body: {}", + eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), + eventContext.getEventData().getBodyAsString()); + } + + @Bean + EventHubsErrorHandler processError() { + return errorContext->log.info("Error occurred in partition processor for partition {}, {}", + errorContext.getPartitionContext().getPartitionId(), + errorContext.getThrowable().getMessage(), + errorContext.getThrowable()); + } + +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/LoggingAspect.java b/src/main/java/it/gov/pagopa/node/cfg_sync/config/LoggingAspect.java index d446451..d4998cd 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/LoggingAspect.java +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/config/LoggingAspect.java @@ -108,7 +108,7 @@ public void handleContextRefresh(ContextRefreshedEvent event) { || prop.toLowerCase().contains("key") || prop.toLowerCase().contains("secret") )) - .forEach(prop -> log.debug("{}: {}", prop, env.getProperty(prop))); + .forEach(prop -> log.debug("{}: {}", prop, ""));//env.getProperty(prop))); } @Around(value = "restController()") diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/MessageReceiveConfiguration.java b/src/main/java/it/gov/pagopa/node/cfg_sync/config/MessageReceiveConfiguration.java new file mode 100644 index 0000000..d4fde39 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfg_sync/config/MessageReceiveConfiguration.java @@ -0,0 +1,53 @@ +//package it.gov.pagopa.node.cfg_sync.config; +// +//import com.azure.spring.integration.eventhubs.inbound.EventHubsInboundChannelAdapter; +//import com.azure.spring.messaging.eventhubs.core.EventHubsProcessorFactory; +//import com.azure.spring.messaging.eventhubs.core.checkpoint.CheckpointConfig; +//import com.azure.spring.messaging.eventhubs.core.checkpoint.CheckpointMode; +//import com.azure.spring.messaging.eventhubs.core.listener.EventHubsMessageListenerContainer; +//import com.azure.spring.messaging.eventhubs.core.properties.EventHubsContainerProperties; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Qualifier; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.integration.annotation.ServiceActivator; +//import org.springframework.integration.channel.DirectChannel; +//import org.springframework.messaging.MessageChannel; +// +//@Configuration +//@Slf4j +//public class MessageReceiveConfiguration { +// +// private static final String INPUT_CHANNEL = "input"; +// private static final String EVENT_HUB_NAME = ""; +// private static final String CONSUMER_GROUP = "$Default"; +// +// @ServiceActivator(inputChannel = INPUT_CHANNEL) +// public void messageReceiver(byte[] payload) { +// String message = new String(payload); +// log.info("New message received: {}", message); +// } +// +// @Bean +// public EventHubsMessageListenerContainer messageListenerContainer(EventHubsProcessorFactory processorFactory) { +// EventHubsContainerProperties containerProperties = new EventHubsContainerProperties(); +// containerProperties.setEventHubName(EVENT_HUB_NAME); +// containerProperties.setConsumerGroup(CONSUMER_GROUP); +// containerProperties.setCheckpointConfig(new CheckpointConfig(CheckpointMode.MANUAL)); +// return new EventHubsMessageListenerContainer(processorFactory, containerProperties); +// } +// +// @Bean +// public EventHubsInboundChannelAdapter messageChannelAdapter(@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel, +// EventHubsMessageListenerContainer listenerContainer) { +// EventHubsInboundChannelAdapter adapter = new EventHubsInboundChannelAdapter(listenerContainer); +// adapter.setOutputChannel(inputChannel); +// return adapter; +// } +// +// @Bean +// public MessageChannel input() { +// return new DirectChannel(); +// } +// +//} \ No newline at end of file diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 1d996ce..14f6431 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -40,4 +40,4 @@ db.nodo.pagopa.postgre.datasource.driverClassName=org.postgresql.Driver db.nodo.nexi.oracle.datasource.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg db.nodo.nexi.oracle.datasource.username=cfg db.nodo.nexi.oracle.datasource.password=${DB_NODO_NEXI_ORACLE_PASSWORD} -db.nodo.nexi.oracle.datasource.driverClassName=oracle.jdbc.driver.OracleDriver \ No newline at end of file +db.nodo.nexi.oracle.datasource.driverClassName=oracle.jdbc.driver.OracleDriver From 60ae1712dd8ab82ede56f8ce70cf99487edfff82 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Thu, 8 Feb 2024 10:55:06 +0100 Subject: [PATCH 05/88] NOD-690: wip --- .../model/nexi/CacheNexiOracle.java | 20 ------------------- .../repository/model/pagopa/CachePagoPA.java | 20 ------------------- .../node/cfg_sync/service/CacheService.java | 9 --------- .../{cfg_sync => cfgsync}/Application.java | 0 .../EventHubClientApplication.java | 2 +- .../client/ApiConfigCacheClient.java | 2 +- .../client/StandInManagerClient.java | 2 +- .../config/EventHubClientConfiguration.java | 3 +-- .../EventHubProcessorClientConfiguration.java | 2 +- .../config/LoggingAspect.java | 2 +- .../config/MappingsConfiguration.java | 2 +- .../config/MessageReceiveConfiguration.java | 0 .../config/OpenApiConfig.java | 4 ++-- .../config/RequestFilter.java | 4 ++-- .../config/ResponseValidator.java | 4 ++-- .../config/WebMvcConfiguration.java | 4 ++-- .../controller/HomeController.java | 2 +- .../controller/SyncCacheController.java | 11 +++++----- .../exception/AppError.java | 2 +- .../exception/AppException.java | 2 +- .../exception/ErrorHandler.java | 4 ++-- .../model/AppCorsConfiguration.java | 2 +- .../{cfg_sync => cfgsync}/model/AppInfo.java | 2 +- .../model/ProblemJson.java | 2 +- .../model/RefreshResponse.java | 2 +- .../model/TargetRefreshEnum.java | 2 +- .../repository/CacheNodoPNexiRepository.java | 0 .../config/NodoONexiConfiguration.java | 2 +- .../config/NodoPagoPAPConfiguration.java | 2 +- .../repository/model/Cache.java | 4 +--- .../model/nexi/CacheNexiOracle.java | 15 ++++++++++++++ .../repository/model/pagopa/CachePagoPA.java | 15 ++++++++++++++ .../nexi/CacheNodoONexiRepository.java | 4 ++-- .../pagopa/CacheNodoPagoPAPRepository.java | 4 ++-- .../service/ApiConfigCacheService.java | 15 +++++++------- .../node/cfgsync/service/CacheService.java | 9 +++++++++ .../service/CacheServiceFactory.java | 4 ++-- .../service/CommonCacheService.java | 12 +++++------ .../service/StandInManagerCacheService.java | 10 +++++----- .../{cfg_sync => cfgsync}/util/Constants.java | 2 +- .../{cfg_sync => cfgsync}/util/Utils.java | 2 +- .../ApplicationTest.java | 2 +- .../OpenApiGenerationTest.java | 2 +- 43 files changed, 100 insertions(+), 115 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheService.java rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/Application.java (100%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/EventHubClientApplication.java (97%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/client/ApiConfigCacheClient.java (88%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/client/StandInManagerClient.java (90%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/EventHubClientConfiguration.java (97%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/EventHubProcessorClientConfiguration.java (96%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/LoggingAspect.java (99%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/MappingsConfiguration.java (91%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/MessageReceiveConfiguration.java (100%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/OpenApiConfig.java (98%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/RequestFilter.java (95%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/ResponseValidator.java (94%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/config/WebMvcConfiguration.java (89%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/controller/HomeController.java (93%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/controller/SyncCacheController.java (91%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/exception/AppError.java (92%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/exception/AppException.java (98%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/exception/ErrorHandler.java (98%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/model/AppCorsConfiguration.java (93%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/model/AppInfo.java (91%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/model/ProblemJson.java (96%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/model/RefreshResponse.java (91%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/model/TargetRefreshEnum.java (83%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/repository/CacheNodoPNexiRepository.java (100%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/repository/config/NodoONexiConfiguration.java (98%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/repository/config/NodoPagoPAPConfiguration.java (98%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/repository/model/Cache.java (85%) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/model/nexi/CacheNexiOracle.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/model/pagopa/CachePagoPA.java rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/repository/nexi/CacheNodoONexiRepository.java (63%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/repository/pagopa/CacheNodoPagoPAPRepository.java (63%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/service/ApiConfigCacheService.java (87%) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/service/CacheServiceFactory.java (89%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/service/CommonCacheService.java (77%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/service/StandInManagerCacheService.java (86%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/util/Constants.java (78%) rename src/main/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/util/Utils.java (95%) rename src/test/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/ApplicationTest.java (89%) rename src/test/java/it/gov/pagopa/node/{cfg_sync => cfgsync}/OpenApiGenerationTest.java (98%) diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java deleted file mode 100644 index 1324ce1..0000000 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/nexi/CacheNexiOracle.java +++ /dev/null @@ -1,20 +0,0 @@ -package it.gov.pagopa.node.cfg_sync.repository.model.nexi; - -import it.gov.pagopa.node.cfg_sync.repository.model.Cache; -import lombok.*; -import lombok.experimental.SuperBuilder; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; -import java.time.LocalDateTime; - -@Getter -@Setter -@Entity -@Table(name = "cache") -public class CacheNexiOracle extends Cache { - -} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java b/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java deleted file mode 100644 index b84dc37..0000000 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/pagopa/CachePagoPA.java +++ /dev/null @@ -1,20 +0,0 @@ -package it.gov.pagopa.node.cfg_sync.repository.model.pagopa; - -import it.gov.pagopa.node.cfg_sync.repository.model.Cache; -import lombok.*; -import lombok.experimental.SuperBuilder; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import java.io.Serializable; -import java.time.LocalDateTime; - -@Getter -@Setter -@Entity -@Table(name = "cache") -public class CachePagoPA extends Cache { - -} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheService.java b/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheService.java deleted file mode 100644 index bb458a0..0000000 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheService.java +++ /dev/null @@ -1,9 +0,0 @@ -package it.gov.pagopa.node.cfg_sync.service; - -import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; - -public interface CacheService { - - TargetRefreshEnum getType(); - void syncCache(); -} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/Application.java b/src/main/java/it/gov/pagopa/node/cfgsync/Application.java similarity index 100% rename from src/main/java/it/gov/pagopa/node/cfg_sync/Application.java rename to src/main/java/it/gov/pagopa/node/cfgsync/Application.java diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/EventHubClientApplication.java b/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java similarity index 97% rename from src/main/java/it/gov/pagopa/node/cfg_sync/EventHubClientApplication.java rename to src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java index 1033620..aa7423c 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/EventHubClientApplication.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync; +package it.gov.pagopa.node.cfgsync; import com.azure.messaging.eventhubs.EventProcessorClient; import org.slf4j.Logger; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/client/ApiConfigCacheClient.java b/src/main/java/it/gov/pagopa/node/cfgsync/client/ApiConfigCacheClient.java similarity index 88% rename from src/main/java/it/gov/pagopa/node/cfg_sync/client/ApiConfigCacheClient.java rename to src/main/java/it/gov/pagopa/node/cfgsync/client/ApiConfigCacheClient.java index 5a53457..00f54fb 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/client/ApiConfigCacheClient.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/client/ApiConfigCacheClient.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.client; +package it.gov.pagopa.node.cfgsync.client; import feign.Headers; import feign.Param; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/client/StandInManagerClient.java b/src/main/java/it/gov/pagopa/node/cfgsync/client/StandInManagerClient.java similarity index 90% rename from src/main/java/it/gov/pagopa/node/cfg_sync/client/StandInManagerClient.java rename to src/main/java/it/gov/pagopa/node/cfgsync/client/StandInManagerClient.java index 3cec05f..b72b3c2 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/client/StandInManagerClient.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/client/StandInManagerClient.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.client; +package it.gov.pagopa.node.cfgsync.client; import feign.Headers; import feign.Param; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java similarity index 97% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java index a3c4aa1..bbf648b 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubClientConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java @@ -1,8 +1,7 @@ -package it.gov.pagopa.node.cfg_sync.config; +package it.gov.pagopa.node.cfgsync.config; import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.messaging.eventhubs.EventHubClientBuilder; -import com.azure.messaging.eventhubs.EventHubProducerClient; import com.azure.messaging.eventhubs.EventProcessorClient; import com.azure.messaging.eventhubs.EventProcessorClientBuilder; import com.azure.messaging.eventhubs.checkpointstore.blob.BlobCheckpointStore; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubProcessorClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubProcessorClientConfiguration.java similarity index 96% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubProcessorClientConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubProcessorClientConfiguration.java index 39bbabe..e8d00e5 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/EventHubProcessorClientConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubProcessorClientConfiguration.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.config; +package it.gov.pagopa.node.cfgsync.config; import com.azure.spring.cloud.service.eventhubs.consumer.EventHubsErrorHandler; import com.azure.spring.cloud.service.eventhubs.consumer.EventHubsRecordMessageListener; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/LoggingAspect.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/LoggingAspect.java similarity index 99% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/LoggingAspect.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/LoggingAspect.java index d4998cd..4a1b278 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/LoggingAspect.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/LoggingAspect.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.config; +package it.gov.pagopa.node.cfgsync.config; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.JoinPoint; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/MappingsConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/MappingsConfiguration.java similarity index 91% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/MappingsConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/MappingsConfiguration.java index d484241..e0c5c7e 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/MappingsConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/MappingsConfiguration.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.config; +package it.gov.pagopa.node.cfgsync.config; import org.modelmapper.ModelMapper; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/MessageReceiveConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/MessageReceiveConfiguration.java similarity index 100% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/MessageReceiveConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/MessageReceiveConfiguration.java diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/OpenApiConfig.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/OpenApiConfig.java similarity index 98% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/OpenApiConfig.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/OpenApiConfig.java index dd0c1c5..1f76a00 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/OpenApiConfig.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/OpenApiConfig.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.config; +package it.gov.pagopa.node.cfgsync.config; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; @@ -14,7 +14,7 @@ import java.util.Objects; import java.util.Optional; -import it.gov.pagopa.node.cfg_sync.util.Constants; +import it.gov.pagopa.node.cfgsync.util.Constants; import org.springdoc.core.customizers.OpenApiCustomiser; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/RequestFilter.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/RequestFilter.java similarity index 95% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/RequestFilter.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/RequestFilter.java index 880ec61..e3f7563 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/RequestFilter.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/RequestFilter.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.config; +package it.gov.pagopa.node.cfgsync.config; import java.io.IOException; import java.util.UUID; @@ -10,7 +10,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import it.gov.pagopa.node.cfg_sync.util.Constants; +import it.gov.pagopa.node.cfgsync.util.Constants; import lombok.extern.slf4j.Slf4j; import org.slf4j.MDC; import org.springframework.core.Ordered; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/ResponseValidator.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/ResponseValidator.java similarity index 94% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/ResponseValidator.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/ResponseValidator.java index 5eb8a76..eb5a089 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/ResponseValidator.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/ResponseValidator.java @@ -1,6 +1,6 @@ -package it.gov.pagopa.node.cfg_sync.config; +package it.gov.pagopa.node.cfgsync.config; -import it.gov.pagopa.node.cfg_sync.exception.AppException; +import it.gov.pagopa.node.cfgsync.exception.AppException; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.Validator; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/config/WebMvcConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/WebMvcConfiguration.java similarity index 89% rename from src/main/java/it/gov/pagopa/node/cfg_sync/config/WebMvcConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/config/WebMvcConfiguration.java index e3c18cd..132a3d3 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/config/WebMvcConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/WebMvcConfiguration.java @@ -1,7 +1,7 @@ -package it.gov.pagopa.node.cfg_sync.config; +package it.gov.pagopa.node.cfgsync.config; import com.fasterxml.jackson.databind.ObjectMapper; -import it.gov.pagopa.node.cfg_sync.model.AppCorsConfiguration; +import it.gov.pagopa.node.cfgsync.model.AppCorsConfiguration; import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/controller/HomeController.java b/src/main/java/it/gov/pagopa/node/cfgsync/controller/HomeController.java similarity index 93% rename from src/main/java/it/gov/pagopa/node/cfg_sync/controller/HomeController.java rename to src/main/java/it/gov/pagopa/node/cfgsync/controller/HomeController.java index cd40385..e2615e7 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/controller/HomeController.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/controller/HomeController.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.controller; +package it.gov.pagopa.node.cfgsync.controller; import io.swagger.v3.oas.annotations.Hidden; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/controller/SyncCacheController.java b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java similarity index 91% rename from src/main/java/it/gov/pagopa/node/cfg_sync/controller/SyncCacheController.java rename to src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java index bed3563..b4df651 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/controller/SyncCacheController.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.controller; +package it.gov.pagopa.node.cfgsync.controller; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -6,10 +6,10 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import it.gov.pagopa.node.cfg_sync.model.ProblemJson; -import it.gov.pagopa.node.cfg_sync.model.RefreshResponse; -import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; -import it.gov.pagopa.node.cfg_sync.service.CacheServiceFactory; +import it.gov.pagopa.node.cfgsync.model.ProblemJson; +import it.gov.pagopa.node.cfgsync.model.RefreshResponse; +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfgsync.service.CacheServiceFactory; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; @@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.io.IOException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.UUID; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppError.java b/src/main/java/it/gov/pagopa/node/cfgsync/exception/AppError.java similarity index 92% rename from src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppError.java rename to src/main/java/it/gov/pagopa/node/cfgsync/exception/AppError.java index 42d0b1c..9e3a9be 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppError.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/exception/AppError.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.exception; +package it.gov.pagopa.node.cfgsync.exception; import lombok.Getter; import org.springframework.http.HttpStatus; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppException.java b/src/main/java/it/gov/pagopa/node/cfgsync/exception/AppException.java similarity index 98% rename from src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppException.java rename to src/main/java/it/gov/pagopa/node/cfgsync/exception/AppException.java index accef50..f9099ec 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/exception/AppException.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/exception/AppException.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.exception; +package it.gov.pagopa.node.cfgsync.exception; import java.util.Formatter; import javax.validation.constraints.NotNull; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/exception/ErrorHandler.java b/src/main/java/it/gov/pagopa/node/cfgsync/exception/ErrorHandler.java similarity index 98% rename from src/main/java/it/gov/pagopa/node/cfg_sync/exception/ErrorHandler.java rename to src/main/java/it/gov/pagopa/node/cfgsync/exception/ErrorHandler.java index ac0c0fc..6ff4386 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/exception/ErrorHandler.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/exception/ErrorHandler.java @@ -1,6 +1,6 @@ -package it.gov.pagopa.node.cfg_sync.exception; +package it.gov.pagopa.node.cfgsync.exception; -import it.gov.pagopa.node.cfg_sync.model.ProblemJson; +import it.gov.pagopa.node.cfgsync.model.ProblemJson; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/model/AppCorsConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/AppCorsConfiguration.java similarity index 93% rename from src/main/java/it/gov/pagopa/node/cfg_sync/model/AppCorsConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/model/AppCorsConfiguration.java index 79d341c..7805601 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/model/AppCorsConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/AppCorsConfiguration.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.model; +package it.gov.pagopa.node.cfgsync.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/model/AppInfo.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/AppInfo.java similarity index 91% rename from src/main/java/it/gov/pagopa/node/cfg_sync/model/AppInfo.java rename to src/main/java/it/gov/pagopa/node/cfgsync/model/AppInfo.java index 439c8d1..013a08d 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/model/AppInfo.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/AppInfo.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.model; +package it.gov.pagopa.node.cfgsync.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AccessLevel; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/model/ProblemJson.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/ProblemJson.java similarity index 96% rename from src/main/java/it/gov/pagopa/node/cfg_sync/model/ProblemJson.java rename to src/main/java/it/gov/pagopa/node/cfgsync/model/ProblemJson.java index 45ad82c..92a1f1f 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/model/ProblemJson.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/ProblemJson.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.model; +package it.gov.pagopa.node.cfgsync.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/model/RefreshResponse.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java similarity index 91% rename from src/main/java/it/gov/pagopa/node/cfg_sync/model/RefreshResponse.java rename to src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java index 7a6ba86..602c100 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/model/RefreshResponse.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.model; +package it.gov.pagopa.node.cfgsync.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.*; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/model/TargetRefreshEnum.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/TargetRefreshEnum.java similarity index 83% rename from src/main/java/it/gov/pagopa/node/cfg_sync/model/TargetRefreshEnum.java rename to src/main/java/it/gov/pagopa/node/cfgsync/model/TargetRefreshEnum.java index 0e7eb46..3b4eb4f 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/model/TargetRefreshEnum.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/TargetRefreshEnum.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.model; +package it.gov.pagopa.node.cfgsync.model; public enum TargetRefreshEnum { diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/CacheNodoPNexiRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/CacheNodoPNexiRepository.java similarity index 100% rename from src/main/java/it/gov/pagopa/node/cfg_sync/repository/CacheNodoPNexiRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/CacheNodoPNexiRepository.java diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java similarity index 98% rename from src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java index 9b816d2..27e9672 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoONexiConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.repository.config; +package it.gov.pagopa.node.cfgsync.repository.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.*; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java similarity index 98% rename from src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java index a0eb2d5..fa6bf07 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/config/NodoPagoPAPConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.repository.config; +package it.gov.pagopa.node.cfgsync.repository.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.*; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/Cache.java similarity index 85% rename from src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/model/Cache.java index fd9cc84..c2292b2 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/model/Cache.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/Cache.java @@ -1,8 +1,6 @@ -package it.gov.pagopa.node.cfg_sync.repository.model; +package it.gov.pagopa.node.cfgsync.repository.model; -import antlr.ANTLRParser; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.NoArgsConstructor; import javax.persistence.Column; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/nexi/CacheNexiOracle.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/nexi/CacheNexiOracle.java new file mode 100644 index 0000000..eec989b --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/nexi/CacheNexiOracle.java @@ -0,0 +1,15 @@ +package it.gov.pagopa.node.cfgsync.repository.model.nexi; + +import it.gov.pagopa.node.cfgsync.repository.model.Cache; +import lombok.*; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Getter +@Setter +@Entity +@Table(name = "cache") +public class CacheNexiOracle extends Cache { + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/pagopa/CachePagoPA.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/pagopa/CachePagoPA.java new file mode 100644 index 0000000..fd48823 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/pagopa/CachePagoPA.java @@ -0,0 +1,15 @@ +package it.gov.pagopa.node.cfgsync.repository.model.pagopa; + +import it.gov.pagopa.node.cfgsync.repository.model.Cache; +import lombok.*; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Getter +@Setter +@Entity +@Table(name = "cache") +public class CachePagoPA extends Cache { + +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexi/CacheNodoONexiRepository.java similarity index 63% rename from src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexi/CacheNodoONexiRepository.java index 781315b..0988ec7 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/nexi/CacheNodoONexiRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexi/CacheNodoONexiRepository.java @@ -1,6 +1,6 @@ -package it.gov.pagopa.node.cfg_sync.repository.nexi; +package it.gov.pagopa.node.cfgsync.repository.nexi; -import it.gov.pagopa.node.cfg_sync.repository.model.nexi.CacheNexiOracle; +import it.gov.pagopa.node.cfgsync.repository.model.nexi.CacheNexiOracle; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java similarity index 63% rename from src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java index 30331f7..5c88fb9 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/repository/pagopa/CacheNodoPagoPAPRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java @@ -1,6 +1,6 @@ -package it.gov.pagopa.node.cfg_sync.repository.pagopa; +package it.gov.pagopa.node.cfgsync.repository.pagopa; -import it.gov.pagopa.node.cfg_sync.repository.model.pagopa.CachePagoPA; +import it.gov.pagopa.node.cfgsync.repository.model.pagopa.CachePagoPA; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java similarity index 87% rename from src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java rename to src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 812dccd..c1b7f1b 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -1,15 +1,14 @@ -package it.gov.pagopa.node.cfg_sync.service; +package it.gov.pagopa.node.cfgsync.service; import feign.Feign; import feign.FeignException; import feign.Response; -import it.gov.pagopa.node.cfg_sync.client.ApiConfigCacheClient; -import it.gov.pagopa.node.cfg_sync.exception.AppError; -import it.gov.pagopa.node.cfg_sync.exception.AppException; -import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; -import it.gov.pagopa.node.cfg_sync.repository.model.Cache; -import it.gov.pagopa.node.cfg_sync.repository.model.pagopa.CachePagoPA; -import it.gov.pagopa.node.cfg_sync.repository.pagopa.CacheNodoPagoPAPRepository; +import it.gov.pagopa.node.cfgsync.client.ApiConfigCacheClient; +import it.gov.pagopa.node.cfgsync.exception.AppError; +import it.gov.pagopa.node.cfgsync.exception.AppException; +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfgsync.repository.model.pagopa.CachePagoPA; +import it.gov.pagopa.node.cfgsync.repository.pagopa.CacheNodoPagoPAPRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java new file mode 100644 index 0000000..45566ab --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java @@ -0,0 +1,9 @@ +package it.gov.pagopa.node.cfgsync.service; + +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; + +public interface CacheService { + + TargetRefreshEnum getType(); + void syncCache(); +} diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheServiceFactory.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheServiceFactory.java similarity index 89% rename from src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheServiceFactory.java rename to src/main/java/it/gov/pagopa/node/cfgsync/service/CacheServiceFactory.java index ff842d1..3787913 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CacheServiceFactory.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheServiceFactory.java @@ -1,6 +1,6 @@ -package it.gov.pagopa.node.cfg_sync.service; +package it.gov.pagopa.node.cfgsync.service; -import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java similarity index 77% rename from src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java rename to src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java index 292cb6b..6f07e67 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/service/CommonCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java @@ -1,10 +1,10 @@ -package it.gov.pagopa.node.cfg_sync.service; +package it.gov.pagopa.node.cfgsync.service; -import it.gov.pagopa.node.cfg_sync.exception.AppError; -import it.gov.pagopa.node.cfg_sync.exception.AppException; -import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; -import it.gov.pagopa.node.cfg_sync.repository.model.Cache; -import it.gov.pagopa.node.cfg_sync.util.Utils; +import it.gov.pagopa.node.cfgsync.exception.AppError; +import it.gov.pagopa.node.cfgsync.exception.AppException; +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfgsync.repository.model.Cache; +import it.gov.pagopa.node.cfgsync.util.Utils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/service/StandInManagerCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java similarity index 86% rename from src/main/java/it/gov/pagopa/node/cfg_sync/service/StandInManagerCacheService.java rename to src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java index e5e3aff..3b7d602 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/service/StandInManagerCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java @@ -1,11 +1,11 @@ -package it.gov.pagopa.node.cfg_sync.service; +package it.gov.pagopa.node.cfgsync.service; import feign.Feign; import feign.FeignException; -import it.gov.pagopa.node.cfg_sync.client.StandInManagerClient; -import it.gov.pagopa.node.cfg_sync.exception.AppError; -import it.gov.pagopa.node.cfg_sync.exception.AppException; -import it.gov.pagopa.node.cfg_sync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfgsync.client.StandInManagerClient; +import it.gov.pagopa.node.cfgsync.exception.AppError; +import it.gov.pagopa.node.cfgsync.exception.AppException; +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/util/Constants.java b/src/main/java/it/gov/pagopa/node/cfgsync/util/Constants.java similarity index 78% rename from src/main/java/it/gov/pagopa/node/cfg_sync/util/Constants.java rename to src/main/java/it/gov/pagopa/node/cfgsync/util/Constants.java index f73b179..d64ba1a 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/util/Constants.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/util/Constants.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.util; +package it.gov.pagopa.node.cfgsync.util; import lombok.experimental.UtilityClass; diff --git a/src/main/java/it/gov/pagopa/node/cfg_sync/util/Utils.java b/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java similarity index 95% rename from src/main/java/it/gov/pagopa/node/cfg_sync/util/Utils.java rename to src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java index 259bbf5..981faaa 100644 --- a/src/main/java/it/gov/pagopa/node/cfg_sync/util/Utils.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync.util; +package it.gov.pagopa.node.cfgsync.util; import javax.persistence.Column; import java.io.ByteArrayOutputStream; diff --git a/src/test/java/it/gov/pagopa/node/cfg_sync/ApplicationTest.java b/src/test/java/it/gov/pagopa/node/cfgsync/ApplicationTest.java similarity index 89% rename from src/test/java/it/gov/pagopa/node/cfg_sync/ApplicationTest.java rename to src/test/java/it/gov/pagopa/node/cfgsync/ApplicationTest.java index c46f4b3..4d5004e 100644 --- a/src/test/java/it/gov/pagopa/node/cfg_sync/ApplicationTest.java +++ b/src/test/java/it/gov/pagopa/node/cfgsync/ApplicationTest.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync; +package it.gov.pagopa.node.cfgsync; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/it/gov/pagopa/node/cfg_sync/OpenApiGenerationTest.java b/src/test/java/it/gov/pagopa/node/cfgsync/OpenApiGenerationTest.java similarity index 98% rename from src/test/java/it/gov/pagopa/node/cfg_sync/OpenApiGenerationTest.java rename to src/test/java/it/gov/pagopa/node/cfgsync/OpenApiGenerationTest.java index a82ebce..8942fd2 100644 --- a/src/test/java/it/gov/pagopa/node/cfg_sync/OpenApiGenerationTest.java +++ b/src/test/java/it/gov/pagopa/node/cfgsync/OpenApiGenerationTest.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfg_sync; +package it.gov.pagopa.node.cfgsync; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; From e902d7abcc85a44587c067a12771137f53543c6f Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Thu, 8 Feb 2024 11:24:11 +0100 Subject: [PATCH 06/88] NOD-690: wip --- .../cfgsync/EventHubClientApplication.java | 14 +---- .../config/EventHubClientConfiguration.java | 25 ++------- .../EventHubProcessorClientConfiguration.java | 28 ---------- .../config/MessageReceiveConfiguration.java | 53 ------------------- .../config/NodoONexiConfiguration.java | 4 +- .../config/NodoPagoPAPConfiguration.java | 4 +- 6 files changed, 9 insertions(+), 119 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubProcessorClientConfiguration.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/config/MessageReceiveConfiguration.java diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java b/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java index aa7423c..937bf9f 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java @@ -12,13 +12,9 @@ @SpringBootApplication public class EventHubClientApplication implements CommandLineRunner { - private static final Logger LOGGER = LoggerFactory.getLogger(EventHubClientApplication.class); -// private final EventHubProducerClient eventHubProducerClient; private final EventProcessorClient eventProcessorClient; - public EventHubClientApplication(//EventHubProducerClient eventHubProducerClient, - EventProcessorClient eventProcessorClient) { -// this.eventHubProducerClient = eventHubProducerClient; + public EventHubClientApplication(EventProcessorClient eventProcessorClient) { this.eventProcessorClient = eventProcessorClient; } @@ -29,14 +25,6 @@ public static void main(String[] args) { @Override public void run(String... args) throws Exception { eventProcessorClient.start(); - // Wait for the processor client to be ready - TimeUnit.SECONDS.sleep(10); - -// eventHubProducerClient.send(Collections.singletonList(new EventData("Hello World"))); -// LOGGER.info("Successfully sent a message to Event Hubs."); -// eventHubProducerClient.close(); - LOGGER.info("Stopping and closing the processor"); - eventProcessorClient.stop(); } } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java index bbf648b..8c65f82 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java @@ -19,7 +19,7 @@ public class EventHubClientConfiguration { private static final String CONSUMER_GROUP = "$Default"; - private static final String STORAGE_ACCOUNT_ENDPOINT = ""; + private static final String STORAGE_ACCOUNT_CONNECTION_STRING = ""; private static final String STORAGE_CONTAINER_NAME = "prova"; @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") @@ -29,16 +29,12 @@ public class EventHubClientConfiguration { @Bean EventHubClientBuilder eventHubClientBuilder() { - return new EventHubClientBuilder().credential(nodoCacheRxConnectionString, nodoCacheRxName, - new DefaultAzureCredentialBuilder() - .build()); + return new EventHubClientBuilder().connectionString(nodoCacheRxConnectionString); } @Bean BlobContainerClientBuilder blobContainerClientBuilder() { - return new BlobContainerClientBuilder().credential(new DefaultAzureCredentialBuilder() - .build()) - .endpoint(STORAGE_ACCOUNT_ENDPOINT) + return new BlobContainerClientBuilder().connectionString(STORAGE_ACCOUNT_CONNECTION_STRING) .containerName(STORAGE_CONTAINER_NAME); } @@ -49,26 +45,13 @@ BlobContainerAsyncClient blobContainerAsyncClient(BlobContainerClientBuilder blo @Bean EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient blobContainerAsyncClient) { - return new EventProcessorClientBuilder().credential(nodoCacheRxConnectionString, nodoCacheRxName, - new DefaultAzureCredentialBuilder() - .build()) + return new EventProcessorClientBuilder().connectionString(nodoCacheRxConnectionString) .consumerGroup(CONSUMER_GROUP) .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) .processEvent(EventHubClientConfiguration::processEvent) .processError(EventHubClientConfiguration::processError); } -// @Bean -// EventHubProducerClient eventHubProducerClient(EventHubClientBuilder eventHubClientBuilder) { -// return eventHubClientBuilder.buildProducerClient(); -// -// } - - @Bean - EventProcessorClient eventProcessorClient(EventProcessorClientBuilder eventProcessorClientBuilder) { - return eventProcessorClientBuilder.buildEventProcessorClient(); - } - public static void processEvent(EventContext eventContext) { log.info("Processing event from partition {} with sequence number {} with body: {}", eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubProcessorClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubProcessorClientConfiguration.java deleted file mode 100644 index e8d00e5..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubProcessorClientConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package it.gov.pagopa.node.cfgsync.config; - -import com.azure.spring.cloud.service.eventhubs.consumer.EventHubsErrorHandler; -import com.azure.spring.cloud.service.eventhubs.consumer.EventHubsRecordMessageListener; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -@Slf4j -public class EventHubProcessorClientConfiguration { - - @Bean - EventHubsRecordMessageListener processEvent() { - return eventContext->log.info("Processing event from partition {} with sequence number {} with body: {}", - eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), - eventContext.getEventData().getBodyAsString()); - } - - @Bean - EventHubsErrorHandler processError() { - return errorContext->log.info("Error occurred in partition processor for partition {}, {}", - errorContext.getPartitionContext().getPartitionId(), - errorContext.getThrowable().getMessage(), - errorContext.getThrowable()); - } - -} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/config/MessageReceiveConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/MessageReceiveConfiguration.java deleted file mode 100644 index d4fde39..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/config/MessageReceiveConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -//package it.gov.pagopa.node.cfg_sync.config; -// -//import com.azure.spring.integration.eventhubs.inbound.EventHubsInboundChannelAdapter; -//import com.azure.spring.messaging.eventhubs.core.EventHubsProcessorFactory; -//import com.azure.spring.messaging.eventhubs.core.checkpoint.CheckpointConfig; -//import com.azure.spring.messaging.eventhubs.core.checkpoint.CheckpointMode; -//import com.azure.spring.messaging.eventhubs.core.listener.EventHubsMessageListenerContainer; -//import com.azure.spring.messaging.eventhubs.core.properties.EventHubsContainerProperties; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.beans.factory.annotation.Qualifier; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -//import org.springframework.integration.annotation.ServiceActivator; -//import org.springframework.integration.channel.DirectChannel; -//import org.springframework.messaging.MessageChannel; -// -//@Configuration -//@Slf4j -//public class MessageReceiveConfiguration { -// -// private static final String INPUT_CHANNEL = "input"; -// private static final String EVENT_HUB_NAME = ""; -// private static final String CONSUMER_GROUP = "$Default"; -// -// @ServiceActivator(inputChannel = INPUT_CHANNEL) -// public void messageReceiver(byte[] payload) { -// String message = new String(payload); -// log.info("New message received: {}", message); -// } -// -// @Bean -// public EventHubsMessageListenerContainer messageListenerContainer(EventHubsProcessorFactory processorFactory) { -// EventHubsContainerProperties containerProperties = new EventHubsContainerProperties(); -// containerProperties.setEventHubName(EVENT_HUB_NAME); -// containerProperties.setConsumerGroup(CONSUMER_GROUP); -// containerProperties.setCheckpointConfig(new CheckpointConfig(CheckpointMode.MANUAL)); -// return new EventHubsMessageListenerContainer(processorFactory, containerProperties); -// } -// -// @Bean -// public EventHubsInboundChannelAdapter messageChannelAdapter(@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel, -// EventHubsMessageListenerContainer listenerContainer) { -// EventHubsInboundChannelAdapter adapter = new EventHubsInboundChannelAdapter(listenerContainer); -// adapter.setOutputChannel(inputChannel); -// return adapter; -// } -// -// @Bean -// public MessageChannel input() { -// return new DirectChannel(); -// } -// -//} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java index 27e9672..f5929ea 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java @@ -19,7 +19,7 @@ @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) }) @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfg_sync.repository.nexi", + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexi", entityManagerFactoryRef = "nodoNexiOEntityManager", transactionManagerRef = "nodoNexiOTransactionManager" ) @@ -32,7 +32,7 @@ public LocalContainerEntityManagerFactoryBean nodoNexiOEntityManager() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(nodoNexiODataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.nexi"); + em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model.nexi"); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java index fa6bf07..4423cca 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java @@ -19,7 +19,7 @@ @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) }) @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfg_sync.repository.pagopa", + basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", entityManagerFactoryRef = "nodoPagoPAPEntityManager", transactionManagerRef = "nodoPagoPAPTransactionManager" ) @@ -34,7 +34,7 @@ public LocalContainerEntityManagerFactoryBean nodoPagoPAPEntityManager() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(nodoPagoPAPDataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.pagopa"); + em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model.pagopa"); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); From ee7d9faed5a42ad366efa9281834c6d40981802f Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Thu, 8 Feb 2024 11:29:29 +0100 Subject: [PATCH 07/88] NOD-690: wip --- .../config/EventHubClientConfiguration.java | 15 +++++++++++---- src/main/resources/application-local.properties | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java index 8c65f82..f5edab9 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java @@ -19,13 +19,15 @@ public class EventHubClientConfiguration { private static final String CONSUMER_GROUP = "$Default"; - private static final String STORAGE_ACCOUNT_CONNECTION_STRING = ""; - private static final String STORAGE_CONTAINER_NAME = "prova"; @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") private String nodoCacheRxConnectionString; @Value("${nodo-dei-pagamenti-cache-rx-name}") private String nodoCacheRxName; + @Value("${nodo-dei-pagamenti-cache-sa-connection-string}") + private String nodoCacheSaConnectionString; + @Value("${nodo-dei-pagamenti-cache-sa-name}") + private String nodoCacheSaContainerName; @Bean EventHubClientBuilder eventHubClientBuilder() { @@ -34,8 +36,8 @@ EventHubClientBuilder eventHubClientBuilder() { @Bean BlobContainerClientBuilder blobContainerClientBuilder() { - return new BlobContainerClientBuilder().connectionString(STORAGE_ACCOUNT_CONNECTION_STRING) - .containerName(STORAGE_CONTAINER_NAME); + return new BlobContainerClientBuilder().connectionString(nodoCacheSaConnectionString) + .containerName(nodoCacheSaContainerName); } @Bean @@ -52,6 +54,11 @@ EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient .processError(EventHubClientConfiguration::processError); } + @Bean + EventProcessorClient eventProcessorClient(EventProcessorClientBuilder eventProcessorClientBuilder) { + return eventProcessorClientBuilder.buildEventProcessorClient(); + } + public static void processEvent(EventContext eventContext) { log.info("Processing event from partition {} with sequence number {} with body: {}", eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 14f6431..e145278 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -24,6 +24,9 @@ service.stand-in-manager.subscriptionKey=${STAND-IN_MANAGER_SUBSCRIPTION_KEY} nodo-dei-pagamenti-cache-rx-connection-string=${NODO_CACHE_RX_CONNECTION_STRING} nodo-dei-pagamenti-cache-rx-name=nodo-dei-pagamenti-cache +nodo-dei-pagamenti-cache-sa-connection-string=${NODO_CACHE_SA_CONNECTION_STRING} +nodo-dei-pagamenti-cache-sa-name=prova + stand-in-rx-connection-string=${STAND-IN-MANAGER_RX_CONNECTION_STRING} stand-in-rx-name=nodo-dei-pagamenti-stand-in From 1f187cee46e3067f7bd5c8cd67ec3ec39806d014 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Thu, 8 Feb 2024 19:07:38 +0100 Subject: [PATCH 08/88] NOD-690: wip --- .gitignore | 1 + docker/local-dbs/docker-compose.yml | 15 ++++ docker/local-dbs/postgres/create_tables.sql | 6 ++ docker/local-dbs/run_docker.sh | 4 + .../gov/pagopa/node/cfgsync/Application.java | 79 ++++++----------- .../cfgsync/EventHubClientApplication.java | 30 ------- .../cfgsync/client/StandInManagerClient.java | 5 +- .../client/model/StandInManagerResponse.java | 15 ++++ .../config/EventHubClientConfiguration.java | 75 ----------------- .../controller/SyncCacheController.java | 2 +- .../repository/CacheNodoPNexiRepository.java | 8 -- ...ation.java => NodoNexiOConfiguration.java} | 6 +- .../config/NodoNexiPConfiguration.java | 73 ++++++++++++++++ .../config/NodoPagoPAPConfiguration.java | 2 +- .../model/{Cache.java => ConfigCache.java} | 9 +- .../repository/model/StandInStations.java | 23 +++++ .../model/nexi/CacheNexiOracle.java | 15 ---- .../repository/model/pagopa/CachePagoPA.java | 15 ---- .../nexi/CacheNodoONexiRepository.java | 8 -- .../nexioracle/CacheNodoNexiPRepository.java | 8 ++ .../nexipostgre/CacheNodoNexiORepository.java | 8 ++ .../pagopa/CacheNodoPagoPAPRepository.java | 4 +- .../service/ApiConfigCacheService.java | 68 ++++++++++++--- .../node/cfgsync/service/CacheService.java | 2 +- .../cfgsync/service/CommonCacheService.java | 8 +- .../service/EventHubCacheConsumer.java | 84 +++++++++++++++++++ .../service/StandInManagerCacheService.java | 58 ++++++++++--- .../gov/pagopa/node/cfgsync/util/Utils.java | 23 +++-- .../resources/application-local.properties | 14 +++- 29 files changed, 408 insertions(+), 260 deletions(-) create mode 100644 docker/local-dbs/docker-compose.yml create mode 100644 docker/local-dbs/postgres/create_tables.sql create mode 100644 docker/local-dbs/run_docker.sh delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/client/model/StandInManagerResponse.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/CacheNodoPNexiRepository.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/config/{NodoONexiConfiguration.java => NodoNexiOConfiguration.java} (97%) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/model/{Cache.java => ConfigCache.java} (74%) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/model/StandInStations.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/model/nexi/CacheNexiOracle.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/model/pagopa/CachePagoPA.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexi/CacheNodoONexiRepository.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/CacheNodoNexiPRepository.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/CacheNodoNexiORepository.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/service/EventHubCacheConsumer.java diff --git a/.gitignore b/.gitignore index 46a7764..89e3789 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ hs_err_pid* # Others **/.DS_Store +/docker/local-dbs/postgres-data/ diff --git a/docker/local-dbs/docker-compose.yml b/docker/local-dbs/docker-compose.yml new file mode 100644 index 0000000..3e70d2b --- /dev/null +++ b/docker/local-dbs/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.9' +services: + postgres: + image: postgres:14 + container_name: postgres_nexi + ports: + - 5432:5432 + volumes: + - ./postgres-data:/var/lib/postgresql/data + - ./postgres/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql + environment: + - POSTGRES_DB=nodo + - POSTGRES_USER=cfg + - POSTGRES_PASSWORD=password + - POSTGRES_ROOT_PASSWORD=root diff --git a/docker/local-dbs/postgres/create_tables.sql b/docker/local-dbs/postgres/create_tables.sql new file mode 100644 index 0000000..e362a22 --- /dev/null +++ b/docker/local-dbs/postgres/create_tables.sql @@ -0,0 +1,6 @@ +CREATE TABLE "cache" ( + id varchar(20) NOT NULL, + "time" timestamp NOT NULL, + "cache" bytea NOT NULL, + "version" varchar(32) NULL +); \ No newline at end of file diff --git a/docker/local-dbs/run_docker.sh b/docker/local-dbs/run_docker.sh new file mode 100644 index 0000000..3031a03 --- /dev/null +++ b/docker/local-dbs/run_docker.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rm -rf postgres-data +docker-compose up -d --remove-orphans --force-recreate \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/Application.java b/src/main/java/it/gov/pagopa/node/cfgsync/Application.java index f944f26..e6f5c88 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/Application.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/Application.java @@ -1,52 +1,27 @@ -//package it.gov.pagopa.node.cfg_sync; -// -//import com.azure.messaging.eventhubs.EventData; -//import com.azure.messaging.eventhubs.EventHubProducerClient; -//import com.azure.messaging.eventhubs.EventProcessorClient; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.boot.CommandLineRunner; -//import org.springframework.boot.SpringApplication; -//import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -//import org.springframework.boot.autoconfigure.SpringBootApplication; -//import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -//import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -//import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; -// -//import java.util.Collections; -//import java.util.concurrent.TimeUnit; -// -//@SpringBootApplication -//@EnableAutoConfiguration(exclude = { -// DataSourceAutoConfiguration.class, -// DataSourceTransactionManagerAutoConfiguration.class, -// HibernateJpaAutoConfiguration.class}) -//@Slf4j -//public class Application implements CommandLineRunner { -// -//// private final EventHubProducerClient eventHubProducerClient; -// private final EventProcessorClient eventProcessorClient; -// -// public Application(//EventHubProducerClient eventHubProducerClient, -// EventProcessorClient eventProcessorClient) { -//// this.eventHubProducerClient = eventHubProducerClient; -// this.eventProcessorClient = eventProcessorClient; -// } -// -// public static void main(String[] args) { -// SpringApplication.run(Application.class, args); -// } -// -// @Override -// public void run(String... args) throws Exception { -// eventProcessorClient.start(); -// // Wait for the processor client to be ready -// TimeUnit.SECONDS.sleep(10); -// -//// eventHubProducerClient.send(Collections.singletonList(new EventData("Hello World"))); -//// log.info("Successfully sent a message to Event Hubs."); -//// eventHubProducerClient.close(); -// log.info("Stopping and closing the processor"); -// eventProcessorClient.stop(); -// } -// -//} +package it.gov.pagopa.node.cfgsync; + +import com.azure.messaging.eventhubs.EventProcessorClient; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@Slf4j +public class Application implements CommandLineRunner { + private final EventProcessorClient eventProcessorClient; + + public Application(EventProcessorClient eventProcessorClient) { + this.eventProcessorClient = eventProcessorClient; + } + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Override + public void run(String... args) throws Exception { + eventProcessorClient.start(); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java b/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java deleted file mode 100644 index 937bf9f..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package it.gov.pagopa.node.cfgsync; - -import com.azure.messaging.eventhubs.EventProcessorClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import java.util.concurrent.TimeUnit; - -@SpringBootApplication -public class EventHubClientApplication implements CommandLineRunner { - - private final EventProcessorClient eventProcessorClient; - - public EventHubClientApplication(EventProcessorClient eventProcessorClient) { - this.eventProcessorClient = eventProcessorClient; - } - - public static void main(String[] args) { - SpringApplication.run(EventHubClientApplication.class, args); - } - - @Override - public void run(String... args) throws Exception { - eventProcessorClient.start(); - } - -} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/client/StandInManagerClient.java b/src/main/java/it/gov/pagopa/node/cfgsync/client/StandInManagerClient.java index b72b3c2..5810f98 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/client/StandInManagerClient.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/client/StandInManagerClient.java @@ -9,11 +9,10 @@ @Service public interface StandInManagerClient { - @RequestLine("GET /cache/refresh") + @RequestLine("GET /stations") @Headers({ - "Content-Type: application/json", "Ocp-Apim-Subscription-Key: {subscriptionKey}" }) - Response refresh(@Param String subscriptionKey); + Response getCache(@Param String subscriptionKey); } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/client/model/StandInManagerResponse.java b/src/main/java/it/gov/pagopa/node/cfgsync/client/model/StandInManagerResponse.java new file mode 100644 index 0000000..bb0892b --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/client/model/StandInManagerResponse.java @@ -0,0 +1,15 @@ +package it.gov.pagopa.node.cfgsync.client.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class StandInManagerResponse { + + private List stations; +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java deleted file mode 100644 index f5edab9..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java +++ /dev/null @@ -1,75 +0,0 @@ -package it.gov.pagopa.node.cfgsync.config; - -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.messaging.eventhubs.EventHubClientBuilder; -import com.azure.messaging.eventhubs.EventProcessorClient; -import com.azure.messaging.eventhubs.EventProcessorClientBuilder; -import com.azure.messaging.eventhubs.checkpointstore.blob.BlobCheckpointStore; -import com.azure.messaging.eventhubs.models.ErrorContext; -import com.azure.messaging.eventhubs.models.EventContext; -import com.azure.storage.blob.BlobContainerAsyncClient; -import com.azure.storage.blob.BlobContainerClientBuilder; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -@Slf4j -public class EventHubClientConfiguration { - - private static final String CONSUMER_GROUP = "$Default"; - - @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") - private String nodoCacheRxConnectionString; - @Value("${nodo-dei-pagamenti-cache-rx-name}") - private String nodoCacheRxName; - @Value("${nodo-dei-pagamenti-cache-sa-connection-string}") - private String nodoCacheSaConnectionString; - @Value("${nodo-dei-pagamenti-cache-sa-name}") - private String nodoCacheSaContainerName; - - @Bean - EventHubClientBuilder eventHubClientBuilder() { - return new EventHubClientBuilder().connectionString(nodoCacheRxConnectionString); - } - - @Bean - BlobContainerClientBuilder blobContainerClientBuilder() { - return new BlobContainerClientBuilder().connectionString(nodoCacheSaConnectionString) - .containerName(nodoCacheSaContainerName); - } - - @Bean - BlobContainerAsyncClient blobContainerAsyncClient(BlobContainerClientBuilder blobContainerClientBuilder) { - return blobContainerClientBuilder.buildAsyncClient(); - } - - @Bean - EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient blobContainerAsyncClient) { - return new EventProcessorClientBuilder().connectionString(nodoCacheRxConnectionString) - .consumerGroup(CONSUMER_GROUP) - .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) - .processEvent(EventHubClientConfiguration::processEvent) - .processError(EventHubClientConfiguration::processError); - } - - @Bean - EventProcessorClient eventProcessorClient(EventProcessorClientBuilder eventProcessorClientBuilder) { - return eventProcessorClientBuilder.buildEventProcessorClient(); - } - - public static void processEvent(EventContext eventContext) { - log.info("Processing event from partition {} with sequence number {} with body: {}", - eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), - eventContext.getEventData().getBodyAsString()); - } - - public static void processError(ErrorContext errorContext) { - log.info("Error occurred in partition processor for partition {}, {}", - errorContext.getPartitionContext().getPartitionId(), - errorContext.getThrowable().getMessage(), - errorContext.getThrowable()); - } - -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java index b4df651..86164b8 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java @@ -83,7 +83,7 @@ public class SyncCacheController { public ResponseEntity cache(@PathVariable TargetRefreshEnum target) { log.debug("Sync {} configuration", target.label); - CacheServiceFactory.getService(target).syncCache(); + CacheServiceFactory.getService(target).sync(); String requestId = UUID.randomUUID().toString(); ZonedDateTime timestamp = ZonedDateTime.now(); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/CacheNodoPNexiRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/CacheNodoPNexiRepository.java deleted file mode 100644 index 8983557..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/CacheNodoPNexiRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -//package it.gov.pagopa.node.cfg_sync.repository; -// -//import it.gov.pagopa.node.cfg_sync.repository.model.Cache; -//import org.springframework.data.jpa.repository.JpaRepository; -//import org.springframework.stereotype.Repository; -// -//@Repository -//public interface CacheNodoPNexiRepository extends JpaRepository { } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiOConfiguration.java similarity index 97% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiOConfiguration.java index f5929ea..a679dc2 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoONexiConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiOConfiguration.java @@ -19,11 +19,11 @@ @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) }) @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexi", + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle", entityManagerFactoryRef = "nodoNexiOEntityManager", transactionManagerRef = "nodoNexiOTransactionManager" ) -public class NodoONexiConfiguration { +public class NodoNexiOConfiguration { @Autowired private Environment env; @@ -32,7 +32,7 @@ public LocalContainerEntityManagerFactoryBean nodoNexiOEntityManager() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(nodoNexiODataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model.nexi"); + em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model"); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.java new file mode 100644 index 0000000..8d99e7a --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.java @@ -0,0 +1,73 @@ +package it.gov.pagopa.node.cfgsync.repository.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.*; +import org.springframework.core.env.Environment; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; + +import javax.sql.DataSource; +import java.util.HashMap; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre", + entityManagerFactoryRef = "nodoNexiPEntityManager", + transactionManagerRef = "nodoNexiPTransactionManager" +) +public class NodoNexiPConfiguration { + + @Autowired + private Environment env; + + @Bean + public LocalContainerEntityManagerFactoryBean nodoNexiPEntityManager() { + LocalContainerEntityManagerFactoryBean em + = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(nodoNexiPDataSource()); + em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model"); + + HibernateJpaVendorAdapter vendorAdapter + = new HibernateJpaVendorAdapter(); + em.setJpaVendorAdapter(vendorAdapter); + HashMap properties = new HashMap<>(); + properties.put("hibernate.hbm2ddl.auto", + env.getProperty("hibernate.hbm2ddl.auto")); + properties.put("hibernate.dialect", + env.getProperty("hibernate.dialect")); + em.setJpaPropertyMap(properties); + + return em; + } + + @Bean + public DataSource nodoNexiPDataSource() { + DriverManagerDataSource dataSource + = new DriverManagerDataSource(); + dataSource.setDriverClassName( + env.getProperty("db.nodo.nexi.postgre.datasource.driverClassName")); + dataSource.setUrl(env.getProperty("db.nodo.nexi.postgre.datasource.url")); + dataSource.setUsername(env.getProperty("db.nodo.nexi.postgre.datasource.username")); + dataSource.setPassword(env.getProperty("db.nodo.nexi.postgre.datasource.password")); + + return dataSource; + } + + @Bean + public PlatformTransactionManager nodoNexiPTransactionManager() { + JpaTransactionManager transactionManager + = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory( + nodoNexiPEntityManager().getObject()); + + return transactionManager; + } +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java index 4423cca..0a7cc2d 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java @@ -34,7 +34,7 @@ public LocalContainerEntityManagerFactoryBean nodoPagoPAPEntityManager() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(nodoPagoPAPDataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model.pagopa"); + em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model"); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/Cache.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/ConfigCache.java similarity index 74% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/model/Cache.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/model/ConfigCache.java index c2292b2..f4f2c5f 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/Cache.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/ConfigCache.java @@ -3,17 +3,16 @@ import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; -import javax.persistence.Column; -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; +import javax.persistence.*; import java.io.Serializable; import java.time.LocalDateTime; @NoArgsConstructor @AllArgsConstructor -@MappedSuperclass -public class Cache implements Serializable { +@Entity +@Table(name = "cache") +public class ConfigCache implements Serializable { @Id @Column(name="ID", columnDefinition = "VARCHAR", length = 20) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/StandInStations.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/StandInStations.java new file mode 100644 index 0000000..a7fc7f0 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/StandInStations.java @@ -0,0 +1,23 @@ +package it.gov.pagopa.node.cfgsync.repository.model; + +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; + + +@NoArgsConstructor +@AllArgsConstructor +@Entity +@Table(name = "stand_in_stations") +public class StandInStations implements Serializable { + + @Id + @Column(name="STATION_CODE", columnDefinition = "VARCHAR", length = 35) + private String stationCode; + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/nexi/CacheNexiOracle.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/nexi/CacheNexiOracle.java deleted file mode 100644 index eec989b..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/nexi/CacheNexiOracle.java +++ /dev/null @@ -1,15 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.model.nexi; - -import it.gov.pagopa.node.cfgsync.repository.model.Cache; -import lombok.*; - -import javax.persistence.Entity; -import javax.persistence.Table; - -@Getter -@Setter -@Entity -@Table(name = "cache") -public class CacheNexiOracle extends Cache { - -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/pagopa/CachePagoPA.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/pagopa/CachePagoPA.java deleted file mode 100644 index fd48823..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/pagopa/CachePagoPA.java +++ /dev/null @@ -1,15 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.model.pagopa; - -import it.gov.pagopa.node.cfgsync.repository.model.Cache; -import lombok.*; - -import javax.persistence.Entity; -import javax.persistence.Table; - -@Getter -@Setter -@Entity -@Table(name = "cache") -public class CachePagoPA extends Cache { - -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexi/CacheNodoONexiRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexi/CacheNodoONexiRepository.java deleted file mode 100644 index 0988ec7..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexi/CacheNodoONexiRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.nexi; - -import it.gov.pagopa.node.cfgsync.repository.model.nexi.CacheNexiOracle; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface CacheNodoONexiRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/CacheNodoNexiPRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/CacheNodoNexiPRepository.java new file mode 100644 index 0000000..f37b2df --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/CacheNodoNexiPRepository.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.node.cfgsync.repository.nexioracle; + +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CacheNodoNexiPRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/CacheNodoNexiORepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/CacheNodoNexiORepository.java new file mode 100644 index 0000000..90dfafa --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/CacheNodoNexiORepository.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.node.cfgsync.repository.nexipostgre; + +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CacheNodoNexiORepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java index 5c88fb9..b7ab42f 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java @@ -1,8 +1,8 @@ package it.gov.pagopa.node.cfgsync.repository.pagopa; -import it.gov.pagopa.node.cfgsync.repository.model.pagopa.CachePagoPA; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface CacheNodoPagoPAPRepository extends JpaRepository { } +public interface CacheNodoPagoPAPRepository extends JpaRepository { } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index c1b7f1b..5035bb6 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -7,21 +7,28 @@ import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; -import it.gov.pagopa.node.cfgsync.repository.model.pagopa.CachePagoPA; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import it.gov.pagopa.node.cfgsync.repository.nexioracle.CacheNodoNexiPRepository; import it.gov.pagopa.node.cfgsync.repository.pagopa.CacheNodoPagoPAPRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionCallbackWithoutResult; +import org.springframework.transaction.support.TransactionTemplate; import java.io.IOException; import java.time.ZonedDateTime; import java.util.Collection; import java.util.Map; +import java.util.NoSuchElementException; -@Component +@Service @Slf4j public class ApiConfigCacheService extends CommonCacheService implements CacheService { @@ -29,16 +36,43 @@ public class ApiConfigCacheService extends CommonCacheService implements CacheSe private static final String HEADER_CACHE_TIMESTAMP = "X-CACHE-TIMESTAMP"; private static final String HEADER_CACHE_VERSION = "X-CACHE-VERSION"; - private final ApiConfigCacheClient apiConfigCacheClient; + @Value("${service.api-config-cache.enabled}") + private boolean enabled; + @Value("${service.api-config-cache.subscriptionKey}") + private String subscriptionKey; + @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") + private String nodoCacheRxConnectionString; + @Value("${nodo-dei-pagamenti-cache-rx-name}") + private String nodoCacheRxName; + @Value("${nodo-dei-pagamenti-cache-sa-connection-string}") + private String nodoCacheSaConnectionString; + @Value("${nodo-dei-pagamenti-cache-sa-name}") + private String nodoCacheSaContainerName; + @Value("${nodo-dei-pagamenti-cache-consumer-group}") + private String nodoCacheConsumerGroup; - @Value("${service.api-config-cache.enabled}") private boolean enabled; - @Value("${service.api-config-cache.subscriptionKey}") private String subscriptionKey; + private final ApiConfigCacheClient apiConfigCacheClient; @Autowired private CacheNodoPagoPAPRepository cacheNodoPagoPAPRepository; + @Autowired + private CacheNodoNexiPRepository cacheNodoNexiPRepository; +// @Autowired +// private TransactionTemplate transactionTemplate; +// +// transactionTemplate.execute(new TransactionCallbackWithoutResult() { +// @Override +// public void doInTransactionWithoutResult(TransactionStatus transactionStatus) { +// cacheNodoPagoPAPRepository.save(configCache); +// cacheNodoNexiPRepository.save(configCache); +// } +// }); - public ApiConfigCacheService(@Value("${service.api-config-cache.host}") String apiConfigCacheUrl) { + private final TransactionTemplate transactionTemplate; + + public ApiConfigCacheService(@Value("${service.api-config-cache.host}") String apiConfigCacheUrl, PlatformTransactionManager transactionManager) { apiConfigCacheClient = Feign.builder().target(ApiConfigCacheClient.class, apiConfigCacheUrl); + transactionTemplate = new TransactionTemplate(transactionManager); } @Override @@ -47,8 +81,8 @@ public TargetRefreshEnum getType() { } @Override - @Transactional("nodoPagoPAPTransactionManager") - public void syncCache() { + @Transactional + public void sync() { try { if( !enabled ) { throw new AppException(AppError.SERVICE_DISABLED, getType()); @@ -71,14 +105,22 @@ public void syncCache() { String cacheTimestamp = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_TIMESTAMP); String cacheVersion = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_VERSION); - CachePagoPA cache = (CachePagoPA) composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); - cacheNodoPagoPAPRepository.save(cache); + ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); + this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { + public void doInTransactionWithoutResult(TransactionStatus status) { + try { + cacheNodoPagoPAPRepository.save(configCache); + cacheNodoNexiPRepository.save(configCache); + } catch(NoSuchElementException ex) { + status.setRollbackOnly(); + } + } + }); } catch (FeignException.GatewayTimeout e) { log.error("SyncService api-config-cache get cache error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); - } - catch (IOException e) { + } catch (IOException e) { log.error("SyncService api-config-cache get cache error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java index 45566ab..13ec7a6 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java @@ -5,5 +5,5 @@ public interface CacheService { TargetRefreshEnum getType(); - void syncCache(); + void sync(); } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java index 6f07e67..d271630 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java @@ -3,7 +3,7 @@ import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; -import it.gov.pagopa.node.cfgsync.repository.model.Cache; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import it.gov.pagopa.node.cfgsync.util.Utils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -20,11 +20,11 @@ public class CommonCacheService { @Value("${app.trimCacheColumn}") private boolean trimCacheColumn; - protected Cache composeCache(String cacheId, LocalDateTime timestamp, String cacheVersion, byte[] cache) throws IOException { + protected ConfigCache composeCache(String cacheId, LocalDateTime timestamp, String cacheVersion, byte[] cache) throws IOException { String version = trimCacheColumn ? - (String) Utils.trimValueColumn(Cache.class, "version", cacheVersion) : cacheVersion; + (String) Utils.trimValueColumn(ConfigCache.class, "version", cacheVersion) : cacheVersion; - return new Cache(cacheId, timestamp, Utils.zipContent(cache), version); + return new ConfigCache(cacheId, timestamp, Utils.zipContent(cache), version); } protected Object getHeaderParameter(TargetRefreshEnum target, Map> headers, String key) { diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/EventHubCacheConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/EventHubCacheConsumer.java new file mode 100644 index 0000000..00ab3c8 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/EventHubCacheConsumer.java @@ -0,0 +1,84 @@ +package it.gov.pagopa.node.cfgsync.service; + +import com.azure.messaging.eventhubs.EventProcessorClient; +import com.azure.messaging.eventhubs.EventProcessorClientBuilder; +import com.azure.messaging.eventhubs.checkpointstore.blob.BlobCheckpointStore; +import com.azure.messaging.eventhubs.models.ErrorContext; +import com.azure.messaging.eventhubs.models.EventContext; +import com.azure.storage.blob.BlobContainerAsyncClient; +import com.azure.storage.blob.BlobContainerClientBuilder; +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class EventHubCacheConsumer { + + @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") + private String nodoCacheRxConnectionString; + @Value("${nodo-dei-pagamenti-cache-rx-name}") + private String nodoCacheRxName; + @Value("${nodo-dei-pagamenti-cache-sa-connection-string}") + private String nodoCacheSaConnectionString; + @Value("${nodo-dei-pagamenti-cache-sa-name}") + private String nodoCacheSaContainerName; + @Value("${nodo-dei-pagamenti-cache-consumer-group}") + private String nodoCacheConsumerGroup; + + @Autowired + private CacheServiceFactory cacheServiceFactory; + +// @Bean +// EventHubClientBuilder eventHubClientBuilder() { +// return new EventHubClientBuilder().connectionString(nodoCacheRxConnectionString); +// } + +// @Bean +// BlobContainerClientBuilder blobContainerClientBuilder() { +// return new BlobContainerClientBuilder().connectionString(nodoCacheSaConnectionString) +// .containerName(nodoCacheSaContainerName); +// } + + @Bean + BlobContainerAsyncClient blobContainerAsyncClient() { + return new BlobContainerClientBuilder().connectionString(nodoCacheSaConnectionString) + .containerName(nodoCacheSaContainerName).buildAsyncClient(); + } + +// @Bean +// EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient blobContainerAsyncClient) { +// return new EventProcessorClientBuilder().connectionString(nodoCacheRxConnectionString) +// .consumerGroup(nodoCacheConsumerGroup) +// .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) +// .processEvent(NodoCacheEHClientConfiguration::processEvent) +// .processError(NodoCacheEHClientConfiguration::processError); +// } + + @Bean + EventProcessorClient eventProcessorClient(BlobContainerAsyncClient blobContainerAsyncClient) { + return new EventProcessorClientBuilder().connectionString(nodoCacheRxConnectionString) + .consumerGroup(nodoCacheConsumerGroup) + .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) + .processEvent(EventHubCacheConsumer::processEvent) + .processError(EventHubCacheConsumer::processError).buildEventProcessorClient(); + } + + public static void processEvent(EventContext eventContext) { + log.info("Processing event from partition {} with sequence number {} with body: {}", + eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), + eventContext.getEventData().getBodyAsString()); + CacheServiceFactory.getService(TargetRefreshEnum.config).sync(); + } + + public static void processError(ErrorContext errorContext) { + log.error("Error occurred in partition processor for partition {}, {}", + errorContext.getPartitionContext().getPartitionId(), + errorContext.getThrowable().getMessage(), + errorContext.getThrowable()); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java index 3b7d602..1925135 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java @@ -1,21 +1,42 @@ package it.gov.pagopa.node.cfgsync.service; +import com.fasterxml.jackson.databind.ObjectMapper; import feign.Feign; import feign.FeignException; +import feign.Response; import it.gov.pagopa.node.cfgsync.client.StandInManagerClient; +import it.gov.pagopa.node.cfgsync.client.model.StandInManagerResponse; import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; -@Component +import java.io.IOException; +import java.util.Collection; +import java.util.Map; + +@Service @Slf4j public class StandInManagerCacheService extends CommonCacheService implements CacheService { - @Value("${service.stand-in-manager.enabled}") private boolean enabled; - @Value("${service.stand-in-manager.subscriptionKey}") private String subscriptionKey; + @Value("${service.stand-in-manager.enabled}") + private boolean enabled; + @Value("${service.stand-in-manager.subscriptionKey}") + private String subscriptionKey; + @Value("${stand-in-rx-connection-string}") + private String standInRxConnectionString; + @Value("${stand-in-rx-name}") + private String standInRxName; + @Value("${stand-in-sa-connection-string}") + private String standInSaConnectionString; + @Value("${stand-in-sa-name}") + private String standInSaContainerName; + @Value("${stand-in-consumer-group}") + private String standInConsumerGroup; private final StandInManagerClient standInManagerClient; @@ -29,23 +50,34 @@ public TargetRefreshEnum getType() { } @Override - public void syncCache() { + public void sync() { try { if( !enabled ) { throw new AppException(AppError.SERVICE_DISABLED, getType()); } log.debug("SyncService stand-in-manager get cache"); -// Response response = standInManagerClient.refresh(subscriptionKey); -// int httpResponseCode = response.status(); -// if (httpResponseCode != HttpStatus.OK.value()) { -// log.error("SyncService stand-in-manager get cache error - result: httpStatusCode[{}]", httpResponseCode); -// } else { -// log.info("SyncService stand-in-manager get cache successful"); -// } + Response response = standInManagerClient.getCache(subscriptionKey); + int httpResponseCode = response.status(); + if (httpResponseCode != HttpStatus.OK.value()) { + log.error("SyncService stand-in-manager get stations error - result: httpStatusCode[{}]", httpResponseCode); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } + log.info("SyncService stand-in-manager get stations successful"); + + Map> headers = response.headers(); + if( headers.isEmpty() ) { + log.error("SyncService api-config-cache get cache error - empty header"); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } + + StandInManagerResponse standInManagerResponse = new ObjectMapper().readValue(response.body().asInputStream(), StandInManagerResponse.class); + //TODO: chiamare repository per salvare le stazioni } catch (FeignException.GatewayTimeout e) { log.error("SyncService stand-in-manager get cache error: Gateway timeout", e); - } catch (FeignException e) { - log.error("SyncService stand-in-manager get cache error", e); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } catch (FeignException | IOException e) { + log.error("SyncService api-config-cache get cache error", e); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); } } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java b/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java index 981faaa..49facb0 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java @@ -3,16 +3,25 @@ import javax.persistence.Column; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.zip.DeflaterOutputStream; +import java.util.zip.Deflater; public class Utils { - public static byte[] zipContent(byte[] datas) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - DeflaterOutputStream dos = new DeflaterOutputStream(out); - dos.write(datas); - dos.close(); - return out.toByteArray(); + public static byte[] zipContent(byte[] input) throws IOException { + Deflater compressor = new Deflater(); + compressor.setLevel(Deflater.BEST_COMPRESSION); + compressor.setInput(input); + compressor.finish(); + + ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length); + + byte[] buf = new byte[1024]; + while (!compressor.finished()) { + int count = compressor.deflate(buf); + bos.write(buf, 0, count); + } + bos.close(); + return bos.toByteArray(); } public static Object trimValueColumn(Class clazz, String columnName, String value) { diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index e145278..78afb8e 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -13,7 +13,7 @@ app.update.nodo.postgre.pagopa=true app.trimCacheColumn=true # Api Config Cache configuration -service.api-config-cache.enabled=false +service.api-config-cache.enabled=true service.api-config-cache.host=https://api.dev.platform.pagopa.it/api-config-cache/p/v1 service.api-config-cache.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} @@ -26,20 +26,26 @@ nodo-dei-pagamenti-cache-rx-connection-string=${NODO_CACHE_RX_CONNECTION_STRING} nodo-dei-pagamenti-cache-rx-name=nodo-dei-pagamenti-cache nodo-dei-pagamenti-cache-sa-connection-string=${NODO_CACHE_SA_CONNECTION_STRING} nodo-dei-pagamenti-cache-sa-name=prova +nodo-dei-pagamenti-cache-consumer-group=$Default stand-in-rx-connection-string=${STAND-IN-MANAGER_RX_CONNECTION_STRING} stand-in-rx-name=nodo-dei-pagamenti-stand-in +stand-in-sa-connection-string=${STAND-IN-MANAGER_SA_CONNECTION_STRING} +stand-in-sa-name=prova +stand-in-consumer-group=$Default # DB -spring.sql.init.continue-on-error=true -spring.datasource.auto-commit=false - db.nodo.pagopa.postgre.datasource.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg db.nodo.pagopa.postgre.datasource.username=cfg db.nodo.pagopa.postgre.datasource.password=${DB_NODO_PAGOPA_POSTGRE_PASSWORD} db.nodo.pagopa.postgre.datasource.driverClassName=org.postgresql.Driver +db.nodo.nexi.postgre.datasource.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=cfg +db.nodo.nexi.postgre.datasource.username=cfg +db.nodo.nexi.postgre.datasource.password=${DB_NODO_NEXI_POSTGRE_PASSWORD} +db.nodo.nexi.postgre.datasource.driverClassName=org.postgresql.Driver + db.nodo.nexi.oracle.datasource.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg db.nodo.nexi.oracle.datasource.username=cfg db.nodo.nexi.oracle.datasource.password=${DB_NODO_NEXI_ORACLE_PASSWORD} From f512c1e2ff2c2fa77afa33ff62bde67a6817b8d2 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Mon, 12 Feb 2024 07:24:50 +0100 Subject: [PATCH 09/88] NOD-690: wip --- docker/local-dbs/docker-compose.yml | 5 +- .../config/NodoNexiOConfiguration.java | 72 ------------------ .../config/NodoNexiPConfiguration.java | 73 ------------------ .../config/NodoPagoPAPConfiguration.java | 76 ------------------- .../NexiCacheOracleConfiguration.java | 62 +++++++++++++++ .../NexiCachePostgreConfiguration.java | 58 ++++++++++++++ .../PagoPACachePostgreConfiguration.java | 62 +++++++++++++++ ...ry.java => NexiCacheOracleRepository.java} | 4 +- ...y.java => NexiCachePostgreRepository.java} | 4 +- ...java => PagoPACachePostgreRepository.java} | 4 +- ...mer.java => ApiConfigCacheEhConsumer.java} | 56 +++++--------- .../service/ApiConfigCacheService.java | 42 +++------- .../service/StandInManagerEhConsumer.java | 68 +++++++++++++++++ ...ervice.java => StandInManagerService.java} | 19 +++-- .../resources/application-local.properties | 71 +++++++++-------- src/main/resources/application.properties | 54 ++++++++++--- 16 files changed, 377 insertions(+), 353 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiOConfiguration.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/{CacheNodoNexiPRepository.java => NexiCacheOracleRepository.java} (55%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/{CacheNodoNexiORepository.java => NexiCachePostgreRepository.java} (55%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/{CacheNodoPagoPAPRepository.java => PagoPACachePostgreRepository.java} (54%) rename src/main/java/it/gov/pagopa/node/cfgsync/service/{EventHubCacheConsumer.java => ApiConfigCacheEhConsumer.java} (52%) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java rename src/main/java/it/gov/pagopa/node/cfgsync/service/{StandInManagerCacheService.java => StandInManagerService.java} (84%) diff --git a/docker/local-dbs/docker-compose.yml b/docker/local-dbs/docker-compose.yml index 3e70d2b..8212c25 100644 --- a/docker/local-dbs/docker-compose.yml +++ b/docker/local-dbs/docker-compose.yml @@ -7,9 +7,8 @@ services: - 5432:5432 volumes: - ./postgres-data:/var/lib/postgresql/data - - ./postgres/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql + - ./postgres:/docker-entrypoint-initdb.d environment: - POSTGRES_DB=nodo - POSTGRES_USER=cfg - - POSTGRES_PASSWORD=password - - POSTGRES_ROOT_PASSWORD=root + - POSTGRES_PASSWORD=password \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiOConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiOConfiguration.java deleted file mode 100644 index a679dc2..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiOConfiguration.java +++ /dev/null @@ -1,72 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.*; -import org.springframework.core.env.Environment; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; - -import javax.sql.DataSource; -import java.util.HashMap; - -@Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) -@EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle", - entityManagerFactoryRef = "nodoNexiOEntityManager", - transactionManagerRef = "nodoNexiOTransactionManager" -) -public class NodoNexiOConfiguration { - @Autowired - private Environment env; - - @Bean - public LocalContainerEntityManagerFactoryBean nodoNexiOEntityManager() { - LocalContainerEntityManagerFactoryBean em - = new LocalContainerEntityManagerFactoryBean(); - em.setDataSource(nodoNexiODataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model"); - - HibernateJpaVendorAdapter vendorAdapter - = new HibernateJpaVendorAdapter(); - em.setJpaVendorAdapter(vendorAdapter); - HashMap properties = new HashMap<>(); - properties.put("hibernate.hbm2ddl.auto", - env.getProperty("hibernate.hbm2ddl.auto")); - properties.put("hibernate.dialect", - env.getProperty("hibernate.dialect")); - em.setJpaPropertyMap(properties); - - return em; - } - - @Bean - public DataSource nodoNexiODataSource() { - DriverManagerDataSource dataSource - = new DriverManagerDataSource(); - dataSource.setDriverClassName( - env.getProperty("db.nodo.nexi.oracle.datasource.driverClassName")); - dataSource.setUrl(env.getProperty("db.nodo.nexi.oracle.datasource.url")); - dataSource.setUsername(env.getProperty("db.nodo.nexi.oracle.datasource.username")); - dataSource.setPassword(env.getProperty("db.nodo.nexi.oracle.datasource.password")); - - return dataSource; - } - - @Bean - public PlatformTransactionManager nodoNexiOTransactionManager() { - JpaTransactionManager transactionManager - = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory( - nodoNexiOEntityManager().getObject()); - - return transactionManager; - } -} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.java deleted file mode 100644 index 8d99e7a..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.java +++ /dev/null @@ -1,73 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.*; -import org.springframework.core.env.Environment; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; - -import javax.sql.DataSource; -import java.util.HashMap; - -@Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) -@EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre", - entityManagerFactoryRef = "nodoNexiPEntityManager", - transactionManagerRef = "nodoNexiPTransactionManager" -) -public class NodoNexiPConfiguration { - - @Autowired - private Environment env; - - @Bean - public LocalContainerEntityManagerFactoryBean nodoNexiPEntityManager() { - LocalContainerEntityManagerFactoryBean em - = new LocalContainerEntityManagerFactoryBean(); - em.setDataSource(nodoNexiPDataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model"); - - HibernateJpaVendorAdapter vendorAdapter - = new HibernateJpaVendorAdapter(); - em.setJpaVendorAdapter(vendorAdapter); - HashMap properties = new HashMap<>(); - properties.put("hibernate.hbm2ddl.auto", - env.getProperty("hibernate.hbm2ddl.auto")); - properties.put("hibernate.dialect", - env.getProperty("hibernate.dialect")); - em.setJpaPropertyMap(properties); - - return em; - } - - @Bean - public DataSource nodoNexiPDataSource() { - DriverManagerDataSource dataSource - = new DriverManagerDataSource(); - dataSource.setDriverClassName( - env.getProperty("db.nodo.nexi.postgre.datasource.driverClassName")); - dataSource.setUrl(env.getProperty("db.nodo.nexi.postgre.datasource.url")); - dataSource.setUsername(env.getProperty("db.nodo.nexi.postgre.datasource.username")); - dataSource.setPassword(env.getProperty("db.nodo.nexi.postgre.datasource.password")); - - return dataSource; - } - - @Bean - public PlatformTransactionManager nodoNexiPTransactionManager() { - JpaTransactionManager transactionManager - = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory( - nodoNexiPEntityManager().getObject()); - - return transactionManager; - } -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java deleted file mode 100644 index 0a7cc2d..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoPagoPAPConfiguration.java +++ /dev/null @@ -1,76 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.*; -import org.springframework.core.env.Environment; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; - -import javax.sql.DataSource; -import java.util.HashMap; - -@Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) -@EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", - entityManagerFactoryRef = "nodoPagoPAPEntityManager", - transactionManagerRef = "nodoPagoPAPTransactionManager" -) -public class NodoPagoPAPConfiguration { - - @Autowired - private Environment env; - - @Bean - @Primary - public LocalContainerEntityManagerFactoryBean nodoPagoPAPEntityManager() { - LocalContainerEntityManagerFactoryBean em - = new LocalContainerEntityManagerFactoryBean(); - em.setDataSource(nodoPagoPAPDataSource()); - em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model"); - - HibernateJpaVendorAdapter vendorAdapter - = new HibernateJpaVendorAdapter(); - em.setJpaVendorAdapter(vendorAdapter); - HashMap properties = new HashMap<>(); - properties.put("hibernate.hbm2ddl.auto", - env.getProperty("hibernate.hbm2ddl.auto")); - properties.put("hibernate.dialect", - env.getProperty("hibernate.dialect")); - em.setJpaPropertyMap(properties); - - return em; - } - - @Primary - @Bean - public DataSource nodoPagoPAPDataSource() { - DriverManagerDataSource dataSource - = new DriverManagerDataSource(); - dataSource.setDriverClassName( - env.getProperty("db.nodo.pagopa.postgre.datasource.driverClassName")); - dataSource.setUrl(env.getProperty("db.nodo.pagopa.postgre.datasource.url")); - dataSource.setUsername(env.getProperty("db.nodo.pagopa.postgre.datasource.username")); - dataSource.setPassword(env.getProperty("db.nodo.pagopa.postgre.datasource.password")); - - return dataSource; - } - - @Primary - @Bean - public PlatformTransactionManager nodoPagoPAPTransactionManager() { - JpaTransactionManager transactionManager - = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory( - nodoPagoPAPEntityManager().getObject()); - - return transactionManager; - } -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java new file mode 100644 index 0000000..2a42a14 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java @@ -0,0 +1,62 @@ +package it.gov.pagopa.node.cfgsync.repository.config; + +import com.zaxxer.hikari.HikariDataSource; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.*; +import org.springframework.core.env.Environment; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableTransactionManagement +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle", + entityManagerFactoryRef = "nexiCacheOracleEntityManagerFactory", + transactionManagerRef = "nexiCacheOracleTransactionManager" +) +public class NexiCacheOracleConfiguration { + + @Autowired + private Environment env; + + @Bean + @ConfigurationProperties("spring.datasource.nexi.oracle.cache") + public DataSourceProperties nexiCacheOracleDatasourceProperties() { + return new DataSourceProperties(); + } + + @Bean + @ConfigurationProperties("spring.datasource.nexi.oracle.cache.configuration") + public DataSource nexiCacheOracleDataSource() { + return nexiCacheOracleDatasourceProperties().initializeDataSourceBuilder() + .type(HikariDataSource.class).build(); + } + + @Bean(name = "nexiCacheOracleEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean nexiCacheOracleEntityManagerFactory(EntityManagerFactoryBuilder builder) { + return builder + .dataSource(nexiCacheOracleDataSource()) + .packages(ConfigCache.class) + .build(); + } + + @Bean + public PlatformTransactionManager nexiCacheOracleTransactionManager( + final @Qualifier("nexiCacheOracleEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiCacheOracleEntityManagerFactory) { + return new JpaTransactionManager(nexiCacheOracleEntityManagerFactory.getObject()); + } +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java new file mode 100644 index 0000000..7edee7a --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java @@ -0,0 +1,58 @@ +package it.gov.pagopa.node.cfgsync.repository.configuration; + +import com.zaxxer.hikari.HikariDataSource; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.*; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableTransactionManagement +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre", + entityManagerFactoryRef = "nexiCachePostgreEntityManagerFactory", + transactionManagerRef = "nexiCachePostgreTransactionManager" +) +public class NexiCachePostgreConfiguration { + + @Bean + @ConfigurationProperties("spring.datasource.nexi.postgre.cache") + public DataSourceProperties nexiCachePostgreDatasourceProperties() { + return new DataSourceProperties(); + } + + @Bean + @ConfigurationProperties("spring.datasource.nexi.postgre.cache.configuration") + public DataSource nexiCachePostgreDataSource() { + return nexiCachePostgreDatasourceProperties().initializeDataSourceBuilder() + .type(HikariDataSource.class).build(); + } + + @Bean(name = "nexiCachePostgreEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean nexiCachePostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { + return builder + .dataSource(nexiCachePostgreDataSource()) + .packages(ConfigCache.class) + .build(); + } + + @Bean + public PlatformTransactionManager nexiCachePostgreTransactionManager( + final @Qualifier("nexiCachePostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiCachePostgreEntityManagerFactory) { + return new JpaTransactionManager(nexiCachePostgreEntityManagerFactory.getObject()); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java new file mode 100644 index 0000000..efb0a73 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java @@ -0,0 +1,62 @@ +package it.gov.pagopa.node.cfgsync.repository.configuration; + +import com.zaxxer.hikari.HikariDataSource; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.*; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableTransactionManagement +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", + entityManagerFactoryRef = "pagoPACachePostgreEntityManagerFactory", + transactionManagerRef = "pagoPACachePostgreTransactionManager" +) +public class PagoPACachePostgreConfiguration { + + @Bean + @Primary + @ConfigurationProperties("spring.datasource.pagopa.postgre.cache") + public DataSourceProperties pagoPACachePostgreDatasourceProperties() { + return new DataSourceProperties(); + } + + @Bean + @Primary + @ConfigurationProperties("spring.datasource.pagopa.postgre.cache.configuration") + public DataSource pagoPACachePostgreDataSource() { + return pagoPACachePostgreDatasourceProperties().initializeDataSourceBuilder() + .type(HikariDataSource.class).build(); + } + + @Primary + @Bean(name = "pagoPACachePostgreEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean pagoPACachePostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { + return builder + .dataSource(pagoPACachePostgreDataSource()) + .packages(ConfigCache.class) + .build(); + } + + @Primary + @Bean + public PlatformTransactionManager pagoPACachePostgreTransactionManager( + final @Qualifier("pagoPACachePostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagoPACachePostgreEntityManagerFactory) { + return new JpaTransactionManager(pagoPACachePostgreEntityManagerFactory.getObject()); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/CacheNodoNexiPRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java similarity index 55% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/CacheNodoNexiPRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java index f37b2df..0277223 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/CacheNodoNexiPRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java @@ -2,7 +2,5 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -@Repository -public interface CacheNodoNexiPRepository extends JpaRepository { } \ No newline at end of file +public interface NexiCacheOracleRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/CacheNodoNexiORepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java similarity index 55% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/CacheNodoNexiORepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java index 90dfafa..7bb6e79 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/CacheNodoNexiORepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java @@ -2,7 +2,5 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -@Repository -public interface CacheNodoNexiORepository extends JpaRepository { } \ No newline at end of file +public interface NexiCachePostgreRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java similarity index 54% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java index b7ab42f..b3cb058 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/CacheNodoPagoPAPRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java @@ -2,7 +2,5 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -@Repository -public interface CacheNodoPagoPAPRepository extends JpaRepository { } +public interface PagoPACachePostgreRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/EventHubCacheConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java similarity index 52% rename from src/main/java/it/gov/pagopa/node/cfgsync/service/EventHubCacheConsumer.java rename to src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java index 00ab3c8..7eaa7f1 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/EventHubCacheConsumer.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java @@ -11,60 +11,42 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Service; @Slf4j @Service -public class EventHubCacheConsumer { +@ConditionalOnProperty(prefix = "api-config-cache.consumer", name = "enabled") +public class ApiConfigCacheEhConsumer { - @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") - private String nodoCacheRxConnectionString; - @Value("${nodo-dei-pagamenti-cache-rx-name}") - private String nodoCacheRxName; - @Value("${nodo-dei-pagamenti-cache-sa-connection-string}") - private String nodoCacheSaConnectionString; - @Value("${nodo-dei-pagamenti-cache-sa-name}") - private String nodoCacheSaContainerName; - @Value("${nodo-dei-pagamenti-cache-consumer-group}") - private String nodoCacheConsumerGroup; + @Value("${api-config-cache.rx-connection-string}") + private String configCacheRxConnectionString; + @Value("${api-config-cache.rx-name}") + private String configCacheRxName; + @Value("${api-config-cache.sa-connection-string}") + private String configCacheSaConnectionString; + @Value("${api-config-cache.sa-name}") + private String configCacheSaContainerName; + @Value("${api-config-cache.consumer-group}") + private String configCacheConsumerGroup; @Autowired private CacheServiceFactory cacheServiceFactory; -// @Bean -// EventHubClientBuilder eventHubClientBuilder() { -// return new EventHubClientBuilder().connectionString(nodoCacheRxConnectionString); -// } - -// @Bean -// BlobContainerClientBuilder blobContainerClientBuilder() { -// return new BlobContainerClientBuilder().connectionString(nodoCacheSaConnectionString) -// .containerName(nodoCacheSaContainerName); -// } - @Bean BlobContainerAsyncClient blobContainerAsyncClient() { - return new BlobContainerClientBuilder().connectionString(nodoCacheSaConnectionString) - .containerName(nodoCacheSaContainerName).buildAsyncClient(); + return new BlobContainerClientBuilder().connectionString(configCacheSaConnectionString) + .containerName(configCacheSaContainerName).buildAsyncClient(); } -// @Bean -// EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient blobContainerAsyncClient) { -// return new EventProcessorClientBuilder().connectionString(nodoCacheRxConnectionString) -// .consumerGroup(nodoCacheConsumerGroup) -// .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) -// .processEvent(NodoCacheEHClientConfiguration::processEvent) -// .processError(NodoCacheEHClientConfiguration::processError); -// } - @Bean EventProcessorClient eventProcessorClient(BlobContainerAsyncClient blobContainerAsyncClient) { - return new EventProcessorClientBuilder().connectionString(nodoCacheRxConnectionString) - .consumerGroup(nodoCacheConsumerGroup) + return new EventProcessorClientBuilder().connectionString(configCacheRxConnectionString) + .consumerGroup(configCacheConsumerGroup) .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) - .processEvent(EventHubCacheConsumer::processEvent) - .processError(EventHubCacheConsumer::processError).buildEventProcessorClient(); + .processEvent(ApiConfigCacheEhConsumer::processEvent) + .processError(ApiConfigCacheEhConsumer::processError).buildEventProcessorClient(); } public static void processEvent(EventContext eventContext) { diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 5035bb6..29c3aff 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -8,8 +8,8 @@ import it.gov.pagopa.node.cfgsync.exception.AppException; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; -import it.gov.pagopa.node.cfgsync.repository.nexioracle.CacheNodoNexiPRepository; -import it.gov.pagopa.node.cfgsync.repository.pagopa.CacheNodoPagoPAPRepository; +import it.gov.pagopa.node.cfgsync.repository.nexipostgre.NexiCachePostgreRepository; +import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgreRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -17,7 +17,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionCallbackWithoutResult; import org.springframework.transaction.support.TransactionTemplate; @@ -36,41 +35,21 @@ public class ApiConfigCacheService extends CommonCacheService implements CacheSe private static final String HEADER_CACHE_TIMESTAMP = "X-CACHE-TIMESTAMP"; private static final String HEADER_CACHE_VERSION = "X-CACHE-VERSION"; - @Value("${service.api-config-cache.enabled}") + @Value("${api-config-cache.service.enabled}") private boolean enabled; - @Value("${service.api-config-cache.subscriptionKey}") + @Value("${api-config-cache.service.subscriptionKey}") private String subscriptionKey; - @Value("${nodo-dei-pagamenti-cache-rx-connection-string}") - private String nodoCacheRxConnectionString; - @Value("${nodo-dei-pagamenti-cache-rx-name}") - private String nodoCacheRxName; - @Value("${nodo-dei-pagamenti-cache-sa-connection-string}") - private String nodoCacheSaConnectionString; - @Value("${nodo-dei-pagamenti-cache-sa-name}") - private String nodoCacheSaContainerName; - @Value("${nodo-dei-pagamenti-cache-consumer-group}") - private String nodoCacheConsumerGroup; private final ApiConfigCacheClient apiConfigCacheClient; @Autowired - private CacheNodoPagoPAPRepository cacheNodoPagoPAPRepository; + private PagoPACachePostgreRepository pagoPACachePostgreRepository; @Autowired - private CacheNodoNexiPRepository cacheNodoNexiPRepository; -// @Autowired -// private TransactionTemplate transactionTemplate; -// -// transactionTemplate.execute(new TransactionCallbackWithoutResult() { -// @Override -// public void doInTransactionWithoutResult(TransactionStatus transactionStatus) { -// cacheNodoPagoPAPRepository.save(configCache); -// cacheNodoNexiPRepository.save(configCache); -// } -// }); + private NexiCachePostgreRepository nexiCachePostgreRepository; private final TransactionTemplate transactionTemplate; - public ApiConfigCacheService(@Value("${service.api-config-cache.host}") String apiConfigCacheUrl, PlatformTransactionManager transactionManager) { + public ApiConfigCacheService(@Value("${api-config-cache.service.host}") String apiConfigCacheUrl, PlatformTransactionManager transactionManager) { apiConfigCacheClient = Feign.builder().target(ApiConfigCacheClient.class, apiConfigCacheUrl); transactionTemplate = new TransactionTemplate(transactionManager); } @@ -110,8 +89,8 @@ public void sync() { this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { public void doInTransactionWithoutResult(TransactionStatus status) { try { - cacheNodoPagoPAPRepository.save(configCache); - cacheNodoNexiPRepository.save(configCache); + pagoPACachePostgreRepository.save(configCache); + nexiCachePostgreRepository.save(configCache); } catch(NoSuchElementException ex) { status.setRollbackOnly(); } @@ -123,6 +102,9 @@ public void doInTransactionWithoutResult(TransactionStatus status) { } catch (IOException e) { log.error("SyncService api-config-cache get cache error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } catch (Exception e) { + log.error("SyncService api-config-cache get cache error", e); + throw new AppException(AppError.INTERNAL_SERVER_ERROR); } } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java new file mode 100644 index 0000000..649c126 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java @@ -0,0 +1,68 @@ +package it.gov.pagopa.node.cfgsync.service; + +import com.azure.messaging.eventhubs.EventProcessorClient; +import com.azure.messaging.eventhubs.EventProcessorClientBuilder; +import com.azure.messaging.eventhubs.checkpointstore.blob.BlobCheckpointStore; +import com.azure.messaging.eventhubs.models.ErrorContext; +import com.azure.messaging.eventhubs.models.EventContext; +import com.azure.storage.blob.BlobContainerAsyncClient; +import com.azure.storage.blob.BlobContainerClientBuilder; +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@ConditionalOnProperty(prefix = "stand-in-manager.consumer", name = "enabled") +public class StandInManagerEhConsumer { + + @Value("${stand-in-manager.rx-connection-string}") + private String standInManagerRxConnectionString; + @Value("${stand-in-manager.rx-name}") + private String standInManagerRxName; + @Value("${stand-in-manager.sa-connection-string}") + private String standInManagerSaConnectionString; + @Value("${stand-in-manager.sa-name}") + private String standInManagerSaContainerName; + @Value("${stand-in-manager.consumer-group}") + private String standInManagerConsumerGroup; + + @Autowired + private CacheServiceFactory cacheServiceFactory; + + @Bean + BlobContainerAsyncClient blobContainerStandInAsyncClient() { + return new BlobContainerClientBuilder().connectionString(standInManagerSaConnectionString) + .containerName(standInManagerSaContainerName).buildAsyncClient(); + } + + @Bean + EventProcessorClient eventProcessorStandInClient(BlobContainerAsyncClient blobContainerAsyncClient) { + return new EventProcessorClientBuilder().connectionString(standInManagerRxConnectionString) + .consumerGroup(standInManagerConsumerGroup) + .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) + .processEvent(StandInManagerEhConsumer::processEvent) + .processError(StandInManagerEhConsumer::processError).buildEventProcessorClient(); + } + + public static void processEvent(EventContext eventContext) { + log.info("Processing event {} from partition {} with sequence number {} with body: {}", + TargetRefreshEnum.standin.label, + eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), + eventContext.getEventData().getBodyAsString()); + CacheServiceFactory.getService(TargetRefreshEnum.config).sync(); + } + + public static void processError(ErrorContext errorContext) { + log.error("Error occurred in partition processor {} for partition {}, {}", + TargetRefreshEnum.standin.label, + errorContext.getPartitionContext().getPartitionId(), + errorContext.getThrowable().getMessage(), + errorContext.getThrowable()); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java similarity index 84% rename from src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java rename to src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 1925135..fa9c196 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -12,7 +12,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import java.io.IOException; @@ -21,26 +20,26 @@ @Service @Slf4j -public class StandInManagerCacheService extends CommonCacheService implements CacheService { +public class StandInManagerService extends CommonCacheService implements CacheService { - @Value("${service.stand-in-manager.enabled}") + @Value("${stand-in-manager.service.enabled}") private boolean enabled; - @Value("${service.stand-in-manager.subscriptionKey}") + @Value("${stand-in-manager.service.subscriptionKey}") private String subscriptionKey; - @Value("${stand-in-rx-connection-string}") + @Value("${stand-in-manager.rx-connection-string}") private String standInRxConnectionString; - @Value("${stand-in-rx-name}") + @Value("${stand-in-manager.rx-name}") private String standInRxName; - @Value("${stand-in-sa-connection-string}") + @Value("${stand-in-manager.sa-connection-string}") private String standInSaConnectionString; - @Value("${stand-in-sa-name}") + @Value("${stand-in-manager.sa-name}") private String standInSaContainerName; - @Value("${stand-in-consumer-group}") + @Value("${stand-in-manager.consumer-group}") private String standInConsumerGroup; private final StandInManagerClient standInManagerClient; - public StandInManagerCacheService(@Value("${service.stand-in-manager.host}") String standInManagerUrl) { + public StandInManagerService(@Value("${stand-in-manager.service.host}") String standInManagerUrl) { standInManagerClient = Feign.builder().target(StandInManagerClient.class, standInManagerUrl); } diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 78afb8e..8fe5385 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -13,40 +13,47 @@ app.update.nodo.postgre.pagopa=true app.trimCacheColumn=true # Api Config Cache configuration -service.api-config-cache.enabled=true -service.api-config-cache.host=https://api.dev.platform.pagopa.it/api-config-cache/p/v1 -service.api-config-cache.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} +api-config-cache.service.enabled=true +api-config-cache.service.host=https://api.dev.platform.pagopa.it/api-config-cache/p/v1 +api-config-cache.service.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} -# Stand-in Manager configuration -service.stand-in-manager.enabled=true -service.stand-in-manager.host=https://api.dev.platform.pagopa.it/technical-support/stand-in/api/v1 -service.stand-in-manager.subscriptionKey=${STAND-IN_MANAGER_SUBSCRIPTION_KEY} - -nodo-dei-pagamenti-cache-rx-connection-string=${NODO_CACHE_RX_CONNECTION_STRING} -nodo-dei-pagamenti-cache-rx-name=nodo-dei-pagamenti-cache -nodo-dei-pagamenti-cache-sa-connection-string=${NODO_CACHE_SA_CONNECTION_STRING} -nodo-dei-pagamenti-cache-sa-name=prova -nodo-dei-pagamenti-cache-consumer-group=$Default +api-config-cache.consumer.enabled=true +api-config-cache.rx-connection-string=${API_CONFIG_CACHE_RX_CONNECTION_STRING} +api-config-cache.rx-name=nodo-dei-pagamenti-cache +api-config-cache.sa-connection-string=${API_CONFIG_CACHE_SA_CONNECTION_STRING} +api-config-cache.sa-name=prova +api-config-cache.consumer-group=$Default +# Stand-in Manager configuration +stand-in-manager.service.enabled=true +stand-in-manager.service.host=https://api.dev.platform.pagopa.it/technical-support/stand-in/api/v1 +stand-in-manager.service.subscriptionKey=${STAND_IN_MANAGER_SUBSCRIPTION_KEY} -stand-in-rx-connection-string=${STAND-IN-MANAGER_RX_CONNECTION_STRING} -stand-in-rx-name=nodo-dei-pagamenti-stand-in -stand-in-sa-connection-string=${STAND-IN-MANAGER_SA_CONNECTION_STRING} -stand-in-sa-name=prova -stand-in-consumer-group=$Default +stand-in-manager.consumer.enabled=false +stand-in-manager.rx-connection-string=${STAND_IN_MANAGER_RX_CONNECTION_STRING} +stand-in-manager.rx-name=nodo-dei-pagamenti-stand-in +stand-in-manager.sa-connection-string=${STAND_IN_MANAGER_SA_CONNECTION_STRING} +stand-in-manager.sa-name=prova +stand-in-manager.consumer-group=$Default # DB -db.nodo.pagopa.postgre.datasource.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg -db.nodo.pagopa.postgre.datasource.username=cfg -db.nodo.pagopa.postgre.datasource.password=${DB_NODO_PAGOPA_POSTGRE_PASSWORD} -db.nodo.pagopa.postgre.datasource.driverClassName=org.postgresql.Driver - -db.nodo.nexi.postgre.datasource.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=cfg -db.nodo.nexi.postgre.datasource.username=cfg -db.nodo.nexi.postgre.datasource.password=${DB_NODO_NEXI_POSTGRE_PASSWORD} -db.nodo.nexi.postgre.datasource.driverClassName=org.postgresql.Driver - -db.nodo.nexi.oracle.datasource.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg -db.nodo.nexi.oracle.datasource.username=cfg -db.nodo.nexi.oracle.datasource.password=${DB_NODO_NEXI_ORACLE_PASSWORD} -db.nodo.nexi.oracle.datasource.driverClassName=oracle.jdbc.driver.OracleDriver +#spring.jpa.hibernate.ddl-auto=update +#spring.jpa.generate-ddl=true +spring.jpa.show-sql=true + +spring.datasource.continue-on-error=true + +spring.datasource.pagopa.postgre.cache.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg +spring.datasource.pagopa.postgre.cache.username=cfg +spring.datasource.pagopa.postgre.cache.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} +spring.datasource.pagopa.postgre.cache.driver-class-name=org.postgresql.Driver + +spring.datasource.nexi.postgre.cache.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=public +spring.datasource.nexi.postgre.cache.username=cfg +spring.datasource.nexi.postgre.cache.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} +spring.datasource.nexi.postgre.cache.driver-class-name=org.postgresql.Driver + +spring.datasource.nexi.oracle.cache.url=jdbc:oracle:thin:@//localhost:1521/cfg +spring.datasource.nexi.oracle.cache.username=cfg +spring.datasource.nexi.oracle.cache.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} +spring.datasource.nexi.oracle.cache.driver-class-name=oracle.jdbc.driver.OracleDriver \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 32d3677..663cd58 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -30,19 +30,51 @@ cors.configuration=${CORS_CONFIGURATION:'{"origins": ["*"], "methods": ["*"]}'} # Functionality -app.update.nodo.oracle.nexi=${APP_UPDATE_NODO_ORACLE_NEXI:true} -app.update.nodo.postgre.nexi=${APP_UPDATE_NODO_POSTGRE_NEXI:true} -app.update.nodo.postgre.pagopa=${APP_UPDATE_NODO_POSTGRE_PAGOA:true} -app.trimCacheColumn=${APP_TRIM_CACHE_COLUMN:true} +app.update.nodo.oracle.nexi=true +app.update.nodo.postgre.nexi=true +app.update.nodo.postgre.pagopa=true +app.trimCacheColumn=true # Api Config Cache configuration -service.api-config-cache.host=${API_CONFIG_CACHE_HOST} -service.api-config-cache.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} +api-config-cache.service.enabled=true +api-config-cache.service.host=https://api.dev.platform.pagopa.it/api-config-cache/p/v1 +api-config-cache.service.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} -#EventHub -nodo-dei-pagamenti-cache-rx-connection-string=${CACHE_RX_CONNECTION_STRING} -nodo-dei-pagamenti-cache-rx-name=${CACHET_RX_NAME:nodo-dei-pagamenti-cache} +api-config-cache.consumer.enabled=true +api-config-cache.rx-connection-string=${API_CONFIG_CACHE_RX_CONNECTION_STRING} +api-config-cache.rx-name=nodo-dei-pagamenti-cache +api-config-cache.sa-connection-string=${API_CONFIG_CACHE_SA_CONNECTION_STRING} +api-config-cache.sa-name=prova +api-config-cache.consumer-group=$Default + +# Stand-in Manager configuration +stand-in-manager.service.enabled=true +stand-in-manager.service.host=https://api.dev.platform.pagopa.it/technical-support/stand-in/api/v1 +stand-in-manager.service.subscriptionKey=${STAND_IN_MANAGER_SUBSCRIPTION_KEY} + +stand-in-manager.consumer.enabled=false +stand-in-manager.rx-connection-string=${STAND_IN_MANAGER_RX_CONNECTION_STRING} +stand-in-manager.rx-name=nodo-dei-pagamenti-stand-in +stand-in-manager.sa-connection-string=${STAND_IN_MANAGER_SA_CONNECTION_STRING} +stand-in-manager.sa-name=prova +stand-in-manager.consumer-group=$Default # DB -spring.sql.init.continue-on-error=${APP_INIT_CONTINUE_ON_ERROR:false} -spring.datasource.auto-commit=${DATASOURCE_AUTO_COMMIT:false} +#spring.jpa.hibernate.ddl-auto=update +#spring.jpa.generate-ddl=true +spring.jpa.show-sql=true + +spring.datasource.pagopa.postgre.cache.url=${DB_PAGOPA_POSTGRE_CACHE_URL} +spring.datasource.pagopa.postgre.cache.username=${DB_PAGOPA_POSTGRE_CACHE_USER} +spring.datasource.pagopa.postgre.cache.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} +spring.datasource.pagopa.postgre.cache.driver-class-name=org.postgresql.Driver + +spring.datasource.nexi.postgre.cache.url=${DB_NEXI_POSTGRE_CACHE_URL} +spring.datasource.nexi.postgre.cache.username=${DB_NEXI_POSTGRE_CACHE_USER} +spring.datasource.nexi.postgre.cache.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} +spring.datasource.nexi.postgre.cache.driver-class-name=org.postgresql.Driver + +spring.datasource.nexi.oracle.cache.url=${DB_NEXI_ORACLE_CACHE_URL} +spring.datasource.nexi.oracle.cache.username=${DB_NEXI_ORACLE_CACHE_USER} +spring.datasource.nexi.oracle.cache.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} +spring.datasource.nexi.oracle.cache.driver-class-name=oracle.jdbc.driver.OracleDriver From fdfe4e587ceb298d248e8805ce8ddbfd43c34b99 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Fri, 16 Feb 2024 11:15:03 +0100 Subject: [PATCH 10/88] NOD-690: wip --- .../controller/SyncCacheController.java | 99 +++++++++++++------ .../node/cfgsync/model/RefreshResponse.java | 5 +- .../NexiCacheOracleConfiguration.java | 4 +- .../NexiCachePostgreConfiguration.java | 4 +- .../NexiStandInOracleConfiguration.java | 68 +++++++++++++ .../NexiStandInPostgreConfiguration.java | 64 ++++++++++++ .../PagoPACachePostgreConfiguration.java | 4 +- .../PagoPAStandInPostgreConfiguration.java | 61 ++++++++++++ .../NexiCacheOracleRepository.java | 2 +- .../standin/NexiStandInOracleRepository.java | 7 ++ .../NexiCachePostgreRepository.java | 2 +- .../standin/NexiStandInPostgreRepository.java | 6 ++ .../PagoPACachePostgreRepository.java | 2 +- .../PagoPAStandInPostgreRepository.java | 6 ++ .../service/ApiConfigCacheEhConsumer.java | 16 +-- .../service/ApiConfigCacheService.java | 43 ++++---- .../node/cfgsync/service/CacheService.java | 9 -- .../cfgsync/service/CacheServiceFactory.java | 32 ------ .../service/StandInManagerEhConsumer.java | 15 +-- .../service/StandInManagerService.java | 76 +++++++++----- .../gov/pagopa/node/cfgsync/util/Utils.java | 18 ++-- .../resources/application-local.properties | 37 +++++-- src/main/resources/application.properties | 9 +- src/main/resources/logback-spring.xml | 4 + 24 files changed, 432 insertions(+), 161 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInOracleConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInPostgreConfiguration.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAStandInPostgreConfiguration.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/{ => cache}/NexiCacheOracleRepository.java (77%) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/standin/NexiStandInOracleRepository.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/{ => cache}/NexiCachePostgreRepository.java (77%) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/standin/NexiStandInPostgreRepository.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/{ => cache}/PagoPACachePostgreRepository.java (78%) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/standin/PagoPAStandInPostgreRepository.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/service/CacheServiceFactory.java diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java index 86164b8..d83c726 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java @@ -8,38 +8,35 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import it.gov.pagopa.node.cfgsync.model.ProblemJson; import it.gov.pagopa.node.cfgsync.model.RefreshResponse; -import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; -import it.gov.pagopa.node.cfgsync.service.CacheServiceFactory; +import it.gov.pagopa.node.cfgsync.service.ApiConfigCacheService; +import it.gov.pagopa.node.cfgsync.service.StandInManagerService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.UUID; - @Slf4j @RestController -@RequestMapping("/sync") +@RequestMapping("/ndp") @Validated public class SyncCacheController { @Autowired - private CacheServiceFactory cacheServiceFactory; + private ApiConfigCacheService apiConfigCacheService; + @Autowired + private StandInManagerService standInManagerService; @Operation( - summary = "Sync target v1 config", + summary = "Force stand-in configuration update", security = {@SecurityRequirement(name = "ApiKey")}, tags = { - "Cache", + "StandIn", }) @ApiResponses( value = { @@ -61,10 +58,6 @@ public class SyncCacheController { responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema())), - @ApiResponse( - responseCode = "403", - description = "Forbidden", - content = @Content(schema = @Schema())), @ApiResponse( responseCode = "429", description = "Too many requests", @@ -77,24 +70,68 @@ public class SyncCacheController { mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))) }) - @GetMapping( - value = "/v1/{target}", - produces = {MediaType.APPLICATION_JSON_VALUE}) - public ResponseEntity cache(@PathVariable TargetRefreshEnum target) { - - log.debug("Sync {} configuration", target.label); - CacheServiceFactory.getService(target).sync(); + @PostMapping( + value = "/stand-in", + consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity standin() { - String requestId = UUID.randomUUID().toString(); - ZonedDateTime timestamp = ZonedDateTime.now(); - - HttpHeaders responseHeaders = new HttpHeaders(); - responseHeaders.set("X-REQUEST-ID", requestId); - responseHeaders.set("X-CACHE-TIMESTAMP", DateTimeFormatter.ISO_DATE_TIME.format(timestamp)); + log.debug("Force stand-in configuration update"); + standInManagerService.forceStandIn(); return ResponseEntity.ok() - .headers(responseHeaders) - .body(RefreshResponse.builder().timestamp(timestamp).id(requestId).build()); + .body(RefreshResponse.builder().serviceIdentifier("").status("done").build()); } + @Operation( + summary = "Force cache configuration update", + security = {@SecurityRequirement(name = "ApiKey")}, + tags = { + "Cache", + }) + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + description = "OK", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE + )), + @ApiResponse( + responseCode = "400", + description = "Bad Request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "401", + description = "Unauthorized", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "429", + description = "Too many requests", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "500", + description = "Service unavailable", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))) + }) + @PostMapping( + value = "/cache", + consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity cache() { + + log.debug("Force cache configuration update"); + apiConfigCacheService.forceCacheUpdate(); + + return ResponseEntity.ok() + .body(RefreshResponse.builder().serviceIdentifier("").status("done").build()); + } + } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java index 602c100..babdbfd 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java @@ -14,7 +14,6 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class RefreshResponse { - @NotNull private String id; -// @NotNull private String version; - @NotNull private ZonedDateTime timestamp; + @NotNull private String serviceIdentifier; + @NotNull private String status; } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java index 2a42a14..f8c28e0 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java @@ -4,6 +4,7 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; @@ -24,10 +25,11 @@ }) @EnableTransactionManagement @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle", + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle.cache", entityManagerFactoryRef = "nexiCacheOracleEntityManagerFactory", transactionManagerRef = "nexiCacheOracleTransactionManager" ) +@ConditionalOnProperty(prefix = "spring.datasource.nexi.oracle.cache", name = "enabled") public class NexiCacheOracleConfiguration { @Autowired diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java index 7edee7a..31b3633 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java @@ -3,6 +3,7 @@ import com.zaxxer.hikari.HikariDataSource; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; @@ -22,10 +23,11 @@ }) @EnableTransactionManagement @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre", + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre.cache", entityManagerFactoryRef = "nexiCachePostgreEntityManagerFactory", transactionManagerRef = "nexiCachePostgreTransactionManager" ) +@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgre.cache", name = "enabled") public class NexiCachePostgreConfiguration { @Bean diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInOracleConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInOracleConfiguration.java new file mode 100644 index 0000000..e7794e3 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInOracleConfiguration.java @@ -0,0 +1,68 @@ +package it.gov.pagopa.node.cfgsync.repository.configuration; + +import com.zaxxer.hikari.HikariDataSource; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.PropertySources; +import org.springframework.core.env.Environment; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableTransactionManagement +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle.standin", + entityManagerFactoryRef = "nexiStandInOracleEntityManagerFactory", + transactionManagerRef = "nexiStandInOracleTransactionManager" +) +@ConditionalOnProperty(prefix = "spring.datasource.nexi.oracle.standin", name = "enabled") +public class NexiStandInOracleConfiguration { + + @Autowired + private Environment env; + + @Bean + @ConfigurationProperties("spring.datasource.nexi.oracle.standin") + public DataSourceProperties nexiStandInOracleDatasourceProperties() { + return new DataSourceProperties(); + } + + @Bean + @ConfigurationProperties("spring.datasource.nexi.oracle.standin.configuration") + public DataSource nexiStandInOracleDataSource() { + return nexiStandInOracleDatasourceProperties().initializeDataSourceBuilder() + .type(HikariDataSource.class).build(); + } + + @Bean(name = "nexiStandInOracleEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean nexiStandInOracleEntityManagerFactory(EntityManagerFactoryBuilder builder) { + return builder + .dataSource(nexiStandInOracleDataSource()) + .packages(StandInStations.class) + .build(); + } + + @Bean + public PlatformTransactionManager nexiStandInOracleTransactionManager( + final @Qualifier("nexiStandInOracleEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiStandInOracleEntityManagerFactory) { + return new JpaTransactionManager(nexiStandInOracleEntityManagerFactory.getObject()); + } +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInPostgreConfiguration.java new file mode 100644 index 0000000..8fa6207 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInPostgreConfiguration.java @@ -0,0 +1,64 @@ +package it.gov.pagopa.node.cfgsync.repository.configuration; + +import com.zaxxer.hikari.HikariDataSource; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.PropertySources; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableTransactionManagement +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre.standin", + entityManagerFactoryRef = "nexiStandInPostgreEntityManagerFactory", + transactionManagerRef = "nexiStandInPostgreTransactionManager" +) +@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgre.standin", name = "enabled") +public class NexiStandInPostgreConfiguration { + + @Bean + @ConfigurationProperties("spring.datasource.nexi.postgre.standin") + public DataSourceProperties nexiStandInPostgreDatasourceProperties() { + return new DataSourceProperties(); + } + + @Bean + @ConfigurationProperties("spring.datasource.nexi.postgre.standin.configuration") + public DataSource nexiStandInPostgreDataSource() { + return nexiStandInPostgreDatasourceProperties().initializeDataSourceBuilder() + .type(HikariDataSource.class).build(); + } + + @Bean(name = "nexiStandInPostgreEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean nexiStandInPostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { + return builder + .dataSource(nexiStandInPostgreDataSource()) + .packages(StandInStations.class) + .build(); + } + + @Bean + public PlatformTransactionManager nexiStandInPostgreTransactionManager( + final @Qualifier("nexiStandInPostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiStandInPostgreEntityManagerFactory) { + return new JpaTransactionManager(nexiStandInPostgreEntityManagerFactory.getObject()); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java index efb0a73..a5e45c9 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java @@ -3,6 +3,7 @@ import com.zaxxer.hikari.HikariDataSource; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; @@ -22,10 +23,11 @@ }) @EnableTransactionManagement @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", + basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa.cache", entityManagerFactoryRef = "pagoPACachePostgreEntityManagerFactory", transactionManagerRef = "pagoPACachePostgreTransactionManager" ) +@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgre.cache", name = "enabled") public class PagoPACachePostgreConfiguration { @Bean diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAStandInPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAStandInPostgreConfiguration.java new file mode 100644 index 0000000..fcad044 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAStandInPostgreConfiguration.java @@ -0,0 +1,61 @@ +package it.gov.pagopa.node.cfgsync.repository.configuration; + +import com.zaxxer.hikari.HikariDataSource; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.*; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; + +@Configuration +@PropertySources({ + @PropertySource("classpath:/application.properties"), + @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +}) +@EnableTransactionManagement +@EnableJpaRepositories( + basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa.standin", + entityManagerFactoryRef = "pagoPAStandInPostgreEntityManagerFactory", + transactionManagerRef = "pagoPAStandInPostgreTransactionManager" +) +@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgre.standin", name = "enabled") +public class PagoPAStandInPostgreConfiguration { + + @Bean + @ConfigurationProperties("spring.datasource.pagopa.postgre.standin") + public DataSourceProperties pagoPAStandInPostgreDatasourceProperties() { + return new DataSourceProperties(); + } + + @Bean + @ConfigurationProperties("spring.datasource.pagopa.postgre.standin.configuration") + public DataSource pagoPAStandInPostgreDataSource() { + return pagoPAStandInPostgreDatasourceProperties().initializeDataSourceBuilder() + .type(HikariDataSource.class).build(); + } + + @Bean(name = "pagoPAStandInPostgreEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean pagoPAStandInPostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { + return builder + .dataSource(pagoPAStandInPostgreDataSource()) + .packages(StandInStations.class) + .build(); + } + + @Bean + public PlatformTransactionManager pagoPAStandInPostgreTransactionManager( + final @Qualifier("pagoPAStandInPostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagoPAStandInPostgreEntityManagerFactory) { + return new JpaTransactionManager(pagoPAStandInPostgreEntityManagerFactory.getObject()); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/cache/NexiCacheOracleRepository.java similarity index 77% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/cache/NexiCacheOracleRepository.java index 0277223..6b6e8f4 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/cache/NexiCacheOracleRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.nexioracle; +package it.gov.pagopa.node.cfgsync.repository.nexioracle.cache; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/standin/NexiStandInOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/standin/NexiStandInOracleRepository.java new file mode 100644 index 0000000..9ff63f1 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/standin/NexiStandInOracleRepository.java @@ -0,0 +1,7 @@ +package it.gov.pagopa.node.cfgsync.repository.nexioracle.standin; + +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface NexiStandInOracleRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/cache/NexiCachePostgreRepository.java similarity index 77% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/cache/NexiCachePostgreRepository.java index 7bb6e79..10fbb35 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/cache/NexiCachePostgreRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.nexipostgre; +package it.gov.pagopa.node.cfgsync.repository.nexipostgre.cache; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/standin/NexiStandInPostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/standin/NexiStandInPostgreRepository.java new file mode 100644 index 0000000..021a5a6 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/standin/NexiStandInPostgreRepository.java @@ -0,0 +1,6 @@ +package it.gov.pagopa.node.cfgsync.repository.nexipostgre.standin; + +import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface NexiStandInPostgreRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/cache/PagoPACachePostgreRepository.java similarity index 78% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/cache/PagoPACachePostgreRepository.java index b3cb058..54373bd 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/cache/PagoPACachePostgreRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.pagopa; +package it.gov.pagopa.node.cfgsync.repository.pagopa.cache; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/standin/PagoPAStandInPostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/standin/PagoPAStandInPostgreRepository.java new file mode 100644 index 0000000..2b0719e --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/standin/PagoPAStandInPostgreRepository.java @@ -0,0 +1,6 @@ +package it.gov.pagopa.node.cfgsync.repository.pagopa.standin; + +import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PagoPAStandInPostgreRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java index 7eaa7f1..3d36190 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java @@ -7,7 +7,7 @@ import com.azure.messaging.eventhubs.models.EventContext; import com.azure.storage.blob.BlobContainerAsyncClient; import com.azure.storage.blob.BlobContainerClientBuilder; -import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -17,6 +17,7 @@ @Slf4j @Service +@RequiredArgsConstructor @ConditionalOnProperty(prefix = "api-config-cache.consumer", name = "enabled") public class ApiConfigCacheEhConsumer { @@ -31,8 +32,7 @@ public class ApiConfigCacheEhConsumer { @Value("${api-config-cache.consumer-group}") private String configCacheConsumerGroup; - @Autowired - private CacheServiceFactory cacheServiceFactory; + private final ApiConfigCacheService apiConfigCacheService; @Bean BlobContainerAsyncClient blobContainerAsyncClient() { @@ -45,18 +45,18 @@ EventProcessorClient eventProcessorClient(BlobContainerAsyncClient blobContainer return new EventProcessorClientBuilder().connectionString(configCacheRxConnectionString) .consumerGroup(configCacheConsumerGroup) .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) - .processEvent(ApiConfigCacheEhConsumer::processEvent) - .processError(ApiConfigCacheEhConsumer::processError).buildEventProcessorClient(); + .processEvent(this::processEvent) + .processError(this::processError).buildEventProcessorClient(); } - public static void processEvent(EventContext eventContext) { + public void processEvent(EventContext eventContext) { log.info("Processing event from partition {} with sequence number {} with body: {}", eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), eventContext.getEventData().getBodyAsString()); - CacheServiceFactory.getService(TargetRefreshEnum.config).sync(); + apiConfigCacheService.forceCacheUpdate(); } - public static void processError(ErrorContext errorContext) { + public void processError(ErrorContext errorContext) { log.error("Error occurred in partition processor for partition {}, {}", errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable().getMessage(), diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 29c3aff..9b68927 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -8,8 +8,9 @@ import it.gov.pagopa.node.cfgsync.exception.AppException; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; -import it.gov.pagopa.node.cfgsync.repository.nexipostgre.NexiCachePostgreRepository; -import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgreRepository; +import it.gov.pagopa.node.cfgsync.repository.nexioracle.cache.NexiCacheOracleRepository; +import it.gov.pagopa.node.cfgsync.repository.nexipostgre.cache.NexiCachePostgreRepository; +import it.gov.pagopa.node.cfgsync.repository.pagopa.cache.PagoPACachePostgreRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -29,7 +30,7 @@ @Service @Slf4j -public class ApiConfigCacheService extends CommonCacheService implements CacheService { +public class ApiConfigCacheService extends CommonCacheService { private static final String HEADER_CACHE_ID = "X-CACHE-ID"; private static final String HEADER_CACHE_TIMESTAMP = "X-CACHE-TIMESTAMP"; @@ -44,8 +45,19 @@ public class ApiConfigCacheService extends CommonCacheService implements CacheSe @Autowired private PagoPACachePostgreRepository pagoPACachePostgreRepository; - @Autowired - private NexiCachePostgreRepository nexiCachePostgreRepository; +// @Autowired +// private NexiCachePostgreRepository nexiCachePostgreRepository; +// @Autowired +// private NexiCacheOracleRepository nexiCacheOracleRepository; + + @Value("${spring.datasource.pagopa.postgre.cache.enabled}") + private Boolean pagopaPostgreCacheEnabled; + + @Value("${spring.datasource.nexi.postgre.cache.enabled}") + private Boolean nexiPostgreCacheEnabled; + + @Value("${spring.datasource.nexi.oracle.cache.enabled}") + private Boolean nexiOracleCacheEnabled; private final TransactionTemplate transactionTemplate; @@ -54,17 +66,11 @@ public ApiConfigCacheService(@Value("${api-config-cache.service.host}") String a transactionTemplate = new TransactionTemplate(transactionManager); } - @Override - public TargetRefreshEnum getType() { - return TargetRefreshEnum.config; - } - - @Override @Transactional - public void sync() { + public void forceCacheUpdate() { try { if( !enabled ) { - throw new AppException(AppError.SERVICE_DISABLED, getType()); + throw new AppException(AppError.SERVICE_DISABLED, TargetRefreshEnum.config); } log.debug("SyncService api-config-cache get cache"); Response response = apiConfigCacheClient.getCache(subscriptionKey); @@ -80,17 +86,18 @@ public void sync() { log.error("SyncService api-config-cache get cache error - empty header"); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } - String cacheId = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_ID); - String cacheTimestamp = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_TIMESTAMP); - String cacheVersion = (String) getHeaderParameter(getType(), headers, HEADER_CACHE_VERSION); + String cacheId = (String) getHeaderParameter(TargetRefreshEnum.config, headers, HEADER_CACHE_ID); + String cacheTimestamp = (String) getHeaderParameter(TargetRefreshEnum.config, headers, HEADER_CACHE_TIMESTAMP); + String cacheVersion = (String) getHeaderParameter(TargetRefreshEnum.config, headers, HEADER_CACHE_VERSION); ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { public void doInTransactionWithoutResult(TransactionStatus status) { try { - pagoPACachePostgreRepository.save(configCache); - nexiCachePostgreRepository.save(configCache); + if( pagopaPostgreCacheEnabled ) pagoPACachePostgreRepository.save(configCache); +// if( nexiPostgreCacheEnabled ) nexiCachePostgreRepository.save(configCache); +// if( nexiOracleCacheEnabled ) nexiCacheOracleRepository.save(configCache); } catch(NoSuchElementException ex) { status.setRollbackOnly(); } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java deleted file mode 100644 index 13ec7a6..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheService.java +++ /dev/null @@ -1,9 +0,0 @@ -package it.gov.pagopa.node.cfgsync.service; - -import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; - -public interface CacheService { - - TargetRefreshEnum getType(); - void sync(); -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheServiceFactory.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheServiceFactory.java deleted file mode 100644 index 3787913..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/CacheServiceFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package it.gov.pagopa.node.cfgsync.service; - -import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Service -public class CacheServiceFactory { - - @Autowired - private List services; - - private static final Map myServiceCache = new HashMap<>(); - - @PostConstruct - public void initMyServiceCache() { - for(CacheService service : services) { - myServiceCache.put(service.getType(), service); - } - } - - public static CacheService getService(TargetRefreshEnum target) { - CacheService service = myServiceCache.get(target); - if(service == null) throw new RuntimeException("Unknown service: " + target.label); - return service; - } -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java index 649c126..99c1103 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java @@ -8,6 +8,7 @@ import com.azure.storage.blob.BlobContainerAsyncClient; import com.azure.storage.blob.BlobContainerClientBuilder; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -17,6 +18,7 @@ @Slf4j @Service +@RequiredArgsConstructor @ConditionalOnProperty(prefix = "stand-in-manager.consumer", name = "enabled") public class StandInManagerEhConsumer { @@ -31,8 +33,7 @@ public class StandInManagerEhConsumer { @Value("${stand-in-manager.consumer-group}") private String standInManagerConsumerGroup; - @Autowired - private CacheServiceFactory cacheServiceFactory; + private final StandInManagerService standInManagerService; @Bean BlobContainerAsyncClient blobContainerStandInAsyncClient() { @@ -45,19 +46,19 @@ EventProcessorClient eventProcessorStandInClient(BlobContainerAsyncClient blobCo return new EventProcessorClientBuilder().connectionString(standInManagerRxConnectionString) .consumerGroup(standInManagerConsumerGroup) .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) - .processEvent(StandInManagerEhConsumer::processEvent) - .processError(StandInManagerEhConsumer::processError).buildEventProcessorClient(); + .processEvent(this::processEvent) + .processError(this::processError).buildEventProcessorClient(); } - public static void processEvent(EventContext eventContext) { + public void processEvent(EventContext eventContext) { log.info("Processing event {} from partition {} with sequence number {} with body: {}", TargetRefreshEnum.standin.label, eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), eventContext.getEventData().getBodyAsString()); - CacheServiceFactory.getService(TargetRefreshEnum.config).sync(); + standInManagerService.forceStandIn(); } - public static void processError(ErrorContext errorContext) { + public void processError(ErrorContext errorContext) { log.error("Error occurred in partition processor {} for partition {}, {}", TargetRefreshEnum.standin.label, errorContext.getPartitionContext().getPartitionId(), diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index fa9c196..ee858e5 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -5,22 +5,31 @@ import feign.FeignException; import feign.Response; import it.gov.pagopa.node.cfgsync.client.StandInManagerClient; -import it.gov.pagopa.node.cfgsync.client.model.StandInManagerResponse; import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import it.gov.pagopa.node.cfgsync.repository.nexioracle.standin.NexiStandInOracleRepository; +import it.gov.pagopa.node.cfgsync.repository.nexipostgre.standin.NexiStandInPostgreRepository; +import it.gov.pagopa.node.cfgsync.repository.pagopa.standin.PagoPAStandInPostgreRepository; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionCallbackWithoutResult; +import org.springframework.transaction.support.TransactionTemplate; import java.io.IOException; -import java.util.Collection; -import java.util.Map; +import java.util.List; +import java.util.NoSuchElementException; @Service @Slf4j -public class StandInManagerService extends CommonCacheService implements CacheService { +public class StandInManagerService extends CommonCacheService { @Value("${stand-in-manager.service.enabled}") private boolean enabled; @@ -38,23 +47,39 @@ public class StandInManagerService extends CommonCacheService implements CacheSe private String standInConsumerGroup; private final StandInManagerClient standInManagerClient; + private final ObjectMapper objectMapper; - public StandInManagerService(@Value("${stand-in-manager.service.host}") String standInManagerUrl) { - standInManagerClient = Feign.builder().target(StandInManagerClient.class, standInManagerUrl); - } + @Autowired + private PagoPAStandInPostgreRepository pagoPAStandInPostgreRepository; +// @Autowired +// private NexiStandInPostgreRepository nexiStandInPostgreRepository; +// @Autowired +// private NexiStandInOracleRepository nexiStandInOracleRepository; + + @Value("${spring.datasource.pagopa.postgre.standin.enabled}") + private Boolean pagopaPostgreStandInEnabled; + + @Value("${spring.datasource.nexi.postgre.standin.enabled}") + private Boolean nexiPostgreStandInEnabled; + + @Value("${spring.datasource.nexi.oracle.standin.enabled}") + private Boolean nexiOracleStandInEnabled; - @Override - public TargetRefreshEnum getType() { - return TargetRefreshEnum.standin; + private final TransactionTemplate transactionTemplate; + + public StandInManagerService(@Value("${stand-in-manager.service.host}") String standInManagerUrl, ObjectMapper objectMapper, PlatformTransactionManager transactionManager) { + standInManagerClient = Feign.builder().target(StandInManagerClient.class, standInManagerUrl); + transactionTemplate = new TransactionTemplate(transactionManager); + this.objectMapper = objectMapper; } - @Override - public void sync() { + @Transactional + public void forceStandIn() { try { if( !enabled ) { - throw new AppException(AppError.SERVICE_DISABLED, getType()); + throw new AppException(AppError.SERVICE_DISABLED, TargetRefreshEnum.standin); } - log.debug("SyncService stand-in-manager get cache"); + log.debug("SyncService api-config-cache get stations"); Response response = standInManagerClient.getCache(subscriptionKey); int httpResponseCode = response.status(); if (httpResponseCode != HttpStatus.OK.value()) { @@ -63,19 +88,24 @@ public void sync() { } log.info("SyncService stand-in-manager get stations successful"); - Map> headers = response.headers(); - if( headers.isEmpty() ) { - log.error("SyncService api-config-cache get cache error - empty header"); - throw new AppException(AppError.INTERNAL_SERVER_ERROR); - } + List stations = (List) objectMapper.readValue(response.body().asInputStream().readAllBytes(), List.class); - StandInManagerResponse standInManagerResponse = new ObjectMapper().readValue(response.body().asInputStream(), StandInManagerResponse.class); - //TODO: chiamare repository per salvare le stazioni + this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { + public void doInTransactionWithoutResult(TransactionStatus status) { + try { + if( pagopaPostgreStandInEnabled ) pagoPAStandInPostgreRepository.saveAll(stations); +// if( nexiPostgreStandInEnabled ) nexiStandInPostgreRepository.saveAll(stations); +// if( nexiOracleStandInEnabled ) nexiStandInOracleRepository.saveAll(stations); + } catch(NoSuchElementException ex) { + status.setRollbackOnly(); + } + } + }); } catch (FeignException.GatewayTimeout e) { - log.error("SyncService stand-in-manager get cache error: Gateway timeout", e); + log.error("SyncService stand-in-manager get stations error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } catch (FeignException | IOException e) { - log.error("SyncService api-config-cache get cache error", e); + log.error("SyncService stand-in-manager get stations error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java b/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java index 49facb0..84ac54e 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/util/Utils.java @@ -4,24 +4,18 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.Deflater; +import java.util.zip.GZIPOutputStream; public class Utils { public static byte[] zipContent(byte[] input) throws IOException { - Deflater compressor = new Deflater(); - compressor.setLevel(Deflater.BEST_COMPRESSION); - compressor.setInput(input); - compressor.finish(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length); - - byte[] buf = new byte[1024]; - while (!compressor.finished()) { - int count = compressor.deflate(buf); - bos.write(buf, 0, count); - } + GZIPOutputStream gzip = new GZIPOutputStream(bos); + gzip.write(input); + gzip.close(); + byte[] compressed = bos.toByteArray(); bos.close(); - return bos.toByteArray(); + return compressed; } public static Object trimValueColumn(Class clazz, String columnName, String value) { diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 8fe5385..83b52e8 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -21,39 +21,58 @@ api-config-cache.consumer.enabled=true api-config-cache.rx-connection-string=${API_CONFIG_CACHE_RX_CONNECTION_STRING} api-config-cache.rx-name=nodo-dei-pagamenti-cache api-config-cache.sa-connection-string=${API_CONFIG_CACHE_SA_CONNECTION_STRING} -api-config-cache.sa-name=prova +api-config-cache.sa-name=synccachereadevent api-config-cache.consumer-group=$Default # Stand-in Manager configuration stand-in-manager.service.enabled=true -stand-in-manager.service.host=https://api.dev.platform.pagopa.it/technical-support/stand-in/api/v1 +stand-in-manager.service.host=https://api.dev.platform.pagopa.it/stand-in-manager/api/v1/stations stand-in-manager.service.subscriptionKey=${STAND_IN_MANAGER_SUBSCRIPTION_KEY} -stand-in-manager.consumer.enabled=false +stand-in-manager.consumer.enabled=true stand-in-manager.rx-connection-string=${STAND_IN_MANAGER_RX_CONNECTION_STRING} stand-in-manager.rx-name=nodo-dei-pagamenti-stand-in stand-in-manager.sa-connection-string=${STAND_IN_MANAGER_SA_CONNECTION_STRING} -stand-in-manager.sa-name=prova +stand-in-manager.sa-name=synstandinreadevent stand-in-manager.consumer-group=$Default # DB -#spring.jpa.hibernate.ddl-auto=update -#spring.jpa.generate-ddl=true spring.jpa.show-sql=true -spring.datasource.continue-on-error=true - +spring.datasource.pagopa.postgre.cache.enabled=true spring.datasource.pagopa.postgre.cache.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg spring.datasource.pagopa.postgre.cache.username=cfg spring.datasource.pagopa.postgre.cache.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} spring.datasource.pagopa.postgre.cache.driver-class-name=org.postgresql.Driver +spring.datasource.pagopa.postgre.standin.enabled=true +spring.datasource.pagopa.postgre.standin.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg +spring.datasource.pagopa.postgre.standin.username=cfg +spring.datasource.pagopa.postgre.standin.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} +spring.datasource.pagopa.postgre.standin.driver-class-name=org.postgresql.Driver + +spring.datasource.nexi.postgre.cache.enabled=false spring.datasource.nexi.postgre.cache.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=public spring.datasource.nexi.postgre.cache.username=cfg spring.datasource.nexi.postgre.cache.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} spring.datasource.nexi.postgre.cache.driver-class-name=org.postgresql.Driver +spring.datasource.nexi.postgre.standin.enabled=false +spring.datasource.nexi.postgre.standin.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=public +spring.datasource.nexi.postgre.standin.username=cfg +spring.datasource.nexi.postgre.standin.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} +spring.datasource.nexi.postgre.standin.driver-class-name=org.postgresql.Driver + +spring.datasource.nexi.oracle.cache.enabled=false spring.datasource.nexi.oracle.cache.url=jdbc:oracle:thin:@//localhost:1521/cfg spring.datasource.nexi.oracle.cache.username=cfg spring.datasource.nexi.oracle.cache.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} -spring.datasource.nexi.oracle.cache.driver-class-name=oracle.jdbc.driver.OracleDriver \ No newline at end of file +spring.datasource.nexi.oracle.cache.driver-class-name=oracle.jdbc.driver.OracleDriver + +spring.datasource.nexi.oracle.standin.enabled=false +spring.datasource.nexi.oracle.standin.url=jdbc:oracle:thin:@//localhost:1521/cfg +spring.datasource.nexi.oracle.standin.username=cfg +spring.datasource.nexi.oracle.standin.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} +spring.datasource.nexi.oracle.standin.driver-class-name=oracle.jdbc.driver.OracleDriver + +spring.autoconfigure.exclude= \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 663cd58..496b52b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -44,19 +44,19 @@ api-config-cache.consumer.enabled=true api-config-cache.rx-connection-string=${API_CONFIG_CACHE_RX_CONNECTION_STRING} api-config-cache.rx-name=nodo-dei-pagamenti-cache api-config-cache.sa-connection-string=${API_CONFIG_CACHE_SA_CONNECTION_STRING} -api-config-cache.sa-name=prova +api-config-cache.sa-name=syncreadevent api-config-cache.consumer-group=$Default # Stand-in Manager configuration stand-in-manager.service.enabled=true -stand-in-manager.service.host=https://api.dev.platform.pagopa.it/technical-support/stand-in/api/v1 +stand-in-manager.service.host=https://api.dev.platform.pagopa.it/stand-in-manager/api/v1/stations stand-in-manager.service.subscriptionKey=${STAND_IN_MANAGER_SUBSCRIPTION_KEY} stand-in-manager.consumer.enabled=false stand-in-manager.rx-connection-string=${STAND_IN_MANAGER_RX_CONNECTION_STRING} stand-in-manager.rx-name=nodo-dei-pagamenti-stand-in stand-in-manager.sa-connection-string=${STAND_IN_MANAGER_SA_CONNECTION_STRING} -stand-in-manager.sa-name=prova +stand-in-manager.sa-name=syncreadevent stand-in-manager.consumer-group=$Default # DB @@ -64,16 +64,19 @@ stand-in-manager.consumer-group=$Default #spring.jpa.generate-ddl=true spring.jpa.show-sql=true +spring.datasource.pagopa.postgre.cache=true spring.datasource.pagopa.postgre.cache.url=${DB_PAGOPA_POSTGRE_CACHE_URL} spring.datasource.pagopa.postgre.cache.username=${DB_PAGOPA_POSTGRE_CACHE_USER} spring.datasource.pagopa.postgre.cache.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} spring.datasource.pagopa.postgre.cache.driver-class-name=org.postgresql.Driver +spring.datasource.nexi.postgre.cache=true spring.datasource.nexi.postgre.cache.url=${DB_NEXI_POSTGRE_CACHE_URL} spring.datasource.nexi.postgre.cache.username=${DB_NEXI_POSTGRE_CACHE_USER} spring.datasource.nexi.postgre.cache.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} spring.datasource.nexi.postgre.cache.driver-class-name=org.postgresql.Driver +spring.datasource.nexi.oracle.cache.enabled=false spring.datasource.nexi.oracle.cache.url=${DB_NEXI_ORACLE_CACHE_URL} spring.datasource.nexi.oracle.cache.username=${DB_NEXI_ORACLE_CACHE_USER} spring.datasource.nexi.oracle.cache.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index f7beb7e..3bf1e61 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -13,6 +13,8 @@ + + @@ -28,6 +30,8 @@ + + From 7f0c04cea1c74dfdc156e7d0848839af6ef8ebd7 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 12:45:44 +0100 Subject: [PATCH 11/88] wip --- .../gov/pagopa/node/cfgsync/Application.java | 16 +---- .../node/cfgsync/model/StationsResponse.java | 16 +++++ ...n.java => PagoPAPostgreConfiguration.java} | 10 +-- .../PagoPAStandInPostgreConfiguration.java | 61 ------------------- .../PagoPACachePostgreRepository.java | 2 +- .../PagoPAStandInPostgreRepository.java | 2 +- .../service/ApiConfigCacheEhConsumer.java | 17 +++--- .../service/ApiConfigCacheService.java | 10 ++- .../service/StandInManagerEhConsumer.java | 17 +++--- .../service/StandInManagerService.java | 36 +++++------ .../resources/application-local.properties | 53 +++++++--------- src/main/resources/application.properties | 44 ++++++------- 12 files changed, 101 insertions(+), 183 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/model/StationsResponse.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/{PagoPACachePostgreConfiguration.java => PagoPAPostgreConfiguration.java} (93%) delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAStandInPostgreConfiguration.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/{cache => }/PagoPACachePostgreRepository.java (78%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/{standin => }/PagoPAStandInPostgreRepository.java (78%) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/Application.java b/src/main/java/it/gov/pagopa/node/cfgsync/Application.java index e6f5c88..bd1547e 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/Application.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/Application.java @@ -1,27 +1,13 @@ package it.gov.pagopa.node.cfgsync; -import com.azure.messaging.eventhubs.EventProcessorClient; import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @Slf4j -public class Application implements CommandLineRunner { - private final EventProcessorClient eventProcessorClient; - - public Application(EventProcessorClient eventProcessorClient) { - this.eventProcessorClient = eventProcessorClient; - } - +public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } - - @Override - public void run(String... args) throws Exception { - eventProcessorClient.start(); - } - } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/StationsResponse.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/StationsResponse.java new file mode 100644 index 0000000..f0cb9e6 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/StationsResponse.java @@ -0,0 +1,16 @@ +package it.gov.pagopa.node.cfgsync.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.*; + +import java.util.List; + +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class StationsResponse { + private List stations; +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java similarity index 93% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java index a5e45c9..58a0fdd 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPACachePostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java @@ -23,23 +23,23 @@ }) @EnableTransactionManagement @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa.cache", + basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", entityManagerFactoryRef = "pagoPACachePostgreEntityManagerFactory", transactionManagerRef = "pagoPACachePostgreTransactionManager" ) -@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgre.cache", name = "enabled") -public class PagoPACachePostgreConfiguration { +@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgre", name = "enabled") +public class PagoPAPostgreConfiguration { @Bean @Primary - @ConfigurationProperties("spring.datasource.pagopa.postgre.cache") + @ConfigurationProperties("spring.datasource.pagopa.postgre") public DataSourceProperties pagoPACachePostgreDatasourceProperties() { return new DataSourceProperties(); } @Bean @Primary - @ConfigurationProperties("spring.datasource.pagopa.postgre.cache.configuration") + @ConfigurationProperties("spring.datasource.pagopa.postgre.configuration") public DataSource pagoPACachePostgreDataSource() { return pagoPACachePostgreDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAStandInPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAStandInPostgreConfiguration.java deleted file mode 100644 index fcad044..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAStandInPostgreConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.configuration; - -import com.zaxxer.hikari.HikariDataSource; -import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; -import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.*; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.sql.DataSource; - -@Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) -@EnableTransactionManagement -@EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa.standin", - entityManagerFactoryRef = "pagoPAStandInPostgreEntityManagerFactory", - transactionManagerRef = "pagoPAStandInPostgreTransactionManager" -) -@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgre.standin", name = "enabled") -public class PagoPAStandInPostgreConfiguration { - - @Bean - @ConfigurationProperties("spring.datasource.pagopa.postgre.standin") - public DataSourceProperties pagoPAStandInPostgreDatasourceProperties() { - return new DataSourceProperties(); - } - - @Bean - @ConfigurationProperties("spring.datasource.pagopa.postgre.standin.configuration") - public DataSource pagoPAStandInPostgreDataSource() { - return pagoPAStandInPostgreDatasourceProperties().initializeDataSourceBuilder() - .type(HikariDataSource.class).build(); - } - - @Bean(name = "pagoPAStandInPostgreEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean pagoPAStandInPostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { - return builder - .dataSource(pagoPAStandInPostgreDataSource()) - .packages(StandInStations.class) - .build(); - } - - @Bean - public PlatformTransactionManager pagoPAStandInPostgreTransactionManager( - final @Qualifier("pagoPAStandInPostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagoPAStandInPostgreEntityManagerFactory) { - return new JpaTransactionManager(pagoPAStandInPostgreEntityManagerFactory.getObject()); - } - -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/cache/PagoPACachePostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java similarity index 78% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/cache/PagoPACachePostgreRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java index 54373bd..b3cb058 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/cache/PagoPACachePostgreRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.pagopa.cache; +package it.gov.pagopa.node.cfgsync.repository.pagopa; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/standin/PagoPAStandInPostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgreRepository.java similarity index 78% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/standin/PagoPAStandInPostgreRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgreRepository.java index 2b0719e..f984f19 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/standin/PagoPAStandInPostgreRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgreRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.pagopa.standin; +package it.gov.pagopa.node.cfgsync.repository.pagopa; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java index 3d36190..14df3df 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java @@ -9,12 +9,12 @@ import com.azure.storage.blob.BlobContainerClientBuilder; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; + @Slf4j @Service @RequiredArgsConstructor @@ -34,19 +34,16 @@ public class ApiConfigCacheEhConsumer { private final ApiConfigCacheService apiConfigCacheService; - @Bean - BlobContainerAsyncClient blobContainerAsyncClient() { - return new BlobContainerClientBuilder().connectionString(configCacheSaConnectionString) + @PostConstruct + public void post(){ + BlobContainerAsyncClient blobContainerAsyncClient = new BlobContainerClientBuilder().connectionString(configCacheSaConnectionString) .containerName(configCacheSaContainerName).buildAsyncClient(); - } - - @Bean - EventProcessorClient eventProcessorClient(BlobContainerAsyncClient blobContainerAsyncClient) { - return new EventProcessorClientBuilder().connectionString(configCacheRxConnectionString) + EventProcessorClient eventProcessorClient = new EventProcessorClientBuilder().connectionString(configCacheRxConnectionString) .consumerGroup(configCacheConsumerGroup) .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) .processEvent(this::processEvent) .processError(this::processError).buildEventProcessorClient(); + eventProcessorClient.start(); } public void processEvent(EventContext eventContext) { diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 9b68927..08b4415 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -8,9 +8,7 @@ import it.gov.pagopa.node.cfgsync.exception.AppException; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; -import it.gov.pagopa.node.cfgsync.repository.nexioracle.cache.NexiCacheOracleRepository; -import it.gov.pagopa.node.cfgsync.repository.nexipostgre.cache.NexiCachePostgreRepository; -import it.gov.pagopa.node.cfgsync.repository.pagopa.cache.PagoPACachePostgreRepository; +import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgreRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -50,13 +48,13 @@ public class ApiConfigCacheService extends CommonCacheService { // @Autowired // private NexiCacheOracleRepository nexiCacheOracleRepository; - @Value("${spring.datasource.pagopa.postgre.cache.enabled}") + @Value("${pagopa.postgre.cache.write.enabled}") private Boolean pagopaPostgreCacheEnabled; - @Value("${spring.datasource.nexi.postgre.cache.enabled}") + @Value("${nexi.postgre.cache.write.enabled}") private Boolean nexiPostgreCacheEnabled; - @Value("${spring.datasource.nexi.oracle.cache.enabled}") + @Value("${nexi.oracle.cache.write.enabled}") private Boolean nexiOracleCacheEnabled; private final TransactionTemplate transactionTemplate; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java index 99c1103..5093b1f 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java @@ -10,12 +10,12 @@ import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; + @Slf4j @Service @RequiredArgsConstructor @@ -35,19 +35,16 @@ public class StandInManagerEhConsumer { private final StandInManagerService standInManagerService; - @Bean - BlobContainerAsyncClient blobContainerStandInAsyncClient() { - return new BlobContainerClientBuilder().connectionString(standInManagerSaConnectionString) + @PostConstruct + public void post(){ + BlobContainerAsyncClient blobContainerAsyncClient = new BlobContainerClientBuilder().connectionString(standInManagerSaConnectionString) .containerName(standInManagerSaContainerName).buildAsyncClient(); - } - - @Bean - EventProcessorClient eventProcessorStandInClient(BlobContainerAsyncClient blobContainerAsyncClient) { - return new EventProcessorClientBuilder().connectionString(standInManagerRxConnectionString) + EventProcessorClient eventProcessorClient = new EventProcessorClientBuilder().connectionString(standInManagerRxConnectionString) .consumerGroup(standInManagerConsumerGroup) .checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)) .processEvent(this::processEvent) .processError(this::processError).buildEventProcessorClient(); + eventProcessorClient.start(); } public void processEvent(EventContext eventContext) { diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index ee858e5..4284cfa 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -7,11 +7,10 @@ import it.gov.pagopa.node.cfgsync.client.StandInManagerClient; import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; +import it.gov.pagopa.node.cfgsync.model.StationsResponse; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; -import it.gov.pagopa.node.cfgsync.repository.nexioracle.standin.NexiStandInOracleRepository; -import it.gov.pagopa.node.cfgsync.repository.nexipostgre.standin.NexiStandInPostgreRepository; -import it.gov.pagopa.node.cfgsync.repository.pagopa.standin.PagoPAStandInPostgreRepository; +import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgreRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -26,6 +25,7 @@ import java.io.IOException; import java.util.List; import java.util.NoSuchElementException; +import java.util.stream.Collectors; @Service @Slf4j @@ -35,17 +35,6 @@ public class StandInManagerService extends CommonCacheService { private boolean enabled; @Value("${stand-in-manager.service.subscriptionKey}") private String subscriptionKey; - @Value("${stand-in-manager.rx-connection-string}") - private String standInRxConnectionString; - @Value("${stand-in-manager.rx-name}") - private String standInRxName; - @Value("${stand-in-manager.sa-connection-string}") - private String standInSaConnectionString; - @Value("${stand-in-manager.sa-name}") - private String standInSaContainerName; - @Value("${stand-in-manager.consumer-group}") - private String standInConsumerGroup; - private final StandInManagerClient standInManagerClient; private final ObjectMapper objectMapper; @@ -56,13 +45,13 @@ public class StandInManagerService extends CommonCacheService { // @Autowired // private NexiStandInOracleRepository nexiStandInOracleRepository; - @Value("${spring.datasource.pagopa.postgre.standin.enabled}") + @Value("${pagopa.postgre.standin.write.enabled}") private Boolean pagopaPostgreStandInEnabled; - @Value("${spring.datasource.nexi.postgre.standin.enabled}") + @Value("${nexi.postgre.standin.write.enabled}") private Boolean nexiPostgreStandInEnabled; - @Value("${spring.datasource.nexi.oracle.standin.enabled}") + @Value("${nexi.oracle.standin.write.enabled}") private Boolean nexiOracleStandInEnabled; private final TransactionTemplate transactionTemplate; @@ -88,14 +77,17 @@ public void forceStandIn() { } log.info("SyncService stand-in-manager get stations successful"); - List stations = (List) objectMapper.readValue(response.body().asInputStream().readAllBytes(), List.class); - + StationsResponse stations = objectMapper.readValue(response.body().asInputStream().readAllBytes(), StationsResponse.class); + List stationsEntities = stations.getStations().stream().map(s -> new StandInStations(s)).collect(Collectors.toList()); this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { public void doInTransactionWithoutResult(TransactionStatus status) { try { - if( pagopaPostgreStandInEnabled ) pagoPAStandInPostgreRepository.saveAll(stations); -// if( nexiPostgreStandInEnabled ) nexiStandInPostgreRepository.saveAll(stations); -// if( nexiOracleStandInEnabled ) nexiStandInOracleRepository.saveAll(stations); + if( pagopaPostgreStandInEnabled ) { + pagoPAStandInPostgreRepository.deleteAll(); + pagoPAStandInPostgreRepository.saveAll(stationsEntities); + } +// if( nexiPostgreStandInEnabled ) nexiStandInPostgreRepository.saveAll(stationsEntities); +// if( nexiOracleStandInEnabled ) nexiStandInOracleRepository.saveAll(stationsEntities); } catch(NoSuchElementException ex) { status.setRollbackOnly(); } diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 83b52e8..c6c648e 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -26,7 +26,7 @@ api-config-cache.consumer-group=$Default # Stand-in Manager configuration stand-in-manager.service.enabled=true -stand-in-manager.service.host=https://api.dev.platform.pagopa.it/stand-in-manager/api/v1/stations +stand-in-manager.service.host=https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 stand-in-manager.service.subscriptionKey=${STAND_IN_MANAGER_SUBSCRIPTION_KEY} stand-in-manager.consumer.enabled=true @@ -39,40 +39,31 @@ stand-in-manager.consumer-group=$Default # DB spring.jpa.show-sql=true -spring.datasource.pagopa.postgre.cache.enabled=true -spring.datasource.pagopa.postgre.cache.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg -spring.datasource.pagopa.postgre.cache.username=cfg -spring.datasource.pagopa.postgre.cache.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} -spring.datasource.pagopa.postgre.cache.driver-class-name=org.postgresql.Driver +spring.datasource.pagopa.postgre.enabled=true +spring.datasource.pagopa.postgre.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg +spring.datasource.pagopa.postgre.username=cfg +spring.datasource.pagopa.postgre.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} +spring.datasource.pagopa.postgre.driver-class-name=org.postgresql.Driver -spring.datasource.pagopa.postgre.standin.enabled=true -spring.datasource.pagopa.postgre.standin.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg -spring.datasource.pagopa.postgre.standin.username=cfg -spring.datasource.pagopa.postgre.standin.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} -spring.datasource.pagopa.postgre.standin.driver-class-name=org.postgresql.Driver -spring.datasource.nexi.postgre.cache.enabled=false -spring.datasource.nexi.postgre.cache.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=public -spring.datasource.nexi.postgre.cache.username=cfg -spring.datasource.nexi.postgre.cache.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} -spring.datasource.nexi.postgre.cache.driver-class-name=org.postgresql.Driver +spring.datasource.nexi.postgre.enabled=false +spring.datasource.nexi.postgre.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=public +spring.datasource.nexi.postgre.username=cfg +spring.datasource.nexi.postgre.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} +spring.datasource.nexi.postgre.driver-class-name=org.postgresql.Driver -spring.datasource.nexi.postgre.standin.enabled=false -spring.datasource.nexi.postgre.standin.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=public -spring.datasource.nexi.postgre.standin.username=cfg -spring.datasource.nexi.postgre.standin.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} -spring.datasource.nexi.postgre.standin.driver-class-name=org.postgresql.Driver +spring.datasource.nexi.oracle.enabled=false +spring.datasource.nexi.oracle.url=jdbc:oracle:thin:@//localhost:1521/cfg +spring.datasource.nexi.oracle.username=cfg +spring.datasource.nexi.oracle.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} +spring.datasource.nexi.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver -spring.datasource.nexi.oracle.cache.enabled=false -spring.datasource.nexi.oracle.cache.url=jdbc:oracle:thin:@//localhost:1521/cfg -spring.datasource.nexi.oracle.cache.username=cfg -spring.datasource.nexi.oracle.cache.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} -spring.datasource.nexi.oracle.cache.driver-class-name=oracle.jdbc.driver.OracleDriver +pagopa.postgre.cache.write.enabled=true +nexi.postgre.cache.write.enabled=false +nexi.oracle.cache.write.enabled=false -spring.datasource.nexi.oracle.standin.enabled=false -spring.datasource.nexi.oracle.standin.url=jdbc:oracle:thin:@//localhost:1521/cfg -spring.datasource.nexi.oracle.standin.username=cfg -spring.datasource.nexi.oracle.standin.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} -spring.datasource.nexi.oracle.standin.driver-class-name=oracle.jdbc.driver.OracleDriver +pagopa.postgre.standin.write.enabled=true +nexi.postgre.standin.write.enabled=false +nexi.oracle.standin.write.enabled=false spring.autoconfigure.exclude= \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 496b52b..63cfc77 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -44,19 +44,19 @@ api-config-cache.consumer.enabled=true api-config-cache.rx-connection-string=${API_CONFIG_CACHE_RX_CONNECTION_STRING} api-config-cache.rx-name=nodo-dei-pagamenti-cache api-config-cache.sa-connection-string=${API_CONFIG_CACHE_SA_CONNECTION_STRING} -api-config-cache.sa-name=syncreadevent +api-config-cache.sa-name=synccachereadevent api-config-cache.consumer-group=$Default # Stand-in Manager configuration stand-in-manager.service.enabled=true -stand-in-manager.service.host=https://api.dev.platform.pagopa.it/stand-in-manager/api/v1/stations +stand-in-manager.service.host=https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 stand-in-manager.service.subscriptionKey=${STAND_IN_MANAGER_SUBSCRIPTION_KEY} -stand-in-manager.consumer.enabled=false +stand-in-manager.consumer.enabled=true stand-in-manager.rx-connection-string=${STAND_IN_MANAGER_RX_CONNECTION_STRING} stand-in-manager.rx-name=nodo-dei-pagamenti-stand-in stand-in-manager.sa-connection-string=${STAND_IN_MANAGER_SA_CONNECTION_STRING} -stand-in-manager.sa-name=syncreadevent +stand-in-manager.sa-name=synstandinreadevent stand-in-manager.consumer-group=$Default # DB @@ -64,20 +64,22 @@ stand-in-manager.consumer-group=$Default #spring.jpa.generate-ddl=true spring.jpa.show-sql=true -spring.datasource.pagopa.postgre.cache=true -spring.datasource.pagopa.postgre.cache.url=${DB_PAGOPA_POSTGRE_CACHE_URL} -spring.datasource.pagopa.postgre.cache.username=${DB_PAGOPA_POSTGRE_CACHE_USER} -spring.datasource.pagopa.postgre.cache.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} -spring.datasource.pagopa.postgre.cache.driver-class-name=org.postgresql.Driver - -spring.datasource.nexi.postgre.cache=true -spring.datasource.nexi.postgre.cache.url=${DB_NEXI_POSTGRE_CACHE_URL} -spring.datasource.nexi.postgre.cache.username=${DB_NEXI_POSTGRE_CACHE_USER} -spring.datasource.nexi.postgre.cache.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} -spring.datasource.nexi.postgre.cache.driver-class-name=org.postgresql.Driver - -spring.datasource.nexi.oracle.cache.enabled=false -spring.datasource.nexi.oracle.cache.url=${DB_NEXI_ORACLE_CACHE_URL} -spring.datasource.nexi.oracle.cache.username=${DB_NEXI_ORACLE_CACHE_USER} -spring.datasource.nexi.oracle.cache.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} -spring.datasource.nexi.oracle.cache.driver-class-name=oracle.jdbc.driver.OracleDriver +spring.datasource.pagopa.postgre.enabled=true +spring.datasource.pagopa.postgre.url=${DB_PAGOPA_POSTGRE_URL} +spring.datasource.pagopa.postgre.username=${DB_PAGOPA_POSTGRE_USER} +spring.datasource.pagopa.postgre.password=${DB_PAGOPA_POSTGRE_PASSWORD} +spring.datasource.pagopa.postgre.driver-class-name=org.postgresql.Driver + +spring.datasource.nexi.postgre.enabled=false +spring.datasource.nexi.postgre.url=${DB_NEXI_POSTGRE_URL} +spring.datasource.nexi.postgre.username=${DB_NEXI_POSTGRE_USER} +spring.datasource.nexi.postgre.password=${DB_NEXI_POSTGRE_PASSWORD} +spring.datasource.nexi.postgre.driver-class-name=org.postgresql.Driver + +spring.datasource.nexi.oracle.enabled=false +spring.datasource.nexi.oracle.url=${DB_NEXI_ORACLE_URL} +spring.datasource.nexi.oracle.username=${DB_NEXI_ORACLE_USER} +spring.datasource.nexi.oracle.password=${DB_NEXI_ORACLE_PASSWORD} +spring.datasource.nexi.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver + +spring.autoconfigure.exclude= \ No newline at end of file From 9cfb31941596b18408353bc61bd002fbbd48cd39 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 14:09:14 +0100 Subject: [PATCH 12/88] wip --- infra/04_apim_api.tf | 8 ++++---- infra/99_locals.tf | 2 +- infra/env/weu-dev/backend.tfvars | 2 +- infra/env/weu-dev/terraform.tfvars | 4 ++-- infra/env/weu-prod/backend.tfvars | 2 +- infra/env/weu-prod/terraform.tfvars | 4 ++-- infra/env/weu-uat/backend.tfvars | 2 +- infra/env/weu-uat/terraform.tfvars | 4 ++-- infra/policy/_base_policy.xml | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/infra/04_apim_api.tf b/infra/04_apim_api.tf index b24ae4d..5fadc78 100644 --- a/infra/04_apim_api.tf +++ b/infra/04_apim_api.tf @@ -1,9 +1,9 @@ locals { - repo_name = "TODO" # TODO add the name of the repository + repo_name = "pagopa-node-cfg-sync" - display_name = "TODO" # TODO - description = "TODO" # TODO - path = "TODO" # TODO add your base path + display_name = "pagoPA Node CFG sync" + description = "Sync node cfg across multiple instances" + path = "node-cfg-sync" host = "api.${var.apim_dns_zone_prefix}.${var.external_domain}" hostname = var.hostname diff --git a/infra/99_locals.tf b/infra/99_locals.tf index 5ed42d0..7ab7679 100644 --- a/infra/99_locals.tf +++ b/infra/99_locals.tf @@ -4,7 +4,7 @@ locals { apim = { name = "${local.product}-apim" rg = "${local.product}-api-rg" - product_id = "TODO" # TODO product id to import from pagopa-infra + product_id = "apiconfig-cache" } } diff --git a/infra/env/weu-dev/backend.tfvars b/infra/env/weu-dev/backend.tfvars index 619395b..3a78667 100644 --- a/infra/env/weu-dev/backend.tfvars +++ b/infra/env/weu-dev/backend.tfvars @@ -1,4 +1,4 @@ resource_group_name = "io-infra-rg" storage_account_name = "pagopainfraterraformdev" container_name = "azurermstate" -key = ".infra.tfstate" # TODO +key = "pagopa-node-cfg-sync.infra.tfstate" diff --git a/infra/env/weu-dev/terraform.tfvars b/infra/env/weu-dev/terraform.tfvars index 63a0705..dc1f204 100644 --- a/infra/env/weu-dev/terraform.tfvars +++ b/infra/env/weu-dev/terraform.tfvars @@ -6,10 +6,10 @@ tags = { CreatedBy = "Terraform" Environment = "Dev" Owner = "pagoPA" - Source = "https://github.com/pagopa/your-repository" # TODO + Source = "https://github.com/pagopa/pagopa-node-cfg-sync" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } apim_dns_zone_prefix = "dev.platform" external_domain = "pagopa.it" -hostname = "weudev..internal.dev.platform.pagopa.it" # TODO +hostname = "weudev.nodo.internal.dev.platform.pagopa.it" diff --git a/infra/env/weu-prod/backend.tfvars b/infra/env/weu-prod/backend.tfvars index dac1727..9c90c9b 100644 --- a/infra/env/weu-prod/backend.tfvars +++ b/infra/env/weu-prod/backend.tfvars @@ -1,4 +1,4 @@ resource_group_name = "io-infra-rg" storage_account_name = "pagopainfraterraformprod" container_name = "azurermstate" -key = ".infra.tfstate" # TODO +key = "pagopa-node-cfg-sync.infra.tfstate" diff --git a/infra/env/weu-prod/terraform.tfvars b/infra/env/weu-prod/terraform.tfvars index 77f85af..72e93c9 100644 --- a/infra/env/weu-prod/terraform.tfvars +++ b/infra/env/weu-prod/terraform.tfvars @@ -6,10 +6,10 @@ tags = { CreatedBy = "Terraform" Environment = "Prod" Owner = "pagoPA" - Source = "https://github.com/pagopa/your-repository" # TODO + Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } apim_dns_zone_prefix = "platform" external_domain = "pagopa.it" -hostname = "weuprod..internal.platform.pagopa.it" # TODO +hostname = "weuprod.nodo.internal.platform.pagopa.it" diff --git a/infra/env/weu-uat/backend.tfvars b/infra/env/weu-uat/backend.tfvars index 6f406b1..5726fd5 100644 --- a/infra/env/weu-uat/backend.tfvars +++ b/infra/env/weu-uat/backend.tfvars @@ -1,4 +1,4 @@ resource_group_name = "io-infra-rg" storage_account_name = "pagopainfraterraformuat" container_name = "azurermstate" -key = ".infra.tfstate" # TODO +key = "pagopa-node-cfg-sync.infra.tfstate" diff --git a/infra/env/weu-uat/terraform.tfvars b/infra/env/weu-uat/terraform.tfvars index e8160f1..f551a20 100644 --- a/infra/env/weu-uat/terraform.tfvars +++ b/infra/env/weu-uat/terraform.tfvars @@ -6,10 +6,10 @@ tags = { CreatedBy = "Terraform" Environment = "Uat" Owner = "pagoPA" - Source = "https://github.com/pagopa/your-repository" # TODO + Source = "https://github.com/pagopa/pagopa-node-cfg-sync" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } apim_dns_zone_prefix = "uat.platform" external_domain = "pagopa.it" -hostname = "weuuat..internal.uat.platform.pagopa.it" # TODO +hostname = "weuuat.nodo.internal.uat.platform.pagopa.it" diff --git a/infra/policy/_base_policy.xml b/infra/policy/_base_policy.xml index e3b583c..f9d9b59 100644 --- a/infra/policy/_base_policy.xml +++ b/infra/policy/_base_policy.xml @@ -1,7 +1,7 @@ - + From 3af09aa1118eb439c514bee64aa0ea9e606c42c4 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 14:18:01 +0100 Subject: [PATCH 13/88] wip --- .../05h_deploy_with_github_runner.yml | 28 +++++++++++++++++++ infra/env/weu-dev/terraform.tfvars | 2 +- infra/env/weu-uat/terraform.tfvars | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/05h_deploy_with_github_runner.yml b/.github/workflows/05h_deploy_with_github_runner.yml index f74571b..ba534c9 100644 --- a/.github/workflows/05h_deploy_with_github_runner.yml +++ b/.github/workflows/05h_deploy_with_github_runner.yml @@ -81,3 +81,31 @@ jobs: resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }} runner_name: ${{ needs.create_runner.outputs.runner_name }} pat_token: ${{ secrets.BOT_TOKEN_GITHUB }} + update_openapi: + needs: [ deploy ] + runs-on: ubuntu-latest + name: Update OpenAPI + if: ${{ inputs.target == inputs.environment }} + environment: ${{ inputs.environment }} + steps: + - name: Checkout + id: checkout + # from https://github.com/actions/checkout/commits/main + uses: actions/checkout@1f9a0c22da41e6ebfa534300ef656657ea2c6707 + with: + persist-credentials: false + + - name: Setup Terraform + # from https://github.com/hashicorp/setup-terraform/commits/main + uses: hashicorp/setup-terraform@8feba2b913ea459066180f9cb177f58a881cf146 + with: + terraform_version: "1.3.6" + + - name: Login + id: login + # from https://github.com/Azure/login/commits/master + uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 + with: + client-id: ${{ secrets.CD_CLIENT_ID }} + tenant-id: ${{ secrets.TENANT_ID }} + subscription-id: ${{ secrets.SUBSCRIPTION_ID }} \ No newline at end of file diff --git a/infra/env/weu-dev/terraform.tfvars b/infra/env/weu-dev/terraform.tfvars index dc1f204..a9c968b 100644 --- a/infra/env/weu-dev/terraform.tfvars +++ b/infra/env/weu-dev/terraform.tfvars @@ -6,7 +6,7 @@ tags = { CreatedBy = "Terraform" Environment = "Dev" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } diff --git a/infra/env/weu-uat/terraform.tfvars b/infra/env/weu-uat/terraform.tfvars index f551a20..6c74411 100644 --- a/infra/env/weu-uat/terraform.tfvars +++ b/infra/env/weu-uat/terraform.tfvars @@ -6,7 +6,7 @@ tags = { CreatedBy = "Terraform" Environment = "Uat" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } From 73516fc1241a263c49ffa2520bd2222f01cd90e9 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 14:20:16 +0100 Subject: [PATCH 14/88] wip --- .identity/99_variables.tf | 2 +- .identity/env/dev/terraform.tfvars | 2 +- .identity/env/prod/terraform.tfvars | 2 +- .identity/env/uat/terraform.tfvars | 2 +- .opex/env/prod/terraform.tfvars | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.identity/99_variables.tf b/.identity/99_variables.tf index 00c1d9e..07a10b5 100644 --- a/.identity/99_variables.tf +++ b/.identity/99_variables.tf @@ -65,7 +65,7 @@ variable "tags" { CreatedBy = "Terraform" Environment = "PROD" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } } \ No newline at end of file diff --git a/.identity/env/dev/terraform.tfvars b/.identity/env/dev/terraform.tfvars index 23f0915..b29ab5b 100644 --- a/.identity/env/dev/terraform.tfvars +++ b/.identity/env/dev/terraform.tfvars @@ -7,6 +7,6 @@ tags = { CreatedBy = "Terraform" Environment = "Dev" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } \ No newline at end of file diff --git a/.identity/env/prod/terraform.tfvars b/.identity/env/prod/terraform.tfvars index 12ebd13..e1b2e22 100644 --- a/.identity/env/prod/terraform.tfvars +++ b/.identity/env/prod/terraform.tfvars @@ -7,6 +7,6 @@ tags = { CreatedBy = "Terraform" Environment = "Prod" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } diff --git a/.identity/env/uat/terraform.tfvars b/.identity/env/uat/terraform.tfvars index fc696fe..c467d67 100644 --- a/.identity/env/uat/terraform.tfvars +++ b/.identity/env/uat/terraform.tfvars @@ -7,6 +7,6 @@ tags = { CreatedBy = "Terraform" Environment = "Uat" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } diff --git a/.opex/env/prod/terraform.tfvars b/.opex/env/prod/terraform.tfvars index 99c807b..f731d2b 100644 --- a/.opex/env/prod/terraform.tfvars +++ b/.opex/env/prod/terraform.tfvars @@ -6,6 +6,6 @@ tags = { CreatedBy = "Terraform" Environment = "Prod" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } From c29404c375729cb18ec74f02b71d40418a6dd074 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 14:23:14 +0100 Subject: [PATCH 15/88] wip --- .identity/99_variables.tf | 2 +- .identity/env/dev/terraform.tfvars | 2 +- .identity/env/prod/terraform.tfvars | 2 +- .identity/env/uat/terraform.tfvars | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.identity/99_variables.tf b/.identity/99_variables.tf index 07a10b5..00c1d9e 100644 --- a/.identity/99_variables.tf +++ b/.identity/99_variables.tf @@ -65,7 +65,7 @@ variable "tags" { CreatedBy = "Terraform" Environment = "PROD" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } } \ No newline at end of file diff --git a/.identity/env/dev/terraform.tfvars b/.identity/env/dev/terraform.tfvars index b29ab5b..23f0915 100644 --- a/.identity/env/dev/terraform.tfvars +++ b/.identity/env/dev/terraform.tfvars @@ -7,6 +7,6 @@ tags = { CreatedBy = "Terraform" Environment = "Dev" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } \ No newline at end of file diff --git a/.identity/env/prod/terraform.tfvars b/.identity/env/prod/terraform.tfvars index e1b2e22..12ebd13 100644 --- a/.identity/env/prod/terraform.tfvars +++ b/.identity/env/prod/terraform.tfvars @@ -7,6 +7,6 @@ tags = { CreatedBy = "Terraform" Environment = "Prod" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } diff --git a/.identity/env/uat/terraform.tfvars b/.identity/env/uat/terraform.tfvars index c467d67..fc696fe 100644 --- a/.identity/env/uat/terraform.tfvars +++ b/.identity/env/uat/terraform.tfvars @@ -7,6 +7,6 @@ tags = { CreatedBy = "Terraform" Environment = "Uat" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } From 1596714971045923f75239c0e8ebf5d6e725cee7 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 14:24:27 +0100 Subject: [PATCH 16/88] wip --- .opex/env/prod/terraform.tfvars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.opex/env/prod/terraform.tfvars b/.opex/env/prod/terraform.tfvars index f731d2b..99c807b 100644 --- a/.opex/env/prod/terraform.tfvars +++ b/.opex/env/prod/terraform.tfvars @@ -6,6 +6,6 @@ tags = { CreatedBy = "Terraform" Environment = "Prod" Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-node-cfg-sync.git" + Source = "https://github.com/pagopa/pagopa-node-cfg-sync" CostCenter = "TS310 - PAGAMENTI & SERVIZI" } From 662fa6a9946c477040d54f139fe4a8620d55c92e Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 16 Feb 2024 13:38:37 +0000 Subject: [PATCH 17/88] Bump to version 0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio [skip ci] --- helm/Chart.yaml | 4 +- helm/values-dev.yaml | 21 ++-- helm/values-prod.yaml | 19 ++-- helm/values-uat.yaml | 18 ++-- openapi/openapi.json | 239 ++++++++++++++++++++++-------------------- pom.xml | 2 +- 6 files changed, 154 insertions(+), 149 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index b608062..1508ea8 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.0.0 -appVersion: 0.0.0 +version: 0.1.0 +appVersion: 0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 24c105c..ed5c466 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0" + tag: "0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -68,19 +68,15 @@ microservice-chart: DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' CACHET_TX_NAME: "nodo-dei-pagamenti-cache" - NODO_ORACLE_NEXI_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" NODO_ORACLE_NEXI_DB_CONFIG_USER: "cfg" NODO_ORACLE_NEXI_DB_CONFIG_DRIVER: "org.postgresql.Driver" - NODO_POSTGRE_NEXI_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" NODO_POSTGRE_NEXI_DB_CONFIG_USER: "cfg" NODO_POSTGRE_NEXI_DB_CONFIG_DRIVER: "org.postgresql.Driver" - NODO_POSTGRE_PAGOPA_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" NODO_POSTGRE_PAGOPA_DB_CONFIG_USER: "cfg" NODO_POSTGRE_PAGOPA_DB_CONFIG_DRIVER: "org.postgresql.Driver" - OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" @@ -99,8 +95,8 @@ microservice-chart: keyvault: name: "pagopa-d-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -111,7 +107,7 @@ microservice-chart: values: - user canaryDelivery: - create: true + create: false ingress: create: true canary: @@ -127,6 +123,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-node-cfg-sync tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } - + envConfig: {} + envSecret: {} diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 4baba44..82aa855 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0" + tag: "0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -83,8 +83,8 @@ microservice-chart: keyvault: name: "pagopa-d-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -101,10 +101,10 @@ microservice-chart: labelSelector: matchLabels: app.kubernetes.io/instance: "pagopa-node-cfg-sync" - namespaces: [ "nodo" ] + namespaces: ["nodo"] topologyKey: topology.kubernetes.io/zone canaryDelivery: - create: true + create: false ingress: create: true canary: @@ -120,6 +120,5 @@ microservice-chart: repository: ghcr.io/pagopa/yourname # TODO tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } - + envConfig: {} + envSecret: {} diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 168b4a2..957b096 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0" + tag: "0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -68,7 +68,6 @@ microservice-chart: DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' CACHET_TX_NAME: "nodo-dei-pagamenti-cache" - OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=uat" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" @@ -84,8 +83,8 @@ microservice-chart: keyvault: name: "pagopa-d-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -96,7 +95,7 @@ microservice-chart: values: - user canaryDelivery: - create: true + create: false ingress: create: true canary: @@ -112,6 +111,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-node-cfg-sync tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } - + envConfig: {} + envSecret: {} diff --git a/openapi/openapi.json b/openapi/openapi.json index d0d4522..09917f4 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,161 +1,174 @@ { - "openapi" : "3.0.1", - "info" : { - "title" : "cfg-sync", - "description" : "Microservice to update configuration schema of Nodo dei Pagamenti", - "termsOfService" : "https://www.pagopa.gov.it/", - "version" : "0.0.0" + "openapi": "3.0.1", + "info": { + "title": "cfg-sync", + "description": "Microservice to update configuration schema of Nodo dei Pagamenti", + "termsOfService": "https://www.pagopa.gov.it/", + "version": "0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" }, - "servers" : [ { - "url" : "http://localhost", - "description" : "Generated server url" - } ], - "paths" : { - "/sync/v1/{target}" : { - "get" : { - "tags" : [ "Cache" ], - "summary" : "Sync target v1 config", - "operationId" : "cache", - "parameters" : [ { - "name" : "target", - "in" : "path", - "required" : true, - "schema" : { - "type" : "string", - "enum" : [ "CONFIG", "STANDIN" ] + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/sync/v1/{target}": { + "get": { + "tags": [ + "Cache" + ], + "summary": "Sync target v1 config", + "operationId": "cache", + "parameters": [ + { + "name": "target", + "in": "path", + "required": true, + "schema": { + "type": "string", + "enum": [ + "CONFIG", + "STANDIN" + ] + } } - } ], - "responses" : { - "200" : { - "description" : "OK", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + ], + "responses": { + "200": { + "description": "OK", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { } + "content": { + "application/json": {} } }, - "400" : { - "description" : "Bad Request", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "400": { + "description": "Bad Request", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } }, - "401" : { - "description" : "Unauthorized", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "401": { + "description": "Unauthorized", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "403" : { - "description" : "Forbidden", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "403": { + "description": "Forbidden", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "429" : { - "description" : "Too many requests", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "429": { + "description": "Too many requests", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "500" : { - "description" : "Service unavailable", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "500": { + "description": "Service unavailable", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } } }, - "security" : [ { - "ApiKey" : [ ] - } ] + "security": [ + { + "ApiKey": [] + } + ] }, - "parameters" : [ { - "name" : "X-Request-Id", - "in" : "header", - "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema" : { - "type" : "string" + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } } - } ] + ] } }, - "components" : { - "schemas" : { - "ProblemJson" : { - "type" : "object", - "properties" : { - "title" : { - "type" : "string", - "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "components": { + "schemas": { + "ProblemJson": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" }, - "status" : { - "maximum" : 600, - "minimum" : 100, - "type" : "integer", - "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format" : "int32", - "example" : 200 + "status": { + "maximum": 600, + "minimum": 100, + "type": "integer", + "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format": "int32", + "example": 200 }, - "detail" : { - "type" : "string", - "description" : "A human readable explanation specific to this occurrence of the problem.", - "example" : "There was an error processing the request" + "detail": { + "type": "string", + "description": "A human readable explanation specific to this occurrence of the problem.", + "example": "There was an error processing the request" } } } }, - "securitySchemes" : { - "ApiKey" : { - "type" : "apiKey", - "description" : "The API key to access this function app.", - "name" : "Ocp-Apim-Subscription-Key", - "in" : "header" + "securitySchemes": { + "ApiKey": { + "type": "apiKey", + "description": "The API key to access this function app.", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" } } } -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index 1127e43..bf522ac 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0 + 0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 7e28d8e4cd3ffa6e5b699c4f89fc175caa60fede Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 14:41:52 +0100 Subject: [PATCH 18/88] wip --- helm/values-dev.yaml | 43 ++++++++++++++--------- src/main/resources/application.properties | 6 ++-- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index ed5c466..de95b2f 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -62,21 +62,21 @@ microservice-chart: type: Utilization # Allowed types are 'Utilization' or 'AverageValue' value: "75" envConfig: - WEBSITE_SITE_NAME: 'pagopa-node-cfg-sync' # required to show cloud role name in application insights + WEBSITE_SITE_NAME: 'pagopa-node-cfg-sync' ENV: 'azure-dev' APP_LOGGING_LEVEL: 'DEBUG' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - CACHET_TX_NAME: "nodo-dei-pagamenti-cache" - NODO_ORACLE_NEXI_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" - NODO_ORACLE_NEXI_DB_CONFIG_USER: "cfg" - NODO_ORACLE_NEXI_DB_CONFIG_DRIVER: "org.postgresql.Driver" - NODO_POSTGRE_NEXI_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" - NODO_POSTGRE_NEXI_DB_CONFIG_USER: "cfg" - NODO_POSTGRE_NEXI_DB_CONFIG_DRIVER: "org.postgresql.Driver" - NODO_POSTGRE_PAGOPA_DB_CONFIG_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" - NODO_POSTGRE_PAGOPA_DB_CONFIG_USER: "cfg" - NODO_POSTGRE_PAGOPA_DB_CONFIG_DRIVER: "org.postgresql.Driver" + + DB_NEXI_POSTGRE_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + DB_NEXI_POSTGRE_USER: "cfg" + + DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))" + DB_NEXI_ORACLE_USER: "NODO4_CFG" + + DB_PAGOPA_POSTGRE_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + DB_PAGOPA_POSTGRE_USER: "cfg" + OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" @@ -87,11 +87,22 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' - CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key" - NODO_ORACLE_NEXI_DB_CONFIG_PASSWORD: "oracle-db-cfg-password" - NODO_POSTGRE_NEXI_DB_CONFIG_PASSWORD: "postgresql-db-cfg-password" - NODO_POSTGRE_PAGOPA_DB_CONFIG_PASSWORD: "db-cfg-password" - OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token + + DB_PAGOPA_POSTGRE_PASSWORD: "db-cfg-password" + DB_NEXI_POSTGRE_URL: "postgresql-db-cfg-password" + DB_NEXI_ORACLE_URL: "oracle-db-cfg-password" + + API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key" + API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key" + + STAND_IN_MANAGER_RX_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-rx-connection-string-key" + STAND_IN_MANAGER_SA_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-sa-connection-string-key" + + API_CONFIG_CACHE_SUBSCRIPTION_KEY: "api-config-cache-subscription-key-string" + STAND_IN_MANAGER_SUBSCRIPTION_KEY: "standin-manager-subscription-key" + + + OTEL_EXPORTER_OTLP_HEADERS: "elastic-apm-secret-token" keyvault: name: "pagopa-d-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 63cfc77..41c0d35 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -68,18 +68,18 @@ spring.datasource.pagopa.postgre.enabled=true spring.datasource.pagopa.postgre.url=${DB_PAGOPA_POSTGRE_URL} spring.datasource.pagopa.postgre.username=${DB_PAGOPA_POSTGRE_USER} spring.datasource.pagopa.postgre.password=${DB_PAGOPA_POSTGRE_PASSWORD} -spring.datasource.pagopa.postgre.driver-class-name=org.postgresql.Driver +#spring.datasource.pagopa.postgre.driver-class-name=org.postgresql.Driver spring.datasource.nexi.postgre.enabled=false spring.datasource.nexi.postgre.url=${DB_NEXI_POSTGRE_URL} spring.datasource.nexi.postgre.username=${DB_NEXI_POSTGRE_USER} spring.datasource.nexi.postgre.password=${DB_NEXI_POSTGRE_PASSWORD} -spring.datasource.nexi.postgre.driver-class-name=org.postgresql.Driver +#spring.datasource.nexi.postgre.driver-class-name=org.postgresql.Driver spring.datasource.nexi.oracle.enabled=false spring.datasource.nexi.oracle.url=${DB_NEXI_ORACLE_URL} spring.datasource.nexi.oracle.username=${DB_NEXI_ORACLE_USER} spring.datasource.nexi.oracle.password=${DB_NEXI_ORACLE_PASSWORD} -spring.datasource.nexi.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver +#spring.datasource.nexi.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver spring.autoconfigure.exclude= \ No newline at end of file From d81195df8075100f61c7d36c64614422dd20a615 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 16:06:19 +0100 Subject: [PATCH 19/88] wip --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0d7aa0c..afeadcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM maven:3.9.5-amazoncorretto-17-al2023@sha256:eeaa7ab572d931f7273fc5cf31429923f172091ae388969e11f42ec6dd817d74 as buildtime WORKDIR /build COPY . . -RUN mvn clean package +RUN mvn clean package -DskipTests FROM amazoncorretto:17.0.9-alpine3.18@sha256:df48bf2e183230040890460ddb4359a10aa6c7aad24bd88899482c52053c7e17 as builder From be0e929d05e2076be9189e877243195bc8990e11 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 16 Feb 2024 15:07:24 +0000 Subject: [PATCH 20/88] Bump to version 0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 12 +----------- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 17 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 1508ea8..6c28052 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.1.0 -appVersion: 0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio +version: 0.2.0 +appVersion: 0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index de95b2f..b801ae2 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: @@ -67,16 +67,12 @@ microservice-chart: APP_LOGGING_LEVEL: 'DEBUG' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - DB_NEXI_POSTGRE_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_NEXI_POSTGRE_USER: "cfg" - DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))" DB_NEXI_ORACLE_USER: "NODO4_CFG" - DB_PAGOPA_POSTGRE_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_PAGOPA_POSTGRE_USER: "cfg" - OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" @@ -87,21 +83,15 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' - DB_PAGOPA_POSTGRE_PASSWORD: "db-cfg-password" DB_NEXI_POSTGRE_URL: "postgresql-db-cfg-password" DB_NEXI_ORACLE_URL: "oracle-db-cfg-password" - API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key" API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key" - STAND_IN_MANAGER_RX_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-rx-connection-string-key" STAND_IN_MANAGER_SA_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-sa-connection-string-key" - API_CONFIG_CACHE_SUBSCRIPTION_KEY: "api-config-cache-subscription-key-string" STAND_IN_MANAGER_SUBSCRIPTION_KEY: "standin-manager-subscription-key" - - OTEL_EXPORTER_OTLP_HEADERS: "elastic-apm-secret-token" keyvault: name: "pagopa-d-nodo-kv" diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 82aa855..c84dd8b 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 957b096..215d0ae 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 09917f4..96d84d4 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + "version": "0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index bf522ac..2b33a16 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-1-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio + 0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 903d20e4553c02a5765e54046b51a24b3abbff8f Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 16:26:34 +0100 Subject: [PATCH 21/88] wip --- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 4 ++-- helm/values-uat.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index b801ae2..4d5c8e2 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -1,5 +1,5 @@ microservice-chart: - namespace: "node-cfg-sync" + namespace: "apiconfig" nameOverride: "" fullnameOverride: "" image: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index c84dd8b..fd6ed32 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -1,5 +1,5 @@ microservice-chart: - namespace: "node-cfg-sync" + namespace: "apiconfig" nameOverride: "" fullnameOverride: "" image: @@ -101,7 +101,7 @@ microservice-chart: labelSelector: matchLabels: app.kubernetes.io/instance: "pagopa-node-cfg-sync" - namespaces: ["nodo"] + namespaces: ["apiconfig"] topologyKey: topology.kubernetes.io/zone canaryDelivery: create: false diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 215d0ae..988d27f 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -1,5 +1,5 @@ microservice-chart: - namespace: "node-cfg-sync" + namespace: "apiconfig" nameOverride: "" fullnameOverride: "" image: From 27cfcb4da0b701b0c169bedf5c67ec39deed7c3d Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 16 Feb 2024 15:27:46 +0000 Subject: [PATCH 22/88] Bump to version 0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 6c28052..5514fba 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.2.0 -appVersion: 0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio +version: 0.3.0 +appVersion: 0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 4d5c8e2..3ed3bad 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index fd6ed32..3cf4ad7 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 988d27f..32e6aab 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 96d84d4..c4ff67b 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + "version": "0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 2b33a16..6488746 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-2-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio + 0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 84212327ef44d93f8f88b0d0048ce56aa5a2f284 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 16:40:21 +0100 Subject: [PATCH 23/88] wip --- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 4 ++-- helm/values-uat.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 3ed3bad..0fe1310 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -1,5 +1,5 @@ microservice-chart: - namespace: "apiconfig" + namespace: "nodo" nameOverride: "" fullnameOverride: "" image: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 3cf4ad7..188863c 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -1,5 +1,5 @@ microservice-chart: - namespace: "apiconfig" + namespace: "nodo" nameOverride: "" fullnameOverride: "" image: @@ -101,7 +101,7 @@ microservice-chart: labelSelector: matchLabels: app.kubernetes.io/instance: "pagopa-node-cfg-sync" - namespaces: ["apiconfig"] + namespaces: ["nodo"] topologyKey: topology.kubernetes.io/zone canaryDelivery: create: false diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 32e6aab..86ab611 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -1,5 +1,5 @@ microservice-chart: - namespace: "apiconfig" + namespace: "nodo" nameOverride: "" fullnameOverride: "" image: From 7ea8377f63b1b0c4ab4a625364d45b9257e978ee Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 16 Feb 2024 15:42:19 +0000 Subject: [PATCH 24/88] Bump to version 0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 5514fba..2d938a4 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.3.0 -appVersion: 0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio +version: 0.4.0 +appVersion: 0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 0fe1310..5dd281e 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 188863c..dcff1ca 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 86ab611..c664465 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index c4ff67b..c7d734b 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + "version": "0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 6488746..0b039c7 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-3-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio + 0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 0501107df76789f56bb366589648eb946dcbcc14 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Fri, 16 Feb 2024 16:48:27 +0100 Subject: [PATCH 25/88] NOD-690: wip --- .../controller/SyncCacheController.java | 39 ++++++---- .../pagopa/node/cfgsync/model/SyncStatus.java | 19 +++++ .../node/cfgsync/model/SyncStatusEnum.java | 8 ++ ...hResponse.java => SyncStatusResponse.java} | 5 +- ...tion.java => NexiOracleConfiguration.java} | 32 ++++---- ...ion.java => NexiPostgreConfiguration.java} | 28 +++---- .../NexiStandInOracleConfiguration.java | 68 ----------------- .../NexiStandInPostgreConfiguration.java | 64 ---------------- .../PagoPAPostgreConfiguration.java | 26 +++---- .../NexiCacheOracleRepository.java | 2 +- .../NexiStandInOracleRepository.java | 2 +- .../NexiCachePostgreRepository.java | 2 +- .../NexiStandInPostgreRepository.java | 2 +- .../service/ApiConfigCacheEhConsumer.java | 7 +- .../service/ApiConfigCacheService.java | 60 ++++++++++----- .../service/StandInManagerEhConsumer.java | 2 +- .../service/StandInManagerService.java | 74 ++++++++++++------- .../resources/application-local.properties | 25 ++++--- 18 files changed, 212 insertions(+), 253 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatus.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusEnum.java rename src/main/java/it/gov/pagopa/node/cfgsync/model/{RefreshResponse.java => SyncStatusResponse.java} (79%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/{NexiCacheOracleConfiguration.java => NexiOracleConfiguration.java} (58%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/{NexiCachePostgreConfiguration.java => NexiPostgreConfiguration.java} (61%) delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInOracleConfiguration.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInPostgreConfiguration.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/{cache => }/NexiCacheOracleRepository.java (77%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/{standin => }/NexiStandInOracleRepository.java (81%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/{cache => }/NexiCachePostgreRepository.java (77%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/{standin => }/NexiStandInPostgreRepository.java (77%) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java index d83c726..2ddd426 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java @@ -7,7 +7,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import it.gov.pagopa.node.cfgsync.model.ProblemJson; -import it.gov.pagopa.node.cfgsync.model.RefreshResponse; +import it.gov.pagopa.node.cfgsync.model.SyncStatus; +import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; +import it.gov.pagopa.node.cfgsync.model.SyncStatusResponse; import it.gov.pagopa.node.cfgsync.service.ApiConfigCacheService; import it.gov.pagopa.node.cfgsync.service.StandInManagerService; import lombok.extern.slf4j.Slf4j; @@ -15,11 +17,14 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + @Slf4j @RestController @RequestMapping("/ndp") @@ -74,13 +79,18 @@ public class SyncCacheController { value = "/stand-in", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity standin() { + public ResponseEntity> standin() { log.debug("Force stand-in configuration update"); - standInManagerService.forceStandIn(); + Map syncStatusEnumMap = standInManagerService.forceStandIn(); + + List syncStatusResponseList = syncStatusEnumMap.entrySet() + .stream() + .map(e -> SyncStatusResponse.builder().serviceIdentifier(e.getKey()).status(e.getValue()).build()) + .collect(Collectors.toList()); return ResponseEntity.ok() - .body(RefreshResponse.builder().serviceIdentifier("").status("done").build()); + .body(syncStatusResponseList); } @Operation( @@ -94,10 +104,9 @@ public ResponseEntity standin() { @ApiResponse( responseCode = "200", description = "OK", - content = - @Content( - mediaType = MediaType.APPLICATION_JSON_VALUE - )), + content =@Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = List.class))), @ApiResponse( responseCode = "400", description = "Bad Request", @@ -125,13 +134,17 @@ public ResponseEntity standin() { value = "/cache", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity cache() { - + public ResponseEntity> cache() { log.debug("Force cache configuration update"); - apiConfigCacheService.forceCacheUpdate(); + Map syncStatusEnumMap = apiConfigCacheService.forceCacheUpdate(); + + List syncStatusResponseList = syncStatusEnumMap.entrySet() + .stream() + .map(e -> SyncStatusResponse.builder().serviceIdentifier(e.getKey()).status(e.getValue()).build()) + .collect(Collectors.toList()); return ResponseEntity.ok() - .body(RefreshResponse.builder().serviceIdentifier("").status("done").build()); + .body(syncStatusResponseList); } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatus.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatus.java new file mode 100644 index 0000000..7ff0add --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatus.java @@ -0,0 +1,19 @@ +package it.gov.pagopa.node.cfgsync.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.*; + +import javax.validation.constraints.NotNull; + +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class SyncStatus { + + @NotNull + private String serviceIdentifier; + @NotNull private SyncStatusEnum status; +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusEnum.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusEnum.java new file mode 100644 index 0000000..c9e548d --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusEnum.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.node.cfgsync.model; + +public enum SyncStatusEnum { + + done, + disabled, + error; +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusResponse.java similarity index 79% rename from src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java rename to src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusResponse.java index babdbfd..fdb5a8e 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/model/RefreshResponse.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusResponse.java @@ -4,7 +4,6 @@ import lombok.*; import javax.validation.constraints.NotNull; -import java.time.ZonedDateTime; @Data @Builder(toBuilder = true) @@ -12,8 +11,8 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @ToString @JsonIgnoreProperties(ignoreUnknown = true) -public class RefreshResponse { +public class SyncStatusResponse { @NotNull private String serviceIdentifier; - @NotNull private String status; + @NotNull private SyncStatusEnum status; } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java similarity index 58% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java index f8c28e0..da0fa95 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCacheOracleConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java @@ -25,40 +25,40 @@ }) @EnableTransactionManagement @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle.cache", - entityManagerFactoryRef = "nexiCacheOracleEntityManagerFactory", - transactionManagerRef = "nexiCacheOracleTransactionManager" + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle", + entityManagerFactoryRef = "nexiOracleEntityManagerFactory", + transactionManagerRef = "nexiOracleTransactionManager" ) -@ConditionalOnProperty(prefix = "spring.datasource.nexi.oracle.cache", name = "enabled") -public class NexiCacheOracleConfiguration { +@ConditionalOnProperty(prefix = "spring.datasource.nexi.oracle", name = "enabled") +public class NexiOracleConfiguration { @Autowired private Environment env; @Bean - @ConfigurationProperties("spring.datasource.nexi.oracle.cache") - public DataSourceProperties nexiCacheOracleDatasourceProperties() { + @ConfigurationProperties("spring.datasource.nexi.oracle") + public DataSourceProperties nexiOracleDatasourceProperties() { return new DataSourceProperties(); } @Bean - @ConfigurationProperties("spring.datasource.nexi.oracle.cache.configuration") - public DataSource nexiCacheOracleDataSource() { - return nexiCacheOracleDatasourceProperties().initializeDataSourceBuilder() + @ConfigurationProperties("spring.datasource.nexi.oracle.configuration") + public DataSource nexiOracleDataSource() { + return nexiOracleDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); } - @Bean(name = "nexiCacheOracleEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean nexiCacheOracleEntityManagerFactory(EntityManagerFactoryBuilder builder) { + @Bean(name = "nexiOracleEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean nexiOracleEntityManagerFactory(EntityManagerFactoryBuilder builder) { return builder - .dataSource(nexiCacheOracleDataSource()) + .dataSource(nexiOracleDataSource()) .packages(ConfigCache.class) .build(); } @Bean - public PlatformTransactionManager nexiCacheOracleTransactionManager( - final @Qualifier("nexiCacheOracleEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiCacheOracleEntityManagerFactory) { - return new JpaTransactionManager(nexiCacheOracleEntityManagerFactory.getObject()); + public PlatformTransactionManager nexiOracleTransactionManager( + final @Qualifier("nexiOracleEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiOracleEntityManagerFactory) { + return new JpaTransactionManager(nexiOracleEntityManagerFactory.getObject()); } } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java similarity index 61% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java index 31b3633..6c8f33c 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiCachePostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java @@ -23,38 +23,38 @@ }) @EnableTransactionManagement @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre.cache", + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre", entityManagerFactoryRef = "nexiCachePostgreEntityManagerFactory", transactionManagerRef = "nexiCachePostgreTransactionManager" ) -@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgre.cache", name = "enabled") -public class NexiCachePostgreConfiguration { +@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgre", name = "enabled") +public class NexiPostgreConfiguration { @Bean - @ConfigurationProperties("spring.datasource.nexi.postgre.cache") - public DataSourceProperties nexiCachePostgreDatasourceProperties() { + @ConfigurationProperties("spring.datasource.nexi.postgre") + public DataSourceProperties nexiPostgreDatasourceProperties() { return new DataSourceProperties(); } @Bean - @ConfigurationProperties("spring.datasource.nexi.postgre.cache.configuration") - public DataSource nexiCachePostgreDataSource() { - return nexiCachePostgreDatasourceProperties().initializeDataSourceBuilder() + @ConfigurationProperties("spring.datasource.nexi.postgre.configuration") + public DataSource nexiPostgreDataSource() { + return nexiPostgreDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); } - @Bean(name = "nexiCachePostgreEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean nexiCachePostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { + @Bean(name = "nexiPostgreEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean nexiPostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { return builder - .dataSource(nexiCachePostgreDataSource()) + .dataSource(nexiPostgreDataSource()) .packages(ConfigCache.class) .build(); } @Bean - public PlatformTransactionManager nexiCachePostgreTransactionManager( - final @Qualifier("nexiCachePostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiCachePostgreEntityManagerFactory) { - return new JpaTransactionManager(nexiCachePostgreEntityManagerFactory.getObject()); + public PlatformTransactionManager nexiPostgreTransactionManager( + final @Qualifier("nexiPostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiPostgreEntityManagerFactory) { + return new JpaTransactionManager(nexiPostgreEntityManagerFactory.getObject()); } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInOracleConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInOracleConfiguration.java deleted file mode 100644 index e7794e3..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInOracleConfiguration.java +++ /dev/null @@ -1,68 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.configuration; - -import com.zaxxer.hikari.HikariDataSource; -import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; -import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.PropertySources; -import org.springframework.core.env.Environment; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.sql.DataSource; - -@Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) -@EnableTransactionManagement -@EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle.standin", - entityManagerFactoryRef = "nexiStandInOracleEntityManagerFactory", - transactionManagerRef = "nexiStandInOracleTransactionManager" -) -@ConditionalOnProperty(prefix = "spring.datasource.nexi.oracle.standin", name = "enabled") -public class NexiStandInOracleConfiguration { - - @Autowired - private Environment env; - - @Bean - @ConfigurationProperties("spring.datasource.nexi.oracle.standin") - public DataSourceProperties nexiStandInOracleDatasourceProperties() { - return new DataSourceProperties(); - } - - @Bean - @ConfigurationProperties("spring.datasource.nexi.oracle.standin.configuration") - public DataSource nexiStandInOracleDataSource() { - return nexiStandInOracleDatasourceProperties().initializeDataSourceBuilder() - .type(HikariDataSource.class).build(); - } - - @Bean(name = "nexiStandInOracleEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean nexiStandInOracleEntityManagerFactory(EntityManagerFactoryBuilder builder) { - return builder - .dataSource(nexiStandInOracleDataSource()) - .packages(StandInStations.class) - .build(); - } - - @Bean - public PlatformTransactionManager nexiStandInOracleTransactionManager( - final @Qualifier("nexiStandInOracleEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiStandInOracleEntityManagerFactory) { - return new JpaTransactionManager(nexiStandInOracleEntityManagerFactory.getObject()); - } -} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInPostgreConfiguration.java deleted file mode 100644 index 8fa6207..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiStandInPostgreConfiguration.java +++ /dev/null @@ -1,64 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.configuration; - -import com.zaxxer.hikari.HikariDataSource; -import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; -import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.PropertySources; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.sql.DataSource; - -@Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) -@EnableTransactionManagement -@EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre.standin", - entityManagerFactoryRef = "nexiStandInPostgreEntityManagerFactory", - transactionManagerRef = "nexiStandInPostgreTransactionManager" -) -@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgre.standin", name = "enabled") -public class NexiStandInPostgreConfiguration { - - @Bean - @ConfigurationProperties("spring.datasource.nexi.postgre.standin") - public DataSourceProperties nexiStandInPostgreDatasourceProperties() { - return new DataSourceProperties(); - } - - @Bean - @ConfigurationProperties("spring.datasource.nexi.postgre.standin.configuration") - public DataSource nexiStandInPostgreDataSource() { - return nexiStandInPostgreDatasourceProperties().initializeDataSourceBuilder() - .type(HikariDataSource.class).build(); - } - - @Bean(name = "nexiStandInPostgreEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean nexiStandInPostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { - return builder - .dataSource(nexiStandInPostgreDataSource()) - .packages(StandInStations.class) - .build(); - } - - @Bean - public PlatformTransactionManager nexiStandInPostgreTransactionManager( - final @Qualifier("nexiStandInPostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiStandInPostgreEntityManagerFactory) { - return new JpaTransactionManager(nexiStandInPostgreEntityManagerFactory.getObject()); - } - -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java index 58a0fdd..b017219 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java @@ -24,41 +24,41 @@ @EnableTransactionManagement @EnableJpaRepositories( basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", - entityManagerFactoryRef = "pagoPACachePostgreEntityManagerFactory", - transactionManagerRef = "pagoPACachePostgreTransactionManager" + entityManagerFactoryRef = "pagoPAPostgreEntityManagerFactory", + transactionManagerRef = "pagoPAPostgreTransactionManager" ) @ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgre", name = "enabled") public class PagoPAPostgreConfiguration { - @Bean @Primary + @Bean @ConfigurationProperties("spring.datasource.pagopa.postgre") - public DataSourceProperties pagoPACachePostgreDatasourceProperties() { + public DataSourceProperties pagoPAPostgreDatasourceProperties() { return new DataSourceProperties(); } - @Bean @Primary + @Bean @ConfigurationProperties("spring.datasource.pagopa.postgre.configuration") - public DataSource pagoPACachePostgreDataSource() { - return pagoPACachePostgreDatasourceProperties().initializeDataSourceBuilder() + public DataSource pagoPAPostgreDataSource() { + return pagoPAPostgreDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); } @Primary - @Bean(name = "pagoPACachePostgreEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean pagoPACachePostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { + @Bean(name = "pagoPAPostgreEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean pagoPAPostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { return builder - .dataSource(pagoPACachePostgreDataSource()) + .dataSource(pagoPAPostgreDataSource()) .packages(ConfigCache.class) .build(); } @Primary @Bean - public PlatformTransactionManager pagoPACachePostgreTransactionManager( - final @Qualifier("pagoPACachePostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagoPACachePostgreEntityManagerFactory) { - return new JpaTransactionManager(pagoPACachePostgreEntityManagerFactory.getObject()); + public PlatformTransactionManager pagoPAPostgreTransactionManager( + final @Qualifier("pagoPAPostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagoPAPostgreEntityManagerFactory) { + return new JpaTransactionManager(pagoPAPostgreEntityManagerFactory.getObject()); } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/cache/NexiCacheOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java similarity index 77% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/cache/NexiCacheOracleRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java index 6b6e8f4..0277223 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/cache/NexiCacheOracleRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.nexioracle.cache; +package it.gov.pagopa.node.cfgsync.repository.nexioracle; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/standin/NexiStandInOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java similarity index 81% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/standin/NexiStandInOracleRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java index 9ff63f1..9d0b1df 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/standin/NexiStandInOracleRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.nexioracle.standin; +package it.gov.pagopa.node.cfgsync.repository.nexioracle; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/cache/NexiCachePostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java similarity index 77% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/cache/NexiCachePostgreRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java index 10fbb35..7bb6e79 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/cache/NexiCachePostgreRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.nexipostgre.cache; +package it.gov.pagopa.node.cfgsync.repository.nexipostgre; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/standin/NexiStandInPostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiStandInPostgreRepository.java similarity index 77% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/standin/NexiStandInPostgreRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiStandInPostgreRepository.java index 021a5a6..0086d72 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/standin/NexiStandInPostgreRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiStandInPostgreRepository.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.nexipostgre.standin; +package it.gov.pagopa.node.cfgsync.repository.nexipostgre; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java index 14df3df..45c8ca4 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java @@ -7,6 +7,7 @@ import com.azure.messaging.eventhubs.models.EventContext; import com.azure.storage.blob.BlobContainerAsyncClient; import com.azure.storage.blob.BlobContainerClientBuilder; +import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -47,14 +48,16 @@ public void post(){ } public void processEvent(EventContext eventContext) { - log.info("Processing event from partition {} with sequence number {} with body: {}", + log.info("Processing event {} from partition {} with sequence number {} with body: {}", + TargetRefreshEnum.config.label, eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), eventContext.getEventData().getBodyAsString()); apiConfigCacheService.forceCacheUpdate(); } public void processError(ErrorContext errorContext) { - log.error("Error occurred in partition processor for partition {}, {}", + log.error("Error occurred for {} from partition {}: {}", + TargetRefreshEnum.config.label, errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable().getMessage(), errorContext.getThrowable()); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 08b4415..236aacb 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -6,6 +6,7 @@ import it.gov.pagopa.node.cfgsync.client.ApiConfigCacheClient; import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; +import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgreRepository; @@ -15,16 +16,15 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; import org.springframework.transaction.support.TransactionTemplate; import java.io.IOException; +import java.time.Instant; import java.time.ZonedDateTime; import java.util.Collection; +import java.util.HashMap; import java.util.Map; -import java.util.NoSuchElementException; @Service @Slf4j @@ -50,22 +50,26 @@ public class ApiConfigCacheService extends CommonCacheService { @Value("${pagopa.postgre.cache.write.enabled}") private Boolean pagopaPostgreCacheEnabled; + @Value("${pagopa.postgre.serviceIdentifier}") + private String pagopaPostgreServiceIdentifier; @Value("${nexi.postgre.cache.write.enabled}") private Boolean nexiPostgreCacheEnabled; + @Value("${nexi.postgre.serviceIdentifier}") + private String nexiPostgreServiceIdentifier; @Value("${nexi.oracle.cache.write.enabled}") private Boolean nexiOracleCacheEnabled; + @Value("${nexi.oracle.serviceIdentifier}") + private String nexiOracleServiceIdentifier; - private final TransactionTemplate transactionTemplate; - - public ApiConfigCacheService(@Value("${api-config-cache.service.host}") String apiConfigCacheUrl, PlatformTransactionManager transactionManager) { + public ApiConfigCacheService(@Value("${api-config-cache.service.host}") String apiConfigCacheUrl) { apiConfigCacheClient = Feign.builder().target(ApiConfigCacheClient.class, apiConfigCacheUrl); - transactionTemplate = new TransactionTemplate(transactionManager); } @Transactional - public void forceCacheUpdate() { + public Map forceCacheUpdate() { + Map syncStatusMap = new HashMap<>(); try { if( !enabled ) { throw new AppException(AppError.SERVICE_DISABLED, TargetRefreshEnum.config); @@ -88,19 +92,38 @@ public void forceCacheUpdate() { String cacheTimestamp = (String) getHeaderParameter(TargetRefreshEnum.config, headers, HEADER_CACHE_TIMESTAMP); String cacheVersion = (String) getHeaderParameter(TargetRefreshEnum.config, headers, HEADER_CACHE_VERSION); + log.info("SyncService cacheId:[{}], cacheTimestamp:[{}], cacheVersion:[{}]", cacheId, Instant.from(ZonedDateTime.parse(cacheTimestamp)), cacheVersion); + ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); - this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { - public void doInTransactionWithoutResult(TransactionStatus status) { - try { - if( pagopaPostgreCacheEnabled ) pagoPACachePostgreRepository.save(configCache); -// if( nexiPostgreCacheEnabled ) nexiCachePostgreRepository.save(configCache); -// if( nexiOracleCacheEnabled ) nexiCacheOracleRepository.save(configCache); - } catch(NoSuchElementException ex) { - status.setRollbackOnly(); - } + try { + if( pagopaPostgreCacheEnabled ) { + pagoPACachePostgreRepository.save(configCache); + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); + } else { + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); } - }); + } catch(Exception ex) { + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error); + } +// try { +// if (nexiPostgreCacheEnabled) { +// nexiCachePostgreRepository.save(configCache); +// } else { +// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); +// } +// } catch(Exception ex) { +// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); +// } +// try { +// if( nexiOracleCacheEnabled ) { +// nexiCacheOracleRepository.save(configCache); +// } else { +// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); +// } +// } catch(Exception ex) { +// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); +// } } catch (FeignException.GatewayTimeout e) { log.error("SyncService api-config-cache get cache error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); @@ -111,5 +134,6 @@ public void doInTransactionWithoutResult(TransactionStatus status) { log.error("SyncService api-config-cache get cache error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } + return syncStatusMap; } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java index 5093b1f..996336c 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerEhConsumer.java @@ -56,7 +56,7 @@ public void processEvent(EventContext eventContext) { } public void processError(ErrorContext errorContext) { - log.error("Error occurred in partition processor {} for partition {}, {}", + log.error("Error occurred for {} from partition {}: {}", TargetRefreshEnum.standin.label, errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable().getMessage(), diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 4284cfa..c388dbe 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -8,6 +8,7 @@ import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; import it.gov.pagopa.node.cfgsync.model.StationsResponse; +import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgreRepository; @@ -16,15 +17,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; import java.io.IOException; +import java.util.HashMap; import java.util.List; -import java.util.NoSuchElementException; +import java.util.Map; import java.util.stream.Collectors; @Service @@ -47,28 +45,32 @@ public class StandInManagerService extends CommonCacheService { @Value("${pagopa.postgre.standin.write.enabled}") private Boolean pagopaPostgreStandInEnabled; + @Value("${pagopa.postgre.serviceIdentifier}") + private String pagopaPostgreServiceIdentifier; @Value("${nexi.postgre.standin.write.enabled}") private Boolean nexiPostgreStandInEnabled; + @Value("${nexi.postgre.serviceIdentifier}") + private String nexiPostgreServiceIdentifier; @Value("${nexi.oracle.standin.write.enabled}") private Boolean nexiOracleStandInEnabled; + @Value("${nexi.oracle.serviceIdentifier}") + private String nexiOracleServiceIdentifier; - private final TransactionTemplate transactionTemplate; - - public StandInManagerService(@Value("${stand-in-manager.service.host}") String standInManagerUrl, ObjectMapper objectMapper, PlatformTransactionManager transactionManager) { + public StandInManagerService(@Value("${stand-in-manager.service.host}") String standInManagerUrl, ObjectMapper objectMapper) { standInManagerClient = Feign.builder().target(StandInManagerClient.class, standInManagerUrl); - transactionTemplate = new TransactionTemplate(transactionManager); this.objectMapper = objectMapper; } @Transactional - public void forceStandIn() { + public Map forceStandIn() { + Map syncStatusMap = new HashMap<>(); try { if( !enabled ) { throw new AppException(AppError.SERVICE_DISABLED, TargetRefreshEnum.standin); } - log.debug("SyncService api-config-cache get stations"); + log.debug("SyncService stand-in-manager get stations"); Response response = standInManagerClient.getCache(subscriptionKey); int httpResponseCode = response.status(); if (httpResponseCode != HttpStatus.OK.value()) { @@ -78,21 +80,42 @@ public void forceStandIn() { log.info("SyncService stand-in-manager get stations successful"); StationsResponse stations = objectMapper.readValue(response.body().asInputStream().readAllBytes(), StationsResponse.class); - List stationsEntities = stations.getStations().stream().map(s -> new StandInStations(s)).collect(Collectors.toList()); - this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { - public void doInTransactionWithoutResult(TransactionStatus status) { - try { - if( pagopaPostgreStandInEnabled ) { - pagoPAStandInPostgreRepository.deleteAll(); - pagoPAStandInPostgreRepository.saveAll(stationsEntities); - } -// if( nexiPostgreStandInEnabled ) nexiStandInPostgreRepository.saveAll(stationsEntities); -// if( nexiOracleStandInEnabled ) nexiStandInOracleRepository.saveAll(stationsEntities); - } catch(NoSuchElementException ex) { - status.setRollbackOnly(); - } + log.info("SyncService {} stations found", stations.getStations().size()); + List stationsEntities = stations.getStations().stream().map(StandInStations::new).collect(Collectors.toList()); + + try { + if (pagopaPostgreStandInEnabled) { + pagoPAStandInPostgreRepository.deleteAll(); + pagoPAStandInPostgreRepository.saveAll(stationsEntities); + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); + } else { + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); } - }); + } catch(Exception ex) { + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error); + } +// try { +// if (nexiPostgreStandInEnabled) { +// nexiStandInPostgreRepository.deleteAll(); +// nexiStandInPostgreRepository.saveAll(stationsEntities); +// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done); +// } else { +// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); +// } +// } catch(Exception ex) { +// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); +// } +// try { +// if( nexiOracleStandInEnabled ) { +// nexiStandInOracleRepository.deleteAll(); +// nexiStandInOracleRepository.saveAll(stationsEntities); +// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); +// } else { +// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); +// } +// } catch(Exception ex) { +// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); +// } } catch (FeignException.GatewayTimeout e) { log.error("SyncService stand-in-manager get stations error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); @@ -100,5 +123,6 @@ public void doInTransactionWithoutResult(TransactionStatus status) { log.error("SyncService stand-in-manager get stations error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } + return syncStatusMap; } } diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index c6c648e..92a0791 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -12,6 +12,18 @@ app.update.nodo.postgre.nexi=true app.update.nodo.postgre.pagopa=true app.trimCacheColumn=true +pagopa.postgre.cache.write.enabled=true +pagopa.postgre.standin.write.enabled=true +pagopa.postgre.serviceIdentifier=${DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER} + +nexi.postgre.cache.write.enabled=false +nexi.postgre.standin.write.enabled=false +nexi.postgre.serviceIdentifier=${DB_NEXI_POSTGRE_SERVICE_IDENTIFIER} + +nexi.oracle.cache.write.enabled=false +nexi.oracle.standin.write.enabled=false +nexi.oracle.serviceIdentifier=${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} + # Api Config Cache configuration api-config-cache.service.enabled=true api-config-cache.service.host=https://api.dev.platform.pagopa.it/api-config-cache/p/v1 @@ -37,7 +49,7 @@ stand-in-manager.sa-name=synstandinreadevent stand-in-manager.consumer-group=$Default # DB -spring.jpa.show-sql=true +spring.jpa.show-sql=false spring.datasource.pagopa.postgre.enabled=true spring.datasource.pagopa.postgre.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg @@ -45,7 +57,6 @@ spring.datasource.pagopa.postgre.username=cfg spring.datasource.pagopa.postgre.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} spring.datasource.pagopa.postgre.driver-class-name=org.postgresql.Driver - spring.datasource.nexi.postgre.enabled=false spring.datasource.nexi.postgre.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=public spring.datasource.nexi.postgre.username=cfg @@ -57,13 +68,3 @@ spring.datasource.nexi.oracle.url=jdbc:oracle:thin:@//localhost:1521/cfg spring.datasource.nexi.oracle.username=cfg spring.datasource.nexi.oracle.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} spring.datasource.nexi.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver - -pagopa.postgre.cache.write.enabled=true -nexi.postgre.cache.write.enabled=false -nexi.oracle.cache.write.enabled=false - -pagopa.postgre.standin.write.enabled=true -nexi.postgre.standin.write.enabled=false -nexi.oracle.standin.write.enabled=false - -spring.autoconfigure.exclude= \ No newline at end of file From 1cb7201447106029307a35a8d925c8f3348de9e0 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 16 Feb 2024 15:50:56 +0000 Subject: [PATCH 26/88] Bump to version 0.0.0-5-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 2d938a4..9f62e29 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.4.0 -appVersion: 0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio +version: 0.5.0 +appVersion: 0.0.0-5-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 5dd281e..c4d552e 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-5-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index dcff1ca..c8d1116 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-5-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index c664465..652ce82 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + tag: "0.0.0-5-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index c7d734b..4f79051 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio" + "version": "0.0.0-5-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 0b039c7..1bfb488 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-4-NOD-690-config-cache-nodo-cfg-sync-implementazione-microservizio + 0.0.0-5-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From ec3e8c8dfae9ae1d66ee1a535803552dc9bcd0f4 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 18:03:43 +0100 Subject: [PATCH 27/88] wip --- helm/values-dev.yaml | 20 ++-- .../NexiOracleConfiguration.java | 8 +- .../NexiPostgreConfiguration.java | 14 +-- .../PagoPAPostgreConfiguration.java | 12 +- .../service/ApiConfigCacheService.java | 25 ++-- .../service/StandInManagerService.java | 31 ++--- .../resources/application-local.properties | 70 ------------ src/main/resources/application-local.yaml | 78 +++++++++++++ src/main/resources/application.properties | 85 -------------- src/main/resources/application.yaml | 107 ++++++++++++++++++ 10 files changed, 245 insertions(+), 205 deletions(-) delete mode 100644 src/main/resources/application-local.properties create mode 100644 src/main/resources/application-local.yaml delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yaml diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index c4d552e..6e4115d 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -67,12 +67,18 @@ microservice-chart: APP_LOGGING_LEVEL: 'DEBUG' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - DB_NEXI_POSTGRE_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" - DB_NEXI_POSTGRE_USER: "cfg" + DB_NEXI_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + DB_NEXI_POSTGRES_USER: "cfg" + DB_NEXI_POSTGRES_ENABLED: "true" + DB_NEXI_POSTGRE_SERVICE_IDENTIFIER: "NDP004DEV" DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))" DB_NEXI_ORACLE_USER: "NODO4_CFG" - DB_PAGOPA_POSTGRE_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" - DB_PAGOPA_POSTGRE_USER: "cfg" + DB_NEXI_ORACLE_ENABLED: "true" + DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV" + DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + DB_PAGOPA_POSTGRES_USER: "cfg" + DB_PAGOPA_POSTGRES_ENABLED: "true" + DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER: "NDP001DEV" OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" @@ -83,9 +89,9 @@ microservice-chart: envSecret: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' - DB_PAGOPA_POSTGRE_PASSWORD: "db-cfg-password" - DB_NEXI_POSTGRE_URL: "postgresql-db-cfg-password" - DB_NEXI_ORACLE_URL: "oracle-db-cfg-password" + DB_PAGOPA_POSTGRES_PASSWORD: "db-cfg-password" + DB_NEXI_POSTGRES_PASSWORD: "postgresql-db-cfg-password" + DB_NEXI_ORACLE_PASSWORD: "oracle-db-cfg-password" API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key" API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key" STAND_IN_MANAGER_RX_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-rx-connection-string-key" diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java index da0fa95..c72f990 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java @@ -19,10 +19,10 @@ import javax.sql.DataSource; @Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) +//@PropertySources({ +// @PropertySource("classpath:/application.properties"), +// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +//}) @EnableTransactionManagement @EnableJpaRepositories( basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle", diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java index 6c8f33c..0d171a8 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java @@ -17,21 +17,21 @@ import javax.sql.DataSource; @Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) +//@PropertySources({ +// @PropertySource("classpath:/application.properties"), +// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +//}) @EnableTransactionManagement @EnableJpaRepositories( - basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre", + basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgres", entityManagerFactoryRef = "nexiCachePostgreEntityManagerFactory", transactionManagerRef = "nexiCachePostgreTransactionManager" ) -@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgre", name = "enabled") +@ConditionalOnProperty(prefix = "spring.datasource.nexi.postgres", name = "enabled") public class NexiPostgreConfiguration { @Bean - @ConfigurationProperties("spring.datasource.nexi.postgre") + @ConfigurationProperties("spring.datasource.nexi.postgres") public DataSourceProperties nexiPostgreDatasourceProperties() { return new DataSourceProperties(); } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java index b017219..1338db2 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java @@ -17,22 +17,22 @@ import javax.sql.DataSource; @Configuration -@PropertySources({ - @PropertySource("classpath:/application.properties"), - @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -}) +//@PropertySources({ +// @PropertySource("classpath:/application.properties"), +// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) +//}) @EnableTransactionManagement @EnableJpaRepositories( basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", entityManagerFactoryRef = "pagoPAPostgreEntityManagerFactory", transactionManagerRef = "pagoPAPostgreTransactionManager" ) -@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgre", name = "enabled") +@ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgres", name = "enabled") public class PagoPAPostgreConfiguration { @Primary @Bean - @ConfigurationProperties("spring.datasource.pagopa.postgre") + @ConfigurationProperties("spring.datasource.pagopa.postgres") public DataSourceProperties pagoPAPostgreDatasourceProperties() { return new DataSourceProperties(); } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 236aacb..73c96a1 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -9,15 +9,15 @@ import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiCacheOracleRepository; +import it.gov.pagopa.node.cfgsync.repository.nexipostgre.NexiCachePostgreRepository; import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgreRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; import java.io.IOException; import java.time.Instant; @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Optional; @Service @Slf4j @@ -43,24 +44,24 @@ public class ApiConfigCacheService extends CommonCacheService { @Autowired private PagoPACachePostgreRepository pagoPACachePostgreRepository; -// @Autowired -// private NexiCachePostgreRepository nexiCachePostgreRepository; -// @Autowired -// private NexiCacheOracleRepository nexiCacheOracleRepository; + @Autowired(required = false) + private Optional nexiCachePostgreRepository; + @Autowired(required = false) + private Optional nexiCacheOracleRepository; - @Value("${pagopa.postgre.cache.write.enabled}") + @Value("${app.write.cache.pagopa-postgres}") private Boolean pagopaPostgreCacheEnabled; - @Value("${pagopa.postgre.serviceIdentifier}") + @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgreServiceIdentifier; - @Value("${nexi.postgre.cache.write.enabled}") + @Value("${app.write.cache.nexi-postgres}") private Boolean nexiPostgreCacheEnabled; - @Value("${nexi.postgre.serviceIdentifier}") + @Value("${app.identifiers.nexi-postgres}") private String nexiPostgreServiceIdentifier; - @Value("${nexi.oracle.cache.write.enabled}") + @Value("${app.write.cache.nexi-oracle}") private Boolean nexiOracleCacheEnabled; - @Value("${nexi.oracle.serviceIdentifier}") + @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; public ApiConfigCacheService(@Value("${api-config-cache.service.host}") String apiConfigCacheUrl) { diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index c388dbe..2acd316 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -11,6 +11,8 @@ import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiStandInOracleRepository; +import it.gov.pagopa.node.cfgsync.repository.nexipostgre.NexiStandInPostgreRepository; import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgreRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; @Service @@ -36,26 +39,26 @@ public class StandInManagerService extends CommonCacheService { private final StandInManagerClient standInManagerClient; private final ObjectMapper objectMapper; - @Autowired - private PagoPAStandInPostgreRepository pagoPAStandInPostgreRepository; -// @Autowired -// private NexiStandInPostgreRepository nexiStandInPostgreRepository; -// @Autowired -// private NexiStandInOracleRepository nexiStandInOracleRepository; + @Autowired(required = false) + private Optional pagoPAStandInPostgreRepository; + @Autowired(required = false) + private Optional nexiStandInPostgreRepository; + @Autowired(required = false) + private Optional nexiStandInOracleRepository; - @Value("${pagopa.postgre.standin.write.enabled}") + @Value("${app.write.standin.pagopa-postgres}") private Boolean pagopaPostgreStandInEnabled; - @Value("${pagopa.postgre.serviceIdentifier}") + @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgreServiceIdentifier; - @Value("${nexi.postgre.standin.write.enabled}") + @Value("${app.write.standin.nexi-postgres}") private Boolean nexiPostgreStandInEnabled; - @Value("${nexi.postgre.serviceIdentifier}") + @Value("${app.identifiers.nexi-postgres}") private String nexiPostgreServiceIdentifier; - @Value("${nexi.oracle.standin.write.enabled}") + @Value("${app.write.standin.nexi-oracle}") private Boolean nexiOracleStandInEnabled; - @Value("${nexi.oracle.serviceIdentifier}") + @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; public StandInManagerService(@Value("${stand-in-manager.service.host}") String standInManagerUrl, ObjectMapper objectMapper) { @@ -85,8 +88,8 @@ public Map forceStandIn() { try { if (pagopaPostgreStandInEnabled) { - pagoPAStandInPostgreRepository.deleteAll(); - pagoPAStandInPostgreRepository.saveAll(stationsEntities); + pagoPAStandInPostgreRepository.get().deleteAll(); + pagoPAStandInPostgreRepository.get().saveAll(stationsEntities); syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties deleted file mode 100644 index 92a0791..0000000 --- a/src/main/resources/application-local.properties +++ /dev/null @@ -1,70 +0,0 @@ -# Info -info.properties.environment=local -# Logging -logging.level.root=INFO -logging.level.it.gov.pagopa=DEBUG -# CORS configuration -cors.configuration={"origins": ["*"], "methods": ["*"]} - -# Functionality -app.update.nodo.oracle.nexi=true -app.update.nodo.postgre.nexi=true -app.update.nodo.postgre.pagopa=true -app.trimCacheColumn=true - -pagopa.postgre.cache.write.enabled=true -pagopa.postgre.standin.write.enabled=true -pagopa.postgre.serviceIdentifier=${DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER} - -nexi.postgre.cache.write.enabled=false -nexi.postgre.standin.write.enabled=false -nexi.postgre.serviceIdentifier=${DB_NEXI_POSTGRE_SERVICE_IDENTIFIER} - -nexi.oracle.cache.write.enabled=false -nexi.oracle.standin.write.enabled=false -nexi.oracle.serviceIdentifier=${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} - -# Api Config Cache configuration -api-config-cache.service.enabled=true -api-config-cache.service.host=https://api.dev.platform.pagopa.it/api-config-cache/p/v1 -api-config-cache.service.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} - -api-config-cache.consumer.enabled=true -api-config-cache.rx-connection-string=${API_CONFIG_CACHE_RX_CONNECTION_STRING} -api-config-cache.rx-name=nodo-dei-pagamenti-cache -api-config-cache.sa-connection-string=${API_CONFIG_CACHE_SA_CONNECTION_STRING} -api-config-cache.sa-name=synccachereadevent -api-config-cache.consumer-group=$Default - -# Stand-in Manager configuration -stand-in-manager.service.enabled=true -stand-in-manager.service.host=https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 -stand-in-manager.service.subscriptionKey=${STAND_IN_MANAGER_SUBSCRIPTION_KEY} - -stand-in-manager.consumer.enabled=true -stand-in-manager.rx-connection-string=${STAND_IN_MANAGER_RX_CONNECTION_STRING} -stand-in-manager.rx-name=nodo-dei-pagamenti-stand-in -stand-in-manager.sa-connection-string=${STAND_IN_MANAGER_SA_CONNECTION_STRING} -stand-in-manager.sa-name=synstandinreadevent -stand-in-manager.consumer-group=$Default - -# DB -spring.jpa.show-sql=false - -spring.datasource.pagopa.postgre.enabled=true -spring.datasource.pagopa.postgre.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg -spring.datasource.pagopa.postgre.username=cfg -spring.datasource.pagopa.postgre.password=${DB_PAGOPA_POSTGRE_CACHE_PASSWORD} -spring.datasource.pagopa.postgre.driver-class-name=org.postgresql.Driver - -spring.datasource.nexi.postgre.enabled=false -spring.datasource.nexi.postgre.url=jdbc:postgresql://localhost:5432/nodo?currentSchema=public -spring.datasource.nexi.postgre.username=cfg -spring.datasource.nexi.postgre.password=${DB_NEXI_POSTGRE_CACHE_PASSWORD} -spring.datasource.nexi.postgre.driver-class-name=org.postgresql.Driver - -spring.datasource.nexi.oracle.enabled=false -spring.datasource.nexi.oracle.url=jdbc:oracle:thin:@//localhost:1521/cfg -spring.datasource.nexi.oracle.username=cfg -spring.datasource.nexi.oracle.password=${DB_NEXI_ORACLE_CACHE_PASSWORD} -spring.datasource.nexi.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml new file mode 100644 index 0000000..65e106b --- /dev/null +++ b/src/main/resources/application-local.yaml @@ -0,0 +1,78 @@ +info: + properties: + environment: local +cors: + configuration: '{"origins": ["*"], "methods": ["*"]}' + +app: + trimCacheColumn: 'true' + identifiers: + pagopa-postgres: ${DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER} + nexi-postgres: ${DB_NEXI_POSTGRE_SERVICE_IDENTIFIER} + nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} + write: + cache: + pagopa-postgres: 'true' + nexi-postgres: 'false' + nexi-oracle: 'false' + standin: + pagopa-postgres: 'true' + nexi-postgres: 'false' + nexi-oracle: 'false' + +spring: + datasource: + pagopa: + postgres: + url: jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg + username: cfg + password: ${DB_PAGOPA_POSTGRE_PASSWORD} + enabled: 'true' + nexi: + oracle: + url: jdbc:oracle:thin:@//localhost:1521/cfg + username: cfg + password: ${DB_NEXI_ORACLE_PASSWORD} + enabled: 'false' + postgres: + url: jdbc:postgresql://localhost:5432/nodo?currentSchema=public + username: cfg + password: ${DB_NEXI_POSTGRE_PASSWORD} + enabled: 'false' + jpa: + show-sql: 'false' + +stand-in-manager: + rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} + rx-name: nodo-dei-pagamenti-stand-in + service: + subscriptionKey: ${STAND_IN_MANAGER_SUBSCRIPTION_KEY} + enabled: 'true' + host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 + consumer: + enabled: 'true' + sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING} + consumer-group: $Default + sa-name: synstandinreadevent + +api-config-cache: + sa-name: synccachereadevent + service: + subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} + host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 + enabled: 'true' + rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} + sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING} + consumer: + enabled: 'true' + consumer-group: $Default + rx-name: nodo-dei-pagamenti-cache + +logging: + level: + it: + gov: + pagopa: DEBUG + root: INFO + + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 41c0d35..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,85 +0,0 @@ -# Info -info.application.artifactId=@project.artifactId@ -info.application.name=@project.name@ -info.application.version=@project.version@ -info.application.description=@project.description@ -info.properties.environment=${ENV:azure} - -# Actuator -management.endpoints.web.exposure.include=health,info -management.endpoints.jmx.exposure.include=health,info -management.info.env.enabled=true -management.endpoint.health.probes.enabled=true -management.health.livenessState.enabled=true -management.health.readinessState.enabled=true - -# Openapi -springdoc.writer-with-order-by-keys=true -springdoc.writer-with-default-pretty-printer=true - -# Server -server.servlet.context-path=/ -server.port=8080 - -# Logging -logging.level.root=${DEFAULT_LOGGING_LEVEL:INFO} -logging.level.it.gov.pagopa=${APP_LOGGING_LEVEL:INFO} - -# CORS configuration -cors.configuration=${CORS_CONFIGURATION:'{"origins": ["*"], "methods": ["*"]}'} - - -# Functionality -app.update.nodo.oracle.nexi=true -app.update.nodo.postgre.nexi=true -app.update.nodo.postgre.pagopa=true -app.trimCacheColumn=true - -# Api Config Cache configuration -api-config-cache.service.enabled=true -api-config-cache.service.host=https://api.dev.platform.pagopa.it/api-config-cache/p/v1 -api-config-cache.service.subscriptionKey=${API_CONFIG_CACHE_SUBSCRIPTION_KEY} - -api-config-cache.consumer.enabled=true -api-config-cache.rx-connection-string=${API_CONFIG_CACHE_RX_CONNECTION_STRING} -api-config-cache.rx-name=nodo-dei-pagamenti-cache -api-config-cache.sa-connection-string=${API_CONFIG_CACHE_SA_CONNECTION_STRING} -api-config-cache.sa-name=synccachereadevent -api-config-cache.consumer-group=$Default - -# Stand-in Manager configuration -stand-in-manager.service.enabled=true -stand-in-manager.service.host=https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 -stand-in-manager.service.subscriptionKey=${STAND_IN_MANAGER_SUBSCRIPTION_KEY} - -stand-in-manager.consumer.enabled=true -stand-in-manager.rx-connection-string=${STAND_IN_MANAGER_RX_CONNECTION_STRING} -stand-in-manager.rx-name=nodo-dei-pagamenti-stand-in -stand-in-manager.sa-connection-string=${STAND_IN_MANAGER_SA_CONNECTION_STRING} -stand-in-manager.sa-name=synstandinreadevent -stand-in-manager.consumer-group=$Default - -# DB -#spring.jpa.hibernate.ddl-auto=update -#spring.jpa.generate-ddl=true -spring.jpa.show-sql=true - -spring.datasource.pagopa.postgre.enabled=true -spring.datasource.pagopa.postgre.url=${DB_PAGOPA_POSTGRE_URL} -spring.datasource.pagopa.postgre.username=${DB_PAGOPA_POSTGRE_USER} -spring.datasource.pagopa.postgre.password=${DB_PAGOPA_POSTGRE_PASSWORD} -#spring.datasource.pagopa.postgre.driver-class-name=org.postgresql.Driver - -spring.datasource.nexi.postgre.enabled=false -spring.datasource.nexi.postgre.url=${DB_NEXI_POSTGRE_URL} -spring.datasource.nexi.postgre.username=${DB_NEXI_POSTGRE_USER} -spring.datasource.nexi.postgre.password=${DB_NEXI_POSTGRE_PASSWORD} -#spring.datasource.nexi.postgre.driver-class-name=org.postgresql.Driver - -spring.datasource.nexi.oracle.enabled=false -spring.datasource.nexi.oracle.url=${DB_NEXI_ORACLE_URL} -spring.datasource.nexi.oracle.username=${DB_NEXI_ORACLE_USER} -spring.datasource.nexi.oracle.password=${DB_NEXI_ORACLE_PASSWORD} -#spring.datasource.nexi.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver - -spring.autoconfigure.exclude= \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..494dd4f --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,107 @@ +info: + application: + description: '@project.description@' + artifactId: '@project.artifactId@' + version: '@project.version@' + name: '@project.name@' + properties: + environment: ${ENV:azure} +cors: + configuration: '${CORS_CONFIGURATION:''{"origins": ["*"], "methods": ["*"]}''}' +server: + port: '8080' + servlet: + context-path: / +management: + endpoints: + web: + exposure: + include: health,info + jmx: + exposure: + include: health,info + info: + env: + enabled: 'true' + health: + readinessState: + enabled: 'true' + livenessState: + enabled: 'true' + endpoint: + health: + probes: + enabled: 'true' +app: + trimCacheColumn: 'true' + identifiers: + pagopa-postgres: ${DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER} + nexi-postgres: ${DB_NEXI_POSTGRE_SERVICE_IDENTIFIER} + nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} + write: + cache: + pagopa-postgres: 'true' + nexi-postgres: 'false' + nexi-oracle: 'false' + standin: + pagopa-postgres: 'true' + nexi-postgres: 'false' + nexi-oracle: 'false' + +spring: + datasource: + pagopa: + postgres: + url: ${DB_PAGOPA_POSTGRES_URL} + username: ${DB_PAGOPA_POSTGRES_USER} + password: ${DB_PAGOPA_POSTGRES_PASSWORD} + enabled: ${DB_PAGOPA_POSTGRES_ENABLED:'false'} + nexi: + oracle: + url: ${DB_NEXI_ORACLE_URL} + username: ${DB_NEXI_ORACLE_USER} + password: ${DB_NEXI_ORACLE_PASSWORD} + enabled: ${DB_NEXI_ORACLE_ENABLED:'false'} + postgres: + url: ${DB_NEXI_POSTGRES_URL} + username: ${DB_NEXI_POSTGRES_USER} + password: ${DB_NEXI_POSTGRES_PASSWORD} + enabled: ${DB_NEXI_POSTGRES_ENABLED:'false'} + jpa: + show-sql: 'false' + +stand-in-manager: + rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} + rx-name: nodo-dei-pagamenti-stand-in + service: + subscriptionKey: ${STAND_IN_MANAGER_SUBSCRIPTION_KEY} + enabled: 'true' + host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 + consumer: + enabled: 'true' + sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING} + consumer-group: $Default + sa-name: synstandinreadevent + +api-config-cache: + sa-name: synccachereadevent + service: + subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} + host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 + enabled: 'true' + rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} + sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING} + consumer: + enabled: 'true' + consumer-group: $Default + rx-name: nodo-dei-pagamenti-cache +springdoc: + writer-with-default-pretty-printer: 'true' + writer-with-order-by-keys: 'true' + +logging: + level: + it: + gov: + pagopa: ${APP_LOGGING_LEVEL:INFO} + root: ${DEFAULT_LOGGING_LEVEL:INFO} \ No newline at end of file From 7742e66d15fef3f29e44eca21cf32ac7d5de0634 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 16 Feb 2024 17:05:11 +0000 Subject: [PATCH 28/88] Bump to version 0.0.0-6-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 9f62e29..e893c30 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.5.0 -appVersion: 0.0.0-5-NOD-690-nodo-cfg-sync-microservizio +version: 0.6.0 +appVersion: 0.0.0-6-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 6e4115d..83312f4 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-5-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-6-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index c8d1116..e7e16df 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-5-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-6-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 652ce82..1bafd70 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-5-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-6-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 4f79051..fd90c6c 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-5-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-6-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 1bfb488..5eac39c 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-5-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-6-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From a1c2520c6ed385a2b8603e6a35937846ca2728dc Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 18:11:53 +0100 Subject: [PATCH 29/88] wip --- helm/values-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 83312f4..54c2454 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -90,7 +90,7 @@ microservice-chart: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' DB_PAGOPA_POSTGRES_PASSWORD: "db-cfg-password" - DB_NEXI_POSTGRES_PASSWORD: "postgresql-db-cfg-password" + DB_NEXI_POSTGRES_PASSWORD: "oracle-db-cfg-password" #TODO mettere secret giusta DB_NEXI_ORACLE_PASSWORD: "oracle-db-cfg-password" API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key" API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key" From a1f213905824196cd060ce4d6a52eeeedd1ce2ec Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 18:16:37 +0100 Subject: [PATCH 30/88] wip --- helm/values-dev.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 54c2454..ec98b26 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -69,11 +69,11 @@ microservice-chart: CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' DB_NEXI_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_NEXI_POSTGRES_USER: "cfg" - DB_NEXI_POSTGRES_ENABLED: "true" + DB_NEXI_POSTGRES_ENABLED: "false" DB_NEXI_POSTGRE_SERVICE_IDENTIFIER: "NDP004DEV" DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))" DB_NEXI_ORACLE_USER: "NODO4_CFG" - DB_NEXI_ORACLE_ENABLED: "true" + DB_NEXI_ORACLE_ENABLED: "false" DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV" DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_PAGOPA_POSTGRES_USER: "cfg" From d0cea383205eb29f45485d701b671413d08b5cf6 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Fri, 16 Feb 2024 18:22:44 +0100 Subject: [PATCH 31/88] NOD-690: optional repo --- .../service/ApiConfigCacheService.java | 44 +++++++++--------- .../service/StandInManagerService.java | 46 +++++++++---------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 73c96a1..4d6b4b4 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -42,8 +42,8 @@ public class ApiConfigCacheService extends CommonCacheService { private final ApiConfigCacheClient apiConfigCacheClient; - @Autowired - private PagoPACachePostgreRepository pagoPACachePostgreRepository; + @Autowired(required = false) + private Optional pagoPACachePostgreRepository; @Autowired(required = false) private Optional nexiCachePostgreRepository; @Autowired(required = false) @@ -98,8 +98,8 @@ public Map forceCacheUpdate() { ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); try { - if( pagopaPostgreCacheEnabled ) { - pagoPACachePostgreRepository.save(configCache); + if( pagopaPostgreCacheEnabled && pagoPACachePostgreRepository.isPresent() ) { + pagoPACachePostgreRepository.get().save(configCache); syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); @@ -107,24 +107,24 @@ public Map forceCacheUpdate() { } catch(Exception ex) { syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error); } -// try { -// if (nexiPostgreCacheEnabled) { -// nexiCachePostgreRepository.save(configCache); -// } else { -// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); -// } -// } catch(Exception ex) { -// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); -// } -// try { -// if( nexiOracleCacheEnabled ) { -// nexiCacheOracleRepository.save(configCache); -// } else { -// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); -// } -// } catch(Exception ex) { -// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); -// } + try { + if ( nexiPostgreCacheEnabled && nexiCachePostgreRepository.isPresent() ) { + nexiCachePostgreRepository.get().save(configCache); + } else { + syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); + } + try { + if( nexiOracleCacheEnabled && nexiCacheOracleRepository.isPresent() ) { + nexiCacheOracleRepository.get().save(configCache); + } else { + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); + } } catch (FeignException.GatewayTimeout e) { log.error("SyncService api-config-cache get cache error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 2acd316..7e014f6 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -87,7 +87,7 @@ public Map forceStandIn() { List stationsEntities = stations.getStations().stream().map(StandInStations::new).collect(Collectors.toList()); try { - if (pagopaPostgreStandInEnabled) { + if ( pagopaPostgreStandInEnabled && pagoPAStandInPostgreRepository.isPresent() ) { pagoPAStandInPostgreRepository.get().deleteAll(); pagoPAStandInPostgreRepository.get().saveAll(stationsEntities); syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); @@ -97,28 +97,28 @@ public Map forceStandIn() { } catch(Exception ex) { syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error); } -// try { -// if (nexiPostgreStandInEnabled) { -// nexiStandInPostgreRepository.deleteAll(); -// nexiStandInPostgreRepository.saveAll(stationsEntities); -// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done); -// } else { -// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); -// } -// } catch(Exception ex) { -// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); -// } -// try { -// if( nexiOracleStandInEnabled ) { -// nexiStandInOracleRepository.deleteAll(); -// nexiStandInOracleRepository.saveAll(stationsEntities); -// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); -// } else { -// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); -// } -// } catch(Exception ex) { -// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); -// } + try { + if ( nexiPostgreStandInEnabled && nexiStandInPostgreRepository.isPresent() ) { + nexiStandInPostgreRepository.get().deleteAll(); + nexiStandInPostgreRepository.get().saveAll(stationsEntities); + syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done); + } else { + syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); + } + try { + if( nexiOracleStandInEnabled && nexiStandInOracleRepository.isPresent() ) { + nexiStandInOracleRepository.get().deleteAll(); + nexiStandInOracleRepository.get().saveAll(stationsEntities); + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); + } else { + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); + } } catch (FeignException.GatewayTimeout e) { log.error("SyncService stand-in-manager get stations error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); From 8c0f43920ba7322fa5d88767c4df43e3f02e040f Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Fri, 16 Feb 2024 18:40:39 +0100 Subject: [PATCH 32/88] wip --- .../repository/configuration/NexiPostgreConfiguration.java | 2 +- .../repository/configuration/PagoPAPostgreConfiguration.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java index 0d171a8..6bf2a75 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java @@ -37,7 +37,7 @@ public DataSourceProperties nexiPostgreDatasourceProperties() { } @Bean - @ConfigurationProperties("spring.datasource.nexi.postgre.configuration") + @ConfigurationProperties("spring.datasource.nexi.postgres.configuration") public DataSource nexiPostgreDataSource() { return nexiPostgreDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java index 1338db2..1a5a690 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java @@ -39,7 +39,7 @@ public DataSourceProperties pagoPAPostgreDatasourceProperties() { @Primary @Bean - @ConfigurationProperties("spring.datasource.pagopa.postgre.configuration") + @ConfigurationProperties("spring.datasource.pagopa.postgrespostgres.configuration") public DataSource pagoPAPostgreDataSource() { return pagoPAPostgreDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); From 7aa97772834046751ab1ed3b45234866a8861318 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 16 Feb 2024 17:42:04 +0000 Subject: [PATCH 33/88] Bump to version 0.0.0-7-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index e893c30..2447328 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.6.0 -appVersion: 0.0.0-6-NOD-690-nodo-cfg-sync-microservizio +version: 0.7.0 +appVersion: 0.0.0-7-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index ec98b26..b98f79b 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-6-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-7-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index e7e16df..5ef0f85 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-6-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-7-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 1bafd70..8b9f9c3 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-6-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-7-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index fd90c6c..633442b 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-6-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-7-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 5eac39c..f061d11 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-6-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-7-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From f3568622e2bd481aa8e3669f4067f9b02e3e9832 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Mon, 19 Feb 2024 08:48:48 +0100 Subject: [PATCH 34/88] wip --- .../repository/configuration/NexiOracleConfiguration.java | 2 +- .../repository/configuration/NexiPostgreConfiguration.java | 2 +- .../repository/configuration/PagoPAPostgreConfiguration.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java index c72f990..b597779 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java @@ -42,7 +42,7 @@ public DataSourceProperties nexiOracleDatasourceProperties() { } @Bean - @ConfigurationProperties("spring.datasource.nexi.oracle.configuration") + @ConfigurationProperties("spring.datasource.nexi.oracle") public DataSource nexiOracleDataSource() { return nexiOracleDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java index 6bf2a75..599b8b8 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java @@ -37,7 +37,7 @@ public DataSourceProperties nexiPostgreDatasourceProperties() { } @Bean - @ConfigurationProperties("spring.datasource.nexi.postgres.configuration") + @ConfigurationProperties("spring.datasource.nexi.postgres") public DataSource nexiPostgreDataSource() { return nexiPostgreDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java index 1a5a690..6fdf6da 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java @@ -39,7 +39,7 @@ public DataSourceProperties pagoPAPostgreDatasourceProperties() { @Primary @Bean - @ConfigurationProperties("spring.datasource.pagopa.postgrespostgres.configuration") + @ConfigurationProperties("spring.datasource.pagopa.postgres") public DataSource pagoPAPostgreDataSource() { return pagoPAPostgreDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); From 7d649c1409492cb6a17498d8124b7d8d69aa1185 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 19 Feb 2024 07:49:55 +0000 Subject: [PATCH 35/88] Bump to version 0.0.0-8-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 2447328..78f39df 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.7.0 -appVersion: 0.0.0-7-NOD-690-nodo-cfg-sync-microservizio +version: 0.8.0 +appVersion: 0.0.0-8-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index b98f79b..45674bb 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-7-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-8-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 5ef0f85..d630e38 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-7-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-8-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 8b9f9c3..3f96b0c 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-7-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-8-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 633442b..38f80d1 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-7-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-8-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index f061d11..40dea87 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-7-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-8-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From a96a1783a5ec4d9b02041a0f2b458e8afc26e03f Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Mon, 19 Feb 2024 09:45:19 +0100 Subject: [PATCH 36/88] NOD-690: change key secret apiconfig-cache, standin-manager --- helm/values-dev.yaml | 4 ++-- helm/values-prod.yaml | 2 ++ helm/values-uat.yaml | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 45674bb..3969135 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -96,8 +96,8 @@ microservice-chart: API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key" STAND_IN_MANAGER_RX_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-rx-connection-string-key" STAND_IN_MANAGER_SA_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-sa-connection-string-key" - API_CONFIG_CACHE_SUBSCRIPTION_KEY: "api-config-cache-subscription-key-string" - STAND_IN_MANAGER_SUBSCRIPTION_KEY: "standin-manager-subscription-key" + API_CONFIG_CACHE_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key" + STAND_IN_MANAGER_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key" OTEL_EXPORTER_OTLP_HEADERS: "elastic-apm-secret-token" keyvault: name: "pagopa-d-nodo-kv" diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index d630e38..ecb02cb 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -80,6 +80,8 @@ microservice-chart: APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string' CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key" OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token + API_CONFIG_CACHE_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key" + STAND_IN_MANAGER_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key" keyvault: name: "pagopa-d-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 3f96b0c..c594223 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -80,6 +80,8 @@ microservice-chart: APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-u-connection-string' CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key" OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token + API_CONFIG_CACHE_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key" + STAND_IN_MANAGER_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key" keyvault: name: "pagopa-d-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" From 169efcb99697ad6bb1011979210edb0a1ad74779 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 19 Feb 2024 09:34:42 +0000 Subject: [PATCH 37/88] Bump to version 0.0.0-9-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 78f39df..c2c1093 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.8.0 -appVersion: 0.0.0-8-NOD-690-nodo-cfg-sync-microservizio +version: 0.9.0 +appVersion: 0.0.0-9-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 3969135..409c3e8 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-8-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index ecb02cb..b067888 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-8-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index c594223..c4f4e5c 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-8-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 38f80d1..1adae00 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-8-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 40dea87..2f195f3 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-8-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-9-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 8d80cc2725476bd72c2bfab8522f336253259c9c Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 20 Feb 2024 09:45:09 +0100 Subject: [PATCH 38/88] NOD-690: change key secret apiconfig-cache, standin-manager --- src/main/resources/application-local.yaml | 18 ++++++++---------- src/main/resources/application.yaml | 17 +++++++---------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index 65e106b..2f99351 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -49,30 +49,28 @@ stand-in-manager: subscriptionKey: ${STAND_IN_MANAGER_SUBSCRIPTION_KEY} enabled: 'true' host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 - consumer: - enabled: 'true' sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING} + sa-name: standinevents consumer-group: $Default - sa-name: synstandinreadevent + consumer: + enabled: 'true' api-config-cache: - sa-name: synccachereadevent + rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} + rx-name: nodo-dei-pagamenti-cache service: subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 enabled: 'true' - rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING} + sa-name: cacheevents + consumer-group: $Default consumer: enabled: 'true' - consumer-group: $Default - rx-name: nodo-dei-pagamenti-cache logging: level: it: gov: pagopa: DEBUG - root: INFO - - + root: INFO \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 494dd4f..2d99883 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -77,27 +77,24 @@ stand-in-manager: subscriptionKey: ${STAND_IN_MANAGER_SUBSCRIPTION_KEY} enabled: 'true' host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 - consumer: - enabled: 'true' sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING} + sa-name: standinevents consumer-group: $Default - sa-name: synstandinreadevent + consumer: + enabled: 'true' api-config-cache: - sa-name: synccachereadevent + rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} + rx-name: nodo-dei-pagamenti-cache service: subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 enabled: 'true' - rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING} + sa-name: cacheevents + consumer-group: $Default consumer: enabled: 'true' - consumer-group: $Default - rx-name: nodo-dei-pagamenti-cache -springdoc: - writer-with-default-pretty-printer: 'true' - writer-with-order-by-keys: 'true' logging: level: From ee833553168655ce768aeb623371239efcfe9dc6 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 08:48:09 +0000 Subject: [PATCH 39/88] Bump to version 0.0.0-10-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index c2c1093..87a34ad 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.9.0 -appVersion: 0.0.0-9-NOD-690-nodo-cfg-sync-microservizio +version: 0.10.0 +appVersion: 0.0.0-10-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 409c3e8..f24807b 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-10-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index b067888..51cbbba 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-10-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index c4f4e5c..b0dfe39 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-10-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 1adae00..a1ff643 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-10-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 2f195f3..c6ae5bf 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-9-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-10-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From c4822c79df339d4b37959a3e6a98a1cd5f914c83 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 20 Feb 2024 10:13:32 +0100 Subject: [PATCH 40/88] NOD-690: update open-api and swagger info --- openapi/openapi.json | 335 +++++++++++------- .../controller/SyncCacheController.java | 9 +- .../cfgsync/model/SyncStatusResponse.java | 13 +- src/main/resources/application-local.yaml | 5 +- src/test/resources/application.properties | 13 - src/test/resources/application.yaml | 104 ++++++ 6 files changed, 333 insertions(+), 146 deletions(-) delete mode 100644 src/test/resources/application.properties create mode 100644 src/test/resources/application.yaml diff --git a/openapi/openapi.json b/openapi/openapi.json index 1adae00..e5eb969 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,174 +1,257 @@ { - "openapi": "3.0.1", - "info": { - "title": "cfg-sync", - "description": "Microservice to update configuration schema of Nodo dei Pagamenti", - "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" + "openapi" : "3.0.1", + "info" : { + "title" : "cfg-sync", + "description" : "Microservice to update configuration schema of Nodo dei Pagamenti", + "termsOfService" : "https://www.pagopa.gov.it/", + "version" : "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/sync/v1/{target}": { - "get": { - "tags": [ - "Cache" - ], - "summary": "Sync target v1 config", - "operationId": "cache", - "parameters": [ - { - "name": "target", - "in": "path", - "required": true, - "schema": { - "type": "string", - "enum": [ - "CONFIG", - "STANDIN" - ] + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "paths" : { + "/ndp/cache" : { + "post" : { + "tags" : [ "Cache" ], + "summary" : "Force cache configuration update", + "operationId" : "cache", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + }, + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/SyncStatusResponse" + } + } + } } - } - ], - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + }, + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": {} + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + } + }, + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } } }, - "400": { - "description": "Bad Request", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } + } + }, + "security" : [ { + "ApiKey" : [ ] + } ] + }, + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" + } + } ] + }, + "/ndp/stand-in" : { + "post" : { + "tags" : [ "StandIn" ], + "summary" : "Force stand-in configuration update", + "operationId" : "standin", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + }, + "content" : { + "application/json" : { } + } }, - "401": { - "description": "Unauthorized", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" + } + } + }, + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "403": { - "description": "Forbidden", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "429": { - "description": "Too many requests", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "500": { - "description": "Service unavailable", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } } }, - "security": [ - { - "ApiKey": [] - } - ] + "security" : [ { + "ApiKey" : [ ] + } ] }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" } - ] + } ] } }, - "components": { - "schemas": { - "ProblemJson": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "components" : { + "schemas" : { + "ProblemJson" : { + "type" : "object", + "properties" : { + "title" : { + "type" : "string", + "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" }, - "status": { - "maximum": 600, - "minimum": 100, - "type": "integer", - "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format": "int32", - "example": 200 + "status" : { + "maximum" : 600, + "minimum" : 100, + "type" : "integer", + "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format" : "int32", + "example" : 200 + }, + "detail" : { + "type" : "string", + "description" : "A human readable explanation specific to this occurrence of the problem.", + "example" : "There was an error processing the request" + } + } + }, + "SyncStatusResponse" : { + "required" : [ "serviceIdentifier", "status" ], + "type" : "object", + "properties" : { + "serviceIdentifier" : { + "type" : "string", + "description" : "Database service identifier", + "example" : "NDP001" }, - "detail": { - "type": "string", - "description": "A human readable explanation specific to this occurrence of the problem.", - "example": "There was an error processing the request" + "status" : { + "type" : "string", + "description" : "Database sync status result", + "example" : "done", + "enum" : [ "done", "disabled", "error" ] } } } }, - "securitySchemes": { - "ApiKey": { - "type": "apiKey", - "description": "The API key to access this function app.", - "name": "Ocp-Apim-Subscription-Key", - "in": "header" + "securitySchemes" : { + "ApiKey" : { + "type" : "apiKey", + "description" : "The API key to access this function app.", + "name" : "Ocp-Apim-Subscription-Key", + "in" : "header" } } } -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java index 2ddd426..1fe8b86 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java @@ -1,6 +1,7 @@ package it.gov.pagopa.node.cfgsync.controller; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -104,9 +105,11 @@ public ResponseEntity> standin() { @ApiResponse( responseCode = "200", description = "OK", - content =@Content( - mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = List.class))), + content = { + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + array = @ArraySchema(schema = @Schema(implementation = SyncStatusResponse.class))) + }), @ApiResponse( responseCode = "400", description = "Bad Request", diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusResponse.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusResponse.java index fdb5a8e..865a421 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusResponse.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusResponse.java @@ -1,6 +1,7 @@ package it.gov.pagopa.node.cfgsync.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import javax.validation.constraints.NotNull; @@ -13,6 +14,14 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class SyncStatusResponse { - @NotNull private String serviceIdentifier; - @NotNull private SyncStatusEnum status; + @NotNull + @Schema( + example = "NDP001", + description = "Database service identifier") + private String serviceIdentifier; + @NotNull + @Schema( + example = "done", + description = "Database sync status result") + private SyncStatusEnum status; } diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index 2f99351..115cd5c 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -42,6 +42,7 @@ spring: jpa: show-sql: 'false' + stand-in-manager: rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-stand-in @@ -53,7 +54,7 @@ stand-in-manager: sa-name: standinevents consumer-group: $Default consumer: - enabled: 'true' + enabled: 'false' api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} @@ -66,7 +67,7 @@ api-config-cache: sa-name: cacheevents consumer-group: $Default consumer: - enabled: 'true' + enabled: 'false' logging: level: diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties deleted file mode 100644 index d088fac..0000000 --- a/src/test/resources/application.properties +++ /dev/null @@ -1,13 +0,0 @@ -# Info -info.application.artifactId=@project.artifactId@ -info.application.name=@project.name@ -info.application.version=@project.version@ -info.application.description=@project.description@ -info.properties.environment=${ENV:test} -# Server -server.servlet.context-path=/ -# logging -logging.level.root=INFO -logging.level.it.gov.pagopa=INFO -# CORS configuration -cors.configuration={"origins": ["*"], "methods": ["*"]} diff --git a/src/test/resources/application.yaml b/src/test/resources/application.yaml new file mode 100644 index 0000000..1721fb7 --- /dev/null +++ b/src/test/resources/application.yaml @@ -0,0 +1,104 @@ +info: + application: + description: '@project.description@' + artifactId: '@project.artifactId@' + version: '@project.version@' + name: '@project.name@' + properties: + environment: ${ENV:test} +cors: + configuration: '${CORS_CONFIGURATION:''{"origins": ["*"], "methods": ["*"]}''}' +server: + port: '8080' + servlet: + context-path: / +management: + endpoints: + web: + exposure: + include: health,info + jmx: + exposure: + include: health,info + info: + env: + enabled: 'true' + health: + readinessState: + enabled: 'true' + livenessState: + enabled: 'true' + endpoint: + health: + probes: + enabled: 'true' +app: + trimCacheColumn: 'true' + identifiers: + pagopa-postgres: 'NDP001' + nexi-postgres: 'NDP004DEV' + nexi-oracle: 'NDP003' + write: + cache: + pagopa-postgres: 'false' + nexi-postgres: 'false' + nexi-oracle: 'false' + standin: + pagopa-postgres: 'false' + nexi-postgres: 'false' + nexi-oracle: 'false' + +spring: + datasource: + pagopa: + postgres: + url: ${DB_PAGOPA_POSTGRES_URL} + username: ${DB_PAGOPA_POSTGRES_USER} + password: ${DB_PAGOPA_POSTGRES_PASSWORD} + enabled: 'false' + nexi: + oracle: + url: ${DB_NEXI_ORACLE_URL} + username: ${DB_NEXI_ORACLE_USER} + password: ${DB_NEXI_ORACLE_PASSWORD} + enabled: 'false' + postgres: + url: ${DB_NEXI_POSTGRES_URL} + username: ${DB_NEXI_POSTGRES_USER} + password: ${DB_NEXI_POSTGRES_PASSWORD} + enabled: 'false' + jpa: + show-sql: 'false' + +stand-in-manager: + rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} + rx-name: nodo-dei-pagamenti-stand-in + service: + subscriptionKey: '' + enabled: 'false' + host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 + sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING} + sa-name: standinevents + consumer-group: $Default + consumer: + enabled: 'false' + +api-config-cache: + rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} + rx-name: nodo-dei-pagamenti-cache + service: + subscriptionKey: '' + host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 + enabled: 'false' + sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING} + sa-name: cacheevents + consumer-group: $Default + consumer: + enabled: 'false' + +logging: + level: + it: + gov: + pagopa: ${APP_LOGGING_LEVEL:INFO} + root: ${DEFAULT_LOGGING_LEVEL:INFO} \ No newline at end of file From 35a409c286cdde0c90f4cfeb7709bc898a5265b3 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 20 Feb 2024 10:19:49 +0100 Subject: [PATCH 41/88] NOD-690: update open-api and swagger info --- helm/values-dev.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index f24807b..785e675 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -47,8 +47,8 @@ microservice-chart: memory: "512Mi" cpu: "0.25" limits: - memory: "512Mi" - cpu: "0.5" + memory: "1G" + cpu: "1.0" autoscaling: enable: true minReplica: 1 From cc3c7a40fe16dc66d56f26d03802ed95ecac005c Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 09:21:09 +0000 Subject: [PATCH 42/88] Bump to version 0.0.0-11-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 +- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 373 ++++++++++++++++++++++-------------------- pom.xml | 2 +- 6 files changed, 203 insertions(+), 182 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 87a34ad..07e3c40 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.10.0 -appVersion: 0.0.0-10-NOD-690-nodo-cfg-sync-microservizio +version: 0.11.0 +appVersion: 0.0.0-11-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 785e675..c76591b 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-10-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-11-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 51cbbba..5c95f7b 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-10-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-11-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index b0dfe39..fff3326 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-10-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-11-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index e5eb969..e7d725f 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,257 +1,278 @@ { - "openapi" : "3.0.1", - "info" : { - "title" : "cfg-sync", - "description" : "Microservice to update configuration schema of Nodo dei Pagamenti", - "termsOfService" : "https://www.pagopa.gov.it/", - "version" : "0.0.0-9-NOD-690-nodo-cfg-sync-microservizio" + "openapi": "3.0.1", + "info": { + "title": "cfg-sync", + "description": "Microservice to update configuration schema of Nodo dei Pagamenti", + "termsOfService": "https://www.pagopa.gov.it/", + "version": "0.0.0-11-NOD-690-nodo-cfg-sync-microservizio" }, - "servers" : [ { - "url" : "http://localhost", - "description" : "Generated server url" - } ], - "paths" : { - "/ndp/cache" : { - "post" : { - "tags" : [ "Cache" ], - "summary" : "Force cache configuration update", - "operationId" : "cache", - "responses" : { - "200" : { - "description" : "OK", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/ndp/cache": { + "post": { + "tags": [ + "Cache" + ], + "summary": "Force cache configuration update", + "operationId": "cache", + "responses": { + "200": { + "description": "OK", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/SyncStatusResponse" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SyncStatusResponse" } } } } }, - "400" : { - "description" : "Bad Request", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "400": { + "description": "Bad Request", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } }, - "401" : { - "description" : "Unauthorized", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "401": { + "description": "Unauthorized", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "429" : { - "description" : "Too many requests", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "429": { + "description": "Too many requests", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "500" : { - "description" : "Service unavailable", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "500": { + "description": "Service unavailable", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } } }, - "security" : [ { - "ApiKey" : [ ] - } ] + "security": [ + { + "ApiKey": [] + } + ] }, - "parameters" : [ { - "name" : "X-Request-Id", - "in" : "header", - "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema" : { - "type" : "string" + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } } - } ] + ] }, - "/ndp/stand-in" : { - "post" : { - "tags" : [ "StandIn" ], - "summary" : "Force stand-in configuration update", - "operationId" : "standin", - "responses" : { - "200" : { - "description" : "OK", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "/ndp/stand-in": { + "post": { + "tags": [ + "StandIn" + ], + "summary": "Force stand-in configuration update", + "operationId": "standin", + "responses": { + "200": { + "description": "OK", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { } + "content": { + "application/json": {} } }, - "400" : { - "description" : "Bad Request", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "400": { + "description": "Bad Request", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } }, - "401" : { - "description" : "Unauthorized", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "401": { + "description": "Unauthorized", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "429" : { - "description" : "Too many requests", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "429": { + "description": "Too many requests", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "500" : { - "description" : "Service unavailable", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "500": { + "description": "Service unavailable", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } } }, - "security" : [ { - "ApiKey" : [ ] - } ] + "security": [ + { + "ApiKey": [] + } + ] }, - "parameters" : [ { - "name" : "X-Request-Id", - "in" : "header", - "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema" : { - "type" : "string" + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } } - } ] + ] } }, - "components" : { - "schemas" : { - "ProblemJson" : { - "type" : "object", - "properties" : { - "title" : { - "type" : "string", - "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "components": { + "schemas": { + "ProblemJson": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" }, - "status" : { - "maximum" : 600, - "minimum" : 100, - "type" : "integer", - "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format" : "int32", - "example" : 200 + "status": { + "maximum": 600, + "minimum": 100, + "type": "integer", + "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format": "int32", + "example": 200 }, - "detail" : { - "type" : "string", - "description" : "A human readable explanation specific to this occurrence of the problem.", - "example" : "There was an error processing the request" + "detail": { + "type": "string", + "description": "A human readable explanation specific to this occurrence of the problem.", + "example": "There was an error processing the request" } } }, - "SyncStatusResponse" : { - "required" : [ "serviceIdentifier", "status" ], - "type" : "object", - "properties" : { - "serviceIdentifier" : { - "type" : "string", - "description" : "Database service identifier", - "example" : "NDP001" + "SyncStatusResponse": { + "required": [ + "serviceIdentifier", + "status" + ], + "type": "object", + "properties": { + "serviceIdentifier": { + "type": "string", + "description": "Database service identifier", + "example": "NDP001" }, - "status" : { - "type" : "string", - "description" : "Database sync status result", - "example" : "done", - "enum" : [ "done", "disabled", "error" ] + "status": { + "type": "string", + "description": "Database sync status result", + "example": "done", + "enum": [ + "done", + "disabled", + "error" + ] } } } }, - "securitySchemes" : { - "ApiKey" : { - "type" : "apiKey", - "description" : "The API key to access this function app.", - "name" : "Ocp-Apim-Subscription-Key", - "in" : "header" + "securitySchemes": { + "ApiKey": { + "type": "apiKey", + "description": "The API key to access this function app.", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" } } } -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index c6ae5bf..c794c51 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-10-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-11-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From ede77ab179d662d9fb17713499315f3c57a27c42 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 09:29:34 +0000 Subject: [PATCH 43/88] Bump to version 0.0.0-12-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 07e3c40..4d3c271 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.11.0 -appVersion: 0.0.0-11-NOD-690-nodo-cfg-sync-microservizio +version: 0.12.0 +appVersion: 0.0.0-12-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index c76591b..d98c3e8 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-11-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-12-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 5c95f7b..ffba0d7 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-11-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-12-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index fff3326..9dce0a8 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-11-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-12-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index e7d725f..7f7f452 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-11-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-12-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index c794c51..d4757e2 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-11-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-12-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 55d6ba403a8ad5bd49d274b36f46520559d6c91d Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 20 Feb 2024 12:09:02 +0100 Subject: [PATCH 44/88] NOD-690: update open-api and swagger info --- helm/values-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 785e675..e863774 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -75,7 +75,7 @@ microservice-chart: DB_NEXI_ORACLE_USER: "NODO4_CFG" DB_NEXI_ORACLE_ENABLED: "false" DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV" - DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_PAGOPA_POSTGRES_USER: "cfg" DB_PAGOPA_POSTGRES_ENABLED: "true" DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER: "NDP001DEV" From ca0504e86a4e3a79f109b8830ef30b490e488a25 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 11:11:32 +0000 Subject: [PATCH 45/88] Bump to version 0.0.0-13-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 4d3c271..743354d 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.12.0 -appVersion: 0.0.0-12-NOD-690-nodo-cfg-sync-microservizio +version: 0.13.0 +appVersion: 0.0.0-13-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 0aee5ee..8989150 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-12-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-13-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index ffba0d7..7677d0a 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-12-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-13-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 9dce0a8..8552112 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-12-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-13-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 7f7f452..11ef30d 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-12-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-13-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index d4757e2..e703e04 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-12-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-13-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 6b5e2b594e189c75d03a28eb0b04647cb143018b Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 11:35:41 +0000 Subject: [PATCH 46/88] Bump to version 0.0.0-14-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 743354d..877a0d1 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.13.0 -appVersion: 0.0.0-13-NOD-690-nodo-cfg-sync-microservizio +version: 0.14.0 +appVersion: 0.0.0-14-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 8989150..bcc5560 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-13-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-14-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 7677d0a..5686baa 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-13-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-14-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 8552112..b62ff52 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-13-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-14-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 11ef30d..6f4dcad 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-13-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-14-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index e703e04..3ba0cc1 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-13-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-14-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From cdba8fa7159a21632fbed65e6a8f2dfe5c10e5bf Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 20 Feb 2024 12:59:57 +0100 Subject: [PATCH 47/88] NOD-690: fix naming --- helm/values-dev.yaml | 4 +-- ...on.java => NexiPostgresConfiguration.java} | 29 ++++++++---------- ....java => PagoPAPostgresConfiguration.java} | 24 +++++++-------- .../NexiCachePostgreRepository.java | 6 ---- .../NexiStandInPostgreRepository.java | 6 ---- .../NexiCachePostgresRepository.java | 6 ++++ .../NexiStandInPostgresRepository.java | 6 ++++ ...ava => PagoPACachePostgresRepository.java} | 2 +- ...a => PagoPAStandInPostgresRepository.java} | 2 +- .../service/ApiConfigCacheService.java | 30 +++++++++---------- .../service/StandInManagerService.java | 8 ++--- src/main/resources/application-local.yaml | 8 ++--- src/main/resources/application.yaml | 6 ++-- 13 files changed, 67 insertions(+), 70 deletions(-) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/{NexiPostgreConfiguration.java => NexiPostgresConfiguration.java} (59%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/{PagoPAPostgreConfiguration.java => PagoPAPostgresConfiguration.java} (66%) delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiStandInPostgreRepository.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/{PagoPACachePostgreRepository.java => PagoPACachePostgresRepository.java} (66%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/{PagoPAStandInPostgreRepository.java => PagoPAStandInPostgresRepository.java} (65%) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 0aee5ee..c3e437c 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -70,7 +70,7 @@ microservice-chart: DB_NEXI_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_NEXI_POSTGRES_USER: "cfg" DB_NEXI_POSTGRES_ENABLED: "false" - DB_NEXI_POSTGRE_SERVICE_IDENTIFIER: "NDP004DEV" + DB_NEXI_POSTGRES_SERVICE_IDENTIFIER: "NDP004DEV" DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))" DB_NEXI_ORACLE_USER: "NODO4_CFG" DB_NEXI_ORACLE_ENABLED: "false" @@ -78,7 +78,7 @@ microservice-chart: DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_PAGOPA_POSTGRES_USER: "cfg" DB_PAGOPA_POSTGRES_ENABLED: "true" - DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER: "NDP001DEV" + DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER: "NDP001DEV" OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgresConfiguration.java similarity index 59% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgresConfiguration.java index 599b8b8..3c40b8f 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgresConfiguration.java @@ -7,7 +7,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; @@ -17,44 +18,40 @@ import javax.sql.DataSource; @Configuration -//@PropertySources({ -// @PropertySource("classpath:/application.properties"), -// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -//}) @EnableTransactionManagement @EnableJpaRepositories( basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgres", - entityManagerFactoryRef = "nexiCachePostgreEntityManagerFactory", - transactionManagerRef = "nexiCachePostgreTransactionManager" + entityManagerFactoryRef = "nexiCachePostgresEntityManagerFactory", + transactionManagerRef = "nexiCachePostgresTransactionManager" ) @ConditionalOnProperty(prefix = "spring.datasource.nexi.postgres", name = "enabled") -public class NexiPostgreConfiguration { +public class NexiPostgresConfiguration { @Bean @ConfigurationProperties("spring.datasource.nexi.postgres") - public DataSourceProperties nexiPostgreDatasourceProperties() { + public DataSourceProperties nexiPostgresDatasourceProperties() { return new DataSourceProperties(); } @Bean @ConfigurationProperties("spring.datasource.nexi.postgres") - public DataSource nexiPostgreDataSource() { - return nexiPostgreDatasourceProperties().initializeDataSourceBuilder() + public DataSource nexiPostgresDataSource() { + return nexiPostgresDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); } - @Bean(name = "nexiPostgreEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean nexiPostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { + @Bean(name = "nexiPostgresEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean nexiPostgresEntityManagerFactory(EntityManagerFactoryBuilder builder) { return builder - .dataSource(nexiPostgreDataSource()) + .dataSource(nexiPostgresDataSource()) .packages(ConfigCache.class) .build(); } @Bean public PlatformTransactionManager nexiPostgreTransactionManager( - final @Qualifier("nexiPostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiPostgreEntityManagerFactory) { - return new JpaTransactionManager(nexiPostgreEntityManagerFactory.getObject()); + final @Qualifier("nexiPostgresEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiPostgresEntityManagerFactory) { + return new JpaTransactionManager(nexiPostgresEntityManagerFactory.getObject()); } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgresConfiguration.java similarity index 66% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgresConfiguration.java index 6fdf6da..8ca50d4 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgreConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgresConfiguration.java @@ -24,41 +24,41 @@ @EnableTransactionManagement @EnableJpaRepositories( basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", - entityManagerFactoryRef = "pagoPAPostgreEntityManagerFactory", - transactionManagerRef = "pagoPAPostgreTransactionManager" + entityManagerFactoryRef = "pagoPAPostgresEntityManagerFactory", + transactionManagerRef = "pagoPAPostgresTransactionManager" ) @ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgres", name = "enabled") -public class PagoPAPostgreConfiguration { +public class PagoPAPostgresConfiguration { @Primary @Bean @ConfigurationProperties("spring.datasource.pagopa.postgres") - public DataSourceProperties pagoPAPostgreDatasourceProperties() { + public DataSourceProperties pagoPAPostgresDatasourceProperties() { return new DataSourceProperties(); } @Primary @Bean @ConfigurationProperties("spring.datasource.pagopa.postgres") - public DataSource pagoPAPostgreDataSource() { - return pagoPAPostgreDatasourceProperties().initializeDataSourceBuilder() + public DataSource pagoPAPostgresDataSource() { + return pagoPAPostgresDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); } @Primary - @Bean(name = "pagoPAPostgreEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean pagoPAPostgreEntityManagerFactory(EntityManagerFactoryBuilder builder) { + @Bean(name = "pagoPAPostgresEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean pagoPAPostgresEntityManagerFactory(EntityManagerFactoryBuilder builder) { return builder - .dataSource(pagoPAPostgreDataSource()) + .dataSource(pagoPAPostgresDataSource()) .packages(ConfigCache.class) .build(); } @Primary @Bean - public PlatformTransactionManager pagoPAPostgreTransactionManager( - final @Qualifier("pagoPAPostgreEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagoPAPostgreEntityManagerFactory) { - return new JpaTransactionManager(pagoPAPostgreEntityManagerFactory.getObject()); + public PlatformTransactionManager pagoPAPostgresTransactionManager( + final @Qualifier("pagoPAPostgresEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagoPAPostgresEntityManagerFactory) { + return new JpaTransactionManager(pagoPAPostgresEntityManagerFactory.getObject()); } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java deleted file mode 100644 index 7bb6e79..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiCachePostgreRepository.java +++ /dev/null @@ -1,6 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.nexipostgre; - -import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface NexiCachePostgreRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiStandInPostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiStandInPostgreRepository.java deleted file mode 100644 index 0086d72..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgre/NexiStandInPostgreRepository.java +++ /dev/null @@ -1,6 +0,0 @@ -package it.gov.pagopa.node.cfgsync.repository.nexipostgre; - -import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface NexiStandInPostgreRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java new file mode 100644 index 0000000..5d4a118 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java @@ -0,0 +1,6 @@ +package it.gov.pagopa.node.cfgsync.repository.nexipostgres; + +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface NexiCachePostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java new file mode 100644 index 0000000..d4d87f6 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java @@ -0,0 +1,6 @@ +package it.gov.pagopa.node.cfgsync.repository.nexipostgres; + +import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface NexiStandInPostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java similarity index 66% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java index b3cb058..a3f7ccd 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgreRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java @@ -3,4 +3,4 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; -public interface PagoPACachePostgreRepository extends JpaRepository { } \ No newline at end of file +public interface PagoPACachePostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgreRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java similarity index 65% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgreRepository.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java index f984f19..361ae47 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgreRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java @@ -3,4 +3,4 @@ import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import org.springframework.data.jpa.repository.JpaRepository; -public interface PagoPAStandInPostgreRepository extends JpaRepository { } \ No newline at end of file +public interface PagoPAStandInPostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 4d6b4b4..b60ee9c 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -10,8 +10,8 @@ import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiCacheOracleRepository; -import it.gov.pagopa.node.cfgsync.repository.nexipostgre.NexiCachePostgreRepository; -import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgreRepository; +import it.gov.pagopa.node.cfgsync.repository.nexipostgres.NexiCachePostgresRepository; +import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgresRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -43,21 +43,21 @@ public class ApiConfigCacheService extends CommonCacheService { private final ApiConfigCacheClient apiConfigCacheClient; @Autowired(required = false) - private Optional pagoPACachePostgreRepository; + private Optional pagoPACachePostgreRepository; @Autowired(required = false) - private Optional nexiCachePostgreRepository; + private Optional nexiCachePostgreRepository; @Autowired(required = false) private Optional nexiCacheOracleRepository; @Value("${app.write.cache.pagopa-postgres}") - private Boolean pagopaPostgreCacheEnabled; + private Boolean pagopaPostgresCacheEnabled; @Value("${app.identifiers.pagopa-postgres}") - private String pagopaPostgreServiceIdentifier; + private String pagopaPostgresServiceIdentifier; @Value("${app.write.cache.nexi-postgres}") - private Boolean nexiPostgreCacheEnabled; + private Boolean nexiPostgresCacheEnabled; @Value("${app.identifiers.nexi-postgres}") - private String nexiPostgreServiceIdentifier; + private String nexiPostgresServiceIdentifier; @Value("${app.write.cache.nexi-oracle}") private Boolean nexiOracleCacheEnabled; @@ -98,23 +98,23 @@ public Map forceCacheUpdate() { ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); try { - if( pagopaPostgreCacheEnabled && pagoPACachePostgreRepository.isPresent() ) { + if( pagopaPostgresCacheEnabled && pagoPACachePostgreRepository.isPresent() ) { pagoPACachePostgreRepository.get().save(configCache); - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); } else { - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.disabled); } } catch(Exception ex) { - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error); + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.error); } try { - if ( nexiPostgreCacheEnabled && nexiCachePostgreRepository.isPresent() ) { + if ( nexiPostgresCacheEnabled && nexiCachePostgreRepository.isPresent() ) { nexiCachePostgreRepository.get().save(configCache); } else { - syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); + syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.disabled); } } catch(Exception ex) { - syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); + syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.error); } try { if( nexiOracleCacheEnabled && nexiCacheOracleRepository.isPresent() ) { diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 7e014f6..05b02ef 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -12,8 +12,8 @@ import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiStandInOracleRepository; -import it.gov.pagopa.node.cfgsync.repository.nexipostgre.NexiStandInPostgreRepository; -import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgreRepository; +import it.gov.pagopa.node.cfgsync.repository.nexipostgres.NexiStandInPostgresRepository; +import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgresRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -40,9 +40,9 @@ public class StandInManagerService extends CommonCacheService { private final ObjectMapper objectMapper; @Autowired(required = false) - private Optional pagoPAStandInPostgreRepository; + private Optional pagoPAStandInPostgreRepository; @Autowired(required = false) - private Optional nexiStandInPostgreRepository; + private Optional nexiStandInPostgreRepository; @Autowired(required = false) private Optional nexiStandInOracleRepository; diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index 115cd5c..5376bc0 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -7,8 +7,8 @@ cors: app: trimCacheColumn: 'true' identifiers: - pagopa-postgres: ${DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER} - nexi-postgres: ${DB_NEXI_POSTGRE_SERVICE_IDENTIFIER} + pagopa-postgres: ${DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER} + nexi-postgres: ${DB_NEXI_POSTGRES_SERVICE_IDENTIFIER} nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} write: cache: @@ -26,7 +26,7 @@ spring: postgres: url: jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg username: cfg - password: ${DB_PAGOPA_POSTGRE_PASSWORD} + password: ${DB_PAGOPA_POSTGRES_PASSWORD} enabled: 'true' nexi: oracle: @@ -37,7 +37,7 @@ spring: postgres: url: jdbc:postgresql://localhost:5432/nodo?currentSchema=public username: cfg - password: ${DB_NEXI_POSTGRE_PASSWORD} + password: ${DB_NEXI_POSTGRES_PASSWORD} enabled: 'false' jpa: show-sql: 'false' diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 2d99883..29f411a 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -35,9 +35,9 @@ management: app: trimCacheColumn: 'true' identifiers: - pagopa-postgres: ${DB_PAGOPA_POSTGRE_SERVICE_IDENTIFIER} - nexi-postgres: ${DB_NEXI_POSTGRE_SERVICE_IDENTIFIER} - nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} + pagopa-postgres: ${DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER} + nexi-postgres: ${DB_NEXI_POSTGRES_SERVICE_IDENTIFIER} + nexi-oracle: ${DB_NEXI_ORACLES_SERVICE_IDENTIFIER} write: cache: pagopa-postgres: 'true' From a9ece97b4be802a05e601144f2707809cbbf0c92 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 13:07:10 +0000 Subject: [PATCH 48/88] Bump to version 0.0.0-15-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 877a0d1..0f815f1 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.14.0 -appVersion: 0.0.0-14-NOD-690-nodo-cfg-sync-microservizio +version: 0.15.0 +appVersion: 0.0.0-15-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 3b6b5a2..5cebfb8 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-14-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-15-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 5686baa..5947fec 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-14-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-15-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index b62ff52..06bc9c2 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-14-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-15-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 6f4dcad..8ab72b4 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-14-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-15-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 3ba0cc1..e58348f 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-14-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-15-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 9e55b02f95987edf90d4fd310b299ca0738884b1 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 13:22:06 +0000 Subject: [PATCH 49/88] Bump to version 0.0.0-16-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 0f815f1..4703a90 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.15.0 -appVersion: 0.0.0-15-NOD-690-nodo-cfg-sync-microservizio +version: 0.16.0 +appVersion: 0.0.0-16-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 5cebfb8..e5f9866 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-15-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-16-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 5947fec..8a6c47f 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-15-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-16-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 06bc9c2..26a06f7 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-15-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-16-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 8ab72b4..91f6554 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-15-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-16-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index e58348f..1fde56f 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-15-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-16-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 8bdb9e0a8b266f68fed34bebcc73fb2c49252216 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 20 Feb 2024 15:22:34 +0100 Subject: [PATCH 50/88] NOD-690: fix naming --- src/main/resources/application-local.yaml | 1 - src/main/resources/application.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index 5376bc0..eb4f0d5 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -42,7 +42,6 @@ spring: jpa: show-sql: 'false' - stand-in-manager: rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-stand-in diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 29f411a..601b001 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -37,7 +37,7 @@ app: identifiers: pagopa-postgres: ${DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER} nexi-postgres: ${DB_NEXI_POSTGRES_SERVICE_IDENTIFIER} - nexi-oracle: ${DB_NEXI_ORACLES_SERVICE_IDENTIFIER} + nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} write: cache: pagopa-postgres: 'true' From 0d7a0c016fc6e2422c671f1d911739a93be319ec Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 14:24:02 +0000 Subject: [PATCH 51/88] Bump to version 0.0.0-17-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 4703a90..5d2d00c 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.16.0 -appVersion: 0.0.0-16-NOD-690-nodo-cfg-sync-microservizio +version: 0.17.0 +appVersion: 0.0.0-17-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index e5f9866..0e161c9 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-16-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-17-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 8a6c47f..d6f7933 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-16-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-17-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 26a06f7..6e61c15 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-16-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-17-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 91f6554..c8909de 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-16-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-17-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 1fde56f..096eeec 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-16-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-17-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From eac0e51efcbf3860074ea2e55d65c2e5886c9afe Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 20 Feb 2024 17:22:12 +0100 Subject: [PATCH 52/88] NOD-690: fix naming --- helm/values-dev.yaml | 2 +- .../service/ApiConfigCacheService.java | 87 +++++++++------ .../service/StandInManagerService.java | 100 ++++++++++-------- 3 files changed, 111 insertions(+), 78 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index e5f9866..4c3e809 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -90,7 +90,7 @@ microservice-chart: # required APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' DB_PAGOPA_POSTGRES_PASSWORD: "db-cfg-password" - DB_NEXI_POSTGRES_PASSWORD: "oracle-db-cfg-password" #TODO mettere secret giusta + DB_NEXI_POSTGRES_PASSWORD: "db-nexi-cfg-password" DB_NEXI_ORACLE_PASSWORD: "oracle-db-cfg-password" API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key" API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key" diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index b60ee9c..d65a5cc 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -43,24 +43,24 @@ public class ApiConfigCacheService extends CommonCacheService { private final ApiConfigCacheClient apiConfigCacheClient; @Autowired(required = false) - private Optional pagoPACachePostgreRepository; + private Optional pagoPAPostgresRepository; @Autowired(required = false) - private Optional nexiCachePostgreRepository; + private Optional nexiPostgresRepository; @Autowired(required = false) - private Optional nexiCacheOracleRepository; + private Optional nexiOracleRepository; @Value("${app.write.cache.pagopa-postgres}") - private Boolean pagopaPostgresCacheEnabled; + private Boolean pagopaPostgresEnabled; @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgresServiceIdentifier; @Value("${app.write.cache.nexi-postgres}") - private Boolean nexiPostgresCacheEnabled; + private Boolean nexiPostgresEnabled; @Value("${app.identifiers.nexi-postgres}") private String nexiPostgresServiceIdentifier; @Value("${app.write.cache.nexi-oracle}") - private Boolean nexiOracleCacheEnabled; + private Boolean nexiOracleEnabled; @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; @@ -68,7 +68,6 @@ public ApiConfigCacheService(@Value("${api-config-cache.service.host}") String a apiConfigCacheClient = Feign.builder().target(ApiConfigCacheClient.class, apiConfigCacheUrl); } - @Transactional public Map forceCacheUpdate() { Map syncStatusMap = new HashMap<>(); try { @@ -97,34 +96,9 @@ public Map forceCacheUpdate() { ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); - try { - if( pagopaPostgresCacheEnabled && pagoPACachePostgreRepository.isPresent() ) { - pagoPACachePostgreRepository.get().save(configCache); - syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); - } else { - syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.disabled); - } - } catch(Exception ex) { - syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.error); - } - try { - if ( nexiPostgresCacheEnabled && nexiCachePostgreRepository.isPresent() ) { - nexiCachePostgreRepository.get().save(configCache); - } else { - syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.disabled); - } - } catch(Exception ex) { - syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.error); - } - try { - if( nexiOracleCacheEnabled && nexiCacheOracleRepository.isPresent() ) { - nexiCacheOracleRepository.get().save(configCache); - } else { - syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); - } - } catch(Exception ex) { - syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); - } + savePagoPA(syncStatusMap, configCache); + saveNexiPostgres(syncStatusMap, configCache); + saveNexiOracle(syncStatusMap, configCache); } catch (FeignException.GatewayTimeout e) { log.error("SyncService api-config-cache get cache error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); @@ -137,4 +111,47 @@ public Map forceCacheUpdate() { } return syncStatusMap; } + + @Transactional + private void savePagoPA(Map syncStatusMap, ConfigCache configCache) { + try { + if( pagopaPostgresEnabled && pagoPAPostgresRepository.isPresent() ) { + pagoPAPostgresRepository.get().save(configCache); + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); + } else { + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + log.error("SyncService api-config-cache save pagoPA error: {}", ex.getMessage(), ex); + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.error); + } + } + + @Transactional + private void saveNexiOracle(Map syncStatusMap, ConfigCache configCache) { + try { + if( nexiOracleEnabled && nexiOracleRepository.isPresent() ) { + nexiOracleRepository.get().save(configCache); + } else { + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + log.error("SyncService api-config-cache save Nexi Oracle error: {}", ex.getMessage(), ex); + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); + } + } + + @Transactional + private void saveNexiPostgres(Map syncStatusMap, ConfigCache configCache) { + try { + if ( nexiPostgresEnabled && nexiPostgresRepository.isPresent() ) { + nexiPostgresRepository.get().save(configCache); + } else { + syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + log.error("SyncService api-config-cache save Nexi Postgres error: {}", ex.getMessage(), ex); + syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.error); + } + } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 05b02ef..50753d2 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; @Service @Slf4j @@ -40,24 +39,24 @@ public class StandInManagerService extends CommonCacheService { private final ObjectMapper objectMapper; @Autowired(required = false) - private Optional pagoPAStandInPostgreRepository; + private Optional pagoPAPostgreRepository; @Autowired(required = false) - private Optional nexiStandInPostgreRepository; + private Optional nexiPostgreRepository; @Autowired(required = false) - private Optional nexiStandInOracleRepository; + private Optional nexiOracleRepository; @Value("${app.write.standin.pagopa-postgres}") - private Boolean pagopaPostgreStandInEnabled; + private Boolean pagopaPostgreEnabled; @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgreServiceIdentifier; @Value("${app.write.standin.nexi-postgres}") - private Boolean nexiPostgreStandInEnabled; + private Boolean nexiPostgreEnabled; @Value("${app.identifiers.nexi-postgres}") private String nexiPostgreServiceIdentifier; @Value("${app.write.standin.nexi-oracle}") - private Boolean nexiOracleStandInEnabled; + private Boolean nexiOracleEnabled; @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; @@ -66,7 +65,6 @@ public StandInManagerService(@Value("${stand-in-manager.service.host}") String s this.objectMapper = objectMapper; } - @Transactional public Map forceStandIn() { Map syncStatusMap = new HashMap<>(); try { @@ -84,41 +82,11 @@ public Map forceStandIn() { StationsResponse stations = objectMapper.readValue(response.body().asInputStream().readAllBytes(), StationsResponse.class); log.info("SyncService {} stations found", stations.getStations().size()); - List stationsEntities = stations.getStations().stream().map(StandInStations::new).collect(Collectors.toList()); + List stationsEntities = stations.getStations().stream().map(StandInStations::new).toList(); - try { - if ( pagopaPostgreStandInEnabled && pagoPAStandInPostgreRepository.isPresent() ) { - pagoPAStandInPostgreRepository.get().deleteAll(); - pagoPAStandInPostgreRepository.get().saveAll(stationsEntities); - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); - } else { - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); - } - } catch(Exception ex) { - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error); - } - try { - if ( nexiPostgreStandInEnabled && nexiStandInPostgreRepository.isPresent() ) { - nexiStandInPostgreRepository.get().deleteAll(); - nexiStandInPostgreRepository.get().saveAll(stationsEntities); - syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done); - } else { - syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); - } - } catch(Exception ex) { - syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); - } - try { - if( nexiOracleStandInEnabled && nexiStandInOracleRepository.isPresent() ) { - nexiStandInOracleRepository.get().deleteAll(); - nexiStandInOracleRepository.get().saveAll(stationsEntities); - syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); - } else { - syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); - } - } catch(Exception ex) { - syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); - } + savePagoPA(syncStatusMap, stationsEntities); + saveNexiPostgres(syncStatusMap, stationsEntities); + saveNexiOracle(syncStatusMap, stationsEntities); } catch (FeignException.GatewayTimeout e) { log.error("SyncService stand-in-manager get stations error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); @@ -128,4 +96,52 @@ public Map forceStandIn() { } return syncStatusMap; } + + @Transactional + private void savePagoPA(Map syncStatusMap, List stationsEntities) { + try { + if ( pagopaPostgreEnabled && pagoPAPostgreRepository.isPresent() ) { + pagoPAPostgreRepository.get().deleteAll(); + pagoPAPostgreRepository.get().saveAll(stationsEntities); + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); + } else { + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + log.error("SyncService stand-in-manager save PagoPA error: {}", ex.getMessage(), ex); + syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error); + } + } + + @Transactional + private void saveNexiOracle(Map syncStatusMap, List stationsEntities) { + try { + if( nexiOracleEnabled && nexiOracleRepository.isPresent() ) { + nexiOracleRepository.get().deleteAll(); + nexiOracleRepository.get().saveAll(stationsEntities); + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); + } else { + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + log.error("SyncService stand-in-manager save Nexi Oracle error: {}", ex.getMessage(), ex); + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error); + } + } + + @Transactional + private void saveNexiPostgres(Map syncStatusMap, List stationsEntities) { + try { + if ( nexiPostgreEnabled && nexiPostgreRepository.isPresent() ) { + nexiPostgreRepository.get().deleteAll(); + nexiPostgreRepository.get().saveAll(stationsEntities); + syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done); + } else { + syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); + } + } catch(Exception ex) { + log.error("SyncService stand-in-manager save Nexi Postgres error: {}", ex.getMessage(), ex); + syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); + } + } } From d3d83b9ed8c4cc017863cfbc9163f0e9684340b7 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 20 Feb 2024 16:57:04 +0000 Subject: [PATCH 53/88] Bump to version 0.0.0-18-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 5d2d00c..bf5c026 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.17.0 -appVersion: 0.0.0-17-NOD-690-nodo-cfg-sync-microservizio +version: 0.18.0 +appVersion: 0.0.0-18-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 4b4301c..f32b354 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-17-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-18-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index d6f7933..7ba478e 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-17-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-18-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 6e61c15..9efc8ee 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-17-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-18-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index c8909de..a3323e9 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-17-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-18-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 096eeec..838ca1c 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-17-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-18-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From f50153e031ce688dbc9f5faf2f1f97211d01b430 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Wed, 21 Feb 2024 12:37:28 +0100 Subject: [PATCH 54/88] NOD-690: fix exception and rollback --- .../exception/SyncDbStatusException.java | 9 ++++ .../node/cfgsync/model/SyncStatusEnum.java | 1 + .../NexiOracleConfig.java} | 8 +-- .../NexiPostgresConfig.java} | 12 ++--- .../PagoPAPostgresConfig.java} | 36 ++++++------- .../cfgsync/repository/model/ConfigCache.java | 18 ++++--- .../service/ApiConfigCacheService.java | 54 +++++++++++++------ .../cfgsync/service/CommonCacheService.java | 4 +- .../service/StandInManagerService.java | 18 +++---- src/main/resources/application-local.yaml | 6 +-- src/main/resources/application.yaml | 13 ++++- 11 files changed, 108 insertions(+), 71 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/exception/SyncDbStatusException.java rename src/main/java/it/gov/pagopa/node/cfgsync/repository/{configuration/NexiOracleConfiguration.java => config/NexiOracleConfig.java} (90%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/{configuration/NexiPostgresConfiguration.java => config/NexiPostgresConfig.java} (86%) rename src/main/java/it/gov/pagopa/node/cfgsync/repository/{configuration/PagoPAPostgresConfiguration.java => config/PagoPAPostgresConfig.java} (59%) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/exception/SyncDbStatusException.java b/src/main/java/it/gov/pagopa/node/cfgsync/exception/SyncDbStatusException.java new file mode 100644 index 0000000..d08c657 --- /dev/null +++ b/src/main/java/it/gov/pagopa/node/cfgsync/exception/SyncDbStatusException.java @@ -0,0 +1,9 @@ +package it.gov.pagopa.node.cfgsync.exception; + +public class SyncDbStatusException extends Exception{ + + public SyncDbStatusException(String errorMessage) { + super(errorMessage); + } + +} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusEnum.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusEnum.java index c9e548d..eb69000 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusEnum.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatusEnum.java @@ -4,5 +4,6 @@ public enum SyncStatusEnum { done, disabled, + rollback, error; } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NexiOracleConfig.java similarity index 90% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NexiOracleConfig.java index b597779..495af15 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiOracleConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NexiOracleConfig.java @@ -19,10 +19,6 @@ import javax.sql.DataSource; @Configuration -//@PropertySources({ -// @PropertySource("classpath:/application.properties"), -// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -//}) @EnableTransactionManagement @EnableJpaRepositories( basePackages = "it.gov.pagopa.node.cfgsync.repository.nexioracle", @@ -30,7 +26,7 @@ transactionManagerRef = "nexiOracleTransactionManager" ) @ConditionalOnProperty(prefix = "spring.datasource.nexi.oracle", name = "enabled") -public class NexiOracleConfiguration { +public class NexiOracleConfig { @Autowired private Environment env; @@ -56,7 +52,7 @@ public LocalContainerEntityManagerFactoryBean nexiOracleEntityManagerFactory(Ent .build(); } - @Bean + @Bean(name = "nexiOracleTransactionManager") public PlatformTransactionManager nexiOracleTransactionManager( final @Qualifier("nexiOracleEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiOracleEntityManagerFactory) { return new JpaTransactionManager(nexiOracleEntityManagerFactory.getObject()); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgresConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NexiPostgresConfig.java similarity index 86% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgresConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NexiPostgresConfig.java index 3c40b8f..aab377e 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/NexiPostgresConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NexiPostgresConfig.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.configuration; +package it.gov.pagopa.node.cfgsync.repository.config; import com.zaxxer.hikari.HikariDataSource; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; @@ -21,11 +21,11 @@ @EnableTransactionManagement @EnableJpaRepositories( basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgres", - entityManagerFactoryRef = "nexiCachePostgresEntityManagerFactory", - transactionManagerRef = "nexiCachePostgresTransactionManager" + entityManagerFactoryRef = "nexiPostgresEntityManagerFactory", + transactionManagerRef = "nexiPostgresTransactionManager" ) @ConditionalOnProperty(prefix = "spring.datasource.nexi.postgres", name = "enabled") -public class NexiPostgresConfiguration { +public class NexiPostgresConfig { @Bean @ConfigurationProperties("spring.datasource.nexi.postgres") @@ -48,8 +48,8 @@ public LocalContainerEntityManagerFactoryBean nexiPostgresEntityManagerFactory(E .build(); } - @Bean - public PlatformTransactionManager nexiPostgreTransactionManager( + @Bean(name = "nexiPostgresTransactionManager") + public PlatformTransactionManager nexiPostgresTransactionManager( final @Qualifier("nexiPostgresEntityManagerFactory") LocalContainerEntityManagerFactoryBean nexiPostgresEntityManagerFactory) { return new JpaTransactionManager(nexiPostgresEntityManagerFactory.getObject()); } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgresConfiguration.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/PagoPAPostgresConfig.java similarity index 59% rename from src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgresConfiguration.java rename to src/main/java/it/gov/pagopa/node/cfgsync/repository/config/PagoPAPostgresConfig.java index 8ca50d4..04b6753 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/configuration/PagoPAPostgresConfiguration.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/config/PagoPAPostgresConfig.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.node.cfgsync.repository.configuration; +package it.gov.pagopa.node.cfgsync.repository.config; import com.zaxxer.hikari.HikariDataSource; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; @@ -7,7 +7,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; @@ -17,48 +19,44 @@ import javax.sql.DataSource; @Configuration -//@PropertySources({ -// @PropertySource("classpath:/application.properties"), -// @PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) -//}) @EnableTransactionManagement @EnableJpaRepositories( basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa", - entityManagerFactoryRef = "pagoPAPostgresEntityManagerFactory", - transactionManagerRef = "pagoPAPostgresTransactionManager" + entityManagerFactoryRef = "pagopaPostgresEntityManagerFactory", + transactionManagerRef = "pagopaPostgresTransactionManager" ) @ConditionalOnProperty(prefix = "spring.datasource.pagopa.postgres", name = "enabled") -public class PagoPAPostgresConfiguration { +public class PagoPAPostgresConfig { @Primary @Bean @ConfigurationProperties("spring.datasource.pagopa.postgres") - public DataSourceProperties pagoPAPostgresDatasourceProperties() { + public DataSourceProperties pagopaPostgresDatasourceProperties() { return new DataSourceProperties(); } @Primary @Bean @ConfigurationProperties("spring.datasource.pagopa.postgres") - public DataSource pagoPAPostgresDataSource() { - return pagoPAPostgresDatasourceProperties().initializeDataSourceBuilder() + public DataSource pagopaPostgresDataSource() { + return pagopaPostgresDatasourceProperties().initializeDataSourceBuilder() .type(HikariDataSource.class).build(); } @Primary - @Bean(name = "pagoPAPostgresEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean pagoPAPostgresEntityManagerFactory(EntityManagerFactoryBuilder builder) { + @Bean(name = "pagopaPostgresEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean pagopaPostgresEntityManagerFactory(EntityManagerFactoryBuilder builder) { return builder - .dataSource(pagoPAPostgresDataSource()) + .dataSource(pagopaPostgresDataSource()) .packages(ConfigCache.class) .build(); } @Primary - @Bean - public PlatformTransactionManager pagoPAPostgresTransactionManager( - final @Qualifier("pagoPAPostgresEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagoPAPostgresEntityManagerFactory) { - return new JpaTransactionManager(pagoPAPostgresEntityManagerFactory.getObject()); + @Bean(name = "pagopaPostgresTransactionManager") + public PlatformTransactionManager pagopaPostgresTransactionManager( + final @Qualifier("pagopaPostgresEntityManagerFactory") LocalContainerEntityManagerFactoryBean pagopaPostgresEntityManagerFactory) { + return new JpaTransactionManager(pagopaPostgresEntityManagerFactory.getObject()); } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/ConfigCache.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/ConfigCache.java index f4f2c5f..6fa493e 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/ConfigCache.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/ConfigCache.java @@ -3,26 +3,30 @@ import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; -import javax.persistence.*; -import java.io.Serializable; -import java.time.LocalDateTime; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.time.ZonedDateTime; @NoArgsConstructor @AllArgsConstructor @Entity @Table(name = "cache") -public class ConfigCache implements Serializable { +public class ConfigCache { @Id - @Column(name="ID", columnDefinition = "VARCHAR", length = 20) + @Column(name="ID", nullable = false, columnDefinition = "VARCHAR", length = 20) private String id; - private LocalDateTime time; + @Column(name = "TIME", nullable = false) + private ZonedDateTime time; + @Column(name = "CACHE", nullable = false) private byte[] cache; - @Column(name="VERSION", columnDefinition = "VARCHAR", length = 32) + @Column(name="VERSION", nullable = false, columnDefinition = "VARCHAR", length = 32) private String version; } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index d65a5cc..1a4a563 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -6,6 +6,7 @@ import it.gov.pagopa.node.cfgsync.client.ApiConfigCacheClient; import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; +import it.gov.pagopa.node.cfgsync.exception.SyncDbStatusException; import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; @@ -16,8 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import java.io.IOException; import java.time.Instant; @@ -27,7 +29,7 @@ import java.util.Map; import java.util.Optional; -@Service +@Component @Slf4j public class ApiConfigCacheService extends CommonCacheService { @@ -43,24 +45,24 @@ public class ApiConfigCacheService extends CommonCacheService { private final ApiConfigCacheClient apiConfigCacheClient; @Autowired(required = false) - private Optional pagoPAPostgresRepository; + private Optional pagopaPostgresRepository; @Autowired(required = false) private Optional nexiPostgresRepository; @Autowired(required = false) private Optional nexiOracleRepository; @Value("${app.write.cache.pagopa-postgres}") - private Boolean pagopaPostgresEnabled; + private Boolean pagopaPostgresWrite; @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgresServiceIdentifier; @Value("${app.write.cache.nexi-postgres}") - private Boolean nexiPostgresEnabled; + private Boolean nexiPostgresWrite; @Value("${app.identifiers.nexi-postgres}") private String nexiPostgresServiceIdentifier; @Value("${app.write.cache.nexi-oracle}") - private Boolean nexiOracleEnabled; + private Boolean nexiOracleWrite; @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; @@ -94,29 +96,47 @@ public Map forceCacheUpdate() { log.info("SyncService cacheId:[{}], cacheTimestamp:[{}], cacheVersion:[{}]", cacheId, Instant.from(ZonedDateTime.parse(cacheTimestamp)), cacheVersion); - ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes()); + ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp), cacheVersion, response.body().asInputStream().readAllBytes()); - savePagoPA(syncStatusMap, configCache); - saveNexiPostgres(syncStatusMap, configCache); - saveNexiOracle(syncStatusMap, configCache); + saveAllDatabases(syncStatusMap, configCache); } catch (FeignException.GatewayTimeout e) { log.error("SyncService api-config-cache get cache error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } catch (IOException e) { log.error("SyncService api-config-cache get cache error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } catch (SyncDbStatusException e) { + return syncStatusMap; } catch (Exception e) { log.error("SyncService api-config-cache get cache error", e); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } return syncStatusMap; } - @Transactional + + @Transactional(rollbackFor={SyncDbStatusException.class}) + void saveAllDatabases(Map syncStatusMap, ConfigCache configCache) throws SyncDbStatusException { + savePagoPA(syncStatusMap, configCache); + saveNexiPostgres(syncStatusMap, configCache); + saveNexiOracle(syncStatusMap, configCache); + + if( syncStatusMap.containsValue(SyncStatusEnum.error) ) { + syncStatusMap.forEach((k, v) -> { + if (v == SyncStatusEnum.done) { + syncStatusMap.remove(k); + syncStatusMap.put(k, SyncStatusEnum.rollback); + } + }); + throw new SyncDbStatusException(""); + } + } + private void savePagoPA(Map syncStatusMap, ConfigCache configCache) { try { - if( pagopaPostgresEnabled && pagoPAPostgresRepository.isPresent() ) { - pagoPAPostgresRepository.get().save(configCache); + if( pagopaPostgresWrite && pagopaPostgresRepository.isPresent() ) { + pagopaPostgresRepository.get().save(configCache); syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.disabled); @@ -127,11 +147,11 @@ private void savePagoPA(Map syncStatusMap, ConfigCache c } } - @Transactional private void saveNexiOracle(Map syncStatusMap, ConfigCache configCache) { try { - if( nexiOracleEnabled && nexiOracleRepository.isPresent() ) { + if( nexiOracleWrite && nexiOracleRepository.isPresent() ) { nexiOracleRepository.get().save(configCache); + syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); } @@ -141,11 +161,11 @@ private void saveNexiOracle(Map syncStatusMap, ConfigCac } } - @Transactional private void saveNexiPostgres(Map syncStatusMap, ConfigCache configCache) { try { - if ( nexiPostgresEnabled && nexiPostgresRepository.isPresent() ) { + if ( nexiPostgresWrite && nexiPostgresRepository.isPresent() ) { nexiPostgresRepository.get().save(configCache); + syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.disabled); } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java index d271630..fe2abeb 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java @@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Value; import java.io.IOException; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; import java.util.Collection; import java.util.List; import java.util.Map; @@ -20,7 +20,7 @@ public class CommonCacheService { @Value("${app.trimCacheColumn}") private boolean trimCacheColumn; - protected ConfigCache composeCache(String cacheId, LocalDateTime timestamp, String cacheVersion, byte[] cache) throws IOException { + protected ConfigCache composeCache(String cacheId, ZonedDateTime timestamp, String cacheVersion, byte[] cache) throws IOException { String version = trimCacheColumn ? (String) Utils.trimValueColumn(ConfigCache.class, "version", cacheVersion) : cacheVersion; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 50753d2..6bfa4b9 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -39,24 +39,24 @@ public class StandInManagerService extends CommonCacheService { private final ObjectMapper objectMapper; @Autowired(required = false) - private Optional pagoPAPostgreRepository; + private Optional pagopaPostgresRepository; @Autowired(required = false) private Optional nexiPostgreRepository; @Autowired(required = false) private Optional nexiOracleRepository; @Value("${app.write.standin.pagopa-postgres}") - private Boolean pagopaPostgreEnabled; + private Boolean pagopaPostgreWrite; @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgreServiceIdentifier; @Value("${app.write.standin.nexi-postgres}") - private Boolean nexiPostgreEnabled; + private Boolean nexiPostgreWrite; @Value("${app.identifiers.nexi-postgres}") private String nexiPostgreServiceIdentifier; @Value("${app.write.standin.nexi-oracle}") - private Boolean nexiOracleEnabled; + private Boolean nexiOracleWrite; @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; @@ -100,9 +100,9 @@ public Map forceStandIn() { @Transactional private void savePagoPA(Map syncStatusMap, List stationsEntities) { try { - if ( pagopaPostgreEnabled && pagoPAPostgreRepository.isPresent() ) { - pagoPAPostgreRepository.get().deleteAll(); - pagoPAPostgreRepository.get().saveAll(stationsEntities); + if ( pagopaPostgreWrite && pagopaPostgresRepository.isPresent() ) { + pagopaPostgresRepository.get().deleteAll(); + pagopaPostgresRepository.get().saveAll(stationsEntities); syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); @@ -116,7 +116,7 @@ private void savePagoPA(Map syncStatusMap, List syncStatusMap, List stationsEntities) { try { - if( nexiOracleEnabled && nexiOracleRepository.isPresent() ) { + if( nexiOracleWrite && nexiOracleRepository.isPresent() ) { nexiOracleRepository.get().deleteAll(); nexiOracleRepository.get().saveAll(stationsEntities); syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); @@ -132,7 +132,7 @@ private void saveNexiOracle(Map syncStatusMap, List syncStatusMap, List stationsEntities) { try { - if ( nexiPostgreEnabled && nexiPostgreRepository.isPresent() ) { + if ( nexiPostgreWrite && nexiPostgreRepository.isPresent() ) { nexiPostgreRepository.get().deleteAll(); nexiPostgreRepository.get().saveAll(stationsEntities); syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done); diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index eb4f0d5..3f6fb3f 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -13,7 +13,7 @@ app: write: cache: pagopa-postgres: 'true' - nexi-postgres: 'false' + nexi-postgres: 'true' nexi-oracle: 'false' standin: pagopa-postgres: 'true' @@ -38,7 +38,7 @@ spring: url: jdbc:postgresql://localhost:5432/nodo?currentSchema=public username: cfg password: ${DB_NEXI_POSTGRES_PASSWORD} - enabled: 'false' + enabled: 'true' jpa: show-sql: 'false' @@ -66,7 +66,7 @@ api-config-cache: sa-name: cacheevents consumer-group: $Default consumer: - enabled: 'false' + enabled: 'true' logging: level: diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 601b001..828eb9e 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -40,10 +40,12 @@ app: nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} write: cache: + ##permettono di abilitare/disabilitare la scrittura di cache sui vari database pagopa-postgres: 'true' nexi-postgres: 'false' nexi-oracle: 'false' standin: + ##permettono di abilitare/disabilitare la scrittura di standin-stations sui vari database pagopa-postgres: 'true' nexi-postgres: 'false' nexi-oracle: 'false' @@ -55,17 +57,20 @@ spring: url: ${DB_PAGOPA_POSTGRES_URL} username: ${DB_PAGOPA_POSTGRES_USER} password: ${DB_PAGOPA_POSTGRES_PASSWORD} + ##permette di abilitare/disabilitare il datasource al db Postgres PagoPA enabled: ${DB_PAGOPA_POSTGRES_ENABLED:'false'} nexi: oracle: url: ${DB_NEXI_ORACLE_URL} username: ${DB_NEXI_ORACLE_USER} password: ${DB_NEXI_ORACLE_PASSWORD} + ##permette di abilitare/disabilitare il datasource al db Oracle Nexi enabled: ${DB_NEXI_ORACLE_ENABLED:'false'} postgres: url: ${DB_NEXI_POSTGRES_URL} username: ${DB_NEXI_POSTGRES_USER} password: ${DB_NEXI_POSTGRES_PASSWORD} + ##permette di abilitare/disabilitare il datasource al db Postgres Nexi enabled: ${DB_NEXI_POSTGRES_ENABLED:'false'} jpa: show-sql: 'false' @@ -74,26 +79,30 @@ stand-in-manager: rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-stand-in service: + host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 subscriptionKey: ${STAND_IN_MANAGER_SUBSCRIPTION_KEY} + ##permette di abilitare/disabilitare la chiamata al servizio tramite API enabled: 'true' - host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING} sa-name: standinevents consumer-group: $Default consumer: + ##permette di abilitare/disabilitare il consumer enabled: 'true' api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-cache service: - subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 + subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} + ##permette di abilitare/disabilitare la chiamata al servizio tramite API enabled: 'true' sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING} sa-name: cacheevents consumer-group: $Default consumer: + ##permette di abilitare/disabilitare il consumer enabled: 'true' logging: From 680258ac6fedec029553f01da7e93aa3d79f4bab Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Wed, 21 Feb 2024 14:40:48 +0100 Subject: [PATCH 55/88] NOD-690: fix exception and rollback --- .gitignore | 1 + .../NexiStandInOracleRepository.java | 1 - .../NexiCachePostgresRepository.java | 2 +- .../service/ApiConfigCacheService.java | 12 ++-- .../service/StandInManagerService.java | 67 ++++++++++++------- src/main/resources/application-local.yaml | 19 ++++-- 6 files changed, 60 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 89e3789..bebc40a 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ hs_err_pid* # Others **/.DS_Store /docker/local-dbs/postgres-data/ +/Application.run/*.run.xml diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java index 9d0b1df..3eb9a51 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java @@ -1,6 +1,5 @@ package it.gov.pagopa.node.cfgsync.repository.nexioracle; -import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java index 5d4a118..82d450c 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java @@ -3,4 +3,4 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; -public interface NexiCachePostgresRepository extends JpaRepository { } \ No newline at end of file +public interface NexiCachePostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 1a4a563..2c302a3 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -99,23 +99,19 @@ public Map forceCacheUpdate() { ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp), cacheVersion, response.body().asInputStream().readAllBytes()); saveAllDatabases(syncStatusMap, configCache); + } catch (SyncDbStatusException e) { + //viene usata per poter restituire in risposta la mappa degli aggiornamenti + return syncStatusMap; } catch (FeignException.GatewayTimeout e) { log.error("SyncService api-config-cache get cache error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); - } catch (IOException e) { - log.error("SyncService api-config-cache get cache error", e); - throw new AppException(AppError.INTERNAL_SERVER_ERROR); - } catch (SyncDbStatusException e) { - return syncStatusMap; } catch (Exception e) { log.error("SyncService api-config-cache get cache error", e); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } return syncStatusMap; } - @Transactional(rollbackFor={SyncDbStatusException.class}) void saveAllDatabases(Map syncStatusMap, ConfigCache configCache) throws SyncDbStatusException { savePagoPA(syncStatusMap, configCache); @@ -129,7 +125,7 @@ void saveAllDatabases(Map syncStatusMap, ConfigCache con syncStatusMap.put(k, SyncStatusEnum.rollback); } }); - throw new SyncDbStatusException(""); + throw new SyncDbStatusException("Rollback sync"); } } diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 6bfa4b9..2d78ee2 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -7,9 +7,11 @@ import it.gov.pagopa.node.cfgsync.client.StandInManagerClient; import it.gov.pagopa.node.cfgsync.exception.AppError; import it.gov.pagopa.node.cfgsync.exception.AppException; +import it.gov.pagopa.node.cfgsync.exception.SyncDbStatusException; import it.gov.pagopa.node.cfgsync.model.StationsResponse; import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; +import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiStandInOracleRepository; import it.gov.pagopa.node.cfgsync.repository.nexipostgres.NexiStandInPostgresRepository; @@ -20,6 +22,7 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import java.io.IOException; import java.util.HashMap; @@ -41,19 +44,19 @@ public class StandInManagerService extends CommonCacheService { @Autowired(required = false) private Optional pagopaPostgresRepository; @Autowired(required = false) - private Optional nexiPostgreRepository; + private Optional nexiPostgresRepository; @Autowired(required = false) private Optional nexiOracleRepository; @Value("${app.write.standin.pagopa-postgres}") - private Boolean pagopaPostgreWrite; + private Boolean pagopaPostgresWrite; @Value("${app.identifiers.pagopa-postgres}") - private String pagopaPostgreServiceIdentifier; + private String pagopaPostgresServiceIdentifier; @Value("${app.write.standin.nexi-postgres}") - private Boolean nexiPostgreWrite; + private Boolean nexiPostgresWrite; @Value("${app.identifiers.nexi-postgres}") - private String nexiPostgreServiceIdentifier; + private String nexiPostgresServiceIdentifier; @Value("${app.write.standin.nexi-oracle}") private Boolean nexiOracleWrite; @@ -84,40 +87,54 @@ public Map forceStandIn() { log.info("SyncService {} stations found", stations.getStations().size()); List stationsEntities = stations.getStations().stream().map(StandInStations::new).toList(); - savePagoPA(syncStatusMap, stationsEntities); - saveNexiPostgres(syncStatusMap, stationsEntities); - saveNexiOracle(syncStatusMap, stationsEntities); + saveAllDatabases(syncStatusMap, stationsEntities); + } catch (SyncDbStatusException e) { + //viene usata per poter restituire in risposta la mappa degli aggiornamenti + return syncStatusMap; } catch (FeignException.GatewayTimeout e) { log.error("SyncService stand-in-manager get stations error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); - } catch (FeignException | IOException e) { - log.error("SyncService stand-in-manager get stations error", e); + } catch (Exception e) { + log.error("SyncService stand-in-manager get cache error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } return syncStatusMap; } - @Transactional + @Transactional(rollbackFor={SyncDbStatusException.class}) + void saveAllDatabases(Map syncStatusMap, List stationsEntities) throws SyncDbStatusException { + savePagoPA(syncStatusMap, stationsEntities); + saveNexiPostgres(syncStatusMap, stationsEntities); + saveNexiOracle(syncStatusMap, stationsEntities); + + if( syncStatusMap.containsValue(SyncStatusEnum.error) ) { + syncStatusMap.forEach((k, v) -> { + if (v == SyncStatusEnum.done) { + syncStatusMap.remove(k); + syncStatusMap.put(k, SyncStatusEnum.rollback); + } + }); + throw new SyncDbStatusException("Rollback sync"); + } + } + private void savePagoPA(Map syncStatusMap, List stationsEntities) { try { - if ( pagopaPostgreWrite && pagopaPostgresRepository.isPresent() ) { - pagopaPostgresRepository.get().deleteAll(); + if( pagopaPostgresWrite && pagopaPostgresRepository.isPresent() ) { pagopaPostgresRepository.get().saveAll(stationsEntities); - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done); + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); } else { - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled); + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.disabled); } } catch(Exception ex) { - log.error("SyncService stand-in-manager save PagoPA error: {}", ex.getMessage(), ex); - syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error); + log.error("SyncService stand-in-manager save pagoPA error: {}", ex.getMessage(), ex); + syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.error); } } - @Transactional private void saveNexiOracle(Map syncStatusMap, List stationsEntities) { try { if( nexiOracleWrite && nexiOracleRepository.isPresent() ) { - nexiOracleRepository.get().deleteAll(); nexiOracleRepository.get().saveAll(stationsEntities); syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); } else { @@ -129,19 +146,17 @@ private void saveNexiOracle(Map syncStatusMap, List syncStatusMap, List stationsEntities) { try { - if ( nexiPostgreWrite && nexiPostgreRepository.isPresent() ) { - nexiPostgreRepository.get().deleteAll(); - nexiPostgreRepository.get().saveAll(stationsEntities); - syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done); + if ( nexiPostgresWrite && nexiPostgresRepository.isPresent() ) { + nexiPostgresRepository.get().saveAll(stationsEntities); + syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.done); } else { - syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled); + syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.disabled); } } catch(Exception ex) { log.error("SyncService stand-in-manager save Nexi Postgres error: {}", ex.getMessage(), ex); - syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error); + syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.error); } } } diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index 3f6fb3f..dedfda4 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -13,7 +13,7 @@ app: write: cache: pagopa-postgres: 'true' - nexi-postgres: 'true' + nexi-postgres: 'false' nexi-oracle: 'false' standin: pagopa-postgres: 'true' @@ -27,18 +27,21 @@ spring: url: jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg username: cfg password: ${DB_PAGOPA_POSTGRES_PASSWORD} - enabled: 'true' + ##permette di abilitare/disabilitare il datasource al db Postgres PagoPA + enabled: ${DB_PAGOPA_POSTGRES_ENABLED:'false'} nexi: oracle: url: jdbc:oracle:thin:@//localhost:1521/cfg username: cfg password: ${DB_NEXI_ORACLE_PASSWORD} - enabled: 'false' + ##permette di abilitare/disabilitare il datasource al db Oracle Nexi + enabled: ${DB_NEXI_ORACLE_ENABLED:'false'} postgres: url: jdbc:postgresql://localhost:5432/nodo?currentSchema=public username: cfg password: ${DB_NEXI_POSTGRES_PASSWORD} - enabled: 'true' + ##permette di abilitare/disabilitare il datasource al db Postgres Nexi + enabled: ${DB_NEXI_POSTGRES_ENABLED:'false'} jpa: show-sql: 'false' @@ -46,26 +49,30 @@ stand-in-manager: rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-stand-in service: + host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 subscriptionKey: ${STAND_IN_MANAGER_SUBSCRIPTION_KEY} + ##permette di abilitare/disabilitare la chiamata al servizio tramite API enabled: 'true' - host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING} sa-name: standinevents consumer-group: $Default consumer: + ##permette di abilitare/disabilitare il consumer enabled: 'false' api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-cache service: - subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 + subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} + ##permette di abilitare/disabilitare la chiamata al servizio tramite API enabled: 'true' sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING} sa-name: cacheevents consumer-group: $Default consumer: + ##permette di abilitare/disabilitare il consumer enabled: 'true' logging: From 739fd5dc0c0bcdd6852622e77a680890a5f7745f Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 21 Feb 2024 13:42:26 +0000 Subject: [PATCH 56/88] Bump to version 0.0.0-19-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index bf5c026..9c283e4 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.18.0 -appVersion: 0.0.0-18-NOD-690-nodo-cfg-sync-microservizio +version: 0.19.0 +appVersion: 0.0.0-19-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index f32b354..79ebcc3 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-18-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-19-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 7ba478e..71ce37a 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-18-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-19-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 9efc8ee..2dc6e81 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-18-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-19-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index a3323e9..121e216 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-18-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-19-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 838ca1c..b1ad427 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-18-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-19-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From c3129a24ce3f4408d66d721254bf2644c6f47a92 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Wed, 21 Feb 2024 15:17:12 +0100 Subject: [PATCH 57/88] NOD-690: fix annotations --- .../pagopa/node/cfgsync/repository/model/StandInStations.java | 2 +- .../repository/nexioracle/NexiCacheOracleRepository.java | 2 ++ .../repository/nexioracle/NexiStandInOracleRepository.java | 2 ++ .../repository/nexipostgres/NexiCachePostgresRepository.java | 2 ++ .../repository/nexipostgres/NexiStandInPostgresRepository.java | 2 ++ .../repository/pagopa/PagoPACachePostgresRepository.java | 2 ++ .../repository/pagopa/PagoPAStandInPostgresRepository.java | 2 ++ 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/StandInStations.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/StandInStations.java index a7fc7f0..2f17489 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/StandInStations.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/model/StandInStations.java @@ -14,7 +14,7 @@ @AllArgsConstructor @Entity @Table(name = "stand_in_stations") -public class StandInStations implements Serializable { +public class StandInStations { @Id @Column(name="STATION_CODE", columnDefinition = "VARCHAR", length = 35) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java index 0277223..7ee65ac 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java @@ -2,5 +2,7 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +@Repository public interface NexiCacheOracleRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java index 3eb9a51..fc166dd 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java @@ -2,5 +2,7 @@ import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +@Repository public interface NexiStandInOracleRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java index 82d450c..3c0d032 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java @@ -2,5 +2,7 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +@Repository public interface NexiCachePostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java index d4d87f6..a718391 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java @@ -2,5 +2,7 @@ import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +@Repository public interface NexiStandInPostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java index a3f7ccd..fb1ecdd 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java @@ -2,5 +2,7 @@ import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +@Repository public interface PagoPACachePostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java index 361ae47..f002e23 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java @@ -2,5 +2,7 @@ import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +@Repository public interface PagoPAStandInPostgresRepository extends JpaRepository { } \ No newline at end of file From c056ce06498da0e707a61e34ce6c02a1f41c7d2e Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 21 Feb 2024 14:18:36 +0000 Subject: [PATCH 58/88] Bump to version 0.0.0-20-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 9c283e4..f8ee7ef 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.19.0 -appVersion: 0.0.0-19-NOD-690-nodo-cfg-sync-microservizio +version: 0.20.0 +appVersion: 0.0.0-20-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 79ebcc3..c0e4378 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-19-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-20-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 71ce37a..4627b30 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-19-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-20-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 2dc6e81..8dd82e7 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-19-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-20-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 121e216..1a6d396 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-19-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-20-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index b1ad427..0749ecd 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-19-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-20-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From d98cbdf2d9a3f97ba17b50e0ca7eab0fb95afbd7 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Wed, 21 Feb 2024 15:27:27 +0100 Subject: [PATCH 59/88] wip --- src/main/resources/application.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 828eb9e..f01aac2 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -57,6 +57,7 @@ spring: url: ${DB_PAGOPA_POSTGRES_URL} username: ${DB_PAGOPA_POSTGRES_USER} password: ${DB_PAGOPA_POSTGRES_PASSWORD} + database-platform: org.hibernate.dialect.PostgreSQL10Dialect ##permette di abilitare/disabilitare il datasource al db Postgres PagoPA enabled: ${DB_PAGOPA_POSTGRES_ENABLED:'false'} nexi: From dfa3f9eb6a6a5f0f5e046a292f34947fd7a3a144 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 21 Feb 2024 14:28:46 +0000 Subject: [PATCH 60/88] Bump to version 0.0.0-21-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index f8ee7ef..6d8f2b2 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.20.0 -appVersion: 0.0.0-20-NOD-690-nodo-cfg-sync-microservizio +version: 0.21.0 +appVersion: 0.0.0-21-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index c0e4378..6c6b93d 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-20-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-21-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 4627b30..06192c6 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-20-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-21-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 8dd82e7..bc91b49 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-20-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-21-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 1a6d396..771fe32 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-20-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-21-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 0749ecd..7abbb05 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-20-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-21-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From b0e024c1d860dac0d39cf8de54d3944706a4a10d Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Wed, 21 Feb 2024 16:34:35 +0100 Subject: [PATCH 61/88] wip --- .dockerignore | 1 + helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1de5659 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 6c6b93d..691c192 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -79,7 +79,7 @@ microservice-chart: DB_PAGOPA_POSTGRES_USER: "cfg" DB_PAGOPA_POSTGRES_ENABLED: "true" DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER: "NDP001DEV" - OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" + OTEL_SERVICE_NAME: "pagopanodecfgsync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" OTEL_TRACES_EXPORTER: otlp diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 06192c6..92a8373 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -68,7 +68,7 @@ microservice-chart: DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' CACHET_TX_NAME: "nodo-dei-pagamenti-cache" - OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" + OTEL_SERVICE_NAME: "pagopanodecfgsync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=prod" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" OTEL_TRACES_EXPORTER: otlp diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index bc91b49..361c08a 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -68,7 +68,7 @@ microservice-chart: DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' CACHET_TX_NAME: "nodo-dei-pagamenti-cache" - OTEL_SERVICE_NAME: "pagopa-node-cfg-sync" + OTEL_SERVICE_NAME: "pagopanodecfgsync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=uat" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" OTEL_TRACES_EXPORTER: otlp From 7900ac1bc78f2191cc2dfffebf4f3eac7d155ab7 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 21 Feb 2024 15:36:02 +0000 Subject: [PATCH 62/88] Bump to version 0.0.0-22-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 6d8f2b2..53ca88f 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.21.0 -appVersion: 0.0.0-21-NOD-690-nodo-cfg-sync-microservizio +version: 0.22.0 +appVersion: 0.0.0-22-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 691c192..6172f46 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-21-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-22-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 92a8373..dfd0e77 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-21-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-22-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 361c08a..b1e9a0c 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-21-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-22-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 771fe32..0c98d62 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-21-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-22-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 7abbb05..91f2a77 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-21-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-22-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 1553311a2f44fb1bbf23e3bcc104a992ff56cfa3 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Wed, 21 Feb 2024 18:22:27 +0100 Subject: [PATCH 63/88] wip --- Dockerfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index afeadcc..0a2d781 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,19 +8,20 @@ RUN mvn clean package -DskipTests FROM amazoncorretto:17.0.9-alpine3.18@sha256:df48bf2e183230040890460ddb4359a10aa6c7aad24bd88899482c52053c7e17 as builder -COPY --from=buildtime /build/target/*.jar application.jar +WORKDIR /app +COPY --from=buildtime /build/target/*.jar /app/application.jar RUN java -Djarmode=layertools -jar application.jar extract FROM ghcr.io/pagopa/docker-base-springboot-openjdk17:v1.1.0@sha256:6fa320d452fa22066441f1ef292d15eb06f944bc8bca293e1a91ea460d30a613 +WORKDIR /app ADD --chown=spring:spring https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.25.1/opentelemetry-javaagent.jar . -COPY --chown=spring:spring --from=builder dependencies/ ./ -COPY --chown=spring:spring --from=builder snapshot-dependencies/ ./ +COPY --chown=spring:spring --from=builder /app/dependencies/ ./ +COPY --chown=spring:spring --from=builder /app/snapshot-dependencies/ ./ # https://github.com/moby/moby/issues/37965#issuecomment-426853382 -RUN true -COPY --chown=spring:spring --from=builder spring-boot-loader/ ./ -COPY --chown=spring:spring --from=builder application/ ./ +COPY --chown=spring:spring --from=builder /app/spring-boot-loader/ ./ +COPY --chown=spring:spring --from=builder /app/application/ ./ EXPOSE 8080 From 141ec06841df241861f21d9f623e304afb7042d3 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 21 Feb 2024 17:23:56 +0000 Subject: [PATCH 64/88] Bump to version 0.0.0-23-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 53ca88f..45461bd 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.22.0 -appVersion: 0.0.0-22-NOD-690-nodo-cfg-sync-microservizio +version: 0.23.0 +appVersion: 0.0.0-23-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 6172f46..5700795 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-22-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index dfd0e77..d6ba73a 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-22-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index b1e9a0c..2e5f672 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-22-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 0c98d62..144dc5b 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-22-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 91f2a77..963abdd 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-22-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-23-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 0e0d149593f5dc5df39c682a03bfe3209961f1da Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Wed, 21 Feb 2024 18:41:14 +0100 Subject: [PATCH 65/88] wip --- openapi/openapi.json | 373 +++++++++++++--------------- src/main/resources/application.yaml | 1 - src/test/resources/application.yaml | 2 +- 3 files changed, 177 insertions(+), 199 deletions(-) diff --git a/openapi/openapi.json b/openapi/openapi.json index 144dc5b..de6e359 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,278 +1,257 @@ { - "openapi": "3.0.1", - "info": { - "title": "cfg-sync", - "description": "Microservice to update configuration schema of Nodo dei Pagamenti", - "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" + "openapi" : "3.0.1", + "info" : { + "title" : "cfg-sync", + "description" : "Microservice to update configuration schema of Nodo dei Pagamenti", + "termsOfService" : "https://www.pagopa.gov.it/", + "version" : "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/ndp/cache": { - "post": { - "tags": [ - "Cache" - ], - "summary": "Force cache configuration update", - "operationId": "cache", - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "paths" : { + "/ndp/cache" : { + "post" : { + "tags" : [ "Cache" ], + "summary" : "Force cache configuration update", + "operationId" : "cache", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SyncStatusResponse" + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/SyncStatusResponse" } } } } }, - "400": { - "description": "Bad Request", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "401": { - "description": "Unauthorized", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "429": { - "description": "Too many requests", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "500": { - "description": "Service unavailable", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } } }, - "security": [ - { - "ApiKey": [] - } - ] + "security" : [ { + "ApiKey" : [ ] + } ] }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" } - ] + } ] }, - "/ndp/stand-in": { - "post": { - "tags": [ - "StandIn" - ], - "summary": "Force stand-in configuration update", - "operationId": "standin", - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "/ndp/stand-in" : { + "post" : { + "tags" : [ "StandIn" ], + "summary" : "Force stand-in configuration update", + "operationId" : "standin", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": {} + "content" : { + "application/json" : { } } }, - "400": { - "description": "Bad Request", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "401": { - "description": "Unauthorized", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "429": { - "description": "Too many requests", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "500": { - "description": "Service unavailable", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } } }, - "security": [ - { - "ApiKey": [] - } - ] + "security" : [ { + "ApiKey" : [ ] + } ] }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" } - ] + } ] } }, - "components": { - "schemas": { - "ProblemJson": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "components" : { + "schemas" : { + "ProblemJson" : { + "type" : "object", + "properties" : { + "title" : { + "type" : "string", + "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" }, - "status": { - "maximum": 600, - "minimum": 100, - "type": "integer", - "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format": "int32", - "example": 200 + "status" : { + "maximum" : 600, + "minimum" : 100, + "type" : "integer", + "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format" : "int32", + "example" : 200 }, - "detail": { - "type": "string", - "description": "A human readable explanation specific to this occurrence of the problem.", - "example": "There was an error processing the request" + "detail" : { + "type" : "string", + "description" : "A human readable explanation specific to this occurrence of the problem.", + "example" : "There was an error processing the request" } } }, - "SyncStatusResponse": { - "required": [ - "serviceIdentifier", - "status" - ], - "type": "object", - "properties": { - "serviceIdentifier": { - "type": "string", - "description": "Database service identifier", - "example": "NDP001" + "SyncStatusResponse" : { + "required" : [ "serviceIdentifier", "status" ], + "type" : "object", + "properties" : { + "serviceIdentifier" : { + "type" : "string", + "description" : "Database service identifier", + "example" : "NDP001" }, - "status": { - "type": "string", - "description": "Database sync status result", - "example": "done", - "enum": [ - "done", - "disabled", - "error" - ] + "status" : { + "type" : "string", + "description" : "Database sync status result", + "example" : "done", + "enum" : [ "done", "disabled", "rollback", "error" ] } } } }, - "securitySchemes": { - "ApiKey": { - "type": "apiKey", - "description": "The API key to access this function app.", - "name": "Ocp-Apim-Subscription-Key", - "in": "header" + "securitySchemes" : { + "ApiKey" : { + "type" : "apiKey", + "description" : "The API key to access this function app.", + "name" : "Ocp-Apim-Subscription-Key", + "in" : "header" } } } -} +} \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index f01aac2..828eb9e 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -57,7 +57,6 @@ spring: url: ${DB_PAGOPA_POSTGRES_URL} username: ${DB_PAGOPA_POSTGRES_USER} password: ${DB_PAGOPA_POSTGRES_PASSWORD} - database-platform: org.hibernate.dialect.PostgreSQL10Dialect ##permette di abilitare/disabilitare il datasource al db Postgres PagoPA enabled: ${DB_PAGOPA_POSTGRES_ENABLED:'false'} nexi: diff --git a/src/test/resources/application.yaml b/src/test/resources/application.yaml index 1721fb7..369c006 100644 --- a/src/test/resources/application.yaml +++ b/src/test/resources/application.yaml @@ -7,7 +7,7 @@ info: properties: environment: ${ENV:test} cors: - configuration: '${CORS_CONFIGURATION:''{"origins": ["*"], "methods": ["*"]}''}' + configuration: '{"origins": ["*"], "methods": ["*"]}' server: port: '8080' servlet: From 8ff29242d0addb3ef6f9ff01112b3de0637958e8 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 21 Feb 2024 17:43:11 +0000 Subject: [PATCH 66/88] Bump to version 0.0.0-24-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 +- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 374 ++++++++++++++++++++++-------------------- pom.xml | 2 +- 6 files changed, 204 insertions(+), 182 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 45461bd..16256fb 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.23.0 -appVersion: 0.0.0-23-NOD-690-nodo-cfg-sync-microservizio +version: 0.24.0 +appVersion: 0.0.0-24-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 5700795..0aaf3b3 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-24-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index d6ba73a..8d4434c 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-24-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 2e5f672..3eeb71d 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-24-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index de6e359..6d5c0a7 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,257 +1,279 @@ { - "openapi" : "3.0.1", - "info" : { - "title" : "cfg-sync", - "description" : "Microservice to update configuration schema of Nodo dei Pagamenti", - "termsOfService" : "https://www.pagopa.gov.it/", - "version" : "0.0.0-23-NOD-690-nodo-cfg-sync-microservizio" + "openapi": "3.0.1", + "info": { + "title": "cfg-sync", + "description": "Microservice to update configuration schema of Nodo dei Pagamenti", + "termsOfService": "https://www.pagopa.gov.it/", + "version": "0.0.0-24-NOD-690-nodo-cfg-sync-microservizio" }, - "servers" : [ { - "url" : "http://localhost", - "description" : "Generated server url" - } ], - "paths" : { - "/ndp/cache" : { - "post" : { - "tags" : [ "Cache" ], - "summary" : "Force cache configuration update", - "operationId" : "cache", - "responses" : { - "200" : { - "description" : "OK", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/ndp/cache": { + "post": { + "tags": [ + "Cache" + ], + "summary": "Force cache configuration update", + "operationId": "cache", + "responses": { + "200": { + "description": "OK", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/SyncStatusResponse" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SyncStatusResponse" } } } } }, - "400" : { - "description" : "Bad Request", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "400": { + "description": "Bad Request", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } }, - "401" : { - "description" : "Unauthorized", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "401": { + "description": "Unauthorized", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "429" : { - "description" : "Too many requests", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "429": { + "description": "Too many requests", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "500" : { - "description" : "Service unavailable", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "500": { + "description": "Service unavailable", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } } }, - "security" : [ { - "ApiKey" : [ ] - } ] + "security": [ + { + "ApiKey": [] + } + ] }, - "parameters" : [ { - "name" : "X-Request-Id", - "in" : "header", - "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema" : { - "type" : "string" + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } } - } ] + ] }, - "/ndp/stand-in" : { - "post" : { - "tags" : [ "StandIn" ], - "summary" : "Force stand-in configuration update", - "operationId" : "standin", - "responses" : { - "200" : { - "description" : "OK", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "/ndp/stand-in": { + "post": { + "tags": [ + "StandIn" + ], + "summary": "Force stand-in configuration update", + "operationId": "standin", + "responses": { + "200": { + "description": "OK", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { } + "content": { + "application/json": {} } }, - "400" : { - "description" : "Bad Request", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "400": { + "description": "Bad Request", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } }, - "401" : { - "description" : "Unauthorized", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "401": { + "description": "Unauthorized", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "429" : { - "description" : "Too many requests", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "429": { + "description": "Too many requests", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "500" : { - "description" : "Service unavailable", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "500": { + "description": "Service unavailable", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } } }, - "security" : [ { - "ApiKey" : [ ] - } ] + "security": [ + { + "ApiKey": [] + } + ] }, - "parameters" : [ { - "name" : "X-Request-Id", - "in" : "header", - "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema" : { - "type" : "string" + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } } - } ] + ] } }, - "components" : { - "schemas" : { - "ProblemJson" : { - "type" : "object", - "properties" : { - "title" : { - "type" : "string", - "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "components": { + "schemas": { + "ProblemJson": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" }, - "status" : { - "maximum" : 600, - "minimum" : 100, - "type" : "integer", - "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format" : "int32", - "example" : 200 + "status": { + "maximum": 600, + "minimum": 100, + "type": "integer", + "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format": "int32", + "example": 200 }, - "detail" : { - "type" : "string", - "description" : "A human readable explanation specific to this occurrence of the problem.", - "example" : "There was an error processing the request" + "detail": { + "type": "string", + "description": "A human readable explanation specific to this occurrence of the problem.", + "example": "There was an error processing the request" } } }, - "SyncStatusResponse" : { - "required" : [ "serviceIdentifier", "status" ], - "type" : "object", - "properties" : { - "serviceIdentifier" : { - "type" : "string", - "description" : "Database service identifier", - "example" : "NDP001" + "SyncStatusResponse": { + "required": [ + "serviceIdentifier", + "status" + ], + "type": "object", + "properties": { + "serviceIdentifier": { + "type": "string", + "description": "Database service identifier", + "example": "NDP001" }, - "status" : { - "type" : "string", - "description" : "Database sync status result", - "example" : "done", - "enum" : [ "done", "disabled", "rollback", "error" ] + "status": { + "type": "string", + "description": "Database sync status result", + "example": "done", + "enum": [ + "done", + "disabled", + "rollback", + "error" + ] } } } }, - "securitySchemes" : { - "ApiKey" : { - "type" : "apiKey", - "description" : "The API key to access this function app.", - "name" : "Ocp-Apim-Subscription-Key", - "in" : "header" + "securitySchemes": { + "ApiKey": { + "type": "apiKey", + "description": "The API key to access this function app.", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" } } } -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index 963abdd..62d7822 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-23-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-24-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From db31b6cf26026704b94a052171ef1df0e1bcc021 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Wed, 21 Feb 2024 18:46:43 +0100 Subject: [PATCH 67/88] wip --- .../workflows/05h_deploy_with_github_runner.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/05h_deploy_with_github_runner.yml b/.github/workflows/05h_deploy_with_github_runner.yml index ba534c9..c9a1fa6 100644 --- a/.github/workflows/05h_deploy_with_github_runner.yml +++ b/.github/workflows/05h_deploy_with_github_runner.yml @@ -85,7 +85,7 @@ jobs: needs: [ deploy ] runs-on: ubuntu-latest name: Update OpenAPI - if: ${{ inputs.target == inputs.environment }} + if: ${{ inputs.target == inputs.environment || inputs.target == 'all' }} environment: ${{ inputs.environment }} steps: - name: Checkout @@ -108,4 +108,16 @@ jobs: with: client-id: ${{ secrets.CD_CLIENT_ID }} tenant-id: ${{ secrets.TENANT_ID }} - subscription-id: ${{ secrets.SUBSCRIPTION_ID }} \ No newline at end of file + subscription-id: ${{ secrets.SUBSCRIPTION_ID }} + + - name: Terraform Apply + shell: bash + run: | + cd ./infra + export ARM_CLIENT_ID="${{ secrets.CLIENT_ID }}" + export ARM_SUBSCRIPTION_ID=$(az account show --query id --output tsv) + export ARM_TENANT_ID=$(az account show --query tenantId --output tsv) + export ARM_USE_OIDC=true + export ARM_ACCESS_KEY=$(az storage account keys list --resource-group io-infra-rg --account-name pagopainfraterraform${{inputs.environment}} --query '[0].value' -o tsv) + bash ./terraform.sh init weu-${{ inputs.environment }} + bash ./terraform.sh apply weu-${{ inputs.environment }} -auto-approve \ No newline at end of file From c8e172e3088215937f30607c228ff59e61fccd0b Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Wed, 21 Feb 2024 18:55:15 +0100 Subject: [PATCH 68/88] wip --- .../node/cfgsync/controller/SyncCacheController.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java index 1fe8b86..170d4dd 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java @@ -8,7 +8,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import it.gov.pagopa.node.cfgsync.model.ProblemJson; -import it.gov.pagopa.node.cfgsync.model.SyncStatus; import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; import it.gov.pagopa.node.cfgsync.model.SyncStatusResponse; import it.gov.pagopa.node.cfgsync.service.ApiConfigCacheService; @@ -18,7 +17,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -76,9 +75,8 @@ public class SyncCacheController { mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))) }) - @PostMapping( + @GetMapping( value = "/stand-in", - consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> standin() { @@ -133,9 +131,8 @@ public ResponseEntity> standin() { mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))) }) - @PostMapping( + @GetMapping( value = "/cache", - consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> cache() { log.debug("Force cache configuration update"); From 916a84c205231e120c193a45fd919f79f3a800e0 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 21 Feb 2024 17:56:33 +0000 Subject: [PATCH 69/88] Bump to version 0.0.0-25-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 16256fb..adad114 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.24.0 -appVersion: 0.0.0-24-NOD-690-nodo-cfg-sync-microservizio +version: 0.25.0 +appVersion: 0.0.0-25-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 0aaf3b3..a213fa8 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-24-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-25-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 8d4434c..085d1e0 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-24-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-25-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 3eeb71d..9a8106a 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-24-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-25-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 6d5c0a7..2069c01 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-24-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-25-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 62d7822..9796b7e 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-24-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-25-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 23648ae9f0ef187176cc9777bc4ba67a22d7e981 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 21 Feb 2024 18:10:18 +0000 Subject: [PATCH 70/88] Bump to version 0.0.0-26-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index adad114..9e49121 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.25.0 -appVersion: 0.0.0-25-NOD-690-nodo-cfg-sync-microservizio +version: 0.26.0 +appVersion: 0.0.0-26-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index a213fa8..79913a1 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-25-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 085d1e0..d83dbb8 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-25-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 9a8106a..602e75a 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-25-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 2069c01..a9455b2 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-25-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 9796b7e..1e3b46a 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-25-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-26-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 51efce8975aa678d356dbbd8381046502adfc226 Mon Sep 17 00:00:00 2001 From: Lorenzo Catalano Date: Wed, 21 Feb 2024 19:13:04 +0100 Subject: [PATCH 71/88] wip --- helm/values-dev.yaml | 4 +- openapi/openapi.json | 362 ++++++++++++++++++++----------------------- 2 files changed, 172 insertions(+), 194 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 79913a1..d3d737a 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -10,14 +10,14 @@ microservice-chart: httpGet: path: /actuator/health/liveness port: 8080 - initialDelaySeconds: 90 + initialDelaySeconds: 30 failureThreshold: 6 periodSeconds: 10 readinessProbe: httpGet: path: /actuator/health/readiness port: 8080 - initialDelaySeconds: 90 + initialDelaySeconds: 30 failureThreshold: 6 periodSeconds: 10 deployment: diff --git a/openapi/openapi.json b/openapi/openapi.json index a9455b2..a519910 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -6,274 +6,252 @@ "termsOfService": "https://www.pagopa.gov.it/", "version": "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/ndp/cache": { - "post": { - "tags": [ - "Cache" - ], - "summary": "Force cache configuration update", - "operationId": "cache", - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "paths" : { + "/ndp/cache" : { + "get" : { + "tags" : [ "Cache" ], + "summary" : "Force cache configuration update", + "operationId" : "cache", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SyncStatusResponse" + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/SyncStatusResponse" } } } } }, - "400": { - "description": "Bad Request", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "401": { - "description": "Unauthorized", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "429": { - "description": "Too many requests", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "500": { - "description": "Service unavailable", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } } }, - "security": [ - { - "ApiKey": [] - } - ] + "security" : [ { + "ApiKey" : [ ] + } ] }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" } - ] + } ] }, - "/ndp/stand-in": { - "post": { - "tags": [ - "StandIn" - ], - "summary": "Force stand-in configuration update", - "operationId": "standin", - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "/ndp/stand-in" : { + "get" : { + "tags" : [ "StandIn" ], + "summary" : "Force stand-in configuration update", + "operationId" : "standin", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": {} + "content" : { + "application/json" : { } } }, - "400": { - "description": "Bad Request", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "400" : { + "description" : "Bad Request", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } }, - "401": { - "description": "Unauthorized", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "401" : { + "description" : "Unauthorized", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "429": { - "description": "Too many requests", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "429" : { + "description" : "Too many requests", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } } }, - "500": { - "description": "Service unavailable", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "500" : { + "description" : "Service unavailable", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProblemJson" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ProblemJson" } } } } }, - "security": [ - { - "ApiKey": [] - } - ] + "security" : [ { + "ApiKey" : [ ] + } ] }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" - } + "parameters" : [ { + "name" : "X-Request-Id", + "in" : "header", + "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema" : { + "type" : "string" } - ] + } ] } }, - "components": { - "schemas": { - "ProblemJson": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "components" : { + "schemas" : { + "ProblemJson" : { + "type" : "object", + "properties" : { + "title" : { + "type" : "string", + "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" }, - "status": { - "maximum": 600, - "minimum": 100, - "type": "integer", - "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format": "int32", - "example": 200 + "status" : { + "maximum" : 600, + "minimum" : 100, + "type" : "integer", + "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format" : "int32", + "example" : 200 }, - "detail": { - "type": "string", - "description": "A human readable explanation specific to this occurrence of the problem.", - "example": "There was an error processing the request" + "detail" : { + "type" : "string", + "description" : "A human readable explanation specific to this occurrence of the problem.", + "example" : "There was an error processing the request" } } }, - "SyncStatusResponse": { - "required": [ - "serviceIdentifier", - "status" - ], - "type": "object", - "properties": { - "serviceIdentifier": { - "type": "string", - "description": "Database service identifier", - "example": "NDP001" + "SyncStatusResponse" : { + "required" : [ "serviceIdentifier", "status" ], + "type" : "object", + "properties" : { + "serviceIdentifier" : { + "type" : "string", + "description" : "Database service identifier", + "example" : "NDP001" }, - "status": { - "type": "string", - "description": "Database sync status result", - "example": "done", - "enum": [ - "done", - "disabled", - "rollback", - "error" - ] + "status" : { + "type" : "string", + "description" : "Database sync status result", + "example" : "done", + "enum" : [ "done", "disabled", "rollback", "error" ] } } } }, - "securitySchemes": { - "ApiKey": { - "type": "apiKey", - "description": "The API key to access this function app.", - "name": "Ocp-Apim-Subscription-Key", - "in": "header" + "securitySchemes" : { + "ApiKey" : { + "type" : "apiKey", + "description" : "The API key to access this function app.", + "name" : "Ocp-Apim-Subscription-Key", + "in" : "header" } } } -} +} \ No newline at end of file From 25000724514723380644bfb8666c8d72cc30a698 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Thu, 22 Feb 2024 16:55:06 +0100 Subject: [PATCH 72/88] NOD-690: fix variables and repository --- .../controller/SyncCacheController.java | 111 +++++++++--------- .../pagopa/node/cfgsync/model/SyncStatus.java | 19 --- .../nexioracle/NexiCacheOracleRepository.java | 2 + .../NexiStandInOracleRepository.java | 2 + .../NexiCachePostgresRepository.java | 4 +- .../NexiStandInPostgresRepository.java | 2 + .../pagopa/PagoPACachePostgresRepository.java | 2 + .../PagoPAStandInPostgresRepository.java | 2 + .../service/ApiConfigCacheService.java | 37 +++--- .../service/StandInManagerService.java | 34 +++--- src/main/resources/application-local.yaml | 19 +-- src/main/resources/application.yaml | 21 ++-- 12 files changed, 121 insertions(+), 134 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatus.java diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java index 170d4dd..4095028 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/controller/SyncCacheController.java @@ -17,7 +17,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -37,63 +37,64 @@ public class SyncCacheController { private StandInManagerService standInManagerService; - @Operation( - summary = "Force stand-in configuration update", - security = {@SecurityRequirement(name = "ApiKey")}, - tags = { - "StandIn", - }) - @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "OK", - content = - @Content( - mediaType = MediaType.APPLICATION_JSON_VALUE - )), - @ApiResponse( - responseCode = "400", - description = "Bad Request", - content = - @Content( - mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = ProblemJson.class))), - @ApiResponse( - responseCode = "401", - description = "Unauthorized", - content = @Content(schema = @Schema())), - @ApiResponse( - responseCode = "429", - description = "Too many requests", - content = @Content(schema = @Schema())), - @ApiResponse( - responseCode = "500", - description = "Service unavailable", - content = - @Content( - mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = ProblemJson.class))) - }) - @GetMapping( - value = "/stand-in", - produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> standin() { + @Operation( + summary = "Force stand-in configuration to update", + security = {@SecurityRequirement(name = "ApiKey")}, + tags = { + "StandIn", + }) + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + description = "OK", + content = { + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + array = @ArraySchema(schema = @Schema(implementation = SyncStatusResponse.class))) + }), + @ApiResponse( + responseCode = "400", + description = "Bad Request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))), + @ApiResponse( + responseCode = "401", + description = "Unauthorized", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "429", + description = "Too many requests", + content = @Content(schema = @Schema())), + @ApiResponse( + responseCode = "500", + description = "Service unavailable", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ProblemJson.class))) + }) + @PutMapping( + value = "/stand-in", + produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> standin() { - log.debug("Force stand-in configuration update"); - Map syncStatusEnumMap = standInManagerService.forceStandIn(); + log.debug("Force stand-in configuration to update"); + Map syncStatusEnumMap = standInManagerService.forceStandIn(); - List syncStatusResponseList = syncStatusEnumMap.entrySet() - .stream() - .map(e -> SyncStatusResponse.builder().serviceIdentifier(e.getKey()).status(e.getValue()).build()) - .collect(Collectors.toList()); + List syncStatusResponseList = syncStatusEnumMap.entrySet() + .stream() + .map(e -> SyncStatusResponse.builder().serviceIdentifier(e.getKey()).status(e.getValue()).build()) + .collect(Collectors.toList()); - return ResponseEntity.ok() - .body(syncStatusResponseList); - } + return ResponseEntity.ok() + .body(syncStatusResponseList); + } @Operation( - summary = "Force cache configuration update", + summary = "Force cache configuration to update", security = {@SecurityRequirement(name = "ApiKey")}, tags = { "Cache", @@ -131,11 +132,11 @@ public ResponseEntity> standin() { mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))) }) - @GetMapping( + @PutMapping( value = "/cache", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> cache() { - log.debug("Force cache configuration update"); + log.debug("Force cache configuration to update"); Map syncStatusEnumMap = apiConfigCacheService.forceCacheUpdate(); List syncStatusResponseList = syncStatusEnumMap.entrySet() diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatus.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatus.java deleted file mode 100644 index 7ff0add..0000000 --- a/src/main/java/it/gov/pagopa/node/cfgsync/model/SyncStatus.java +++ /dev/null @@ -1,19 +0,0 @@ -package it.gov.pagopa.node.cfgsync.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.*; - -import javax.validation.constraints.NotNull; - -@Data -@Builder(toBuilder = true) -@NoArgsConstructor -@AllArgsConstructor(access = AccessLevel.PRIVATE) -@ToString -@JsonIgnoreProperties(ignoreUnknown = true) -public class SyncStatus { - - @NotNull - private String serviceIdentifier; - @NotNull private SyncStatusEnum status; -} diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java index 7ee65ac..224b4d9 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiCacheOracleRepository.java @@ -1,8 +1,10 @@ package it.gov.pagopa.node.cfgsync.repository.nexioracle; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository +@ConditionalOnProperty(name = "api-config-cache.write.nexi-oracle") public interface NexiCacheOracleRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java index fc166dd..6a93e84 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexioracle/NexiStandInOracleRepository.java @@ -1,8 +1,10 @@ package it.gov.pagopa.node.cfgsync.repository.nexioracle; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository +@ConditionalOnProperty(name = "stand-in-manager.write.nexi-oracle") public interface NexiStandInOracleRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java index 3c0d032..5004eec 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiCachePostgresRepository.java @@ -1,8 +1,10 @@ package it.gov.pagopa.node.cfgsync.repository.nexipostgres; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface NexiCachePostgresRepository extends JpaRepository { } \ No newline at end of file +@ConditionalOnProperty(name = "api-config-cache.write.nexi-postgres") +public interface NexiCachePostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java index a718391..fe187a9 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/nexipostgres/NexiStandInPostgresRepository.java @@ -1,8 +1,10 @@ package it.gov.pagopa.node.cfgsync.repository.nexipostgres; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository +@ConditionalOnProperty(name = "stand-in-manager.write.nexi-postgres") public interface NexiStandInPostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java index fb1ecdd..b75715e 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPACachePostgresRepository.java @@ -1,8 +1,10 @@ package it.gov.pagopa.node.cfgsync.repository.pagopa; import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository +@ConditionalOnProperty(name = "api-config-cache.write.pagopa-postgres") public interface PagoPACachePostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java index f002e23..838cc9d 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/repository/pagopa/PagoPAStandInPostgresRepository.java @@ -1,8 +1,10 @@ package it.gov.pagopa.node.cfgsync.repository.pagopa; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository +@ConditionalOnProperty(name = "stand-in-manager.write.pagopa-postgres") public interface PagoPAStandInPostgresRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index 2c302a3..b1b7612 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -19,15 +19,12 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.interceptor.TransactionAspectSupport; -import java.io.IOException; import java.time.Instant; import java.time.ZonedDateTime; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.Optional; @Component @Slf4j @@ -45,24 +42,24 @@ public class ApiConfigCacheService extends CommonCacheService { private final ApiConfigCacheClient apiConfigCacheClient; @Autowired(required = false) - private Optional pagopaPostgresRepository; + private PagoPACachePostgresRepository pagopaPostgresRepository; @Autowired(required = false) - private Optional nexiPostgresRepository; + private NexiCachePostgresRepository nexiPostgresRepository; @Autowired(required = false) - private Optional nexiOracleRepository; + private NexiCacheOracleRepository nexiOracleRepository; - @Value("${app.write.cache.pagopa-postgres}") - private Boolean pagopaPostgresWrite; +// @Value("${app.write.cache.pagopa-postgres}") +// private Boolean pagopaPostgresWrite; @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgresServiceIdentifier; - - @Value("${app.write.cache.nexi-postgres}") - private Boolean nexiPostgresWrite; +// +// @Value("${app.write.cache.nexi-postgres}") +// private Boolean nexiPostgresWrite; @Value("${app.identifiers.nexi-postgres}") private String nexiPostgresServiceIdentifier; - - @Value("${app.write.cache.nexi-oracle}") - private Boolean nexiOracleWrite; +// +// @Value("${app.write.cache.nexi-oracle}") +// private Boolean nexiOracleWrite; @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; @@ -131,8 +128,8 @@ void saveAllDatabases(Map syncStatusMap, ConfigCache con private void savePagoPA(Map syncStatusMap, ConfigCache configCache) { try { - if( pagopaPostgresWrite && pagopaPostgresRepository.isPresent() ) { - pagopaPostgresRepository.get().save(configCache); + if( null != pagopaPostgresRepository ) { + pagopaPostgresRepository.save(configCache); syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.disabled); @@ -145,8 +142,8 @@ private void savePagoPA(Map syncStatusMap, ConfigCache c private void saveNexiOracle(Map syncStatusMap, ConfigCache configCache) { try { - if( nexiOracleWrite && nexiOracleRepository.isPresent() ) { - nexiOracleRepository.get().save(configCache); + if( null != nexiOracleRepository ) { + nexiOracleRepository.save(configCache); syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); @@ -159,8 +156,8 @@ private void saveNexiOracle(Map syncStatusMap, ConfigCac private void saveNexiPostgres(Map syncStatusMap, ConfigCache configCache) { try { - if ( nexiPostgresWrite && nexiPostgresRepository.isPresent() ) { - nexiPostgresRepository.get().save(configCache); + if ( null != nexiPostgresRepository ) { + nexiPostgresRepository.save(configCache); syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.disabled); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 2d78ee2..0df5d14 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -11,7 +11,6 @@ import it.gov.pagopa.node.cfgsync.model.StationsResponse; import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum; -import it.gov.pagopa.node.cfgsync.repository.model.ConfigCache; import it.gov.pagopa.node.cfgsync.repository.model.StandInStations; import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiStandInOracleRepository; import it.gov.pagopa.node.cfgsync.repository.nexipostgres.NexiStandInPostgresRepository; @@ -22,13 +21,10 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.interceptor.TransactionAspectSupport; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Optional; @Service @Slf4j @@ -42,24 +38,24 @@ public class StandInManagerService extends CommonCacheService { private final ObjectMapper objectMapper; @Autowired(required = false) - private Optional pagopaPostgresRepository; + private PagoPAStandInPostgresRepository pagopaPostgresRepository; @Autowired(required = false) - private Optional nexiPostgresRepository; + private NexiStandInPostgresRepository nexiPostgresRepository; @Autowired(required = false) - private Optional nexiOracleRepository; + private NexiStandInOracleRepository nexiOracleRepository; - @Value("${app.write.standin.pagopa-postgres}") - private Boolean pagopaPostgresWrite; +// @Value("${app.write.standin.pagopa-postgres}") +// private Boolean pagopaPostgresWrite; @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgresServiceIdentifier; - @Value("${app.write.standin.nexi-postgres}") - private Boolean nexiPostgresWrite; +// @Value("${app.write.standin.nexi-postgres}") +// private Boolean nexiPostgresWrite; @Value("${app.identifiers.nexi-postgres}") private String nexiPostgresServiceIdentifier; - @Value("${app.write.standin.nexi-oracle}") - private Boolean nexiOracleWrite; +// @Value("${app.write.standin.nexi-oracle}") +// private Boolean nexiOracleWrite; @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; @@ -120,8 +116,8 @@ void saveAllDatabases(Map syncStatusMap, List syncStatusMap, List stationsEntities) { try { - if( pagopaPostgresWrite && pagopaPostgresRepository.isPresent() ) { - pagopaPostgresRepository.get().saveAll(stationsEntities); + if( null != pagopaPostgresRepository ) { + pagopaPostgresRepository.saveAll(stationsEntities); syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.disabled); @@ -134,8 +130,8 @@ private void savePagoPA(Map syncStatusMap, List syncStatusMap, List stationsEntities) { try { - if( nexiOracleWrite && nexiOracleRepository.isPresent() ) { - nexiOracleRepository.get().saveAll(stationsEntities); + if( null != nexiOracleRepository ) { + nexiOracleRepository.saveAll(stationsEntities); syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled); @@ -148,8 +144,8 @@ private void saveNexiOracle(Map syncStatusMap, List syncStatusMap, List stationsEntities) { try { - if ( nexiPostgresWrite && nexiPostgresRepository.isPresent() ) { - nexiPostgresRepository.get().saveAll(stationsEntities); + if ( null != nexiPostgresRepository ) { + nexiPostgresRepository.saveAll(stationsEntities); syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.done); } else { syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.disabled); diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index dedfda4..3ba1600 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -10,15 +10,6 @@ app: pagopa-postgres: ${DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER} nexi-postgres: ${DB_NEXI_POSTGRES_SERVICE_IDENTIFIER} nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} - write: - cache: - pagopa-postgres: 'true' - nexi-postgres: 'false' - nexi-oracle: 'false' - standin: - pagopa-postgres: 'true' - nexi-postgres: 'false' - nexi-oracle: 'false' spring: datasource: @@ -59,6 +50,11 @@ stand-in-manager: consumer: ##permette di abilitare/disabilitare il consumer enabled: 'false' + write: + ##permettono di abilitare/disabilitare la scrittura di stand-in sui vari database + pagopa-postgres: 'true' + nexi-postgres: 'false' + nexi-oracle: 'false' api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} @@ -74,6 +70,11 @@ api-config-cache: consumer: ##permette di abilitare/disabilitare il consumer enabled: 'true' + write: + ##permettono di abilitare/disabilitare la scrittura di cache sui vari database + pagopa-postgres: 'true' + nexi-postgres: 'false' + nexi-oracle: 'false' logging: level: diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 828eb9e..da2ea84 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -38,17 +38,6 @@ app: pagopa-postgres: ${DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER} nexi-postgres: ${DB_NEXI_POSTGRES_SERVICE_IDENTIFIER} nexi-oracle: ${DB_NEXI_ORACLE_SERVICE_IDENTIFIER} - write: - cache: - ##permettono di abilitare/disabilitare la scrittura di cache sui vari database - pagopa-postgres: 'true' - nexi-postgres: 'false' - nexi-oracle: 'false' - standin: - ##permettono di abilitare/disabilitare la scrittura di standin-stations sui vari database - pagopa-postgres: 'true' - nexi-postgres: 'false' - nexi-oracle: 'false' spring: datasource: @@ -89,6 +78,11 @@ stand-in-manager: consumer: ##permette di abilitare/disabilitare il consumer enabled: 'true' + write: + ##permettono di abilitare/disabilitare la scrittura di stand-in sui vari database + pagopa-postgres: 'true' + nexi-postgres: 'false' + nexi-oracle: 'false' api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} @@ -104,6 +98,11 @@ api-config-cache: consumer: ##permette di abilitare/disabilitare il consumer enabled: 'true' + write: + ##permettono di abilitare/disabilitare la scrittura di cache sui vari database + pagopa-postgres: 'true' + nexi-postgres: 'false' + nexi-oracle: 'false' logging: level: From a32bc0b8a4930d79e4dfd90c55e86036b1bb6aa2 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Fri, 1 Mar 2024 02:19:41 +0100 Subject: [PATCH 73/88] =?UTF-8?q?NOD-690:=20unit=20tests=20=C3=A8=20fix=20?= =?UTF-8?q?codice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openapi/openapi.json | 29 ++- pom.xml | 20 +- .../node/cfgsync/model/TargetRefreshEnum.java | 2 +- .../service/ApiConfigCacheEhConsumer.java | 4 +- .../service/ApiConfigCacheService.java | 49 +++-- .../cfgsync/service/CommonCacheService.java | 2 +- .../service/StandInManagerService.java | 53 +++-- .../pagopa/node/cfgsync/util/Constants.java | 4 + src/main/resources/application.yaml | 2 +- .../pagopa/node/cfgsync/CacheSyncTest.java | 207 ++++++++++++++++++ .../node/cfgsync/StandInConsumerTest.java | 81 +++++++ .../pagopa/node/cfgsync/StandInSyncTest.java | 181 +++++++++++++++ src/test/resources/application.yaml | 83 ++++--- 13 files changed, 623 insertions(+), 94 deletions(-) create mode 100644 src/test/java/it/gov/pagopa/node/cfgsync/CacheSyncTest.java create mode 100644 src/test/java/it/gov/pagopa/node/cfgsync/StandInConsumerTest.java create mode 100644 src/test/java/it/gov/pagopa/node/cfgsync/StandInSyncTest.java diff --git a/openapi/openapi.json b/openapi/openapi.json index a519910..b7d99d8 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,10 +1,10 @@ { - "openapi": "3.0.1", - "info": { - "title": "cfg-sync", - "description": "Microservice to update configuration schema of Nodo dei Pagamenti", - "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" + "openapi" : "3.0.1", + "info" : { + "title" : "cfg-sync", + "description" : "Microservice to update configuration schema of Nodo dei Pagamenti", + "termsOfService" : "https://www.pagopa.gov.it/", + "version" : "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" }, "servers" : [ { "url" : "http://localhost", @@ -12,9 +12,9 @@ } ], "paths" : { "/ndp/cache" : { - "get" : { + "put" : { "tags" : [ "Cache" ], - "summary" : "Force cache configuration update", + "summary" : "Force cache configuration to update", "operationId" : "cache", "responses" : { "200" : { @@ -111,9 +111,9 @@ } ] }, "/ndp/stand-in" : { - "get" : { + "put" : { "tags" : [ "StandIn" ], - "summary" : "Force stand-in configuration update", + "summary" : "Force stand-in configuration to update", "operationId" : "standin", "responses" : { "200" : { @@ -127,7 +127,14 @@ } }, "content" : { - "application/json" : { } + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/SyncStatusResponse" + } + } + } } }, "400" : { diff --git a/pom.xml b/pom.xml index 1e3b46a..6abd4ed 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.3 + 2.7.7 it.gov.pagopa.node @@ -99,10 +99,6 @@ - - - - com.azure.spring spring-cloud-azure-starter-integration-eventhubs @@ -115,6 +111,12 @@ ${feign-version} + + io.github.openfeign + feign-okhttp + ${feign-version} + + io.github.openfeign feign-jackson @@ -127,6 +129,13 @@ ${feign-version} + + org.mockito + mockito-inline + 2.13.0 + test + + org.springdoc @@ -137,7 +146,6 @@ com.h2database h2 - runtime diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/model/TargetRefreshEnum.java b/src/main/java/it/gov/pagopa/node/cfgsync/model/TargetRefreshEnum.java index 3b4eb4f..2d2c706 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/model/TargetRefreshEnum.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/model/TargetRefreshEnum.java @@ -2,7 +2,7 @@ public enum TargetRefreshEnum { - config("api-config-cache"), + cache("api-config-cache"), standin("stand-in-manager"); public final String label; diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java index 45c8ca4..d8ceaf2 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheEhConsumer.java @@ -49,7 +49,7 @@ public void post(){ public void processEvent(EventContext eventContext) { log.info("Processing event {} from partition {} with sequence number {} with body: {}", - TargetRefreshEnum.config.label, + TargetRefreshEnum.cache.label, eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(), eventContext.getEventData().getBodyAsString()); apiConfigCacheService.forceCacheUpdate(); @@ -57,7 +57,7 @@ public void processEvent(EventContext eventContext) { public void processError(ErrorContext errorContext) { log.error("Error occurred for {} from partition {}: {}", - TargetRefreshEnum.config.label, + TargetRefreshEnum.cache.label, errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable().getMessage(), errorContext.getThrowable()); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java index b1b7612..44f07ef 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/ApiConfigCacheService.java @@ -13,6 +13,7 @@ import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiCacheOracleRepository; import it.gov.pagopa.node.cfgsync.repository.nexipostgres.NexiCachePostgresRepository; import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPACachePostgresRepository; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -23,23 +24,22 @@ import java.time.Instant; import java.time.ZonedDateTime; import java.util.Collection; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; +import static it.gov.pagopa.node.cfgsync.util.Constants.*; + @Component +@Setter @Slf4j public class ApiConfigCacheService extends CommonCacheService { - private static final String HEADER_CACHE_ID = "X-CACHE-ID"; - private static final String HEADER_CACHE_TIMESTAMP = "X-CACHE-TIMESTAMP"; - private static final String HEADER_CACHE_VERSION = "X-CACHE-VERSION"; - @Value("${api-config-cache.service.enabled}") private boolean enabled; @Value("${api-config-cache.service.subscriptionKey}") private String subscriptionKey; - private final ApiConfigCacheClient apiConfigCacheClient; + private ApiConfigCacheClient apiConfigCacheClient; @Autowired(required = false) private PagoPACachePostgresRepository pagopaPostgresRepository; @@ -48,30 +48,33 @@ public class ApiConfigCacheService extends CommonCacheService { @Autowired(required = false) private NexiCacheOracleRepository nexiOracleRepository; -// @Value("${app.write.cache.pagopa-postgres}") -// private Boolean pagopaPostgresWrite; @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgresServiceIdentifier; -// -// @Value("${app.write.cache.nexi-postgres}") -// private Boolean nexiPostgresWrite; + @Value("${app.identifiers.nexi-postgres}") private String nexiPostgresServiceIdentifier; -// -// @Value("${app.write.cache.nexi-oracle}") -// private Boolean nexiOracleWrite; + @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; + @Value("${api-config-cache.write.pagopa-postgres}") + private boolean writePagoPa; + + @Value("${api-config-cache.write.nexi-oracle}") + private boolean writeNexiOracle; + + @Value("${api-config-cache.write.nexi-postgres}") + private boolean writeNexiPostgres; + public ApiConfigCacheService(@Value("${api-config-cache.service.host}") String apiConfigCacheUrl) { apiConfigCacheClient = Feign.builder().target(ApiConfigCacheClient.class, apiConfigCacheUrl); } public Map forceCacheUpdate() { - Map syncStatusMap = new HashMap<>(); + Map syncStatusMap = new LinkedHashMap<>(); try { if( !enabled ) { - throw new AppException(AppError.SERVICE_DISABLED, TargetRefreshEnum.config); + throw new AppException(AppError.SERVICE_DISABLED, TargetRefreshEnum.cache.label); } log.debug("SyncService api-config-cache get cache"); Response response = apiConfigCacheClient.getCache(subscriptionKey); @@ -87,9 +90,9 @@ public Map forceCacheUpdate() { log.error("SyncService api-config-cache get cache error - empty header"); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } - String cacheId = (String) getHeaderParameter(TargetRefreshEnum.config, headers, HEADER_CACHE_ID); - String cacheTimestamp = (String) getHeaderParameter(TargetRefreshEnum.config, headers, HEADER_CACHE_TIMESTAMP); - String cacheVersion = (String) getHeaderParameter(TargetRefreshEnum.config, headers, HEADER_CACHE_VERSION); + String cacheId = (String) getHeaderParameter(TargetRefreshEnum.cache.label, headers, HEADER_CACHE_ID); + String cacheTimestamp = (String) getHeaderParameter(TargetRefreshEnum.cache.label, headers, HEADER_CACHE_TIMESTAMP); + String cacheVersion = (String) getHeaderParameter(TargetRefreshEnum.cache.label, headers, HEADER_CACHE_VERSION); log.info("SyncService cacheId:[{}], cacheTimestamp:[{}], cacheVersion:[{}]", cacheId, Instant.from(ZonedDateTime.parse(cacheTimestamp)), cacheVersion); @@ -102,6 +105,8 @@ public Map forceCacheUpdate() { } catch (FeignException.GatewayTimeout e) { log.error("SyncService api-config-cache get cache error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } catch(AppException appException) { + throw appException; } catch (Exception e) { log.error("SyncService api-config-cache get cache error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); @@ -128,7 +133,7 @@ void saveAllDatabases(Map syncStatusMap, ConfigCache con private void savePagoPA(Map syncStatusMap, ConfigCache configCache) { try { - if( null != pagopaPostgresRepository ) { + if( writePagoPa ) { pagopaPostgresRepository.save(configCache); syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); } else { @@ -142,7 +147,7 @@ private void savePagoPA(Map syncStatusMap, ConfigCache c private void saveNexiOracle(Map syncStatusMap, ConfigCache configCache) { try { - if( null != nexiOracleRepository ) { + if( writeNexiOracle ) { nexiOracleRepository.save(configCache); syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); } else { @@ -156,7 +161,7 @@ private void saveNexiOracle(Map syncStatusMap, ConfigCac private void saveNexiPostgres(Map syncStatusMap, ConfigCache configCache) { try { - if ( null != nexiPostgresRepository ) { + if ( writeNexiPostgres ) { nexiPostgresRepository.save(configCache); syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.done); } else { diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java index fe2abeb..ddf0638 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/CommonCacheService.java @@ -27,7 +27,7 @@ protected ConfigCache composeCache(String cacheId, ZonedDateTime timestamp, Stri return new ConfigCache(cacheId, timestamp, Utils.zipContent(cache), version); } - protected Object getHeaderParameter(TargetRefreshEnum target, Map> headers, String key) { + protected Object getHeaderParameter(String target, Map> headers, String key) { List valueList = headers.get(key).stream().toList(); if(valueList.isEmpty()) { log.error("SyncService {} get cache error - empty parameter '{}'", target, key); diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java index 0df5d14..7bb5585 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/service/StandInManagerService.java @@ -15,6 +15,7 @@ import it.gov.pagopa.node.cfgsync.repository.nexioracle.NexiStandInOracleRepository; import it.gov.pagopa.node.cfgsync.repository.nexipostgres.NexiStandInPostgresRepository; import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgresRepository; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -23,10 +24,12 @@ import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @Service +@Setter @Slf4j public class StandInManagerService extends CommonCacheService { @@ -34,8 +37,9 @@ public class StandInManagerService extends CommonCacheService { private boolean enabled; @Value("${stand-in-manager.service.subscriptionKey}") private String subscriptionKey; - private final StandInManagerClient standInManagerClient; - private final ObjectMapper objectMapper; + + private StandInManagerClient standInManagerClient; + private ObjectMapper objectMapper; @Autowired(required = false) private PagoPAStandInPostgresRepository pagopaPostgresRepository; @@ -44,31 +48,34 @@ public class StandInManagerService extends CommonCacheService { @Autowired(required = false) private NexiStandInOracleRepository nexiOracleRepository; -// @Value("${app.write.standin.pagopa-postgres}") -// private Boolean pagopaPostgresWrite; @Value("${app.identifiers.pagopa-postgres}") private String pagopaPostgresServiceIdentifier; -// @Value("${app.write.standin.nexi-postgres}") -// private Boolean nexiPostgresWrite; @Value("${app.identifiers.nexi-postgres}") private String nexiPostgresServiceIdentifier; -// @Value("${app.write.standin.nexi-oracle}") -// private Boolean nexiOracleWrite; @Value("${app.identifiers.nexi-oracle}") private String nexiOracleServiceIdentifier; + @Value("${stand-in-manager.write.pagopa-postgres}") + private boolean writePagoPa; + + @Value("${stand-in-manager.write.nexi-oracle}") + private boolean writeNexiOracle; + + @Value("${stand-in-manager.write.nexi-postgres}") + private boolean writeNexiPostgres; + public StandInManagerService(@Value("${stand-in-manager.service.host}") String standInManagerUrl, ObjectMapper objectMapper) { standInManagerClient = Feign.builder().target(StandInManagerClient.class, standInManagerUrl); this.objectMapper = objectMapper; } public Map forceStandIn() { - Map syncStatusMap = new HashMap<>(); + Map syncStatusMap = new LinkedHashMap<>(); try { if( !enabled ) { - throw new AppException(AppError.SERVICE_DISABLED, TargetRefreshEnum.standin); + throw new AppException(AppError.SERVICE_DISABLED, TargetRefreshEnum.standin.label); } log.debug("SyncService stand-in-manager get stations"); Response response = standInManagerClient.getCache(subscriptionKey); @@ -83,40 +90,42 @@ public Map forceStandIn() { log.info("SyncService {} stations found", stations.getStations().size()); List stationsEntities = stations.getStations().stream().map(StandInStations::new).toList(); - saveAllDatabases(syncStatusMap, stationsEntities); - } catch (SyncDbStatusException e) { - //viene usata per poter restituire in risposta la mappa degli aggiornamenti - return syncStatusMap; + return saveAllDatabases(syncStatusMap, stationsEntities); } catch (FeignException.GatewayTimeout e) { log.error("SyncService stand-in-manager get stations error: Gateway timeout", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); + } catch(AppException appException) { + throw appException; } catch (Exception e) { log.error("SyncService stand-in-manager get cache error", e); throw new AppException(AppError.INTERNAL_SERVER_ERROR); } - return syncStatusMap; } @Transactional(rollbackFor={SyncDbStatusException.class}) - void saveAllDatabases(Map syncStatusMap, List stationsEntities) throws SyncDbStatusException { + Map saveAllDatabases(Map syncStatusMap, List stationsEntities) { savePagoPA(syncStatusMap, stationsEntities); saveNexiPostgres(syncStatusMap, stationsEntities); saveNexiOracle(syncStatusMap, stationsEntities); + Map syncStatusMapUpdated = new LinkedHashMap<>(); if( syncStatusMap.containsValue(SyncStatusEnum.error) ) { syncStatusMap.forEach((k, v) -> { if (v == SyncStatusEnum.done) { - syncStatusMap.remove(k); - syncStatusMap.put(k, SyncStatusEnum.rollback); + syncStatusMapUpdated.put(k, SyncStatusEnum.rollback); + } else { + syncStatusMapUpdated.put(k, v); } }); - throw new SyncDbStatusException("Rollback sync"); + return syncStatusMapUpdated; + } else { + return syncStatusMap; } } private void savePagoPA(Map syncStatusMap, List stationsEntities) { try { - if( null != pagopaPostgresRepository ) { + if( writePagoPa ) { pagopaPostgresRepository.saveAll(stationsEntities); syncStatusMap.put(pagopaPostgresServiceIdentifier, SyncStatusEnum.done); } else { @@ -130,7 +139,7 @@ private void savePagoPA(Map syncStatusMap, List syncStatusMap, List stationsEntities) { try { - if( null != nexiOracleRepository ) { + if( writeNexiOracle ) { nexiOracleRepository.saveAll(stationsEntities); syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done); } else { @@ -144,7 +153,7 @@ private void saveNexiOracle(Map syncStatusMap, List syncStatusMap, List stationsEntities) { try { - if ( null != nexiPostgresRepository ) { + if ( writeNexiPostgres ) { nexiPostgresRepository.saveAll(stationsEntities); syncStatusMap.put(nexiPostgresServiceIdentifier, SyncStatusEnum.done); } else { diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/util/Constants.java b/src/main/java/it/gov/pagopa/node/cfgsync/util/Constants.java index d64ba1a..635b731 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/util/Constants.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/util/Constants.java @@ -8,4 +8,8 @@ public class Constants { public static final String HEADER_REQUEST_ID = "X-Request-Id"; + public static final String HEADER_CACHE_ID = "X-CACHE-ID"; + public static final String HEADER_CACHE_TIMESTAMP = "X-CACHE-TIMESTAMP"; + public static final String HEADER_CACHE_VERSION = "X-CACHE-VERSION"; + } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index da2ea84..ad1a742 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -88,7 +88,7 @@ api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-cache service: - host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 + host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1/stakeholders/node/cache/schemas/v1 subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} ##permette di abilitare/disabilitare la chiamata al servizio tramite API enabled: 'true' diff --git a/src/test/java/it/gov/pagopa/node/cfgsync/CacheSyncTest.java b/src/test/java/it/gov/pagopa/node/cfgsync/CacheSyncTest.java new file mode 100644 index 0000000..a2f1aac --- /dev/null +++ b/src/test/java/it/gov/pagopa/node/cfgsync/CacheSyncTest.java @@ -0,0 +1,207 @@ +package it.gov.pagopa.node.cfgsync; + +import com.fasterxml.jackson.databind.ObjectMapper; +import feign.Feign; +import feign.FeignException; +import feign.Request; +import feign.Response; +import feign.mock.MockClient; +import feign.mock.MockTarget; +import it.gov.pagopa.node.cfgsync.client.ApiConfigCacheClient; +import it.gov.pagopa.node.cfgsync.client.StandInManagerClient; +import it.gov.pagopa.node.cfgsync.model.*; +import it.gov.pagopa.node.cfgsync.service.ApiConfigCacheService; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.util.ReflectionTestUtils; + +import java.nio.charset.StandardCharsets; +import java.time.Instant; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static it.gov.pagopa.node.cfgsync.util.Constants.*; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +class CacheSyncTest { + + public static final String CACHE_URL = "/ndp/cache"; + public static final String CLIENT_CACHE_PATH = "/cache"; + + @Autowired private ApiConfigCacheService cacheManagerService; + @Autowired private TestRestTemplate restTemplate; + private MockClient mockClient; + + @LocalServerPort private int port; + + @Mock + ApiConfigCacheClient apiConfigCacheClient; + + @Test + void syncCache_400() { + ReflectionTestUtils.setField(cacheManagerService, "enabled", false); + ResponseEntity response = restTemplate.exchange(CACHE_URL, HttpMethod.PUT, null, ProblemJson.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); + assertThat(response.getBody().getTitle()).isEqualTo("Target service disabled"); + assertThat(response.getBody().getStatus()).isEqualTo(400); + assertThat(response.getBody().getDetail()).isEqualTo("Target service api-config-cache disabled"); + ReflectionTestUtils.setField(cacheManagerService, "enabled", true); + } + + @Test + void syncCache_500() { + mockClient = new MockClient().noContent(feign.mock.HttpMethod.GET, CLIENT_CACHE_PATH); + ApiConfigCacheClient apiConfigCacheClient = + Feign.builder().client(mockClient).target(new MockTarget<>(ApiConfigCacheClient.class)); + cacheManagerService.setApiConfigCacheClient(apiConfigCacheClient); + + ResponseEntity response = restTemplate.exchange(CACHE_URL, HttpMethod.PUT, null, ProblemJson.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + assertThat(response.getBody().getStatus()).isEqualTo(500); + assertThat(response.getBody().getTitle()).isEqualTo("Internal Server Error"); + } + + @Test + void ssyncCache_500_ConnectionRefused() { +// mockClient = new MockClient().noContent(feign.mock.HttpMethod.GET, "/stations"); +// standInManagerClient = +// Feign.builder().client(mockClient).target(new MockTarget<>(StandInManagerClient.class)); +// standInManagerService.setStandInManagerClient(standInManagerClient); + + Request request = mock(Request.class); + when(apiConfigCacheClient.getCache(anyString())) + .thenThrow(new FeignException.NotFound("message", request, null, null)); + + ResponseEntity response = restTemplate.exchange(CACHE_URL, HttpMethod.PUT, null, ProblemJson.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + assertThat(response.getBody().getStatus()).isEqualTo(500); + assertThat(response.getBody().getTitle()).isEqualTo("Internal Server Error"); + } + +// @Test +// void syncCache_WritePagoPAPostgresDisabled() throws Exception { +// ObjectMapper objectMapper = new ObjectMapper(); +// +//// HttpHeaders headers = new HttpHeaders(); +//// headers.put(HEADER_CACHE_ID, List.of(String.valueOf(System.currentTimeMillis()))); +//// headers.put(HEADER_CACHE_TIMESTAMP, List.of(Instant.now().toString())); +//// headers.put(HEADER_CACHE_VERSION, List.of("v1.0.0")); +// +// Map> headers = new HashMap<>(); +// headers.put(HEADER_CACHE_ID, List.of(String.valueOf(System.currentTimeMillis()))); +// headers.put(HEADER_CACHE_TIMESTAMP, List.of(Instant.now().toString())); +// headers.put(HEADER_CACHE_VERSION, List.of("v1.0.0")); +// +//// mockClient = new MockClient().ok(feign.mock.HttpMethod.GET, CLIENT_CACHE_PATH, ResponseEntity.ok().headers(headers).build().toString()); +// +// Request request = mock(Request.class); +// mockClient = new MockClient() +// .ok( +// feign.mock.HttpMethod.GET, +// CLIENT_CACHE_PATH, +// Response +// .builder() +// .headers(headers) +// .request(request) +// .body(new byte[0]) +// .build().toString()); +//// mockClient = new MockClient() +//// .ok( +//// feign.mock.HttpMethod.GET, +//// CLIENT_CACHE_PATH, +//// Response +//// .builder() +//// .status(200) +//// .reason("Mocked") +//// .headers(headers) +//// .body(new byte[0]) +//// .build() +//// .toString()); +// ApiConfigCacheClient apiConfigCacheClient = +// Feign.builder().client(mockClient).target(new MockTarget<>(ApiConfigCacheClient.class)); +// cacheManagerService.setApiConfigCacheClient(apiConfigCacheClient); +// ReflectionTestUtils.setField(cacheManagerService, "writePagoPa", false); +// +// ResponseEntity> response = restTemplate.exchange(CACHE_URL, HttpMethod.PUT, null, new ParameterizedTypeReference<>() {}); +// +// assertThat(response.getBody()).isNotNull(); +// assertFalse(response.getHeaders().isEmpty()); +// assertEquals(3, response.getBody()); +// assertThat(response.getBody().get(0).getServiceIdentifier()).isEqualTo("NDP001"); +// assertThat(response.getBody().get(0).getStatus()).isEqualTo(SyncStatusEnum.disabled); +// ReflectionTestUtils.setField(cacheManagerService, "writePagoPa", true); +// } + +// @Test +// void syncCache_WriteNexiOracleDisabled() throws Exception { +// ObjectMapper objectMapper = new ObjectMapper(); +// StationsResponse stationsResponse = StationsResponse.builder().stations(List.of("1234567890", "9876543210")).build(); +// +// mockClient = new MockClient().ok(feign.mock.HttpMethod.GET, CLIENT_CACHE_PATH, objectMapper.writeValueAsBytes(stationsResponse)); +// ApiConfigCacheClient apiConfigCacheClient = +// Feign.builder().client(mockClient).target(new MockTarget<>(ApiConfigCacheClient.class)); +// cacheManagerService.setApiConfigCacheClient(apiConfigCacheClient); +// ReflectionTestUtils.setField(cacheManagerService, "writeNexiOracle", false); +// +// ResponseEntity> response = restTemplate.exchange(CACHE_URL, HttpMethod.PUT, null, new ParameterizedTypeReference<>() {}); +// +// List syncStatusResponseList = response.getBody(); +// +// assertThat(syncStatusResponseList).isNotNull(); +// assertFalse(syncStatusResponseList.isEmpty()); +// assertEquals(3, syncStatusResponseList.size()); +// assertThat(syncStatusResponseList.get(2).getServiceIdentifier()).isEqualTo("NDP003"); +// assertThat(syncStatusResponseList.get(2).getStatus()).isEqualTo(SyncStatusEnum.disabled); +// ReflectionTestUtils.setField(cacheManagerService, "writeNexiOracle", true); +// } + +// @Test +// void syncCache_WriteNexiPostgresDisabled() throws Exception { +// ObjectMapper objectMapper = new ObjectMapper(); +// StationsResponse stationsResponse = StationsResponse.builder().stations(List.of("1234567890", "9876543210")).build(); +// +// mockClient = new MockClient().ok(feign.mock.HttpMethod.GET, CLIENT_CACHE_PATH, objectMapper.writeValueAsBytes(stationsResponse)); +// ApiConfigCacheClient apiConfigCacheClient = +// Feign.builder().client(mockClient).target(new MockTarget<>(ApiConfigCacheClient.class)); +// cacheManagerService.setApiConfigCacheClient(apiConfigCacheClient); +// ReflectionTestUtils.setField(cacheManagerService, "writeNexiPostgres", false); +// +// ResponseEntity> response = restTemplate.exchange(CACHE_URL, HttpMethod.PUT, null, new ParameterizedTypeReference<>() {}); +// +// List syncStatusResponseList = response.getBody(); +// +// assertThat(syncStatusResponseList).isNotNull(); +// assertFalse(syncStatusResponseList.isEmpty()); +// assertEquals(3, syncStatusResponseList.size()); +// assertThat(syncStatusResponseList.get(1).getServiceIdentifier()).isEqualTo("NDP004DEV"); +// assertThat(syncStatusResponseList.get(1).getStatus()).isEqualTo(SyncStatusEnum.disabled); +// +// ReflectionTestUtils.setField(cacheManagerService, "writeNexiPostgres", true); +// } + +} diff --git a/src/test/java/it/gov/pagopa/node/cfgsync/StandInConsumerTest.java b/src/test/java/it/gov/pagopa/node/cfgsync/StandInConsumerTest.java new file mode 100644 index 0000000..4c414e7 --- /dev/null +++ b/src/test/java/it/gov/pagopa/node/cfgsync/StandInConsumerTest.java @@ -0,0 +1,81 @@ +//package it.gov.pagopa.node.cfgsync; +// +//import com.azure.messaging.eventhubs.models.EventContext; +//import com.fasterxml.jackson.databind.ObjectMapper; +//import feign.Feign; +//import feign.mock.MockClient; +//import feign.mock.MockTarget; +//import it.gov.pagopa.node.cfgsync.client.StandInManagerClient; +//import it.gov.pagopa.node.cfgsync.model.ProblemJson; +//import it.gov.pagopa.node.cfgsync.model.StationsResponse; +//import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; +//import it.gov.pagopa.node.cfgsync.model.SyncStatusResponse; +//import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgresRepository; +//import it.gov.pagopa.node.cfgsync.service.StandInManagerEhConsumer; +//import it.gov.pagopa.node.cfgsync.service.StandInManagerService; +//import org.junit.jupiter.api.Test; +//import org.junit.jupiter.api.extension.ExtendWith; +//import org.junit.runner.RunWith; +//import org.mockito.ArgumentMatchers; +//import org.mockito.InjectMocks; +//import org.mockito.Mock; +//import org.mockito.Mockito; +//import org.mockito.junit.jupiter.MockitoExtension; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.boot.test.web.client.TestRestTemplate; +//import org.springframework.boot.test.web.server.LocalServerPort; +//import org.springframework.core.ParameterizedTypeReference; +//import org.springframework.http.HttpMethod; +//import org.springframework.http.HttpStatus; +//import org.springframework.http.ResponseEntity; +//import org.springframework.test.context.junit.jupiter.SpringExtension; +//import org.springframework.test.context.junit4.SpringRunner; +//import org.springframework.test.util.ReflectionTestUtils; +// +//import java.util.List; +// +//import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +//import static org.hamcrest.Matchers.any; +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.assertFalse; +//import static org.mockito.BDDMockito.given; +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +// +//@ExtendWith(MockitoExtension.class) +//@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +//@AutoConfigureMockMvc +//@RunWith(SpringRunner.class) +//class StandInConsumerTest { +// +// public static final String STATIONS_PATH = "/stations"; +// +// @Autowired private StandInManagerService standInManagerService; +// @Autowired private TestRestTemplate restTemplate; +// private MockClient mockClient; +// +// @Mock StandInManagerEhConsumer standInManagerEhConsumer; +// +// @InjectMocks +// private EventContext eventContext; +// +// @Test +// void syncStandIn_400() { +// +// +// StandInManagerEhConsumer consumerClient = mock(StandInManagerEhConsumer.class); +// +// when(consumerClient.processEvent(any())).thenReturn(eventsPublisher.flux()); +// +// standInManagerEhConsumer.processEvent(eventContext); +// +// Mockito.when(standInManagerEhConsumer.processEvent(ArgumentMatchers.any())) +// .thenAnswer(a -> Mono.just(new Object())); +// +// given(standInManagerEhConsumer.processEvent(eventContext)).then( v -> ""); +// assertThat("pippo").isEqualTo("pippo"); +// } +// +//} diff --git a/src/test/java/it/gov/pagopa/node/cfgsync/StandInSyncTest.java b/src/test/java/it/gov/pagopa/node/cfgsync/StandInSyncTest.java new file mode 100644 index 0000000..2ca8cd9 --- /dev/null +++ b/src/test/java/it/gov/pagopa/node/cfgsync/StandInSyncTest.java @@ -0,0 +1,181 @@ +package it.gov.pagopa.node.cfgsync; + +import com.fasterxml.jackson.databind.ObjectMapper; +import feign.Feign; +import feign.mock.MockClient; +import feign.mock.MockTarget; +import it.gov.pagopa.node.cfgsync.client.StandInManagerClient; +import it.gov.pagopa.node.cfgsync.model.ProblemJson; +import it.gov.pagopa.node.cfgsync.model.StationsResponse; +import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum; +import it.gov.pagopa.node.cfgsync.model.SyncStatusResponse; +import it.gov.pagopa.node.cfgsync.repository.pagopa.PagoPAStandInPostgresRepository; +import it.gov.pagopa.node.cfgsync.service.StandInManagerService; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.util.ReflectionTestUtils; + +import java.util.List; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +class StandInSyncTest { + + public static final String STANDIN_URL = "/ndp/stand-in"; + public static final String STATIONS_PATH = "/stations"; + + @Autowired private StandInManagerService standInManagerService; + @Autowired private TestRestTemplate restTemplate; + private MockClient mockClient; + + @LocalServerPort private int port; + + @Test + void syncStandIn_400() { + ReflectionTestUtils.setField(standInManagerService, "enabled", false); + ResponseEntity response = restTemplate.exchange(STANDIN_URL, HttpMethod.PUT, null, ProblemJson.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); + assertThat(response.getBody().getStatus()).isEqualTo(400); + assertThat(response.getBody().getTitle()).isEqualTo("Target service disabled"); + assertThat(response.getBody().getDetail()).isEqualTo("Target service stand-in-manager disabled"); + ReflectionTestUtils.setField(standInManagerService, "enabled", true); + } + + @Test + void syncStandIn_500() { + mockClient = new MockClient().noContent(feign.mock.HttpMethod.GET, "/stations"); + StandInManagerClient standInManagerClient = + Feign.builder().client(mockClient).target(new MockTarget<>(StandInManagerClient.class)); + standInManagerService.setStandInManagerClient(standInManagerClient); + + ResponseEntity response = restTemplate.exchange(STANDIN_URL, HttpMethod.PUT, null, ProblemJson.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + assertThat(response.getBody().getStatus()).isEqualTo(500); + assertThat(response.getBody().getTitle()).isEqualTo("Internal Server Error"); + } + +// @Test +// void syncStandIn_500_ConnectionRefused() { +// Request request = mock(Request.class); +// when(standInManagerClient.getCache(anyString())) +// .thenThrow(new FeignException.NotFound("message", request, null, null)); +// +// ResponseEntity response = restTemplate.exchange(STANDIN_URL, HttpMethod.PUT, null, ProblemJson.class); +// assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); +// assertThat(response.getBody().getStatus()).isEqualTo(500); +// assertThat(response.getBody().getTitle()).isEqualTo("Internal Server Error"); +// } + + @Test + void syncStandIn_ErrorWriteDB() throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + StationsResponse stationsResponse = StationsResponse.builder().stations(List.of("1234567890", "9876543210")).build(); + + mockClient = new MockClient().ok(feign.mock.HttpMethod.GET, STATIONS_PATH, objectMapper.writeValueAsBytes(stationsResponse)); + StandInManagerClient standInManagerClient = + Feign.builder().client(mockClient).target(new MockTarget<>(StandInManagerClient.class)); + standInManagerService.setStandInManagerClient(standInManagerClient); + PagoPAStandInPostgresRepository paStandInPostgresRepository = (PagoPAStandInPostgresRepository)ReflectionTestUtils.getField(standInManagerService, "pagopaPostgresRepository"); + ReflectionTestUtils.setField(standInManagerService, "pagopaPostgresRepository", null); + + ResponseEntity> response = restTemplate.exchange(STANDIN_URL, HttpMethod.PUT, null, new ParameterizedTypeReference<>() {}); + + assertThat(response.getBody()).isNotNull(); + assertFalse(response.getBody().isEmpty()); + assertEquals(3, response.getBody().size()); + assertThat(response.getBody().get(0).getServiceIdentifier()).isEqualTo("NDP001"); + assertThat(response.getBody().get(0).getStatus()).isEqualTo(SyncStatusEnum.error); + assertThat(response.getBody().get(1).getServiceIdentifier()).isEqualTo("NDP004DEV"); + assertThat(response.getBody().get(1).getStatus()).isEqualTo(SyncStatusEnum.rollback); + assertThat(response.getBody().get(2).getServiceIdentifier()).isEqualTo("NDP003"); + assertThat(response.getBody().get(2).getStatus()).isEqualTo(SyncStatusEnum.rollback); + ReflectionTestUtils.setField(standInManagerService, "pagopaPostgresRepository", paStandInPostgresRepository); + } + + @Test + void syncStandIn_WritePagoPAPostgresDisabled() throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + StationsResponse stationsResponse = StationsResponse.builder().stations(List.of("1234567890", "9876543210")).build(); + + mockClient = new MockClient().ok(feign.mock.HttpMethod.GET, STATIONS_PATH, objectMapper.writeValueAsBytes(stationsResponse)); + StandInManagerClient standInManagerClient = + Feign.builder().client(mockClient).target(new MockTarget<>(StandInManagerClient.class)); + standInManagerService.setStandInManagerClient(standInManagerClient); + ReflectionTestUtils.setField(standInManagerService, "writePagoPa", false); + + ResponseEntity> response = restTemplate.exchange(STANDIN_URL, HttpMethod.PUT, null, new ParameterizedTypeReference<>() {}); + + assertThat(response.getBody()).isNotNull(); + assertFalse(response.getBody().isEmpty()); + assertEquals(3, response.getBody().size()); + assertThat(response.getBody().get(0).getServiceIdentifier()).isEqualTo("NDP001"); + assertThat(response.getBody().get(0).getStatus()).isEqualTo(SyncStatusEnum.disabled); + ReflectionTestUtils.setField(standInManagerService, "writePagoPa", true); + } + + @Test + void syncStandIn_WriteNexiOracleDisabled() throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + StationsResponse stationsResponse = StationsResponse.builder().stations(List.of("1234567890", "9876543210")).build(); + + mockClient = new MockClient().ok(feign.mock.HttpMethod.GET, STATIONS_PATH, objectMapper.writeValueAsBytes(stationsResponse)); + StandInManagerClient standInManagerClient = + Feign.builder().client(mockClient).target(new MockTarget<>(StandInManagerClient.class)); + standInManagerService.setStandInManagerClient(standInManagerClient); + ReflectionTestUtils.setField(standInManagerService, "writeNexiOracle", false); + + ResponseEntity> response = restTemplate.exchange(STANDIN_URL, HttpMethod.PUT, null, new ParameterizedTypeReference<>() {}); + + List syncStatusResponseList = response.getBody(); + + assertThat(syncStatusResponseList).isNotNull(); + assertFalse(syncStatusResponseList.isEmpty()); + assertEquals(3, syncStatusResponseList.size()); + assertThat(syncStatusResponseList.get(2).getServiceIdentifier()).isEqualTo("NDP003"); + assertThat(syncStatusResponseList.get(2).getStatus()).isEqualTo(SyncStatusEnum.disabled); + ReflectionTestUtils.setField(standInManagerService, "writeNexiOracle", true); + } + + @Test + void syncStandIn_WriteNexiPostgresDisabled() throws Exception { + ObjectMapper objectMapper = new ObjectMapper(); + StationsResponse stationsResponse = StationsResponse.builder().stations(List.of("1234567890", "9876543210")).build(); + + mockClient = new MockClient().ok(feign.mock.HttpMethod.GET, STATIONS_PATH, objectMapper.writeValueAsBytes(stationsResponse)); + StandInManagerClient standInManagerClient = + Feign.builder().client(mockClient).target(new MockTarget<>(StandInManagerClient.class)); + standInManagerService.setStandInManagerClient(standInManagerClient); + ReflectionTestUtils.setField(standInManagerService, "writeNexiPostgres", false); + + ResponseEntity> response = restTemplate.exchange(STANDIN_URL, HttpMethod.PUT, null, new ParameterizedTypeReference<>() {}); + + List syncStatusResponseList = response.getBody(); + + assertThat(syncStatusResponseList).isNotNull(); + assertFalse(syncStatusResponseList.isEmpty()); + assertEquals(3, syncStatusResponseList.size()); + assertThat(syncStatusResponseList.get(1).getServiceIdentifier()).isEqualTo("NDP004DEV"); + assertThat(syncStatusResponseList.get(1).getStatus()).isEqualTo(SyncStatusEnum.disabled); + + ReflectionTestUtils.setField(standInManagerService, "writeNexiPostgres", true); + } + +} diff --git a/src/test/resources/application.yaml b/src/test/resources/application.yaml index 369c006..66bf745 100644 --- a/src/test/resources/application.yaml +++ b/src/test/resources/application.yaml @@ -38,67 +38,94 @@ app: pagopa-postgres: 'NDP001' nexi-postgres: 'NDP004DEV' nexi-oracle: 'NDP003' - write: - cache: - pagopa-postgres: 'false' - nexi-postgres: 'false' - nexi-oracle: 'false' - standin: - pagopa-postgres: 'false' - nexi-postgres: 'false' - nexi-oracle: 'false' spring: datasource: + url: jdbc:h2:mem:foo;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: + driver-class-name: org.h2.Driver pagopa: postgres: - url: ${DB_PAGOPA_POSTGRES_URL} - username: ${DB_PAGOPA_POSTGRES_USER} - password: ${DB_PAGOPA_POSTGRES_PASSWORD} - enabled: 'false' + url: jdbc:h2:mem:pagopa;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: + ##permette di abilitare/disabilitare il datasource al db Postgres PagoPA + enabled: 'true' nexi: oracle: - url: ${DB_NEXI_ORACLE_URL} - username: ${DB_NEXI_ORACLE_USER} - password: ${DB_NEXI_ORACLE_PASSWORD} - enabled: 'false' + url: jdbc:h2:mem:nexi_oracle;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: + ##permette di abilitare/disabilitare il datasource al db Oracle Nexi + enabled: 'true' postgres: - url: ${DB_NEXI_POSTGRES_URL} - username: ${DB_NEXI_POSTGRES_USER} - password: ${DB_NEXI_POSTGRES_PASSWORD} - enabled: 'false' + url: jdbc:h2:mem:nexi_postgres;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: + ##permette di abilitare/disabilitare il datasource al db Postgres Nexi + enabled: 'true' jpa: - show-sql: 'false' + database: default + generate-ddl: true +# database-platform: org.hibernate.dialect.H2Dialect + hibernate: + ddl-auto: 'create-drop' +# defer-datasource-initialization: true +# show-sql: true +# properties: +# hibernate: +# dialect: H2Dialect +# format_sql: true + h2: + console: + enabled: 'true' + sql: + init: + mode: always stand-in-manager: rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-stand-in service: subscriptionKey: '' - enabled: 'false' - host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 + enabled: 'true' + host: http://localhost:1080 sa-connection-string: ${STAND_IN_MANAGER_SA_CONNECTION_STRING} sa-name: standinevents consumer-group: $Default consumer: + ##permette di abilitare/disabilitare il consumer enabled: 'false' + write: + ##permettono di abilitare/disabilitare la scrittura di stand-in sui vari database + pagopa-postgres: 'true' + nexi-postgres: 'true' + nexi-oracle: 'true' api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-cache service: + host: http://localhost:1080 subscriptionKey: '' - host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1 - enabled: 'false' + ##permette di abilitare/disabilitare la chiamata al servizio tramite API + enabled: 'true' sa-connection-string: ${API_CONFIG_CACHE_SA_CONNECTION_STRING} sa-name: cacheevents consumer-group: $Default consumer: + ##permette di abilitare/disabilitare il consumer enabled: 'false' + write: + ##permettono di abilitare/disabilitare la scrittura di cache sui vari database + pagopa-postgres: 'true' + nexi-postgres: 'true' + nexi-oracle: 'true' logging: level: it: gov: - pagopa: ${APP_LOGGING_LEVEL:INFO} - root: ${DEFAULT_LOGGING_LEVEL:INFO} \ No newline at end of file + pagopa: DEBUG + root: INFO \ No newline at end of file From 1d28a8d23d110d0a6f1469fde24ca2f90145f948 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 1 Mar 2024 08:13:01 +0000 Subject: [PATCH 74/88] Bump to version 0.0.0-27-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 +- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 382 ++++++++++++++++++++++-------------------- pom.xml | 2 +- 6 files changed, 208 insertions(+), 186 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 9e49121..b3e4ea0 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.26.0 -appVersion: 0.0.0-26-NOD-690-nodo-cfg-sync-microservizio +version: 0.27.0 +appVersion: 0.0.0-27-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index d3d737a..a413f95 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-27-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index d83dbb8..f27bcd8 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-27-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 602e75a..62b1936 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-27-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index b7d99d8..874c6ee 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,264 +1,286 @@ { - "openapi" : "3.0.1", - "info" : { - "title" : "cfg-sync", - "description" : "Microservice to update configuration schema of Nodo dei Pagamenti", - "termsOfService" : "https://www.pagopa.gov.it/", - "version" : "0.0.0-26-NOD-690-nodo-cfg-sync-microservizio" + "openapi": "3.0.1", + "info": { + "title": "cfg-sync", + "description": "Microservice to update configuration schema of Nodo dei Pagamenti", + "termsOfService": "https://www.pagopa.gov.it/", + "version": "0.0.0-27-NOD-690-nodo-cfg-sync-microservizio" }, - "servers" : [ { - "url" : "http://localhost", - "description" : "Generated server url" - } ], - "paths" : { - "/ndp/cache" : { - "put" : { - "tags" : [ "Cache" ], - "summary" : "Force cache configuration to update", - "operationId" : "cache", - "responses" : { - "200" : { - "description" : "OK", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/ndp/cache": { + "put": { + "tags": [ + "Cache" + ], + "summary": "Force cache configuration to update", + "operationId": "cache", + "responses": { + "200": { + "description": "OK", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/SyncStatusResponse" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SyncStatusResponse" } } } } }, - "400" : { - "description" : "Bad Request", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "400": { + "description": "Bad Request", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } }, - "401" : { - "description" : "Unauthorized", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "401": { + "description": "Unauthorized", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "429" : { - "description" : "Too many requests", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "429": { + "description": "Too many requests", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "500" : { - "description" : "Service unavailable", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "500": { + "description": "Service unavailable", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } } }, - "security" : [ { - "ApiKey" : [ ] - } ] + "security": [ + { + "ApiKey": [] + } + ] }, - "parameters" : [ { - "name" : "X-Request-Id", - "in" : "header", - "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema" : { - "type" : "string" + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } } - } ] + ] }, - "/ndp/stand-in" : { - "put" : { - "tags" : [ "StandIn" ], - "summary" : "Force stand-in configuration to update", - "operationId" : "standin", - "responses" : { - "200" : { - "description" : "OK", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "/ndp/stand-in": { + "put": { + "tags": [ + "StandIn" + ], + "summary": "Force stand-in configuration to update", + "operationId": "standin", + "responses": { + "200": { + "description": "OK", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/SyncStatusResponse" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SyncStatusResponse" } } } } }, - "400" : { - "description" : "Bad Request", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "400": { + "description": "Bad Request", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } }, - "401" : { - "description" : "Unauthorized", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "401": { + "description": "Unauthorized", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "429" : { - "description" : "Too many requests", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "429": { + "description": "Too many requests", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } } }, - "500" : { - "description" : "Service unavailable", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "500": { + "description": "Service unavailable", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ProblemJson" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProblemJson" } } } } }, - "security" : [ { - "ApiKey" : [ ] - } ] + "security": [ + { + "ApiKey": [] + } + ] }, - "parameters" : [ { - "name" : "X-Request-Id", - "in" : "header", - "description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema" : { - "type" : "string" + "parameters": [ + { + "name": "X-Request-Id", + "in": "header", + "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", + "schema": { + "type": "string" + } } - } ] + ] } }, - "components" : { - "schemas" : { - "ProblemJson" : { - "type" : "object", - "properties" : { - "title" : { - "type" : "string", - "description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" + "components": { + "schemas": { + "ProblemJson": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable" }, - "status" : { - "maximum" : 600, - "minimum" : 100, - "type" : "integer", - "description" : "The HTTP status code generated by the origin server for this occurrence of the problem.", - "format" : "int32", - "example" : 200 + "status": { + "maximum": 600, + "minimum": 100, + "type": "integer", + "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", + "format": "int32", + "example": 200 }, - "detail" : { - "type" : "string", - "description" : "A human readable explanation specific to this occurrence of the problem.", - "example" : "There was an error processing the request" + "detail": { + "type": "string", + "description": "A human readable explanation specific to this occurrence of the problem.", + "example": "There was an error processing the request" } } }, - "SyncStatusResponse" : { - "required" : [ "serviceIdentifier", "status" ], - "type" : "object", - "properties" : { - "serviceIdentifier" : { - "type" : "string", - "description" : "Database service identifier", - "example" : "NDP001" + "SyncStatusResponse": { + "required": [ + "serviceIdentifier", + "status" + ], + "type": "object", + "properties": { + "serviceIdentifier": { + "type": "string", + "description": "Database service identifier", + "example": "NDP001" }, - "status" : { - "type" : "string", - "description" : "Database sync status result", - "example" : "done", - "enum" : [ "done", "disabled", "rollback", "error" ] + "status": { + "type": "string", + "description": "Database sync status result", + "example": "done", + "enum": [ + "done", + "disabled", + "rollback", + "error" + ] } } } }, - "securitySchemes" : { - "ApiKey" : { - "type" : "apiKey", - "description" : "The API key to access this function app.", - "name" : "Ocp-Apim-Subscription-Key", - "in" : "header" + "securitySchemes": { + "ApiKey": { + "type": "apiKey", + "description": "The API key to access this function app.", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" } } } -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index 6abd4ed..b6187d0 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-26-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-27-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From a2ac0522ef44d2dc64eca1641a81a0df584bcbb7 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Mon, 4 Mar 2024 17:37:38 +0100 Subject: [PATCH 75/88] NOD-690: abilitata scrittura su PagoPA e Nexi --- helm/values-dev.yaml | 4 ++-- src/main/resources/application.yaml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index a413f95..00e315c 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -69,11 +69,11 @@ microservice-chart: CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' DB_NEXI_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_NEXI_POSTGRES_USER: "cfg" - DB_NEXI_POSTGRES_ENABLED: "false" + DB_NEXI_POSTGRES_ENABLED: "true" DB_NEXI_POSTGRES_SERVICE_IDENTIFIER: "NDP004DEV" DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))" DB_NEXI_ORACLE_USER: "NODO4_CFG" - DB_NEXI_ORACLE_ENABLED: "false" + DB_NEXI_ORACLE_ENABLED: "true" DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV" DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_PAGOPA_POSTGRES_USER: "cfg" diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index ad1a742..14b3e28 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -81,8 +81,8 @@ stand-in-manager: write: ##permettono di abilitare/disabilitare la scrittura di stand-in sui vari database pagopa-postgres: 'true' - nexi-postgres: 'false' - nexi-oracle: 'false' + nexi-postgres: 'true' + nexi-oracle: 'true' api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} @@ -101,8 +101,8 @@ api-config-cache: write: ##permettono di abilitare/disabilitare la scrittura di cache sui vari database pagopa-postgres: 'true' - nexi-postgres: 'false' - nexi-oracle: 'false' + nexi-postgres: 'true' + nexi-oracle: 'true' logging: level: From b1af67e193913f737faef0b2961eb7ac33705e7c Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 5 Mar 2024 08:18:43 +0000 Subject: [PATCH 76/88] Bump to version 0.0.0-28-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index b3e4ea0..8686618 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.27.0 -appVersion: 0.0.0-27-NOD-690-nodo-cfg-sync-microservizio +version: 0.28.0 +appVersion: 0.0.0-28-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 00e315c..24c44fb 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-27-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-28-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index f27bcd8..a6ba786 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-27-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-28-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 62b1936..a2ea823 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-27-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-28-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 874c6ee..2e29f15 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-27-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-28-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index b6187d0..9890f95 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-27-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-28-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 646217b948f3b8705b401be469da8cff80f8d4dd Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 5 Mar 2024 09:11:24 +0000 Subject: [PATCH 77/88] Bump to version 0.0.0-29-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 8686618..91a3a23 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.28.0 -appVersion: 0.0.0-28-NOD-690-nodo-cfg-sync-microservizio +version: 0.29.0 +appVersion: 0.0.0-29-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 24c44fb..f273431 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-28-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-29-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a6ba786..df7515e 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-28-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-29-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index a2ea823..7c90942 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-28-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-29-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 2e29f15..9eb1382 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-28-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-29-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 9890f95..45e73b2 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-28-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-29-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From b23605883b622679c845e901de4f355c9d0cf1fd Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 5 Mar 2024 10:38:30 +0000 Subject: [PATCH 78/88] Bump to version 0.0.0-30-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 91a3a23..28dd2a5 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.29.0 -appVersion: 0.0.0-29-NOD-690-nodo-cfg-sync-microservizio +version: 0.30.0 +appVersion: 0.0.0-30-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index f273431..de7d628 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-29-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index df7515e..f2696e0 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-29-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 7c90942..865966b 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-29-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 9eb1382..4e36019 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-29-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 45e73b2..dbc7f03 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-29-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-30-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From d084ebf3fa9bc2a64a014aadec3120a5850df846 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 5 Mar 2024 16:00:55 +0100 Subject: [PATCH 79/88] NOD-690: fix user Nexi postgres --- helm/values-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index de7d628..f1557b3 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -68,7 +68,7 @@ microservice-chart: DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' DB_NEXI_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" - DB_NEXI_POSTGRES_USER: "cfg" + DB_NEXI_POSTGRES_USER: "pp_nodo4_cfg" DB_NEXI_POSTGRES_ENABLED: "true" DB_NEXI_POSTGRES_SERVICE_IDENTIFIER: "NDP004DEV" DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))" From d825a0e790615961318aac824503511f41e47f52 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 5 Mar 2024 15:02:29 +0000 Subject: [PATCH 80/88] Bump to version 0.0.0-31-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 28dd2a5..dd95121 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.30.0 -appVersion: 0.0.0-30-NOD-690-nodo-cfg-sync-microservizio +version: 0.31.0 +appVersion: 0.0.0-31-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index f1557b3..d6be733 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-31-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index f2696e0..a980265 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-31-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 865966b..34d5338 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-31-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 4e36019..cda7dff 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-31-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index dbc7f03..86ec80d 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-30-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-31-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From aefcc3161598b11d505dd7703cb237fc76307b9e Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 5 Mar 2024 16:11:15 +0100 Subject: [PATCH 81/88] NOD-690: fix user Nexi postgres --- helm/values-dev.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index d6be733..fbe43c0 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -67,7 +67,7 @@ microservice-chart: APP_LOGGING_LEVEL: 'DEBUG' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - DB_NEXI_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + DB_NEXI_POSTGRES_URL: "jdbc:postgresql://db-postgres-ndp.d.db-nodo-pagamenti.com:5444/ndpspct?prepareThreshold=0¤tSchema=NODO4_CFG" DB_NEXI_POSTGRES_USER: "pp_nodo4_cfg" DB_NEXI_POSTGRES_ENABLED: "true" DB_NEXI_POSTGRES_SERVICE_IDENTIFIER: "NDP004DEV" @@ -75,7 +75,7 @@ microservice-chart: DB_NEXI_ORACLE_USER: "NODO4_CFG" DB_NEXI_ORACLE_ENABLED: "true" DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV" - DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.postgres.database.azure.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" + DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0¤tSchema=cfg" DB_PAGOPA_POSTGRES_USER: "cfg" DB_PAGOPA_POSTGRES_ENABLED: "true" DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER: "NDP001DEV" From 3b9e8bd4e5b9015176cdf44dcf67c73487dc3f76 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 5 Mar 2024 16:14:22 +0100 Subject: [PATCH 82/88] NOD-690: fix user Nexi postgres --- helm/values-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index fbe43c0..37eb11c 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-31-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: From d46ecbbd3082a59b5e6dcbe477ba5eb61b1584a1 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 5 Mar 2024 15:15:28 +0000 Subject: [PATCH 83/88] Bump to version 0.0.0-32-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index dd95121..599fb15 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.31.0 -appVersion: 0.0.0-31-NOD-690-nodo-cfg-sync-microservizio +version: 0.32.0 +appVersion: 0.0.0-32-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 37eb11c..82560f9 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-30-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-32-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a980265..a1b483f 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-31-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-32-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 34d5338..f03818e 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-31-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-32-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index cda7dff..4336aa8 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-31-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-32-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 86ec80d..dfa6efc 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-31-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-32-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 6df2620a1be86998ef8bbb3f47d6d11f79a30e1d Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 5 Mar 2024 16:43:29 +0100 Subject: [PATCH 84/88] NOD-690: fix cache uri --- helm/values-dev.yaml | 2 ++ helm/values-uat.yaml | 2 ++ src/main/resources/application.yaml | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 82560f9..d659bff 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -79,6 +79,8 @@ microservice-chart: DB_PAGOPA_POSTGRES_USER: "cfg" DB_PAGOPA_POSTGRES_ENABLED: "true" DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER: "NDP001DEV" + API_CONFIG_CACHE_URL: "https://api.dev.platform.pagopa.it/api-config-cache/p/v1/stakeholders/node/cache/schemas/v1" + STAND_IN_MANAGER_URL: "https://api.dev.platform.pagopa.it/stand-in-manager/api/v1" OTEL_SERVICE_NAME: "pagopanodecfgsync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index f03818e..edb4649 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -68,6 +68,8 @@ microservice-chart: DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' CACHET_TX_NAME: "nodo-dei-pagamenti-cache" + API_CONFIG_CACHE_URL: "https://api.uat.platform.pagopa.it/api-config-cache/p/v1/stakeholders/node/cache/schemas/v1" + STAND_IN_MANAGER_URL: "https://api.uat.platform.pagopa.it/stand-in-manager/api/v1" OTEL_SERVICE_NAME: "pagopanodecfgsync" OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=uat" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 14b3e28..67e06b9 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -68,7 +68,7 @@ stand-in-manager: rx-connection-string: ${STAND_IN_MANAGER_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-stand-in service: - host: https://api.dev.platform.pagopa.it/stand-in-manager/api/v1 + host: ${STAND_IN_MANAGER_URL} subscriptionKey: ${STAND_IN_MANAGER_SUBSCRIPTION_KEY} ##permette di abilitare/disabilitare la chiamata al servizio tramite API enabled: 'true' @@ -88,7 +88,7 @@ api-config-cache: rx-connection-string: ${API_CONFIG_CACHE_RX_CONNECTION_STRING} rx-name: nodo-dei-pagamenti-cache service: - host: https://api.dev.platform.pagopa.it/api-config-cache/p/v1/stakeholders/node/cache/schemas/v1 + host: ${API_CONFIG_CACHE_URL} subscriptionKey: ${API_CONFIG_CACHE_SUBSCRIPTION_KEY} ##permette di abilitare/disabilitare la chiamata al servizio tramite API enabled: 'true' From 3da60253d29c0edec837c08edb4d2aa1ac9f9b11 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 5 Mar 2024 15:44:39 +0000 Subject: [PATCH 85/88] Bump to version 0.0.0-33-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 599fb15..f542cb6 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.32.0 -appVersion: 0.0.0-32-NOD-690-nodo-cfg-sync-microservizio +version: 0.33.0 +appVersion: 0.0.0-33-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index d659bff..04a2102 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-32-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-33-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a1b483f..4dd5ee4 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-32-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-33-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index edb4649..005dc71 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-32-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-33-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 4336aa8..121a17c 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-32-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-33-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index dfa6efc..9f96f7d 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-32-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-33-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From 9355167678dd5803feff5000300570f84ce23fe7 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 5 Mar 2024 16:51:25 +0100 Subject: [PATCH 86/88] NOD-690: fix cache uri --- .../it/gov/pagopa/node/cfgsync/client/ApiConfigCacheClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/node/cfgsync/client/ApiConfigCacheClient.java b/src/main/java/it/gov/pagopa/node/cfgsync/client/ApiConfigCacheClient.java index 00f54fb..8bcbd3f 100644 --- a/src/main/java/it/gov/pagopa/node/cfgsync/client/ApiConfigCacheClient.java +++ b/src/main/java/it/gov/pagopa/node/cfgsync/client/ApiConfigCacheClient.java @@ -9,7 +9,7 @@ @Service public interface ApiConfigCacheClient { - @RequestLine("GET /cache") + @RequestLine("GET /") @Headers({ "Ocp-Apim-Subscription-Key: {subscriptionKey}" }) From 8b74a02855afe49b1f077052aaabebb536ced413 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 5 Mar 2024 15:52:46 +0000 Subject: [PATCH 87/88] Bump to version 0.0.0-34-NOD-690-nodo-cfg-sync-microservizio [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index f542cb6..5d2418f 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 0.33.0 -appVersion: 0.0.0-33-NOD-690-nodo-cfg-sync-microservizio +version: 0.34.0 +appVersion: 0.0.0-34-NOD-690-nodo-cfg-sync-microservizio dependencies: - name: microservice-chart version: 2.8.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 04a2102..a3b7e74 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-33-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-34-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 4dd5ee4..faffe91 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-33-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-34-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 005dc71..252c326 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-node-cfg-sync - tag: "0.0.0-33-NOD-690-nodo-cfg-sync-microservizio" + tag: "0.0.0-34-NOD-690-nodo-cfg-sync-microservizio" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 121a17c..5c7fb7b 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "cfg-sync", "description": "Microservice to update configuration schema of Nodo dei Pagamenti", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.0.0-33-NOD-690-nodo-cfg-sync-microservizio" + "version": "0.0.0-34-NOD-690-nodo-cfg-sync-microservizio" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 9f96f7d..63525a4 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.gov.pagopa.node cfg-sync - 0.0.0-33-NOD-690-nodo-cfg-sync-microservizio + 0.0.0-34-NOD-690-nodo-cfg-sync-microservizio Microservice to update configuration schema of Nodo dei Pagamenti From dd2ea9c3463ad9c7f0bcbb33d7141e8792a266b4 Mon Sep 17 00:00:00 2001 From: Francesco Parisi Date: Tue, 5 Mar 2024 17:17:49 +0100 Subject: [PATCH 88/88] NOD-690: fix product_id --- infra/99_locals.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/99_locals.tf b/infra/99_locals.tf index 7ab7679..f2b41af 100644 --- a/infra/99_locals.tf +++ b/infra/99_locals.tf @@ -4,7 +4,7 @@ locals { apim = { name = "${local.product}-apim" rg = "${local.product}-api-rg" - product_id = "apiconfig-cache" + product_id = "cfg-for-node" } }