Skip to content

Commit

Permalink
[PAGOPA-2160] fix: resolved bug on wrong sessionID extraction (#115)
Browse files Browse the repository at this point in the history
Co-authored-by: pagopa-github-bot <[email protected]>
  • Loading branch information
andrea-deri and pagopa-github-bot authored Sep 19, 2024
1 parent 57872eb commit 194c794
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 11 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
description: A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing them with GPD system
type: application
version: 0.197.0
appVersion: 0.3.2
version: 0.198.0
appVersion: 0.3.2-1-PAGOPA-2160
dependencies:
- name: microservice-chart
version: 3.0.0
Expand Down
2 changes: 1 addition & 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
tag: "0.3.2"
tag: "0.3.2-1-PAGOPA-2160"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 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
tag: "0.3.2"
tag: "0.3.2-1-PAGOPA-2160"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 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
tag: "0.3.2"
tag: "0.3.2-1-PAGOPA-2160"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion openapi/openapi_redirect.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.1",
"info": {
"title": "WISP-Converter-redirect",
"version": "0.3.2"
"version": "0.3.2-1-PAGOPA-2160"
},
"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</artifactId>
<version>0.3.2</version>
<version>0.3.2-1-PAGOPA-2160</version>
<name>pagoPA WISP Converter</name>
<description>A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import it.gov.pagopa.wispconverter.repository.model.RTRequestEntity;
import it.gov.pagopa.wispconverter.repository.model.enumz.InternalStepStatus;
import it.gov.pagopa.wispconverter.service.model.re.ReEventDto;
import it.gov.pagopa.wispconverter.util.Constants;
import it.gov.pagopa.wispconverter.util.ReUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -45,6 +47,13 @@ public RTRequestEntity getRTRequestEntity(String id, String partitionKey) {
RTRequestEntity rtRequestEntity = optRTReqEntity.orElseThrow(() -> new AppException(AppErrorCodeMessageEnum.PERSISTENCE_RT_NOT_FOUND, id, partitionKey));

// generate and save RE event internal for change status
String idempotencyKey = rtRequestEntity.getIdempotencyKey();
if (idempotencyKey != null) {
String[] idempotencyKeySections = idempotencyKey.split("_");
if (idempotencyKeySections.length > 0) {
MDC.put(Constants.MDC_SESSION_ID, idempotencyKeySections[0]);
}
}
generateRE(rtRequestEntity.getPayload());

return rtRequestEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import jakarta.xml.soap.SOAPMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
Expand Down Expand Up @@ -93,7 +92,6 @@ public void processMessage(ServiceBusReceivedMessageContext context) {
String receiptId = idSections[1] + "_" + idSections[2];

// get RT request entity from database
MDC.put(Constants.MDC_SESSION_ID, receiptId);
RTRequestEntity rtRequestEntity = rtRetryComosService.getRTRequestEntity(receiptId, rtInsertionDate);
String idempotencyKey = rtRequestEntity.getIdempotencyKey();
ReceiptTypeEnum receiptType = rtRequestEntity.getReceiptType();
Expand Down Expand Up @@ -152,8 +150,12 @@ private void resendRTToCreditorInstitution(String receiptId, RTRequestEntity rec
IntestazionePPT header = jaxbElementUtil.getHeader(envelopeElement, IntestazionePPT.class);

// set MDC session data for RE
String noticeNumberFromIdempotencyKey = null;
String[] idempotencyKeySections = idempotencyKey.split("_");
MDCUtil.setSessionDataInfo(header, idempotencyKeySections[2]);
if (idempotencyKeySections.length > 1 && !"null".equals(idempotencyKeySections[1])) {
noticeNumberFromIdempotencyKey = idempotencyKeySections[1];
}
MDCUtil.setSessionDataInfo(header, noticeNumberFromIdempotencyKey);

String rawPayload = new String(unzippedPayload);
paaInviaRTSenderService.sendToCreditorInstitution(receipt.getUrl(), extractHeaders(receipt.getHeaders()), rawPayload);
Expand Down

0 comments on commit 194c794

Please sign in to comment.