Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOD-890] fix: Enrichment on RE events for tracing purpose #19

Merged
merged 10 commits into from
May 9, 2024
Merged
2 changes: 1 addition & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: pagopa-wisp-converter
description: A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing them with GPD system
type: application
version: 0.44.0
version: 0.46.0
appVersion: 0.0.16
dependencies:
- name: microservice-chart
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ microservice-chart:
CLIENT_CHECKOUT_READ_TIMEOUT: '5000'
CLIENT_DECOUPLERCACHING_READ_TIMEOUT: '5000'
CLIENT_CACHE_READ_TIMEOUT: '5000'
CLIENT_GPD_HOST: 'https://api.dev.platform.pagopa.it/gpd/api/v1'
CLIENT_GPD_HOST: 'https://api.dev.platform.pagopa.it/gpd/api/v2'
CLIENT_IUVGENERATOR_HOST: 'https://api.dev.platform.pagopa.it/shared/pagopa-iuvgenerator/v1'
CLIENT_CHECKOUT_HOST: 'https://api.dev.platform.pagopa.it/checkout/carts-auth/v1'
CLIENT_DECOUPLERCACHING_HOST: 'https://api.dev.platform.pagopa.it/wisp-converter/caching/api/v1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,87 @@

import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;

import lombok.*;
import org.springframework.data.annotation.Id;
import it.gov.pagopa.wispconverter.repository.model.enumz.*;
import lombok.Builder;
import lombok.Data;
import org.springframework.data.annotation.Id;

import java.time.Instant;

@Container(containerName = "re")
@Data
@Builder(toBuilder = true)
public class ReEventEntity {
//// START KEY
@Id
private String id;

@PartitionKey
private String partitionKey;
//// END KEY

//// START LOGICAL REF
private String requestId; //gruppo, tutte le chiamate fatte con lo stesso X-Request-ID
private String operationId; //id operation associato a un requestId
private String clientOperationId; //id client operation associato a un operationId
private ComponenteEnum componente; //componente che scrive l'evento
private Instant insertedTimestamp; //ora di inserimento evento
//// END LOGICAL REF

//// START FIELD FOR INTERFACE AND INTERN CHANGE
private CategoriaEventoEnum categoriaEvento;
private SottoTipoEventoEnum sottoTipoEvento;
//// END FIELD FOR INTERFACE AND INTERN CHANGE

//// START FIELD FOR INTERFACE
private CallTypeEnum callType;

private String fruitore;
private String fruitoreDescr;
private String erogatore;
private String erogatoreDescr;

private EsitoEnum esito;

private String httpMethod;
private String httpUri;
private String httpHeaders;
private String httpCallRemoteAddress;

private Integer httpStatusCode;
private Long executionTimeMs;

private String compressedPayload; //zip+Base64
private Integer compressedPayloadLength;

private String businessProcess;

private String operationStatus; //dettaglio response in uscita
private String operationErrorTitle; //dettaglio response in uscita
private String operationErrorDetail; //dettaglio response in uscita
private String operationErrorCode; //dettaglio response in uscita
//// END FIELD FOR INTERFACE

//// START FIELD FOR INTERN CHANGE
private String idDominio;
private String iuv;
private String ccp;
private String psp;
private String tipoVersamento;
private String tipoEvento;
private String stazione;
private String canale;
private String parametriSpecificiInterfaccia;
private String status;
private String info;

private String pspDescr;
private String noticeNumber;
private String creditorReferenceId;
private String paymentToken;
private String sessionIdOriginal;
private Boolean standIn;
//// END FIELD FOR INTERN CHANGE
//// START KEY
@Id
private String id;

@PartitionKey
private String partitionKey;
//// END KEY

//// START LOGICAL REF
private String requestId; //gruppo, tutte le chiamate fatte con lo stesso X-Request-ID
private String operationId; //id operation associato a un requestId
private String clientOperationId; //id client operation associato a un operationId
private ComponenteEnum componente; //componente che scrive l'evento
private Instant insertedTimestamp; //ora di inserimento evento
//// END LOGICAL REF

//// START FIELD FOR INTERFACE AND INTERN CHANGE
private CategoriaEventoEnum categoriaEvento;
private SottoTipoEventoEnum sottoTipoEvento;
//// END FIELD FOR INTERFACE AND INTERN CHANGE

//// START FIELD FOR INTERFACE
private CallTypeEnum callType;

private String fruitore;
private String fruitoreDescr;
private String erogatore;
private String erogatoreDescr;

private EsitoEnum esito;

private String httpMethod;
private String httpUri;
private String httpHeaders;
private String httpCallRemoteAddress;

private Integer httpStatusCode;
private Long executionTimeMs;

private String compressedPayload; //zip+Base64
private Integer compressedPayloadLength;

private String businessProcess;

private String operationStatus; //dettaglio response in uscita
private String operationErrorTitle; //dettaglio response in uscita
private String operationErrorDetail; //dettaglio response in uscita
private String operationErrorCode; //dettaglio response in uscita
//// END FIELD FOR INTERFACE

//// START FIELD FOR INTERN CHANGE
private String idDominio;
private String cartId;
private String iuv;
private String noticeNumber;
private String ccp;
private String psp;
//private String tipoVersamento; TODO remove this comment
private String tipoEvento;
private String stazione;
private String canale;
//private String parametriSpecificiInterfaccia; TODO remove this comment
private String status;
private String info;

//private String pspDescr; TODO remove this comment
//private String creditorReferenceId; TODO remove this comment
private String paymentToken;
private String sessionIdOriginal;
//private Boolean standIn; TODO remove this comment
//// END FIELD FOR INTERN CHANGE

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ private ReEventDto generateRE(String redirectUrl) {
.erogatore(NODO_DEI_PAGAMENTI_SPC)
.erogatoreDescr(NODO_DEI_PAGAMENTI_SPC)
.sessionIdOriginal(MDC.get(Constants.MDC_SESSION_ID))
.tipoEvento(MDC.get(Constants.MDC_EVENT_TYPE))
.cartId(MDC.get(Constants.MDC_CART_ID))
.idDominio(MDC.get(Constants.MDC_DOMAIN_ID))
.stazione(MDC.get(Constants.MDC_STATION_ID))
.iuv(MDC.get(Constants.MDC_IUV)) // null if nodoInviaCarrelloRPT
.noticeNumber(MDC.get(Constants.MDC_NOTICE_NUMBER)) // null if nodoInviaCarrelloRPT
.info(String.format("Redirect URL = [%s]", redirectUrl))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,24 @@ private ReEventDto generateRE(it.gov.pagopa.gen.wispconverter.client.gpd.model.P
.erogatore(NODO_DEI_PAGAMENTI_SPC)
.erogatoreDescr(NODO_DEI_PAGAMENTI_SPC)
.sessionIdOriginal(MDC.get(Constants.MDC_SESSION_ID))
.tipoEvento(MDC.get(Constants.MDC_EVENT_TYPE))
.cartId(MDC.get(Constants.MDC_CART_ID))
.idDominio(MDC.get(Constants.MDC_DOMAIN_ID))
.stazione(MDC.get(Constants.MDC_STATION_ID))
.info(String.format("IUPD = [%s]", paymentPosition.getIupd()))
.idDominio(commonRPTFieldsDTO.getCreditorInstitutionId())
.stazione(commonRPTFieldsDTO.getStationId())
.build();

List<PaymentOptionModelDto> paymentOptions = paymentPosition.getPaymentOption();
if (paymentOptions != null && !paymentOptions.isEmpty()) {
PaymentOptionModelDto paymentOption = paymentOptions.get(0);
reEventDto.setNoticeNumber(paymentOption.getNav());
reEventDto.setIuv(paymentOption.getIuv());
String nav = paymentOption.getNav();
reEventDto.setNoticeNumber(nav);
String iuv = paymentOption.getIuv();
reEventDto.setIuv(iuv);
if (Constants.NODO_INVIA_RPT.equals(MDC.get(Constants.MDC_EVENT_TYPE))) {
MDC.put(Constants.MDC_IUV, iuv);
MDC.put(Constants.MDC_NOTICE_NUMBER, nav);
}
}

return reEventDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ private ReEventDto generateRE() {
.erogatore(NODO_DEI_PAGAMENTI_SPC)
.erogatoreDescr(NODO_DEI_PAGAMENTI_SPC)
.sessionIdOriginal(MDC.get(Constants.MDC_SESSION_ID))
.tipoEvento(MDC.get(Constants.MDC_EVENT_TYPE))
.cartId(MDC.get(Constants.MDC_CART_ID))
.idDominio(MDC.get(Constants.MDC_DOMAIN_ID))
.stazione(MDC.get(Constants.MDC_STATION_ID))
.iuv(MDC.get(Constants.MDC_IUV)) // null if nodoInviaCarrelloRPT
.noticeNumber(MDC.get(Constants.MDC_NOTICE_NUMBER)) // null if nodoInviaCarrelloRPT
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,17 @@ public CommonRPTFieldsDTO extractRPTContentDTOs(String primitive, String payload

CommonRPTFieldsDTO commonRPTFieldsDTO;
switch (primitive) {
case "nodoInviaRPT" -> commonRPTFieldsDTO = extractRPTContentDTOsFromNodoInviaRPT(soapMessage);
case "nodoInviaCarrelloRPT" ->
case Constants.NODO_INVIA_RPT -> commonRPTFieldsDTO = extractRPTContentDTOsFromNodoInviaRPT(soapMessage);
case Constants.NODO_INVIA_CARRELLO_RPT ->
commonRPTFieldsDTO = extractRPTContentDTOsFromNodoInviaCarrelloRPT(soapMessage);
default -> throw new AppException(AppErrorCodeMessageEnum.PARSING_PRIMITIVE_NOT_VALID);
}

//generate and save re event internal for change status
MDC.put(Constants.MDC_EVENT_TYPE, primitive);
MDC.put(Constants.MDC_CART_ID, commonRPTFieldsDTO.getCartId());
MDC.put(Constants.MDC_DOMAIN_ID, commonRPTFieldsDTO.getCreditorInstitutionId());
MDC.put(Constants.MDC_STATION_ID, commonRPTFieldsDTO.getStationId());
reService.addRe(generateRE());

return commonRPTFieldsDTO;
Expand Down Expand Up @@ -190,6 +194,10 @@ private ReEventDto generateRE() {
.erogatore(NODO_DEI_PAGAMENTI_SPC)
.erogatoreDescr(NODO_DEI_PAGAMENTI_SPC)
.sessionIdOriginal(MDC.get(Constants.MDC_SESSION_ID))
.tipoEvento(MDC.get(Constants.MDC_EVENT_TYPE))
.cartId(MDC.get(Constants.MDC_CART_ID))
.idDominio(MDC.get(Constants.MDC_DOMAIN_ID))
.stazione(MDC.get(Constants.MDC_STATION_ID))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ private ReEventDto generateReInternal(RPTRequestEntity rptRequestEntity,

if (psp != null) {
reEventDtoBuilder.psp(psp.getPspCode());
reEventDtoBuilder.pspDescr(psp.getDescription());
}
if (station != null) {
reEventDtoBuilder.stazione(station.getStationCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,24 @@ public class ReEventDto {

//// START FIELD FOR INTERN CHANGE
private String idDominio;
private String cartId;
private String iuv;
private String noticeNumber;
private String ccp;
private String psp;
private String tipoVersamento;
//private String tipoVersamento; TODO remove this comment
private String tipoEvento;
private String stazione;
private String canale;
private String parametriSpecificiInterfaccia;
//private String parametriSpecificiInterfaccia; TODO remove this comment
private String status;
private String info;

private String pspDescr;
private String noticeNumber;
private String creditorReferenceId;
//private String pspDescr; TODO remove this comment
//private String creditorReferenceId; TODO remove this comment
private String paymentToken;
private String sessionIdOriginal;
private Boolean standIn;
// private Boolean standIn; TODO remove this comment
//// END FIELD FOR INTERN CHANGE

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ public class Constants {
public static final String MDC_EROGATORE_DESCR = "erogatoreDescr";

public static final String MDC_SESSION_ID = "sessionId";
public static final String MDC_EVENT_TYPE = "eventType";
public static final String MDC_IUV = "iuv";
public static final String MDC_NOTICE_NUMBER = "noticeNumber";
public static final String MDC_CART_ID = "cartId";
public static final String MDC_DOMAIN_ID = "domainId";
public static final String MDC_STATION_ID = "stationId";
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ private static ReEventDto.ReEventDtoBuilder createBaseReInterface(CategoriaEvent
.httpCallRemoteAddress(httpCallRemoteAddress)
.compressedPayload(compressedPayload)
.compressedPayloadLength(compressedPayloadLength)
.sessionIdOriginal(MDC.get(Constants.MDC_SESSION_ID));
.sessionIdOriginal(MDC.get(Constants.MDC_SESSION_ID))
.tipoEvento(MDC.get(Constants.MDC_EVENT_TYPE))
.cartId(MDC.get(Constants.MDC_CART_ID))
.iuv(MDC.get(Constants.MDC_IUV)) // null if nodoInviaCarrelloRPT
.noticeNumber(MDC.get(Constants.MDC_NOTICE_NUMBER)) // null if nodoInviaCarrelloRPT
.idDominio(MDC.get(Constants.MDC_DOMAIN_ID))
.stazione(MDC.get(Constants.MDC_STATION_ID));
}

private static ReEventDto.ReEventDtoBuilder createBaseReBuilder() {
Expand Down
Loading