Skip to content

Commit

Permalink
Adding Header (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
apurbraj authored Nov 1, 2023
1 parent 33d7250 commit a10de36
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.mifos.connector.channel.camel.config.CamelProperties.BATCH_ID_HEADER;
import static org.mifos.connector.channel.camel.config.CamelProperties.CLIENTCORRELATIONID;
import static org.mifos.connector.channel.camel.config.CamelProperties.REGISTERING_INSTITUTION_ID;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.mifos.connector.channel.gsma_api.GsmaP2PResponseDto;
Expand All @@ -19,6 +20,7 @@ public interface TransferApi {
GsmaP2PResponseDto transfer(@RequestHeader(value = "Platform-TenantId") String tenant,
@RequestHeader(value = BATCH_ID_HEADER, required = false) String batchId,
@RequestHeader(value = CLIENTCORRELATIONID, required = false) String correlationId,
@RequestHeader(value = REGISTERING_INSTITUTION_ID, required = false) String registeringInstitutionId,
@RequestBody TransactionChannelRequestDTO requestBody) throws JsonProcessingException;

@GetMapping("/channel/transfer/{transactionId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.mifos.connector.channel.camel.config.CamelProperties.BATCH_ID;
import static org.mifos.connector.channel.camel.config.CamelProperties.CLIENTCORRELATIONID;
import static org.mifos.connector.channel.camel.config.CamelProperties.REGISTERING_INSTITUTION_ID;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -30,10 +31,10 @@ public class TransferApiController implements TransferApi {
private Logger logger = LoggerFactory.getLogger(this.getClass());

@Override
public GsmaP2PResponseDto transfer(String tenant, String batchId, String correlationId, TransactionChannelRequestDTO requestBody)
throws JsonProcessingException {
public GsmaP2PResponseDto transfer(String tenant, String batchId, String correlationId, String registeringInstitutionId,
TransactionChannelRequestDTO requestBody) throws JsonProcessingException {
Headers headers = new Headers.HeaderBuilder().addHeader("Platform-TenantId", tenant).addHeader(BATCH_ID, batchId)
.addHeader(CLIENTCORRELATIONID, correlationId).build();
.addHeader(CLIENTCORRELATIONID, correlationId).addHeader(REGISTERING_INSTITUTION_ID, registeringInstitutionId).build();
Exchange exchange = SpringWrapperUtil.getDefaultWrappedExchange(producerTemplate.getCamelContext(), headers,
objectMapper.writeValueAsString(requestBody));
logger.info("Client correlation id: " + correlationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ private CamelProperties() {}
public static final String BATCH_ID_HEADER = "X-BatchID";
public static final String PLATFORM_TENANT_ID = "Platform-TenantId";
public static final String PAYMENT_SCHEME_HEADER = "X-Payment-Scheme";
public static final String REGISTERING_INSTITUTION_ID = "X-Registering-Institution-ID";

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static org.mifos.connector.channel.camel.config.CamelProperties.BATCH_ID;
import static org.mifos.connector.channel.camel.config.CamelProperties.CLIENTCORRELATIONID;
import static org.mifos.connector.channel.camel.config.CamelProperties.PAYMENT_SCHEME_HEADER;
import static org.mifos.connector.channel.camel.config.CamelProperties.REGISTERING_INSTITUTION_ID;
import static org.mifos.connector.channel.zeebe.ZeebeMessages.OPERATOR_MANUAL_RECOVERY;
import static org.mifos.connector.channel.zeebe.ZeebeVariables.ACCOUNT;
import static org.mifos.connector.channel.zeebe.ZeebeVariables.AMS;
Expand Down Expand Up @@ -306,12 +307,14 @@ private void transferRoutes() {
extraVariables.put(BATCH_ID, batchIdHeader);

String tenantId = exchange.getIn().getHeader("Platform-TenantId", String.class);
String registeringInstitutionId = exchange.getIn().getHeader("X-Registering-Institution-ID", String.class);
String clientCorrelationId = exchange.getIn().getHeader("X-CorrelationID", String.class);
logger.info("## CHANNEL Client Correlation Id: " + clientCorrelationId);
if (tenantId == null || !dfspIds.contains(tenantId)) {
throw new RuntimeException("Requested tenant " + tenantId + " not configured in the connector!");
}
extraVariables.put(TENANT_ID, tenantId);
extraVariables.put(REGISTERING_INSTITUTION_ID, registeringInstitutionId);

TransactionChannelRequestDTO channelRequest = exchange.getIn().getBody(TransactionChannelRequestDTO.class);
TransactionType transactionType = new TransactionType();
Expand Down

0 comments on commit a10de36

Please sign in to comment.