Skip to content

Commit

Permalink
added url and header override in recovery receipt, added allargs to R…
Browse files Browse the repository at this point in the history
…TRequestEntity
  • Loading branch information
aomegax committed Oct 11, 2024
1 parent c434b40 commit ec69a5f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import it.gov.pagopa.wispconverter.repository.model.enumz.ReceiptTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.springframework.data.annotation.Id;
Expand All @@ -16,6 +18,8 @@
@ToString(exclude = "payload")
@EqualsAndHashCode(exclude = "payload")
@SuperBuilder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class RTRequestEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
@RequiredArgsConstructor
public class RecoveryService {

@Value("${wisp-converter.station-in-forwarder.partial-path}")
private String stationInForwarderPartialPath;

@Value("${wisp-converter.forwarder.api-key}")
private String forwarderSubscriptionKey;
private static final String RPT_ACCETTATA_NODO = "RPT_ACCETTATA_NODO";

private static final String STATUS_RT_SEND_SUCCESS = "RT_SEND_SUCCESS";
Expand Down Expand Up @@ -306,6 +311,9 @@ public RecoveryReceiptReportResponse recoverReceiptToBeReSent(RecoveryReceiptReq
stationConnection.getPort().intValue(),
station.getService() != null ? station.getService().getPath() : ""
);
rtRequestEntity.setUrl(uri.toString());
rtRequestEntity.setHeaders(generateHeader(uri, station));

InetSocketAddress proxyAddress = CommonUtility.constructProxyAddress(uri, station, apimPath);
if (proxyAddress != null) {
rtRequestEntity.setProxyAddress(String.format("%s:%s", proxyAddress.getHostString(), proxyAddress.getPort()));
Expand Down Expand Up @@ -340,7 +348,7 @@ public RecoveryReceiptReportResponse recoverReceiptToBeReSent(RecoveryReceiptReq
rtRequestEntity.setId(overriddenReceiptId);
rtRequestEntity.setDomainId(domainId);
rtRequestEntity.setIdempotencyKey(overriddenIdempotencyKey);
rtRequestEntity.setRetry(46); // TODO set 0
rtRequestEntity.setRetry(0);
rtRequestEntity.setPayload(AppBase64Util.base64Encode(ZipUtil.zip(payload)));
rtRetryRepository.save(rtRequestEntity);

Expand All @@ -366,6 +374,15 @@ public RecoveryReceiptReportResponse recoverReceiptToBeReSent(RecoveryReceiptReq
return response;
}

private List<String> generateHeader(URI uri, StationDto station) {
List<Pair<String, String>> headers = CommonUtility.constructHeadersForPaaInviaRT(uri, station, stationInForwarderPartialPath, forwarderSubscriptionKey);
List<String> formattedHeaders = new LinkedList<>();
for (Pair<String, String> header : headers) {
formattedHeaders.add(header.getFirst() + ":" + header.getSecond());
}
return formattedHeaders;
}

/**
* Regenerate receipt payload according to its type (OK|KO)
*/
Expand Down

0 comments on commit ec69a5f

Please sign in to comment.