Skip to content

Commit

Permalink
Merge branch 'main' into PAGOPA-2389
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-ang authored Dec 17, 2024
2 parents 45fed78 + f6a16bf commit a2d1bdb
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 17 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.290.0
appVersion: 1.0.2-2-PAGOPA-2389
version: 0.289.0
appVersion: 1.0.3
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: &microservice-chart
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "1.0.2-2-PAGOPA-2389"
tag: "1.0.3"
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: &microservice-chart
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "1.0.2-2-PAGOPA-2389"
tag: "1.0.3"
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: &microservice-chart
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "1.0.2-2-PAGOPA-2389"
tag: "1.0.3"
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": "1.0.2-2-PAGOPA-2389"
"version": "1.0.3"
},
"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>1.0.2-2-PAGOPA-2389</version>
<version>1.0.3</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 @@ -30,23 +30,31 @@ public static String generateIdempotencyKeyId(String sessionId, String iuv, Stri
}

public boolean isIdempotencyKeyProcessable(String idempotencyKey, ReceiptTypeEnum receiptType) {

boolean isProcessable = true;

// try to retrieve idempotency key entity from the storage and check if exists
Optional<IdempotencyKeyEntity> optIdempotencyKeyEntity = idempotencyKeyRepository.findById(idempotencyKey);
if (optIdempotencyKeyEntity.isPresent()) {

/*
Check if receipt type (set in idempotency key) is equals to the one defined in the receipt entity.
If they are not equals it is an anomaly, so throw a dedicated exception
*/
if (optIdempotencyKeyEntity.isPresent()) {
// Check if receipt type (set in idempotency key) is equals to the one defined in the receipt entity.
IdempotencyKeyEntity idempotencyKeyEntity = optIdempotencyKeyEntity.get();
if (!receiptType.equals(idempotencyKeyEntity.getReceiptType())) {
ReceiptTypeEnum receiptTypeSent = idempotencyKeyEntity.getReceiptType();

if(receiptType.equals(ReceiptTypeEnum.OK) && receiptTypeSent.equals(ReceiptTypeEnum.KO)) {
// if coming receipt is OK and sent receipt is KO -> reset idempotency key (ie force receipt-ok sending)
idempotencyKeyEntity.setStatus(IdempotencyStatusEnum.FAILED);
idempotencyKeyEntity.setLockedAt(null);
idempotencyKeyEntity.setReceiptType(ReceiptTypeEnum.OK);
idempotencyKeyRepository.save(idempotencyKeyEntity);
} else if(receiptType.equals(ReceiptTypeEnum.KO) && receiptTypeSent.equals(ReceiptTypeEnum.OK)) {
// if coming receipt is KO and sent receipt is OK -> do nothing, it is an anomaly, so throw a dedicated exception
throw new AppException(AppErrorCodeMessageEnum.RECEIPT_GENERATION_ANOMALY_ON_PROCESSING, idempotencyKey, idempotencyKeyEntity.getReceiptType(), receiptType);
} else {
// same type between coming receipt and sent receipt [(OK,OK), (KO,KO)] -> do nothing
log.warn("Attempt to send a receipt of the same type (incoming receipt request {}, receipt type {} sent already) " +
"will not be completed if it is locked or already successfully done.", receiptType, receiptTypeSent);
}

// check the processability of the idempotency key
// check if the idempotency key is processable
isProcessable = !IdempotencyStatusEnum.SUCCESS.equals(idempotencyKeyEntity.getStatus()) && isActiveLockExpired(idempotencyKeyEntity) || IdempotencyStatusEnum.FAILED.equals(idempotencyKeyEntity.getStatus());
}
return isProcessable;
Expand Down

0 comments on commit a2d1bdb

Please sign in to comment.