Skip to content

Commit

Permalink
fix: migrating to new statuses' flow (#13)
Browse files Browse the repository at this point in the history
* fix: migrating to new statuses' flow
* fix: adding missing methods

---------

Co-authored-by: pagopa-github-bot <[email protected]>
  • Loading branch information
andrea-deri and pagopa-github-bot authored Nov 25, 2024
1 parent 0e26594 commit d3082d0
Show file tree
Hide file tree
Showing 31 changed files with 270 additions and 439 deletions.
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-wisp-converter-technical-support
description: A service that permits to handle converted WISP requests for technical support
type: application
version: 0.28.0
appVersion: 0.2.1
version: 0.30.0
appVersion: 0.2.1-2-fix-migration-to-new-statuses
dependencies:
- name: microservice-chart
version: 3.0.0
Expand Down
3 changes: 2 additions & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter-technical-support
tag: "0.2.1"
tag: "0.2.1-2-fix-migration-to-new-statuses"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -69,6 +69,7 @@ microservice-chart:
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
SERVICE_NAME: "pagopa-wisp-converter-technical-support"
COSMOS_URI: "https://pagopa-d-weu-nodo-wispconv-cosmos-account.documents.azure.com:443/"
COSMOS_READ_REGION: "West Europe"
secretProvider:
create: true
envSecrets:
Expand Down
3 changes: 2 additions & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter-technical-support
tag: "0.2.1"
tag: "0.2.1-2-fix-migration-to-new-statuses"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -69,6 +69,7 @@ microservice-chart:
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
SERVICE_NAME: "pagopa-wisp-converter-technical-support"
COSMOS_URI: "https://pagopa-p-weu-nodo-wispconv-cosmos-account.documents.azure.com:443/"
COSMOS_READ_REGION: "North Europe"
secretProvider:
create: true
envSecrets:
Expand Down
3 changes: 2 additions & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter-technical-support
tag: "0.2.1"
tag: "0.2.1-2-fix-migration-to-new-statuses"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -69,6 +69,7 @@ microservice-chart:
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
SERVICE_NAME: "pagopa-wisp-converter-technical-support"
COSMOS_URI: "https://pagopa-u-weu-nodo-wispconv-cosmos-account.documents.azure.com:443/"
COSMOS_READ_REGION: "West Europe"
secretProvider:
create: true
envSecrets:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A service that permits to handle converted WISP requests for technical support",
"termsOfService": "https://www.pagopa.gov.it/",
"title": "wisp-converter-technical-support",
"version": "0.2.1"
"version": "0.2.1-2-fix-migration-to-new-statuses"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>wisp-converter-technical-support</artifactId>
<version>0.2.1</version>
<version>0.2.1-2-fix-migration-to-new-statuses</version>
<name>pagoPA WISP Converter Technical support</name>
<description>A service that permits to handle converted WISP requests for technical support</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.Nullable;

import java.util.List;

@Configuration
@EnableCosmosRepositories("it.gov.pagopa.wispconverter.technicalsupport.repository")
@EnableConfigurationProperties
Expand All @@ -38,6 +40,9 @@ public class CosmosDBConfig extends AbstractCosmosConfiguration {
@Value("${azure.cosmos.populate-query-metrics}")
private Boolean cosmosQueryMetrics;

@Value("${azure.cosmos.read.region}")
private String readRegion;

@Bean
public CosmosClientBuilder getCosmosClientBuilder() {
var azureKeyCredential = new AzureKeyCredential(cosmosKey);
Expand All @@ -46,6 +51,7 @@ public CosmosClientBuilder getCosmosClientBuilder() {
return new CosmosClientBuilder()
.endpoint(cosmosUri)
.credential(azureKeyCredential)
.preferredRegions(List.of(readRegion))
.directMode(directConnectionConfig, gatewayConnectionConfig);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import it.gov.pagopa.wispconverter.technicalsupport.controller.mapper.TechnicalSupportMapperDto;
import it.gov.pagopa.wispconverter.technicalsupport.controller.model.ReEvent;
import it.gov.pagopa.wispconverter.technicalsupport.controller.model.ReEventResponse;
import it.gov.pagopa.wispconverter.technicalsupport.service.ReService;
import it.gov.pagopa.wispconverter.technicalsupport.service.model.ReEventDto;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
Expand All @@ -30,7 +28,6 @@
public class TechnicalSupportController {

private final ReService reService;
private final TechnicalSupportMapperDto technicalSupportMapperDto;

@ApiResponses(value = {
@ApiResponse(
Expand All @@ -40,13 +37,12 @@ public class TechnicalSupportController {
})
@GetMapping(value = "/organizations/{" + ORGANIZATION + "}/notice-number/{" + NOTICE_NUMBER + "}", produces = MediaType.APPLICATION_JSON_VALUE)
public ReEventResponse findByNoticeNumber(
@PathVariable(name = ORGANIZATION) @Schema(example = "12345678900", description = "Id dell'EC") String organizationId,
@PathVariable(name = NOTICE_NUMBER) @Schema(example = "3982273480765907", description = "Numero avviso") String noticeNumber,
@RequestParam(name = DATE_FROM) @Schema(example = "2024-03-18", description = "Data di ricerca DA") LocalDate dateFrom,
@RequestParam(name = DATE_TO) @Schema(example = "2024-03-18", description = "Data di ricerca A") LocalDate dateTo) {
@PathVariable(name = ORGANIZATION) @Schema(example = "12345678900", description = "Creditor institution identifier") String organizationId,
@PathVariable(name = NOTICE_NUMBER) @Schema(example = "3982273480765907", description = "NAV payment code") String noticeNumber,
@RequestParam(name = DATE_FROM) @Schema(example = "2024-03-18", description = "Lower limit date") LocalDate dateFrom,
@RequestParam(name = DATE_TO) @Schema(example = "2024-03-18", description = "Upper limit date") LocalDate dateTo) {

List<ReEventDto> byNoticeNumber = reService.findByNoticeNumber(dateFrom, dateTo, organizationId, noticeNumber);
List<ReEvent> reEventList = technicalSupportMapperDto.toReEventList(byNoticeNumber);
List<ReEvent> reEventList = reService.findByNoticeNumber(dateFrom, dateTo, organizationId, noticeNumber);
return ReEventResponse.builder()
.count(reEventList.size())
.data(reEventList)
Expand All @@ -61,12 +57,12 @@ public ReEventResponse findByNoticeNumber(
})
@GetMapping(value = "/organizations/{" + ORGANIZATION + "}/iuv/{" + IUV + "}", produces = MediaType.APPLICATION_JSON_VALUE)
public ReEventResponse findByIuv(
@PathVariable(name = ORGANIZATION) @Schema(example = "12345678900", description = "Id dell'EC") String organizationId,
@PathVariable(name = IUV) @Schema(example = "982273480765907", description = "Identificativo univoco del versamento") String iuv,
@RequestParam(name = DATE_FROM) @Schema(example = "2024-03-18", description = "Data di ricerca DA") LocalDate dateFrom,
@RequestParam(name = DATE_TO) @Schema(example = "2024-03-18", description = "Data di ricerca A") LocalDate dateTo) {
List<ReEventDto> byNoticeNumber = reService.findByIuv(dateFrom, dateTo, organizationId, iuv);
List<ReEvent> reEventList = technicalSupportMapperDto.toReEventList(byNoticeNumber);
@PathVariable(name = ORGANIZATION) @Schema(example = "12345678900", description = "Creditor institution identifier") String organizationId,
@PathVariable(name = IUV) @Schema(example = "982273480765907", description = "IUV payment code") String iuv,
@RequestParam(name = DATE_FROM) @Schema(example = "2024-03-18", description = "Lower limit date") LocalDate dateFrom,
@RequestParam(name = DATE_TO) @Schema(example = "2024-03-18", description = "Upper limit date") LocalDate dateTo) {

List<ReEvent> reEventList = reService.findByIuv(dateFrom, dateTo, organizationId, iuv);
return ReEventResponse.builder()
.count(reEventList.size())
.data(reEventList)
Expand All @@ -84,31 +80,11 @@ public ReEventResponse findBySessionId(
@PathVariable(name = SESSION_ID) @Schema(example = "12345678900_aa0518a9-194d-4de2-999f-e462c3746e24", description = "Session identifier of the flow") String sessionId,
@RequestParam(name = DATE_FROM) @Schema(example = "2024-03-18", description = "Data di ricerca DA") LocalDate dateFrom,
@RequestParam(name = DATE_TO) @Schema(example = "2024-03-18", description = "Data di ricerca A") LocalDate dateTo) {
List<ReEventDto> bySessionId = reService.findBySessionId(dateFrom, dateTo, sessionId);
List<ReEvent> reEventList = technicalSupportMapperDto.toReEventList(bySessionId);
return ReEventResponse.builder()
.count(reEventList.size())
.data(reEventList)
.build();
}

@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "Successfully retrieved event",
content = @Content(schema = @Schema(implementation = ReEventResponse.class)))
})
@GetMapping(value = "/operation-id/{" + OPERATION_ID + "}", produces = MediaType.APPLICATION_JSON_VALUE)
public ReEventResponse findByOperationId(
@PathVariable(name = OPERATION_ID) @Schema(example = "fcfcbe1e-987a-4914-8fd2-d1e7b67762bf", description = "Identificativo dell'operazione eseguita") String operationId,
@RequestParam(name = DATE_FROM) @Schema(example = "2024-03-18", description = "Data di ricerca DA") LocalDate dateFrom,
@RequestParam(name = DATE_TO) @Schema(example = "2024-03-18", description = "Data di ricerca A") LocalDate dateTo) {
List<ReEventDto> byNoticeNumber = reService.findByOperationId(dateFrom, dateTo, operationId);
List<ReEvent> reEventList = technicalSupportMapperDto.toReEventList(byNoticeNumber);
List<ReEvent> reEventList = reService.findBySessionId(dateFrom, dateTo, sessionId);
return ReEventResponse.builder()
.count(reEventList.size())
.data(reEventList)
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package it.gov.pagopa.wispconverter.technicalsupport.controller.mapper;

import it.gov.pagopa.wispconverter.technicalsupport.controller.model.ReEvent;
import it.gov.pagopa.wispconverter.technicalsupport.repository.model.ReEventEntity;
import it.gov.pagopa.wispconverter.technicalsupport.util.Constants;
import org.mapstruct.*;

import java.util.List;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class ReEventMapper {

@Named("toDto")
@Mapping(target = "requestHeaders", expression = "java(obfuscateSecrets(reEventEntity.getRequestHeaders()))")
@Mapping(target = "responseHeaders", expression = "java(obfuscateSecrets(reEventEntity.getResponseHeaders()))")
@Mapping(target = "requestPayload", expression = "java(it.gov.pagopa.wispconverter.technicalsupport.util.CommonUtility.decompressGZip(reEventEntity.getRequestPayload()))")
@Mapping(target = "responsePayload", expression = "java(it.gov.pagopa.wispconverter.technicalsupport.util.CommonUtility.decompressGZip(reEventEntity.getResponsePayload()))")
@Mapping(target = "operationId", expression = "java(reEventEntity.getOperationId() != null ? reEventEntity.getOperationId() : reEventEntity.getSessionId())")
@Mapping(target = "insertedTimestamp", expression = "java(reEventEntity.getInsertedTimestamp().plus(1, java.time.temporal.ChronoUnit.HOURS))")
public abstract ReEvent toDto(ReEventEntity reEventEntity);

@IterableMapping(qualifiedByName = "toDto")
public abstract List<ReEvent> toDto(List<ReEventEntity> reEventEntity);

public void compact(ReEvent event) {
event.setId(null);
event.setOperationId(null);
event.setHttpMethod(null);
event.setExecutionTimeMs(null);
event.setRequestHeaders(null);
event.setResponseHeaders(null);
event.setOperationErrorLine(null);
event.setOperationErrorDetail(null);
event.setSessionId(null);
event.setPsp(null);
event.setChannel(null);
event.setInfo(null);
event.setRequestPayload(null);
event.setResponsePayload(null);
}

public String obfuscateSecrets(String httpHeaders) {
if (httpHeaders != null) {
httpHeaders = httpHeaders.replaceAll(Constants.SUBSCRIPTION_KEY_PATTERN, "\"Ocp-Apim-Subscription-Key\": [***]");
}
return httpHeaders;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package it.gov.pagopa.wispconverter.technicalsupport.controller.model;

public enum EventCategoryEnum {
INTERFACE,
INTERNAL
}
Loading

0 comments on commit d3082d0

Please sign in to comment.