From aa2a27a79b736212f80532648113de29d0eefc3e Mon Sep 17 00:00:00 2001 From: Jacopo Date: Fri, 20 Oct 2023 13:05:03 +0200 Subject: [PATCH 01/15] [PAGOPA-1305] remove old psp's bundles --- .../it/gov/pagopa/afm/utils/repository/BundleRepository.java | 1 + .../java/it/gov/pagopa/afm/utils/service/CDIService.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java b/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java index 4c8ab1a2..5171681d 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java +++ b/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java @@ -12,4 +12,5 @@ public interface BundleRepository extends CosmosRepository { List findByIdCdiIsNotNull(); List findByIdCdi(String idCdi, PartitionKey pspCode); + List findAllByIdPsp(PartitionKey pspCode); } diff --git a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java index 2bbd3a28..9c935f51 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java +++ b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java @@ -55,6 +55,11 @@ public void deleteCDI(CDI cdiEntity) { } public void saveCDIs(List cdis) { + for (CDI cdi: cdis){ + List bundlesToRemove = bundleRepository.findAllByIdPsp(new PartitionKey(cdi.getIdPsp())); + bundlesToRemove.forEach(elem -> elem.setValidityDateTo(LocalDate.now())); + bundleRepository.saveAll(bundlesToRemove); + } cdisRepository.saveAll(cdis); CompletableFuture.runAsync(() -> turnCDIToBundles(cdis)); } From ac2f617013b2b112c4eacd25941c6468e902aa8e Mon Sep 17 00:00:00 2001 From: Jacopo Date: Fri, 20 Oct 2023 14:33:49 +0200 Subject: [PATCH 02/15] [PAGOPA-1305] fix --- openapi/openapi.json | 913 +++++++++--------- .../afm/utils/config/LoggingAspect.java | 70 +- .../pagopa/afm/utils/service/CDIService.java | 445 ++++----- 3 files changed, 701 insertions(+), 727 deletions(-) diff --git a/openapi/openapi.json b/openapi/openapi.json index cb571cf1..604f3d83 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,681 +1,646 @@ { - "openapi": "3.0.1", - "info": { - "title": "afm-utils", - "description": "Utility microservice for pagoPA AFM", - "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.7.0" + "openapi" : "3.0.1", + "info" : { + "title" : "afm-utils", + "description" : "Utility microservice for pagoPA AFM", + "termsOfService" : "https://www.pagopa.gov.it/", + "version" : "0.6.2-5-PAGOPA-1215-afm-calculator-creare-dashboard-elk" }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/cdis/sync": { - "get": { - "tags": [ - "Import CDI rest API" - ], - "summary": "API to retry the import of the CDIs and convert to bundles.", - "operationId": "syncCDI_1", - "responses": { - "200": { - "description": "Obtained bundle list.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "paths" : { + "/cdis/sync" : { + "get" : { + "tags" : [ "Import CDI rest API" ], + "summary" : "API to retry the import of the CDIs and convert to bundles.", + "operationId" : "syncCDI_1", + "responses" : { + "200" : { + "description" : "Obtained bundle list.", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BundleResponse" + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BundleResponse" } } } } }, - "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" : [ ] + } ] }, - "post": { - "tags": [ - "Import CDI rest API" - ], - "summary": "API to trigger the import of the CDIs and convert to bundles.", - "operationId": "syncCDI", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CDI" + "post" : { + "tags" : [ "Import CDI rest API" ], + "summary" : "API to trigger the import of the CDIs and convert to bundles.", + "operationId" : "syncCDI", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/CDI" } } } }, - "required": true + "required" : true }, - "responses": { - "200": { - "description": "Obtained bundle list.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "responses" : { + "200" : { + "description" : "Obtained bundle list.", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BundleResponse" + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BundleResponse" } } } } }, - "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" : [ ] + } ] }, - "delete": { - "tags": [ - "Delete CDI rest API" - ], - "summary": "API to trigger the bulk deletion of the CDIs and its related bundles.", - "operationId": "syncCDIDeletion", - "responses": { - "200": { - "description": "Obtained bundle list.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "delete" : { + "tags" : [ "Delete CDI rest API" ], + "summary" : "API to trigger the bulk deletion of the CDIs and its related bundles.", + "operationId" : "syncCDIDeletion", + "responses" : { + "200" : { + "description" : "Obtained bundle list.", + "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" + "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" } - ] + } ] }, - "/info": { - "get": { - "tags": [ - "Home" - ], - "summary": "health check", - "description": "Return OK if application is started", - "operationId": "healthCheck", - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "/info" : { + "get" : { + "tags" : [ "Home" ], + "summary" : "health check", + "description" : "Return OK if application is started", + "operationId" : "healthCheck", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AppInfo" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/AppInfo" } } } }, - "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" } - ] + } ] }, - "/psps/{pspCode}/cdis/{idCdi}": { - "delete": { - "tags": [ - "Delete Bundles by id CDI rest API" - ], - "summary": "API to trigger the deletion of the bundles by a CDI id.", - "operationId": "syncBundlesDeletionByIdCDI", - "parameters": [ - { - "name": "idCdi", - "in": "path", - "description": "CDI identifier", - "required": true, - "schema": { - "maxLength": 50, - "minLength": 0, - "type": "string" - } - }, - { - "name": "pspCode", - "in": "path", - "description": "PSP code", - "required": true, - "schema": { - "pattern": "[A-Z0-9_]{6,14}", - "type": "string" - } + "/psps/{pspCode}/cdis/{idCdi}" : { + "delete" : { + "tags" : [ "Delete Bundles by id CDI rest API" ], + "summary" : "API to trigger the deletion of the bundles by a CDI id.", + "operationId" : "syncBundlesDeletionByIdCDI", + "parameters" : [ { + "name" : "idCdi", + "in" : "path", + "description" : "CDI identifier", + "required" : true, + "schema" : { + "maxLength" : 50, + "minLength" : 0, + "type" : "string" } - ], - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + }, { + "name" : "pspCode", + "in" : "path", + "description" : "PSP code", + "required" : true, + "schema" : { + "pattern" : "[A-Z0-9_]{6,14}", + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "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" + "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" } } } }, - "404": { - "description": "Not Found", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "404" : { + "description" : "Not Found", + "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" } } } }, - "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": { - "CDI": { - "type": "object", - "properties": { - "id": { - "type": "string" + "components" : { + "schemas" : { + "CDI" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" }, - "idPsp": { - "type": "string" + "idPsp" : { + "type" : "string" }, - "idCdi": { - "type": "string" + "idCdi" : { + "type" : "string" }, - "abi": { - "type": "string" + "abi" : { + "type" : "string" }, - "digitalStamp": { - "type": "boolean" + "digitalStamp" : { + "type" : "boolean" }, - "validityDateFrom": { - "type": "string" + "validityDateFrom" : { + "type" : "string" }, - "pspBusinessName": { - "type": "string" + "pspBusinessName" : { + "type" : "string" }, - "details": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Detail" + "details" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Detail" } }, - "cdiStatus": { - "type": "string", - "enum": [ - "NEW", - "FAILED", - "PROCESSING" - ] + "cdiStatus" : { + "type" : "string", + "enum" : [ "NEW", "FAILED", "PROCESSING" ] }, - "cdiErrorDesc": { - "type": "string" + "cdiErrorDesc" : { + "type" : "string" } } }, - "Detail": { - "type": "object", - "properties": { - "idBrokerPsp": { - "type": "string" + "Detail" : { + "type" : "object", + "properties" : { + "idBrokerPsp" : { + "type" : "string" }, - "idChannel": { - "type": "string" + "idChannel" : { + "type" : "string" }, - "name": { - "type": "string" + "name" : { + "type" : "string" }, - "description": { - "type": "string" + "description" : { + "type" : "string" }, - "paymentType": { - "type": "string" + "paymentType" : { + "type" : "string" }, - "channelApp": { - "type": "boolean" + "channelApp" : { + "type" : "boolean" }, - "channelCardsCart": { - "type": "boolean" + "channelCardsCart" : { + "type" : "boolean" }, - "serviceAmount": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ServiceAmount" + "serviceAmount" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/ServiceAmount" } } } }, - "ServiceAmount": { - "type": "object", - "properties": { - "paymentAmount": { - "type": "integer", - "format": "int64" - }, - "minPaymentAmount": { - "type": "integer", - "format": "int64" - }, - "maxPaymentAmount": { - "type": "integer", - "format": "int64" + "ServiceAmount" : { + "type" : "object", + "properties" : { + "paymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "minPaymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "maxPaymentAmount" : { + "type" : "integer", + "format" : "int64" } } }, - "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" + "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" } } }, - "BundleResponse": { - "type": "object", - "properties": { - "idBundle": { - "type": "string" + "BundleResponse" : { + "type" : "object", + "properties" : { + "idBundle" : { + "type" : "string" } } }, - "AppInfo": { - "type": "object", - "properties": { - "name": { - "type": "string" + "AppInfo" : { + "type" : "object", + "properties" : { + "name" : { + "type" : "string" }, - "version": { - "type": "string" + "version" : { + "type" : "string" }, - "environment": { - "type": "string" + "environment" : { + "type" : "string" } } } }, - "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/afm/utils/config/LoggingAspect.java b/src/main/java/it/gov/pagopa/afm/utils/config/LoggingAspect.java index 8948ecff..de2a9deb 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/config/LoggingAspect.java +++ b/src/main/java/it/gov/pagopa/afm/utils/config/LoggingAspect.java @@ -1,10 +1,5 @@ package it.gov.pagopa.afm.utils.config; -import java.util.Arrays; -import java.util.stream.StreamSupport; -import javax.annotation.PostConstruct; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; @@ -24,6 +19,12 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.stream.StreamSupport; + @Aspect @Component @Slf4j @@ -44,9 +45,11 @@ public class LoggingAspect { @Value("${info.properties.environment}") private String environment; - @Autowired HttpServletRequest httRequest; + @Autowired + HttpServletRequest httRequest; - @Autowired HttpServletResponse httpResponse; + @Autowired + HttpServletResponse httpResponse; @Pointcut("@within(org.springframework.web.bind.annotation.RestController)") public void restController() { @@ -63,7 +66,9 @@ public void service() { // all service methods } - /** Log essential info of application during the startup. */ + /** + * Log essential info of application during the startup. + */ @PostConstruct public void logStartup() { log.info("-> Starting {} version {} - environment {}", artifactId, version, environment); @@ -80,19 +85,20 @@ public void handleContextRefresh(ContextRefreshedEvent event) { log.debug("Active profiles: {}", Arrays.toString(env.getActiveProfiles())); final MutablePropertySources sources = ((AbstractEnvironment) env).getPropertySources(); StreamSupport.stream(sources.spliterator(), false) - .filter(EnumerablePropertySource.class::isInstance) - .map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()) - .flatMap(Arrays::stream) - .distinct() - .filter( - prop -> - !(prop.toLowerCase().contains("credentials") - || prop.toLowerCase().contains("password") - || prop.toLowerCase().contains("pass") - || prop.toLowerCase().contains("pwd") - || prop.toLowerCase().contains("key") - || prop.toLowerCase().contains("secret"))) - .forEach(prop -> log.debug("{}: {}", prop, env.getProperty(prop))); + .filter(EnumerablePropertySource.class::isInstance) + .map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()) + .flatMap(Arrays::stream) + .distinct() + .filter( + prop -> + !(prop.toLowerCase().contains("credentials") + || prop.toLowerCase().contains("password") + || prop.toLowerCase().contains("pass") + || prop.toLowerCase().contains("pwd") + || prop.toLowerCase().contains("key") + || prop.toLowerCase().contains("secret") + )) + .forEach(prop -> log.debug("{}: {}", prop, env.getProperty(prop))); } @Around(value = "restController()") @@ -100,18 +106,14 @@ public Object logApiInvocation(ProceedingJoinPoint joinPoint) throws Throwable { MDC.put(METHOD, joinPoint.getSignature().getName()); MDC.put(START_TIME, String.valueOf(System.currentTimeMillis())); log.info("{} {}", httRequest.getMethod(), httRequest.getRequestURI()); - log.info( - "Invoking API operation {} - args: {}", - joinPoint.getSignature().getName(), - joinPoint.getArgs()); + log.info("Invoking API operation {} - args: {}", joinPoint.getSignature().getName(), joinPoint.getArgs()); Object result = joinPoint.proceed(); MDC.put(STATUS, "OK"); MDC.put(CODE, String.valueOf(httpResponse.getStatus())); MDC.put(RESPONSE_TIME, getExecutionTime()); - log.info( - "Successful API operation {} - result: {}", joinPoint.getSignature().getName(), result); + log.info("Successful API operation {} - result: {}", joinPoint.getSignature().getName(), result); MDC.remove(STATUS); MDC.remove(CODE); MDC.remove(RESPONSE_TIME); @@ -133,17 +135,19 @@ public void trowingApiInvocation(JoinPoint joinPoint, ResponseEntity result) @Around(value = "repository() || service()") public Object logTrace(ProceedingJoinPoint joinPoint) throws Throwable { - log.debug( - "Call method {} - args: {}", joinPoint.getSignature().toShortString(), joinPoint.getArgs()); + log.debug("Call method {} - args: {}", joinPoint.getSignature().toShortString(), joinPoint.getArgs()); Object result = joinPoint.proceed(); log.debug("Return method {} - result: {}", joinPoint.getSignature().toShortString(), result); return result; } private static String getExecutionTime() { - long endTime = System.currentTimeMillis(); - long startTime = Long.parseLong(MDC.get(START_TIME)); - long executionTime = endTime - startTime; - return String.valueOf(executionTime); + String startTime = MDC.get(START_TIME); + if (startTime != null) { + long endTime = System.currentTimeMillis(); + long executionTime = endTime - Long.parseLong(startTime); + return String.valueOf(executionTime); + } + return "1"; } } diff --git a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java index 9c935f51..ebcec224 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java +++ b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java @@ -17,6 +17,7 @@ import it.gov.pagopa.afm.utils.model.bundle.TouchpointType; import it.gov.pagopa.afm.utils.repository.BundleRepository; import it.gov.pagopa.afm.utils.repository.CDICollectionRepository; + import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -25,6 +26,7 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; + import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import lombok.Setter; @@ -40,252 +42,255 @@ @Setter @Slf4j public class CDIService { - @Autowired private CDICollectionRepository cdisRepository; + @Autowired + private CDICollectionRepository cdisRepository; - @Autowired private BundleRepository bundleRepository; + @Autowired + private BundleRepository bundleRepository; - @Autowired private MarketPlaceClient marketPlaceClient; + @Autowired + private MarketPlaceClient marketPlaceClient; - public CDI updateCDI(CDI cdiEntity) { - return cdisRepository.save(cdiEntity); - } + public CDI updateCDI(CDI cdiEntity) { + return cdisRepository.save(cdiEntity); + } - public void deleteCDI(CDI cdiEntity) { - cdisRepository.delete(cdiEntity); - } + public void deleteCDI(CDI cdiEntity) { + cdisRepository.delete(cdiEntity); + } - public void saveCDIs(List cdis) { - for (CDI cdi: cdis){ - List bundlesToRemove = bundleRepository.findAllByIdPsp(new PartitionKey(cdi.getIdPsp())); - bundlesToRemove.forEach(elem -> elem.setValidityDateTo(LocalDate.now())); - bundleRepository.saveAll(bundlesToRemove); + public void saveCDIs(List cdis) { + for (CDI cdi : cdis) { + List bundlesToRemove = bundleRepository.findAllByIdPsp(new PartitionKey(cdi.getIdPsp())); + bundlesToRemove.forEach(elem -> elem.setValidityDateTo(LocalDate.now())); + bundleRepository.saveAll(bundlesToRemove); + } + cdisRepository.saveAll(cdis); + CompletableFuture.runAsync(() -> turnCDIToBundles(cdis)); } - cdisRepository.saveAll(cdis); - CompletableFuture.runAsync(() -> turnCDIToBundles(cdis)); - } - public List syncCDI() { - return this.turnCDIToBundles(cdisRepository.getWorkableCDIs()); - } + public List syncCDI() { + return this.turnCDIToBundles(cdisRepository.getWorkableCDIs()); + } - public void deleteCDIs() { - List bundlesToBeDeleted = bundleRepository.findByIdCdiIsNotNull(); - bundleRepository.deleteAll(bundlesToBeDeleted); - for (Bundle bundle : bundlesToBeDeleted) { - String idCdi = bundle.getIdCdi(); - List cdisToBeDeleted = cdisRepository.findByIdCdi(idCdi); - try { - cdisRepository.deleteAll(cdisToBeDeleted); - } catch (IllegalArgumentException e) { - log.info(String.format("CDI with ID %s was already deleted.", idCdi)); - } + public void deleteCDIs() { + List bundlesToBeDeleted = bundleRepository.findByIdCdiIsNotNull(); + bundleRepository.deleteAll(bundlesToBeDeleted); + for (Bundle bundle : bundlesToBeDeleted) { + String idCdi = bundle.getIdCdi(); + List cdisToBeDeleted = cdisRepository.findByIdCdi(idCdi); + try { + cdisRepository.deleteAll(cdisToBeDeleted); + } catch (IllegalArgumentException e) { + log.info(String.format("CDI with ID %s was already deleted.", idCdi)); + } + } } - } - public void deleteBundlesByIdCDI(String idCdi, String pspCode) { - List bundlesToBeDeleted = - Optional.of(bundleRepository.findByIdCdi(idCdi, new PartitionKey(pspCode))) - .filter(l -> !CollectionUtils.isEmpty(l)) - .orElseThrow(() -> new AppException(AppError.CDI_NOT_FOUND_ERROR, idCdi, pspCode)) - .stream() - .collect(Collectors.toList()); + public void deleteBundlesByIdCDI(String idCdi, String pspCode) { + List bundlesToBeDeleted = + Optional.of(bundleRepository.findByIdCdi(idCdi, new PartitionKey(pspCode))) + .filter(l -> !CollectionUtils.isEmpty(l)) + .orElseThrow(() -> new AppException(AppError.CDI_NOT_FOUND_ERROR, idCdi, pspCode)) + .stream() + .collect(Collectors.toList()); - for (Bundle bundle : bundlesToBeDeleted) { - try { - Optional.ofNullable(marketPlaceClient) - .ifPresent(result -> marketPlaceClient.removeBundle(pspCode, bundle.getId())); - } catch (FeignException.BadRequest e) { - throw new AppException(AppError.BUNDLE_REQUEST_DATA_ERROR, e.getMessage()); - } catch (FeignException.NotFound e) { - throw new AppException(AppError.BUNDLE_NOT_FOUND_ERROR, e.getMessage()); - } catch (FeignException.Conflict e) { - throw new AppException(AppError.BUNDLE_CONFLICT_ERROR, e.getMessage()); - } catch (FeignException.InternalServerError e) { - throw new AppException(AppError.INTERNAL_SERVER_ERROR, e.getMessage()); - } catch (Exception e) { - log.error("Unexpected Exception", e); - throw new AppException(AppError.UNKNOWN); - } + for (Bundle bundle : bundlesToBeDeleted) { + try { + Optional.ofNullable(marketPlaceClient) + .ifPresent(result -> marketPlaceClient.removeBundle(pspCode, bundle.getId())); + } catch (FeignException.BadRequest e) { + throw new AppException(AppError.BUNDLE_REQUEST_DATA_ERROR, e.getMessage()); + } catch (FeignException.NotFound e) { + throw new AppException(AppError.BUNDLE_NOT_FOUND_ERROR, e.getMessage()); + } catch (FeignException.Conflict e) { + throw new AppException(AppError.BUNDLE_CONFLICT_ERROR, e.getMessage()); + } catch (FeignException.InternalServerError e) { + throw new AppException(AppError.INTERNAL_SERVER_ERROR, e.getMessage()); + } catch (Exception e) { + log.error("Unexpected Exception", e); + throw new AppException(AppError.UNKNOWN); + } + } } - } - private List turnCDIToBundles(List cdis) { - log.info( - "CDIService - turnCDIToBundles executed at: " - + LocalDateTime.now() - + " for CDI list with size: " - + cdis.size()); - List bundleResponses = new ArrayList<>(); - // the status of the items is put on PROCESSING to identify that these records are not in a - // final state - this.setCDIToProcessingStatus(cdis); - for (CDI cdi : cdis) { - // processed only cdis not in FAILED status - if (null != cdi.getCdiStatus() && !cdi.getCdiStatus().equals(StatusType.FAILED)) { - String idPsp = cdi.getIdPsp(); - List bundleRequestList = this.createBundlesByCDI(cdi); - try { - // create marketplace bundle - Optional.ofNullable(this.createBundleByList(idPsp, bundleRequestList)) - .ifPresent(bundleResponses::addAll); - // success -> delete the CDI - this.deleteCDI(cdi); - log.info( - String.format("SUCCESS Bundles creation -> CDI deleted [idCdi=%s]", cdi.getIdCdi())); + private List turnCDIToBundles(List cdis) { + log.info( + "CDIService - turnCDIToBundles executed at: " + + LocalDateTime.now() + + " for CDI list with size: " + + cdis.size()); + List bundleResponses = new ArrayList<>(); + // the status of the items is put on PROCESSING to identify that these records are not in a + // final state + this.setCDIToProcessingStatus(cdis); + for (CDI cdi : cdis) { + // processed only cdis not in FAILED status + if(null != cdi.getCdiStatus() && !cdi.getCdiStatus().equals(StatusType.FAILED)) { + String idPsp = cdi.getIdPsp(); + List bundleRequestList = this.createBundlesByCDI(cdi); + try { + // create marketplace bundle + Optional.ofNullable(this.createBundleByList(idPsp, bundleRequestList)) + .ifPresent(bundleResponses::addAll); + // success -> delete the CDI + this.deleteCDI(cdi); + log.info( + String.format("SUCCESS Bundles creation -> CDI deleted [idCdi=%s]", cdi.getIdCdi())); - } catch (AppException e) { - log.error( - "Error during the creation of the MarketPlace Bundles [idPsp= " - + idPsp - + ", idCdi=" - + cdi.getIdCdi() - + "]", - e); - // error -> set CDI status to failed - cdi.setCdiStatus(StatusType.FAILED); - cdi.setCdiErrorDesc(e.getMessage()); - CDI updated = this.updateCDI(cdi); - log.info( - String.format( - "CDI status updated [idCdi=%s, status=%s, errorDesc=%s]", - Optional.ofNullable(updated).map(result -> updated.getIdCdi()), - Optional.ofNullable(updated).map(result -> updated.getCdiStatus()), - Optional.ofNullable(updated).map(result -> updated.getCdiErrorDesc()))); + } catch (AppException e) { + log.error( + "Error during the creation of the MarketPlace Bundles [idPsp= " + + idPsp + + ", idCdi=" + + cdi.getIdCdi() + + "]", + e); + // error -> set CDI status to failed + cdi.setCdiStatus(StatusType.FAILED); + cdi.setCdiErrorDesc(e.getMessage()); + CDI updated = this.updateCDI(cdi); + log.info( + String.format( + "CDI status updated [idCdi=%s, status=%s, errorDesc=%s]", + Optional.ofNullable(updated).map(result -> updated.getIdCdi()), + Optional.ofNullable(updated).map(result -> updated.getCdiStatus()), + Optional.ofNullable(updated).map(result -> updated.getCdiErrorDesc()))); + } + } } - } + return bundleResponses; } - return bundleResponses; - } - public List createBundlesByCDI(CDI cdi) { - List bundleRequestList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(cdi.getDetails())) { - DateTimeFormatter dfDate = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - BundleRequest bundleRequest = new BundleRequest(); - bundleRequest.setIdCdi(cdi.getIdCdi()); - bundleRequest.setAbi(cdi.getAbi()); - bundleRequest.setDigitalStamp(cdi.getDigitalStamp()); - bundleRequest.setPspBusinessName(cdi.getPspBusinessName()); - bundleRequest.setDigitalStampRestriction(Boolean.FALSE); - bundleRequest.setType(BundleType.GLOBAL); - bundleRequest.setTransferCategoryList(null); - bundleRequest.setValidityDateFrom( - !StringUtils.isEmpty(cdi.getValidityDateFrom()) - ? LocalDate.parse(cdi.getValidityDateFrom(), dfDate) - : null); - bundleRequest.setValidityDateTo(null); - int bundleNumber = 1; - for (Detail d : cdi.getDetails()) { - bundleRequest.setIdChannel(d.getIdChannel()); - bundleRequest.setIdBrokerPsp(d.getIdBrokerPsp()); - bundleRequest.setDescription(d.getDescription()); - bundleRequest.setPaymentType(d.getPaymentType()); - for (ServiceAmount sa : d.getServiceAmount()) { - bundleRequest.setName(d.getName() + "_" + bundleNumber); - bundleNumber++; - bundleRequest.setPaymentAmount(sa.getPaymentAmount()); - bundleRequest.setMinPaymentAmount(sa.getMinPaymentAmount()); - bundleRequest.setMaxPaymentAmount(sa.getMaxPaymentAmount()); - this.addBundleByTouchpoint(d, bundleRequestList, bundleRequest); + public List createBundlesByCDI(CDI cdi) { + List bundleRequestList = new ArrayList<>(); + if(!CollectionUtils.isEmpty(cdi.getDetails())) { + DateTimeFormatter dfDate = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + BundleRequest bundleRequest = new BundleRequest(); + bundleRequest.setIdCdi(cdi.getIdCdi()); + bundleRequest.setAbi(cdi.getAbi()); + bundleRequest.setDigitalStamp(cdi.getDigitalStamp()); + bundleRequest.setPspBusinessName(cdi.getPspBusinessName()); + bundleRequest.setDigitalStampRestriction(Boolean.FALSE); + bundleRequest.setType(BundleType.GLOBAL); + bundleRequest.setTransferCategoryList(null); + bundleRequest.setValidityDateFrom( + !StringUtils.isEmpty(cdi.getValidityDateFrom()) + ? LocalDate.parse(cdi.getValidityDateFrom(), dfDate) + : null); + bundleRequest.setValidityDateTo(null); + int bundleNumber = 1; + for (Detail d : cdi.getDetails()) { + bundleRequest.setIdChannel(d.getIdChannel()); + bundleRequest.setIdBrokerPsp(d.getIdBrokerPsp()); + bundleRequest.setDescription(d.getDescription()); + bundleRequest.setPaymentType(d.getPaymentType()); + for (ServiceAmount sa : d.getServiceAmount()) { + bundleRequest.setName(d.getName() + "_" + bundleNumber); + bundleNumber++; + bundleRequest.setPaymentAmount(sa.getPaymentAmount()); + bundleRequest.setMinPaymentAmount(sa.getMinPaymentAmount()); + bundleRequest.setMaxPaymentAmount(sa.getMaxPaymentAmount()); + this.addBundleByTouchpoint(d, bundleRequestList, bundleRequest); + } + } } - } + return bundleRequestList; } - return bundleRequestList; - } - private void addBundleByTouchpoint( - Detail d, List bundleRequestList, BundleRequest bundleRequest) { + private void addBundleByTouchpoint( + Detail d, List bundleRequestList, BundleRequest bundleRequest) { - boolean isNullTouchPoint = true; + boolean isNullTouchPoint = true; - if (d.getPaymentType().equalsIgnoreCase(PaymentMethodType.PO.name())) { - isNullTouchPoint = false; - BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); - bundleRequestClone.setTouchpoint(TouchpointType.PSP.name()); - bundleRequestClone.setName(bundleRequestClone.getName() + "_" + TouchpointType.PSP.name()); - bundleRequestList.add(bundleRequestClone); - } - if ((d.getPaymentType().equalsIgnoreCase(PaymentMethodType.CP.name()) - && d.getChannelCardsCart() - && d.getChannelApp().equals(Boolean.FALSE)) - || (d.getPaymentType() + if(d.getPaymentType().equalsIgnoreCase(PaymentMethodType.PO.name())) { + isNullTouchPoint = false; + BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); + bundleRequestClone.setTouchpoint(TouchpointType.PSP.name()); + bundleRequestClone.setName(bundleRequestClone.getName() + "_" + TouchpointType.PSP.name()); + bundleRequestList.add(bundleRequestClone); + } + if((d.getPaymentType().equalsIgnoreCase(PaymentMethodType.CP.name()) + && d.getChannelCardsCart() + && d.getChannelApp().equals(Boolean.FALSE)) + || (d.getPaymentType() .matches( - "(?i)" - + PaymentMethodType.BBT - + "|" - + PaymentMethodType.BP - + "|" - + PaymentMethodType.MYBK - + "|" - + PaymentMethodType.AD) - && d.getChannelApp().equals(Boolean.FALSE)) - || (!d.getPaymentType().equalsIgnoreCase(PaymentMethodType.PPAL.name()) - && d.getChannelApp())) { - isNullTouchPoint = false; - BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); - bundleRequestClone.setTouchpoint(TouchpointType.WISP.name()); - bundleRequestClone.setName(bundleRequestClone.getName() + "_" + TouchpointType.WISP.name()); - bundleRequestList.add(bundleRequestClone); - } - if ((d.getPaymentType().equalsIgnoreCase(PaymentMethodType.CP.name()) - && d.getChannelCardsCart() - && d.getChannelApp().equals(Boolean.FALSE)) - || (d.getPaymentType().equalsIgnoreCase(PaymentMethodType.PPAL.name()) - && d.getChannelApp())) { - isNullTouchPoint = false; - BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); - bundleRequestClone.setName(bundleRequestClone.getName() + "_" + TouchpointType.IO.name()); - bundleRequestClone.setTouchpoint(TouchpointType.IO.name()); - bundleRequestList.add(bundleRequestClone); - } - if ((d.getPaymentType().equalsIgnoreCase(PaymentMethodType.CP.name()) - && d.getChannelCardsCart() - && d.getChannelApp().equals(Boolean.FALSE))) { - isNullTouchPoint = false; - BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); - bundleRequestClone.setTouchpoint(TouchpointType.CHECKOUT.name()); - bundleRequestClone.setName( - bundleRequestClone.getName() + "_" + TouchpointType.CHECKOUT.name()); - bundleRequestList.add(bundleRequestClone); - } - if (isNullTouchPoint) { - // default bundle with null touchpoint value - bundleRequestList.add(bundleRequest); + "(?i)" + + PaymentMethodType.BBT + + "|" + + PaymentMethodType.BP + + "|" + + PaymentMethodType.MYBK + + "|" + + PaymentMethodType.AD) + && d.getChannelApp().equals(Boolean.FALSE)) + || (!d.getPaymentType().equalsIgnoreCase(PaymentMethodType.PPAL.name()) + && d.getChannelApp())) { + isNullTouchPoint = false; + BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); + bundleRequestClone.setTouchpoint(TouchpointType.WISP.name()); + bundleRequestClone.setName(bundleRequestClone.getName() + "_" + TouchpointType.WISP.name()); + bundleRequestList.add(bundleRequestClone); + } + if((d.getPaymentType().equalsIgnoreCase(PaymentMethodType.CP.name()) + && d.getChannelCardsCart() + && d.getChannelApp().equals(Boolean.FALSE)) + || (d.getPaymentType().equalsIgnoreCase(PaymentMethodType.PPAL.name()) + && d.getChannelApp())) { + isNullTouchPoint = false; + BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); + bundleRequestClone.setName(bundleRequestClone.getName() + "_" + TouchpointType.IO.name()); + bundleRequestClone.setTouchpoint(TouchpointType.IO.name()); + bundleRequestList.add(bundleRequestClone); + } + if((d.getPaymentType().equalsIgnoreCase(PaymentMethodType.CP.name()) + && d.getChannelCardsCart() + && d.getChannelApp().equals(Boolean.FALSE))) { + isNullTouchPoint = false; + BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); + bundleRequestClone.setTouchpoint(TouchpointType.CHECKOUT.name()); + bundleRequestClone.setName( + bundleRequestClone.getName() + "_" + TouchpointType.CHECKOUT.name()); + bundleRequestList.add(bundleRequestClone); + } + if(isNullTouchPoint) { + // default bundle with null touchpoint value + bundleRequestList.add(bundleRequest); + } } - } - private List createBundleByList( - String idPsp, List bundleRequestList) throws AppException { - List response = null; - try { - response = - Optional.ofNullable(marketPlaceClient) - .map(result -> marketPlaceClient.createBundleByList(idPsp, bundleRequestList)) - .orElseGet(() -> null); - } catch (FeignException.BadRequest e) { - throw new AppException(AppError.BUNDLE_REQUEST_DATA_ERROR, e.getMessage()); - } catch (FeignException.NotFound e) { - throw new AppException(AppError.BUNDLE_NOT_FOUND_ERROR, e.getMessage()); - } catch (FeignException.Conflict e) { - throw new AppException(AppError.BUNDLE_CONFLICT_ERROR, e.getMessage()); - } catch (FeignException.InternalServerError e) { - throw new AppException(AppError.INTERNAL_SERVER_ERROR, e.getMessage()); - } catch (Exception e) { - throw new AppException(AppError.UNKNOWN, e.getMessage()); + private List createBundleByList( + String idPsp, List bundleRequestList) throws AppException { + List response = null; + try { + response = + Optional.ofNullable(marketPlaceClient) + .map(result -> marketPlaceClient.createBundleByList(idPsp, bundleRequestList)) + .orElseGet(() -> null); + } catch (FeignException.BadRequest e) { + throw new AppException(AppError.BUNDLE_REQUEST_DATA_ERROR, e.getMessage()); + } catch (FeignException.NotFound e) { + throw new AppException(AppError.BUNDLE_NOT_FOUND_ERROR, e.getMessage()); + } catch (FeignException.Conflict e) { + throw new AppException(AppError.BUNDLE_CONFLICT_ERROR, e.getMessage()); + } catch (FeignException.InternalServerError e) { + throw new AppException(AppError.INTERNAL_SERVER_ERROR, e.getMessage()); + } catch (Exception e) { + throw new AppException(AppError.UNKNOWN, e.getMessage()); + } + return response; } - return response; - } - // remove when @CosmosDBTrigger function will be used - public void setCDIToProcessingStatus(List items) { - for (CDI cdi : items) { - cdi.setCdiStatus(StatusType.PROCESSING); - CDI updated = this.updateCDI(cdi); - log.info( - String.format( - "CDI status updated [idCdi=%s, status=%s]", - Optional.ofNullable(updated).map(result -> updated.getIdCdi()), - Optional.ofNullable(updated).map(result -> updated.getCdiStatus()))); + // remove when @CosmosDBTrigger function will be used + public void setCDIToProcessingStatus(List items) { + for (CDI cdi : items) { + cdi.setCdiStatus(StatusType.PROCESSING); + CDI updated = this.updateCDI(cdi); + log.info( + String.format( + "CDI status updated [idCdi=%s, status=%s]", + Optional.ofNullable(updated).map(result -> updated.getIdCdi()), + Optional.ofNullable(updated).map(result -> updated.getCdiStatus()))); + } } - } } From 74bc529f471c0e77f00eb197634471b95a35afcc Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 20 Oct 2023 12:40:04 +0000 Subject: [PATCH 03/15] Bump to version 0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp [skip ci] --- helm/Chart.yaml | 4 +- helm/values-dev.yaml | 4 +- helm/values-prod.yaml | 4 +- helm/values-uat.yaml | 4 +- openapi/openapi.json | 913 ++++++++++++++++++++++-------------------- pom.xml | 2 +- 6 files changed, 483 insertions(+), 448 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 2a615e37..60e53ff5 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-utils description: Utility microservice for pagoPA AFM type: application -version: 0.15.0 -appVersion: 0.7.0 +version: 0.15.1 +appVersion: 0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp dependencies: - name: microservice-chart version: 1.21.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index fbf9e384..c46d393a 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -90,7 +90,7 @@ microservice-chart: values: - user canaryDelivery: - create: false + create: true ingress: create: true canary: @@ -104,7 +104,7 @@ microservice-chart: create: true image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.6.2" + tag: "0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always envConfig: {} envSecret: {} diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a155a663..b12c0d29 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -90,7 +90,7 @@ microservice-chart: values: - user canaryDelivery: - create: false + create: true ingress: create: true canary: @@ -104,7 +104,7 @@ microservice-chart: create: true image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.6.2" + tag: "0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always envConfig: {} envSecret: {} diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index ac43f86a..efda525f 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -90,7 +90,7 @@ microservice-chart: values: - user canaryDelivery: - create: false + create: true ingress: create: true canary: @@ -104,7 +104,7 @@ microservice-chart: create: true image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.6.2" + tag: "0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always envConfig: {} envSecret: {} diff --git a/openapi/openapi.json b/openapi/openapi.json index 604f3d83..3482675b 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,646 +1,681 @@ { - "openapi" : "3.0.1", - "info" : { - "title" : "afm-utils", - "description" : "Utility microservice for pagoPA AFM", - "termsOfService" : "https://www.pagopa.gov.it/", - "version" : "0.6.2-5-PAGOPA-1215-afm-calculator-creare-dashboard-elk" + "openapi": "3.0.1", + "info": { + "title": "afm-utils", + "description": "Utility microservice for pagoPA AFM", + "termsOfService": "https://www.pagopa.gov.it/", + "version": "0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" }, - "servers" : [ { - "url" : "http://localhost", - "description" : "Generated server url" - } ], - "paths" : { - "/cdis/sync" : { - "get" : { - "tags" : [ "Import CDI rest API" ], - "summary" : "API to retry the import of the CDIs and convert to bundles.", - "operationId" : "syncCDI_1", - "responses" : { - "200" : { - "description" : "Obtained bundle list.", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/cdis/sync": { + "get": { + "tags": [ + "Import CDI rest API" + ], + "summary": "API to retry the import of the CDIs and convert to bundles.", + "operationId": "syncCDI_1", + "responses": { + "200": { + "description": "Obtained bundle list.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/BundleResponse" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BundleResponse" } } } } }, - "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": [] + } + ] }, - "post" : { - "tags" : [ "Import CDI rest API" ], - "summary" : "API to trigger the import of the CDIs and convert to bundles.", - "operationId" : "syncCDI", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/CDI" + "post": { + "tags": [ + "Import CDI rest API" + ], + "summary": "API to trigger the import of the CDIs and convert to bundles.", + "operationId": "syncCDI", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CDI" } } } }, - "required" : true + "required": true }, - "responses" : { - "200" : { - "description" : "Obtained bundle list.", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "responses": { + "200": { + "description": "Obtained bundle list.", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/BundleResponse" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BundleResponse" } } } } }, - "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": [] + } + ] }, - "delete" : { - "tags" : [ "Delete CDI rest API" ], - "summary" : "API to trigger the bulk deletion of the CDIs and its related bundles.", - "operationId" : "syncCDIDeletion", - "responses" : { - "200" : { - "description" : "Obtained bundle list.", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "delete": { + "tags": [ + "Delete CDI rest API" + ], + "summary": "API to trigger the bulk deletion of the CDIs and its related bundles.", + "operationId": "syncCDIDeletion", + "responses": { + "200": { + "description": "Obtained bundle list.", + "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" + "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" + } } - } ] + ] }, - "/info" : { - "get" : { - "tags" : [ "Home" ], - "summary" : "health check", - "description" : "Return OK if application is started", - "operationId" : "healthCheck", - "responses" : { - "200" : { - "description" : "OK", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "/info": { + "get": { + "tags": [ + "Home" + ], + "summary": "health check", + "description": "Return OK if application is started", + "operationId": "healthCheck", + "responses": { + "200": { + "description": "OK", + "headers": { + "X-Request-Id": { + "description": "This header identifies the call", + "schema": { + "type": "string" } } }, - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/AppInfo" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AppInfo" } } } }, - "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" + } } - } ] + ] }, - "/psps/{pspCode}/cdis/{idCdi}" : { - "delete" : { - "tags" : [ "Delete Bundles by id CDI rest API" ], - "summary" : "API to trigger the deletion of the bundles by a CDI id.", - "operationId" : "syncBundlesDeletionByIdCDI", - "parameters" : [ { - "name" : "idCdi", - "in" : "path", - "description" : "CDI identifier", - "required" : true, - "schema" : { - "maxLength" : 50, - "minLength" : 0, - "type" : "string" - } - }, { - "name" : "pspCode", - "in" : "path", - "description" : "PSP code", - "required" : true, - "schema" : { - "pattern" : "[A-Z0-9_]{6,14}", - "type" : "string" + "/psps/{pspCode}/cdis/{idCdi}": { + "delete": { + "tags": [ + "Delete Bundles by id CDI rest API" + ], + "summary": "API to trigger the deletion of the bundles by a CDI id.", + "operationId": "syncBundlesDeletionByIdCDI", + "parameters": [ + { + "name": "idCdi", + "in": "path", + "description": "CDI identifier", + "required": true, + "schema": { + "maxLength": 50, + "minLength": 0, + "type": "string" + } + }, + { + "name": "pspCode", + "in": "path", + "description": "PSP code", + "required": true, + "schema": { + "pattern": "[A-Z0-9_]{6,14}", + "type": "string" + } } - } ], - "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" } } } }, - "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" } } } }, - "404" : { - "description" : "Not Found", - "headers" : { - "X-Request-Id" : { - "description" : "This header identifies the call", - "schema" : { - "type" : "string" + "404": { + "description": "Not Found", + "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" } } } }, - "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" : { - "CDI" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "string" + "components": { + "schemas": { + "CDI": { + "type": "object", + "properties": { + "id": { + "type": "string" }, - "idPsp" : { - "type" : "string" + "idPsp": { + "type": "string" }, - "idCdi" : { - "type" : "string" + "idCdi": { + "type": "string" }, - "abi" : { - "type" : "string" + "abi": { + "type": "string" }, - "digitalStamp" : { - "type" : "boolean" + "digitalStamp": { + "type": "boolean" }, - "validityDateFrom" : { - "type" : "string" + "validityDateFrom": { + "type": "string" }, - "pspBusinessName" : { - "type" : "string" + "pspBusinessName": { + "type": "string" }, - "details" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Detail" + "details": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Detail" } }, - "cdiStatus" : { - "type" : "string", - "enum" : [ "NEW", "FAILED", "PROCESSING" ] + "cdiStatus": { + "type": "string", + "enum": [ + "NEW", + "FAILED", + "PROCESSING" + ] }, - "cdiErrorDesc" : { - "type" : "string" + "cdiErrorDesc": { + "type": "string" } } }, - "Detail" : { - "type" : "object", - "properties" : { - "idBrokerPsp" : { - "type" : "string" + "Detail": { + "type": "object", + "properties": { + "idBrokerPsp": { + "type": "string" }, - "idChannel" : { - "type" : "string" + "idChannel": { + "type": "string" }, - "name" : { - "type" : "string" + "name": { + "type": "string" }, - "description" : { - "type" : "string" + "description": { + "type": "string" }, - "paymentType" : { - "type" : "string" + "paymentType": { + "type": "string" }, - "channelApp" : { - "type" : "boolean" + "channelApp": { + "type": "boolean" }, - "channelCardsCart" : { - "type" : "boolean" + "channelCardsCart": { + "type": "boolean" }, - "serviceAmount" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/ServiceAmount" + "serviceAmount": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ServiceAmount" } } } }, - "ServiceAmount" : { - "type" : "object", - "properties" : { - "paymentAmount" : { - "type" : "integer", - "format" : "int64" - }, - "minPaymentAmount" : { - "type" : "integer", - "format" : "int64" - }, - "maxPaymentAmount" : { - "type" : "integer", - "format" : "int64" + "ServiceAmount": { + "type": "object", + "properties": { + "paymentAmount": { + "type": "integer", + "format": "int64" + }, + "minPaymentAmount": { + "type": "integer", + "format": "int64" + }, + "maxPaymentAmount": { + "type": "integer", + "format": "int64" } } }, - "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" + "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" } } }, - "BundleResponse" : { - "type" : "object", - "properties" : { - "idBundle" : { - "type" : "string" + "BundleResponse": { + "type": "object", + "properties": { + "idBundle": { + "type": "string" } } }, - "AppInfo" : { - "type" : "object", - "properties" : { - "name" : { - "type" : "string" + "AppInfo": { + "type": "object", + "properties": { + "name": { + "type": "string" }, - "version" : { - "type" : "string" + "version": { + "type": "string" }, - "environment" : { - "type" : "string" + "environment": { + "type": "string" } } } }, - "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 0537dc7e..542f47da 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa afm-utils - 0.7.0 + 0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp afm-utils Utility microservice for pagoPA AFM jar From bd4da493a71486265556c0062d85bf24fc9ea570 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 20 Oct 2023 12:56:17 +0000 Subject: [PATCH 04/15] Bump to version 0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 4 ++-- helm/values-prod.yaml | 4 ++-- helm/values-uat.yaml | 4 ++-- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 60e53ff5..987ffde7 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-utils description: Utility microservice for pagoPA AFM type: application -version: 0.15.1 -appVersion: 0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp +version: 0.16.0 +appVersion: 0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp dependencies: - name: microservice-chart version: 1.21.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index c46d393a..3fa75148 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0" + tag: "0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: @@ -90,7 +90,7 @@ microservice-chart: values: - user canaryDelivery: - create: true + create: false ingress: create: true canary: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index b12c0d29..b761deab 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0" + tag: "0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: @@ -90,7 +90,7 @@ microservice-chart: values: - user canaryDelivery: - create: true + create: false ingress: create: true canary: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index efda525f..92daed1e 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0" + tag: "0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: @@ -90,7 +90,7 @@ microservice-chart: values: - user canaryDelivery: - create: true + create: false ingress: create: true canary: diff --git a/openapi/openapi.json b/openapi/openapi.json index 3482675b..208d1c64 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "afm-utils", "description": "Utility microservice for pagoPA AFM", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + "version": "0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 542f47da..bfe15452 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa afm-utils - 0.7.0-1-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp + 0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp afm-utils Utility microservice for pagoPA AFM jar From 495ce5625349d3752b83f1e7000337ce8b5a2850 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 20 Oct 2023 13:18:41 +0000 Subject: [PATCH 05/15] Bump to version 0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp [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 987ffde7..0b7baf02 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-utils description: Utility microservice for pagoPA AFM type: application -version: 0.16.0 -appVersion: 0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp +version: 0.17.0 +appVersion: 0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp dependencies: - name: microservice-chart version: 1.21.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 3fa75148..8d83639f 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index b761deab..c7bc6ee1 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 92daed1e..51d7c755 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 208d1c64..b8e701a7 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "afm-utils", "description": "Utility microservice for pagoPA AFM", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + "version": "0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" }, "servers": [ { diff --git a/pom.xml b/pom.xml index bfe15452..ab59c123 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa afm-utils - 0.7.0-2-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp + 0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp afm-utils Utility microservice for pagoPA AFM jar From 53ab66df566d4a7c0155fce452ef21786ec09886 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Fri, 20 Oct 2023 15:48:43 +0200 Subject: [PATCH 06/15] [PAGOPA-1305] fix --- src/main/java/it/gov/pagopa/afm/utils/entity/Bundle.java | 1 + src/main/java/it/gov/pagopa/afm/utils/entity/CDI.java | 8 +++----- src/main/java/it/gov/pagopa/afm/utils/entity/Detail.java | 8 +++----- .../it/gov/pagopa/afm/utils/entity/ServiceAmount.java | 7 ++----- .../java/it/gov/pagopa/afm/utils/entity/StatusType.java | 3 +++ .../gov/pagopa/afm/utils/model/bundle/BundleRequest.java | 8 +++----- .../gov/pagopa/afm/utils/model/bundle/BundleResponse.java | 7 ++----- .../it/gov/pagopa/afm/utils/model/bundle/BundleType.java | 2 ++ .../it/gov/pagopa/afm/utils/model/bundle/CDIWrapper.java | 8 +++----- .../pagopa/afm/utils/model/bundle/PaymentMethodType.java | 3 +++ .../gov/pagopa/afm/utils/model/bundle/TouchpointType.java | 3 +++ .../gov/pagopa/afm/utils/repository/BundleRepository.java | 2 +- .../java/it/gov/pagopa/afm/utils/service/CDIService.java | 2 +- 13 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/main/java/it/gov/pagopa/afm/utils/entity/Bundle.java b/src/main/java/it/gov/pagopa/afm/utils/entity/Bundle.java index 1ab74ee5..a8194ca9 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/entity/Bundle.java +++ b/src/main/java/it/gov/pagopa/afm/utils/entity/Bundle.java @@ -19,6 +19,7 @@ @NoArgsConstructor @AllArgsConstructor @Builder(toBuilder = true) +@ToString public class Bundle { @Id @GeneratedValue private String id; diff --git a/src/main/java/it/gov/pagopa/afm/utils/entity/CDI.java b/src/main/java/it/gov/pagopa/afm/utils/entity/CDI.java index c1462eab..43d62a77 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/entity/CDI.java +++ b/src/main/java/it/gov/pagopa/afm/utils/entity/CDI.java @@ -2,11 +2,8 @@ import com.azure.spring.data.cosmos.core.mapping.Container; import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; + +import lombok.*; @Container( containerName = "${azure.cosmos.cdi-container-name}", @@ -17,6 +14,7 @@ @NoArgsConstructor @AllArgsConstructor @Builder +@ToString public class CDI { private String id; private String idPsp; diff --git a/src/main/java/it/gov/pagopa/afm/utils/entity/Detail.java b/src/main/java/it/gov/pagopa/afm/utils/entity/Detail.java index 74ad7608..2dc0ffda 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/entity/Detail.java +++ b/src/main/java/it/gov/pagopa/afm/utils/entity/Detail.java @@ -1,17 +1,15 @@ package it.gov.pagopa.afm.utils.entity; import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; + +import lombok.*; @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder +@ToString public class Detail { private String idBrokerPsp; diff --git a/src/main/java/it/gov/pagopa/afm/utils/entity/ServiceAmount.java b/src/main/java/it/gov/pagopa/afm/utils/entity/ServiceAmount.java index c416d351..2ed00aaa 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/entity/ServiceAmount.java +++ b/src/main/java/it/gov/pagopa/afm/utils/entity/ServiceAmount.java @@ -1,16 +1,13 @@ package it.gov.pagopa.afm.utils.entity; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.*; @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder +@ToString public class ServiceAmount { private Long paymentAmount; private Long minPaymentAmount; diff --git a/src/main/java/it/gov/pagopa/afm/utils/entity/StatusType.java b/src/main/java/it/gov/pagopa/afm/utils/entity/StatusType.java index 3cb0fb87..d54d120c 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/entity/StatusType.java +++ b/src/main/java/it/gov/pagopa/afm/utils/entity/StatusType.java @@ -1,5 +1,8 @@ package it.gov.pagopa.afm.utils.entity; +import lombok.ToString; + +@ToString public enum StatusType { NEW, FAILED, diff --git a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleRequest.java b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleRequest.java index 71cd953e..88de5748 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleRequest.java +++ b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleRequest.java @@ -4,17 +4,15 @@ import java.time.LocalDate; import java.util.List; import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; + +import lombok.*; @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder(toBuilder = true) +@ToString public class BundleRequest implements Serializable { /** generated serialVersionUID */ private static final long serialVersionUID = -3848735995119820291L; diff --git a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleResponse.java b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleResponse.java index edb6826d..7095625b 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleResponse.java +++ b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleResponse.java @@ -1,16 +1,13 @@ package it.gov.pagopa.afm.utils.model.bundle; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.*; @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder(toBuilder = true) +@ToString public class BundleResponse { private String idBundle; } diff --git a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleType.java b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleType.java index c672228c..2ccbd1ef 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleType.java +++ b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/BundleType.java @@ -3,9 +3,11 @@ import it.gov.pagopa.afm.utils.exception.AppException; import java.util.Arrays; import lombok.Getter; +import lombok.ToString; import org.springframework.http.HttpStatus; @Getter +@ToString public enum BundleType { GLOBAL("GLOBAL"), PUBLIC("PUBLIC"), diff --git a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/CDIWrapper.java b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/CDIWrapper.java index eb696e90..653b4fec 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/CDIWrapper.java +++ b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/CDIWrapper.java @@ -2,17 +2,15 @@ import it.gov.pagopa.afm.utils.entity.CDI; import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; + +import lombok.*; @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder +@ToString public class CDIWrapper { private List cdiItems; } diff --git a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/PaymentMethodType.java b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/PaymentMethodType.java index aac9e049..80ae5f80 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/PaymentMethodType.java +++ b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/PaymentMethodType.java @@ -1,5 +1,8 @@ package it.gov.pagopa.afm.utils.model.bundle; +import lombok.ToString; + +@ToString public enum PaymentMethodType { PO, CP, diff --git a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/TouchpointType.java b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/TouchpointType.java index 42c1f622..5016ac2e 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/model/bundle/TouchpointType.java +++ b/src/main/java/it/gov/pagopa/afm/utils/model/bundle/TouchpointType.java @@ -1,5 +1,8 @@ package it.gov.pagopa.afm.utils.model.bundle; +import lombok.ToString; + +@ToString public enum TouchpointType { PSP, WISP, diff --git a/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java b/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java index 5171681d..f8406df9 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java +++ b/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java @@ -12,5 +12,5 @@ public interface BundleRepository extends CosmosRepository { List findByIdCdiIsNotNull(); List findByIdCdi(String idCdi, PartitionKey pspCode); - List findAllByIdPsp(PartitionKey pspCode); + List findAllByIdPsp(String pspCode); } diff --git a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java index ebcec224..4fafc02f 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java +++ b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java @@ -61,7 +61,7 @@ public void deleteCDI(CDI cdiEntity) { public void saveCDIs(List cdis) { for (CDI cdi : cdis) { - List bundlesToRemove = bundleRepository.findAllByIdPsp(new PartitionKey(cdi.getIdPsp())); + List bundlesToRemove = bundleRepository.findAllByIdPsp(cdi.getIdPsp()); bundlesToRemove.forEach(elem -> elem.setValidityDateTo(LocalDate.now())); bundleRepository.saveAll(bundlesToRemove); } From 59847240591faf49a538b37bfb9d8fb941b877b7 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 20 Oct 2023 13:50:21 +0000 Subject: [PATCH 07/15] Bump to version 0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp [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 0b7baf02..636c1429 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-utils description: Utility microservice for pagoPA AFM type: application -version: 0.17.0 -appVersion: 0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp +version: 0.18.0 +appVersion: 0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp dependencies: - name: microservice-chart version: 1.21.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 8d83639f..117801ad 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index c7bc6ee1..b1413354 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 51d7c755..05ed187e 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index b8e701a7..6bafa3ea 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "afm-utils", "description": "Utility microservice for pagoPA AFM", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + "version": "0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" }, "servers": [ { diff --git a/pom.xml b/pom.xml index ab59c123..4ea4e9be 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa afm-utils - 0.7.0-3-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp + 0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp afm-utils Utility microservice for pagoPA AFM jar From d9446811cd344776802a18e100af3bb82de2f219 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Fri, 20 Oct 2023 15:53:44 +0200 Subject: [PATCH 08/15] [PAGOPA-1305] refactor --- .../pagopa/afm/utils/service/CDIService.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java index 4fafc02f..9bebfaa6 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java +++ b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java @@ -60,11 +60,10 @@ public void deleteCDI(CDI cdiEntity) { } public void saveCDIs(List cdis) { - for (CDI cdi : cdis) { - List bundlesToRemove = bundleRepository.findAllByIdPsp(cdi.getIdPsp()); - bundlesToRemove.forEach(elem -> elem.setValidityDateTo(LocalDate.now())); - bundleRepository.saveAll(bundlesToRemove); - } + // first of all we logically remove the old bundles of the PSP + removeOldBundles(cdis); + + // then we save the new bundles cdisRepository.saveAll(cdis); CompletableFuture.runAsync(() -> turnCDIToBundles(cdis)); } @@ -293,4 +292,18 @@ public void setCDIToProcessingStatus(List items) { Optional.ofNullable(updated).map(result -> updated.getCdiStatus()))); } } + + /** + * Remove logically all the PSP's bundles: + * validityDateTo is set to now() + * + * @param cdis the list with the new CDI elements + */ + private void removeOldBundles(List cdis) { + for (CDI cdi : cdis) { + List oldBundlesToRemove = bundleRepository.findAllByIdPsp(cdi.getIdPsp()); + oldBundlesToRemove.forEach(elem -> elem.setValidityDateTo(LocalDate.now())); + bundleRepository.saveAll(oldBundlesToRemove); + } + } } From 1512fec31019b52c32fa009ef0c931c4d5f0edfe Mon Sep 17 00:00:00 2001 From: Jacopo Date: Mon, 23 Oct 2023 10:21:42 +0200 Subject: [PATCH 09/15] [PAGOPA-1305] if a new CDI is upload we'll remove (logically) old GLOBAL bundles --- .../utils/repository/BundleRepository.java | 2 +- .../pagopa/afm/utils/service/CDIService.java | 39 +++++++++---------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java b/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java index f8406df9..b02f9324 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java +++ b/src/main/java/it/gov/pagopa/afm/utils/repository/BundleRepository.java @@ -12,5 +12,5 @@ public interface BundleRepository extends CosmosRepository { List findByIdCdiIsNotNull(); List findByIdCdi(String idCdi, PartitionKey pspCode); - List findAllByIdPsp(String pspCode); + List findAllByIdPspAndType(String pspCode, String type); } diff --git a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java index 9bebfaa6..a35a4c57 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java +++ b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java @@ -3,20 +3,20 @@ import com.azure.cosmos.implementation.apachecommons.lang.StringUtils; import com.azure.cosmos.models.PartitionKey; import feign.FeignException; -import it.gov.pagopa.afm.utils.entity.Bundle; -import it.gov.pagopa.afm.utils.entity.CDI; -import it.gov.pagopa.afm.utils.entity.Detail; -import it.gov.pagopa.afm.utils.entity.ServiceAmount; -import it.gov.pagopa.afm.utils.entity.StatusType; +import it.gov.pagopa.afm.utils.entity.*; import it.gov.pagopa.afm.utils.exception.AppError; import it.gov.pagopa.afm.utils.exception.AppException; -import it.gov.pagopa.afm.utils.model.bundle.BundleRequest; -import it.gov.pagopa.afm.utils.model.bundle.BundleResponse; -import it.gov.pagopa.afm.utils.model.bundle.BundleType; -import it.gov.pagopa.afm.utils.model.bundle.PaymentMethodType; -import it.gov.pagopa.afm.utils.model.bundle.TouchpointType; +import it.gov.pagopa.afm.utils.model.bundle.*; import it.gov.pagopa.afm.utils.repository.BundleRepository; import it.gov.pagopa.afm.utils.repository.CDICollectionRepository; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.SerializationUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.time.LocalDate; import java.time.LocalDateTime; @@ -27,15 +27,6 @@ import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.SerializationUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - @Service @AllArgsConstructor @NoArgsConstructor @@ -300,9 +291,15 @@ public void setCDIToProcessingStatus(List items) { * @param cdis the list with the new CDI elements */ private void removeOldBundles(List cdis) { + DateTimeFormatter dfDate = DateTimeFormatter.ofPattern("yyyy-MM-dd"); for (CDI cdi : cdis) { - List oldBundlesToRemove = bundleRepository.findAllByIdPsp(cdi.getIdPsp()); - oldBundlesToRemove.forEach(elem -> elem.setValidityDateTo(LocalDate.now())); + List oldBundlesToRemove = bundleRepository.findAllByIdPspAndType(cdi.getIdPsp(), "GLOBAL"); + oldBundlesToRemove.forEach(elem -> { + LocalDate dateFrom = LocalDate.parse(cdi.getValidityDateFrom(), dfDate); + if(elem.getValidityDateTo() == null || elem.getValidityDateTo().isAfter(dateFrom)) { + elem.setValidityDateTo(dateFrom.minusDays(1)); + } + }); bundleRepository.saveAll(oldBundlesToRemove); } } From 0717d344d69fdd4263abbc0f02949be39858f3e5 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 23 Oct 2023 08:59:51 +0000 Subject: [PATCH 10/15] Bump to version 0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp [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 636c1429..e868d693 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-utils description: Utility microservice for pagoPA AFM type: application -version: 0.18.0 -appVersion: 0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp +version: 0.19.0 +appVersion: 0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp dependencies: - name: microservice-chart version: 1.21.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 117801ad..8ae6d3e9 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index b1413354..b0200466 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 05ed187e..25902a90 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 6bafa3ea..2d764d08 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "afm-utils", "description": "Utility microservice for pagoPA AFM", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + "version": "0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 4ea4e9be..b1feedc2 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa afm-utils - 0.7.0-4-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp + 0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp afm-utils Utility microservice for pagoPA AFM jar From 7ec15a6a0be15e77a3c44a0d03e162e24ba68529 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Mon, 23 Oct 2023 11:03:18 +0200 Subject: [PATCH 11/15] [PAGOPA-1305] log --- src/main/java/it/gov/pagopa/afm/utils/task/SchedulerTask.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/it/gov/pagopa/afm/utils/task/SchedulerTask.java b/src/main/java/it/gov/pagopa/afm/utils/task/SchedulerTask.java index 3d0034bb..6d3af1ff 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/task/SchedulerTask.java +++ b/src/main/java/it/gov/pagopa/afm/utils/task/SchedulerTask.java @@ -2,12 +2,15 @@ import it.gov.pagopa.afm.utils.service.MarketPlaceClient; import javax.annotation.PostConstruct; + +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; @Component +@Slf4j public class SchedulerTask { @Autowired private ThreadPoolTaskScheduler taskScheduler; @@ -18,6 +21,7 @@ public class SchedulerTask { @PostConstruct public void scheduleRunnableWithCronTrigger() { + log.info("schedule task started: refresh configuration"); MarketPlaceTrigger marketPlaceTrigger = new MarketPlaceTrigger(marketPlaceClient); taskScheduler.schedule(marketPlaceTrigger, cronTrigger); From 826f52630fc0c4a6f15af721660e925573d534e1 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 23 Oct 2023 12:21:56 +0000 Subject: [PATCH 12/15] Bump to version 0.7.0-6-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp [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 e868d693..091d19e0 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-afm-utils description: Utility microservice for pagoPA AFM type: application -version: 0.19.0 -appVersion: 0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp +version: 0.20.0 +appVersion: 0.7.0-6-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp dependencies: - name: microservice-chart version: 1.21.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 8ae6d3e9..3d1959f9 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-6-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index b0200466..226dec8f 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-6-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 25902a90..ad960e30 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-afm-utils - tag: "0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + tag: "0.7.0-6-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 2d764d08..2ec0cd78 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "afm-utils", "description": "Utility microservice for pagoPA AFM", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" + "version": "0.7.0-6-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp" }, "servers": [ { diff --git a/pom.xml b/pom.xml index b1feedc2..23d1cd41 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa afm-utils - 0.7.0-5-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp + 0.7.0-6-PAGOPA-1305-invalidare-i-bundle-settando-la-data-di-fine-validita-per-psp afm-utils Utility microservice for pagoPA AFM jar From c8da9202ea41933ad59d1c7fc1ac0926a16e6e51 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Mon, 23 Oct 2023 16:31:40 +0200 Subject: [PATCH 13/15] [PAGOPA-1305] gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index f2da3d8d..36d6ea3e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ target/**/* .iml /utilities/emulatorcert.crt .cache +/docker/.env +/afm-utils.iml +/helm/charts/ +/.identity/.terraform.lock.hcl From 3aeed5f9a3710ce22cbf7a11fb711ae54b9e81cd Mon Sep 17 00:00:00 2001 From: Jacopo Date: Wed, 25 Oct 2023 11:14:01 +0200 Subject: [PATCH 14/15] [PAGOPA-1305] bug fixing --- .../java/it/gov/pagopa/afm/utils/service/CDIService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java index a35a4c57..9bfd6037 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java +++ b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java @@ -90,7 +90,10 @@ public void deleteBundlesByIdCDI(String idCdi, String pspCode) { Optional.ofNullable(marketPlaceClient) .ifPresent(result -> marketPlaceClient.removeBundle(pspCode, bundle.getId())); } catch (FeignException.BadRequest e) { - throw new AppException(AppError.BUNDLE_REQUEST_DATA_ERROR, e.getMessage()); + // ignore bundle already deleted + if (!e.getMessage().contains("Bundle has been already deleted")){ + throw new AppException(AppError.BUNDLE_REQUEST_DATA_ERROR, e.getMessage()); + } } catch (FeignException.NotFound e) { throw new AppException(AppError.BUNDLE_NOT_FOUND_ERROR, e.getMessage()); } catch (FeignException.Conflict e) { @@ -245,7 +248,8 @@ private void addBundleByTouchpoint( } if(isNullTouchPoint) { // default bundle with null touchpoint value - bundleRequestList.add(bundleRequest); + BundleRequest bundleRequestClone = SerializationUtils.clone(bundleRequest); + bundleRequestList.add(bundleRequestClone); } } From 9b836aacb8a742a9bc2c7acae0414dda4ef0bbb7 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Wed, 25 Oct 2023 11:33:50 +0200 Subject: [PATCH 15/15] [PAGOPA-1305] bug fixing --- openapi/openapi.json | 913 +++++++++--------- .../pagopa/afm/utils/service/CDIService.java | 4 +- 2 files changed, 441 insertions(+), 476 deletions(-) diff --git a/openapi/openapi.json b/openapi/openapi.json index 8d4c560f..ee3684b6 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1,681 +1,646 @@ { - "openapi": "3.0.1", - "info": { - "title": "afm-utils", - "description": "Utility microservice for pagoPA AFM", - "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.8.0" + "openapi" : "3.0.1", + "info" : { + "title" : "afm-utils", + "description" : "@project.description@", + "termsOfService" : "https://www.pagopa.gov.it/", + "version" : "0.8.0" }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/cdis/sync": { - "get": { - "tags": [ - "Import CDI rest API" - ], - "summary": "API to retry the import of the CDIs and convert to bundles.", - "operationId": "syncCDI_1", - "responses": { - "200": { - "description": "Obtained bundle list.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "paths" : { + "/cdis/sync" : { + "get" : { + "tags" : [ "Import CDI rest API" ], + "summary" : "API to retry the import of the CDIs and convert to bundles.", + "operationId" : "syncCDI_1", + "responses" : { + "200" : { + "description" : "Obtained bundle list.", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BundleResponse" + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BundleResponse" } } } } }, - "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" : [ ] + } ] }, - "post": { - "tags": [ - "Import CDI rest API" - ], - "summary": "API to trigger the import of the CDIs and convert to bundles.", - "operationId": "syncCDI", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CDI" + "post" : { + "tags" : [ "Import CDI rest API" ], + "summary" : "API to trigger the import of the CDIs and convert to bundles.", + "operationId" : "syncCDI", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/CDI" } } } }, - "required": true + "required" : true }, - "responses": { - "200": { - "description": "Obtained bundle list.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "responses" : { + "200" : { + "description" : "Obtained bundle list.", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BundleResponse" + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BundleResponse" } } } } }, - "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" : [ ] + } ] }, - "delete": { - "tags": [ - "Delete CDI rest API" - ], - "summary": "API to trigger the bulk deletion of the CDIs and its related bundles.", - "operationId": "syncCDIDeletion", - "responses": { - "200": { - "description": "Obtained bundle list.", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "delete" : { + "tags" : [ "Delete CDI rest API" ], + "summary" : "API to trigger the bulk deletion of the CDIs and its related bundles.", + "operationId" : "syncCDIDeletion", + "responses" : { + "200" : { + "description" : "Obtained bundle list.", + "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" + "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" } - ] + } ] }, - "/info": { - "get": { - "tags": [ - "Home" - ], - "summary": "health check", - "description": "Return OK if application is started", - "operationId": "healthCheck", - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "/info" : { + "get" : { + "tags" : [ "Home" ], + "summary" : "health check", + "description" : "Return OK if application is started", + "operationId" : "healthCheck", + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "X-Request-Id" : { + "description" : "This header identifies the call", + "schema" : { + "type" : "string" } } }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AppInfo" + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/AppInfo" } } } }, - "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" } - ] + } ] }, - "/psps/{pspCode}/cdis/{idCdi}": { - "delete": { - "tags": [ - "Delete Bundles by id CDI rest API" - ], - "summary": "API to trigger the deletion of the bundles by a CDI id.", - "operationId": "syncBundlesDeletionByIdCDI", - "parameters": [ - { - "name": "idCdi", - "in": "path", - "description": "CDI identifier", - "required": true, - "schema": { - "maxLength": 50, - "minLength": 0, - "type": "string" - } - }, - { - "name": "pspCode", - "in": "path", - "description": "PSP code", - "required": true, - "schema": { - "pattern": "[A-Z0-9_]{6,14}", - "type": "string" - } + "/psps/{pspCode}/cdis/{idCdi}" : { + "delete" : { + "tags" : [ "Delete Bundles by id CDI rest API" ], + "summary" : "API to trigger the deletion of the bundles by a CDI id.", + "operationId" : "syncBundlesDeletionByIdCDI", + "parameters" : [ { + "name" : "idCdi", + "in" : "path", + "description" : "CDI identifier", + "required" : true, + "schema" : { + "maxLength" : 50, + "minLength" : 0, + "type" : "string" } - ], - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + }, { + "name" : "pspCode", + "in" : "path", + "description" : "PSP code", + "required" : true, + "schema" : { + "pattern" : "[A-Z0-9_]{6,14}", + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "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" + "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" } } } }, - "404": { - "description": "Not Found", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" + "404" : { + "description" : "Not Found", + "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" } } } }, - "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": { - "CDI": { - "type": "object", - "properties": { - "id": { - "type": "string" + "components" : { + "schemas" : { + "CDI" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" }, - "idPsp": { - "type": "string" + "idPsp" : { + "type" : "string" }, - "idCdi": { - "type": "string" + "idCdi" : { + "type" : "string" }, - "abi": { - "type": "string" + "abi" : { + "type" : "string" }, - "digitalStamp": { - "type": "boolean" + "digitalStamp" : { + "type" : "boolean" }, - "validityDateFrom": { - "type": "string" + "validityDateFrom" : { + "type" : "string" }, - "pspBusinessName": { - "type": "string" + "pspBusinessName" : { + "type" : "string" }, - "details": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Detail" + "details" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Detail" } }, - "cdiStatus": { - "type": "string", - "enum": [ - "NEW", - "FAILED", - "PROCESSING" - ] + "cdiStatus" : { + "type" : "string", + "enum" : [ "StatusType.NEW", "StatusType.FAILED", "StatusType.PROCESSING" ] }, - "cdiErrorDesc": { - "type": "string" + "cdiErrorDesc" : { + "type" : "string" } } }, - "Detail": { - "type": "object", - "properties": { - "idBrokerPsp": { - "type": "string" + "Detail" : { + "type" : "object", + "properties" : { + "idBrokerPsp" : { + "type" : "string" }, - "idChannel": { - "type": "string" + "idChannel" : { + "type" : "string" }, - "name": { - "type": "string" + "name" : { + "type" : "string" }, - "description": { - "type": "string" + "description" : { + "type" : "string" }, - "paymentType": { - "type": "string" + "paymentType" : { + "type" : "string" }, - "channelApp": { - "type": "boolean" + "channelApp" : { + "type" : "boolean" }, - "channelCardsCart": { - "type": "boolean" + "channelCardsCart" : { + "type" : "boolean" }, - "serviceAmount": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ServiceAmount" + "serviceAmount" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/ServiceAmount" } } } }, - "ServiceAmount": { - "type": "object", - "properties": { - "paymentAmount": { - "type": "integer", - "format": "int64" - }, - "minPaymentAmount": { - "type": "integer", - "format": "int64" - }, - "maxPaymentAmount": { - "type": "integer", - "format": "int64" + "ServiceAmount" : { + "type" : "object", + "properties" : { + "paymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "minPaymentAmount" : { + "type" : "integer", + "format" : "int64" + }, + "maxPaymentAmount" : { + "type" : "integer", + "format" : "int64" } } }, - "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" + "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" } } }, - "BundleResponse": { - "type": "object", - "properties": { - "idBundle": { - "type": "string" + "BundleResponse" : { + "type" : "object", + "properties" : { + "idBundle" : { + "type" : "string" } } }, - "AppInfo": { - "type": "object", - "properties": { - "name": { - "type": "string" + "AppInfo" : { + "type" : "object", + "properties" : { + "name" : { + "type" : "string" }, - "version": { - "type": "string" + "version" : { + "type" : "string" }, - "environment": { - "type": "string" + "environment" : { + "type" : "string" } } } }, - "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/afm/utils/service/CDIService.java b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java index 9bfd6037..9218571a 100644 --- a/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java +++ b/src/main/java/it/gov/pagopa/afm/utils/service/CDIService.java @@ -90,8 +90,8 @@ public void deleteBundlesByIdCDI(String idCdi, String pspCode) { Optional.ofNullable(marketPlaceClient) .ifPresent(result -> marketPlaceClient.removeBundle(pspCode, bundle.getId())); } catch (FeignException.BadRequest e) { - // ignore bundle already deleted - if (!e.getMessage().contains("Bundle has been already deleted")){ + // we ignore the bundles already (logically) deleted + if(e.getMessage() == null || !e.getMessage().contains("Bundle has been already deleted")) { throw new AppException(AppError.BUNDLE_REQUEST_DATA_ERROR, e.getMessage()); } } catch (FeignException.NotFound e) {