Skip to content

Commit

Permalink
chore: [PAGOPA-2286] Added recovery by sessionId (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
aomegax authored Oct 18, 2024
2 parents c42ed1a + 4f7d277 commit 7732c09
Show file tree
Hide file tree
Showing 7 changed files with 988 additions and 948 deletions.
1,611 changes: 774 additions & 837 deletions openapi/openapi.json

Large diffs are not rendered by default.

201 changes: 91 additions & 110 deletions openapi/openapi_redirect.json
Original file line number Diff line number Diff line change
@@ -1,142 +1,123 @@
{
"openapi": "3.0.1",
"info": {
"title": "WISP-Converter-redirect",
"version": "0.4.12"
"openapi" : "3.0.1",
"info" : {
"title" : "WISP-Converter-redirect",
"version" : "0.4.12"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"tags": [
{
"description": "Application info APIs",
"name": "Home"
},
{
"description": "Conversion and redirection APIs",
"name": "Redirect"
}
],
"paths": {
"/info": {
"get": {
"operationId": "healthCheck",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AppInfoResponse"
"servers" : [ {
"url" : "http://localhost",
"description" : "Generated server url"
} ],
"tags" : [ {
"description" : "Application info APIs",
"name" : "Home"
}, {
"description" : "Conversion and redirection APIs",
"name" : "Redirect"
} ],
"paths" : {
"/info" : {
"get" : {
"operationId" : "healthCheck",
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/AppInfoResponse"
}
}
},
"description": "OK.",
"headers": {
"X-Request-Id": {
"description": "This header identifies the call",
"schema": {
"type": "string"
"description" : "OK.",
"headers" : {
"X-Request-Id" : {
"description" : "This header identifies the call",
"schema" : {
"type" : "string"
}
}
}
}
},
"security": [
{
"ApiKey": []
}
],
"summary": "Return OK if application is started",
"tags": [
"Home"
]
"security" : [ {
"ApiKey" : [ ]
} ],
"summary" : "Return OK if application is started",
"tags" : [ "Home" ]
},
"parameters": [
{
"description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.",
"in": "header",
"name": "X-Request-Id",
"schema": {
"type": "string"
}
"parameters" : [ {
"description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.",
"in" : "header",
"name" : "X-Request-Id",
"schema" : {
"type" : "string"
}
]
} ]
},
"/payments": {
"get": {
"operationId": "redirect",
"parameters": [
{
"example": "identificativoIntermediarioPA_sessionId",
"in": "query",
"name": "idSession",
"required": true,
"schema": {
"type": "string"
}
"/payments" : {
"get" : {
"operationId" : "redirect",
"parameters" : [ {
"example" : "identificativoIntermediarioPA_sessionId",
"in" : "query",
"name" : "idSession",
"required" : true,
"schema" : {
"type" : "string"
}
],
"responses": {
"302": {
"description": "Redirect to Checkout service.",
"headers": {
"X-Request-Id": {
"description": "This header identifies the call",
"schema": {
"type": "string"
} ],
"responses" : {
"302" : {
"description" : "Redirect to Checkout service.",
"headers" : {
"X-Request-Id" : {
"description" : "This header identifies the call",
"schema" : {
"type" : "string"
}
}
}
}
},
"security": [
{
"ApiKey": []
}
],
"tags": [
"Redirect"
]
"security" : [ {
"ApiKey" : [ ]
} ],
"tags" : [ "Redirect" ]
},
"parameters": [
{
"description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.",
"in": "header",
"name": "X-Request-Id",
"schema": {
"type": "string"
}
"parameters" : [ {
"description" : "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.",
"in" : "header",
"name" : "X-Request-Id",
"schema" : {
"type" : "string"
}
]
} ]
}
},
"components": {
"schemas": {
"AppInfoResponse": {
"type": "object",
"properties": {
"environment": {
"type": "string"
"components" : {
"schemas" : {
"AppInfoResponse" : {
"type" : "object",
"properties" : {
"environment" : {
"type" : "string"
},
"name": {
"type": "string"
"name" : {
"type" : "string"
},
"version": {
"type": "string"
"version" : {
"type" : "string"
}
}
}
},
"securitySchemes": {
"ApiKey": {
"description": "The API key to access this function app.",
"in": "header",
"name": "Ocp-Apim-Subscription-Key",
"type": "apiKey"
"securitySchemes" : {
"ApiKey" : {
"description" : "The API key to access this function app.",
"in" : "header",
"name" : "Ocp-Apim-Subscription-Key",
"type" : "apiKey"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptByPartitionRequest;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptBySessionIdRequest;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptReportResponse;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptRequest;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptResponse;
Expand Down Expand Up @@ -130,4 +131,23 @@ public ResponseEntity<RecoveryReceiptReportResponse> recoverReceiptToBeReSentByP
throw ex;
}
}

@Operation(summary = "Execute reconciliation for OK receipts by sessionId.", description = "Execute reconciliation of all receipts related to the sessionIds of the request", security = {@SecurityRequirement(name = "ApiKey")}, tags = {"Recovery"})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Reconciliation scheduled")
})
@PostMapping(value = "/sessionIds/ok")
public ResponseEntity<RecoveryReceiptReportResponse> recoverReceiptToBeReSentBySessionId(@RequestBody RecoveryReceiptBySessionIdRequest request) {
try {
log.debug("Invoking API operation recoverReceiptToBeReSentBySessionId - args: {}", sanitizeInput(request.toString()));
return ResponseEntity.ok(recoveryService.recoverReceiptOkToBeReSentBySessionIds(request));
} catch (Exception ex) {
String operationId = MDC.get(Constants.MDC_OPERATION_ID);
log.error(String.format("GenericException: operation-id=[%s]", operationId != null ? operationId : "n/a"), ex);
AppException appException = new AppException(ex, AppErrorCodeMessageEnum.ERROR, ex.getMessage());
ErrorResponse errorResponse = errorUtil.forAppException(appException);
log.error("Failed API operation recoverReceiptToBeReSentBySessionId - error: {}", errorResponse);
throw ex;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package it.gov.pagopa.wispconverter.controller.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.List;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class RecoveryReceiptBySessionIdRequest {

private List<String> sessionIds;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package it.gov.pagopa.wispconverter.secondary;

import com.azure.spring.data.cosmos.repository.CosmosRepository;
import it.gov.pagopa.wispconverter.repository.model.IdempotencyKeyEntity;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

@Repository
@Qualifier("secondaryCosmosTemplate")
public interface IdempotencyKeyRepositorySecondary extends CosmosRepository<IdempotencyKeyEntity, String> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ List<ReEventEntity> findBySessionIdAndStatusAndPartitionKey(@Param("date") Strin
@Param("sessionId") String sessionId,
@Param("status") String status);

@Query("SELECT * FROM c " +
"WHERE c.sessionId = @sessionId " +
"AND c.component = 'WISP_SOAP_CONVERTER' " +
"AND c.status = 'RPT_ACCETTATA_NODO' ORDER BY c._ts")
List<ReEventEntity> findRptAccettataNodoBySessionId(@Param("sessionId") String sessionId);

@Query(
"SELECT wispSession.sessionId " +
Expand Down
Loading

0 comments on commit 7732c09

Please sign in to comment.