Skip to content

Commit d5d8f87

Browse files
GOV 287 Enabled liveness and readiness for the key auth story (#102)
* Enabled liveness and readiness * Removed the actuator camel api * Set the isvalid file tot true * Added log to publish zeebe variable * Bug fixed for passing budget account related header to camel * Clientcorrelation id bug fixed * Publishing client correlation id zeebe variable * Info log changed to debug * Zeebe publish variable log changed to info * Updated the connector common
1 parent f70e826 commit d5d8f87

13 files changed

Lines changed: 78 additions & 92 deletions

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ dependencies {
8484
implementation "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
8585
implementation "org.springframework:spring-web:5.3.14"
8686
implementation 'org.springframework.kafka:spring-kafka:2.8.1'
87+
implementation "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
8788

8889
// spring test dependency
8990
testImplementation "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
@@ -107,7 +108,7 @@ dependencies {
107108
// miscellaneous dependency
108109
implementation 'com.google.code.gson:gson:2.8.9'
109110
implementation 'org.json:json:20210307'
110-
implementation 'org.mifos:ph-ee-connector-common:1.5.0-SNAPSHOT'
111+
implementation 'org.mifos:ph-ee-connector-common:1.6.0-rc.1'
111112
implementation 'org.apache.camel.springboot:camel-spring-boot-starter:3.4.0'
112113
implementation 'org.apache.camel:camel-undertow:3.4.0'
113114
implementation 'org.springframework.boot:spring-boot-starter:2.5.2'

src/main/java/org/mifos/processor/bulk/API/definition/BatchTransactions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import java.io.IOException;
1414

15+
import static org.mifos.processor.bulk.camel.config.CamelProperties.*;
1516
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.*;
1617

1718
public interface BatchTransactions {
@@ -22,5 +23,7 @@ String batchTransactions(HttpServletResponse httpServletResponse, @RequestHeader
2223
@RequestHeader(value = FILE_NAME) String fileName,
2324
@RequestHeader(value = PURPOSE) String purpose,
2425
@RequestHeader(value = "Type") String type,
25-
@RequestHeader(value = "Platform-TenantId") String tenant) throws IOException;
26+
@RequestHeader(value = HEADER_PLATFORM_TENANT_ID) String tenant,
27+
@RequestHeader(value = HEADER_REGISTERING_INSTITUTE_ID, required = false) String registeringInstitutionId,
28+
@RequestHeader(value = HEADER_PROGRAM_ID, required = false) String programId) throws IOException;
2629
}

src/main/java/org/mifos/processor/bulk/API/implementation/BatchTransactionsController.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
import org.mifos.processor.bulk.utility.SpringWrapperUtil;
1313
import org.springframework.beans.factory.annotation.Autowired;
1414
import org.springframework.web.bind.annotation.ExceptionHandler;
15+
import org.springframework.web.bind.annotation.RequestHeader;
1516
import org.springframework.web.bind.annotation.RestController;
1617
import org.springframework.web.multipart.MultipartException;
1718
import org.springframework.web.multipart.MultipartFile;
1819
import javax.servlet.http.HttpServletResponse;
1920
import java.io.IOException;
21+
22+
import static org.mifos.processor.bulk.camel.config.CamelProperties.*;
2023
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PURPOSE;
2124
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.FILE_NAME;
2225

@@ -37,19 +40,23 @@ public class BatchTransactionsController implements BatchTransactions {
3740
@Override
3841
public String batchTransactions(HttpServletResponse httpServletResponse,
3942
String requestId, MultipartFile file, String fileName,
40-
String purpose, String type, String tenant) throws IOException {
41-
log.info("Inside api logic");
43+
String purpose, String type, String tenant,
44+
String registeringInstitutionId, String programId) throws IOException {
45+
log.debug("Inside api logic");
4246
String localFileName = fileStorageService.save(file);
4347
Headers headers = new Headers.HeaderBuilder()
44-
.addHeader("X-CorrelationID", requestId)
48+
.addHeader(HEADER_CLIENT_CORRELATION_ID, requestId)
4549
.addHeader(PURPOSE,purpose)
4650
.addHeader(FILE_NAME,localFileName)
4751
.addHeader("Type",type)
48-
.addHeader("Platform-TenantId",tenant)
52+
.addHeader(HEADER_PLATFORM_TENANT_ID,tenant)
53+
.addHeader(HEADER_REGISTERING_INSTITUTE_ID, registeringInstitutionId)
54+
.addHeader(HEADER_PROGRAM_ID, programId)
4955
.build();
50-
56+
log.debug("Headers passed: {}", headers);
5157
Exchange exchange = SpringWrapperUtil.getDefaultWrappedExchange(producerTemplate.getCamelContext(),
5258
headers);
59+
log.debug("Header in exchange: {}", exchange.getIn().getHeaders());
5360
exchange = producerTemplate.send("direct:post-batch-transactions", exchange);
5461
int statusCode = exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
5562
httpServletResponse.setStatus(statusCode);

src/main/java/org/mifos/processor/bulk/API/implementation/BulkTransferController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.io.IOException;
1515

16+
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_PLATFORM_TENANT_ID;
1617
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.FILE_NAME;
1718
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PURPOSE;
1819

@@ -34,7 +35,7 @@ public String bulkTransfer(String requestId, MultipartFile file, String fileName
3435
.addHeader(PURPOSE,purpose)
3536
.addHeader(FILE_NAME,fileName)
3637
.addHeader("Type",type)
37-
.addHeader("Platform-TenantId",tenant)
38+
.addHeader(HEADER_PLATFORM_TENANT_ID,tenant)
3839
.build();
3940
Exchange exchange = SpringWrapperUtil.getDefaultWrappedExchange(producerTemplate.getCamelContext(),
4041
headers);

src/main/java/org/mifos/processor/bulk/api/ApiOriginFilter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
import org.springframework.stereotype.Component;
1414
import org.springframework.web.filter.GenericFilterBean;
1515

16+
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_PLATFORM_TENANT_ID;
17+
1618
public class ApiOriginFilter extends GenericFilterBean {
1719

1820
private Logger logger = LoggerFactory.getLogger(this.getClass());
1921

2022
@Override
2123
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
2224
HttpServletRequest req = (HttpServletRequest) request;
23-
String tenant = req.getHeader("Platform-TenantId");
25+
String tenant = req.getHeader("" +
26+
HEADER_PLATFORM_TENANT_ID);
2427
logger.debug("Tenant Name is : {}", tenant);
2528
logger.info("Client IP Address: {}", req.getRemoteHost());
2629
}

src/main/java/org/mifos/processor/bulk/camel/config/CamelProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@ private CamelProperties() {}
7575
public static final String REGISTERING_INSTITUTE_ID = "registeringInstituteId";
7676
public static final String PROGRAM_ID = "programId";
7777
public static final String IS_UPDATED = "isUpdated";
78+
public static final String HEADER_PLATFORM_TENANT_ID = "Platform-TenantId";
79+
public static final String HEADER_CLIENT_CORRELATION_ID = "X-CorrelationID";
80+
public static final String CLIENT_CORRELATION_ID = "clientCorrelationId";
7881

7982
}

src/main/java/org/mifos/processor/bulk/camel/routes/BatchStatusRoute.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.mifos.processor.bulk.camel.routes;
22

3-
import static org.mifos.processor.bulk.camel.config.CamelProperties.BATCH_STATUS_FAILED;
4-
import static org.mifos.processor.bulk.camel.config.CamelProperties.OPS_APP_ACCESS_TOKEN;
3+
import static org.mifos.processor.bulk.camel.config.CamelProperties.*;
54
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.BATCH_ID;
65
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.COMPLETION_RATE;
76
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.ERROR_CODE;
@@ -40,7 +39,7 @@ public void configure() throws Exception {
4039
getBaseExternalApiRequestRouteDefinition("batch-summary", HttpRequestMethod.GET)
4140
.setHeader(Exchange.REST_HTTP_QUERY, simple("batchId=${exchangeProperty." + BATCH_ID + "}"))
4241
.setHeader("Authorization", simple("Bearer ${exchangeProperty." + OPS_APP_ACCESS_TOKEN + "}"))
43-
.setHeader("Platform-TenantId", simple("${exchangeProperty." + TENANT_ID + "}")).process(exchange -> {
42+
.setHeader(HEADER_PLATFORM_TENANT_ID, simple("${exchangeProperty." + TENANT_ID + "}")).process(exchange -> {
4443
logger.info(exchange.getIn().getHeaders().toString());
4544
}).toD(operationsAppConfig.batchSummaryUrl + "?bridgeEndpoint=true")
4645
.log(LoggingLevel.INFO, "Batch summary API response: \n\n ${body}");

src/main/java/org/mifos/processor/bulk/camel/routes/HealthRoute.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/main/java/org/mifos/processor/bulk/camel/routes/OperationsAuthRoute.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mifos.processor.bulk.camel.routes;
22

3+
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_PLATFORM_TENANT_ID;
34
import static org.mifos.processor.bulk.camel.config.CamelProperties.OPS_APP_ACCESS_TOKEN;
45
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.TENANT_ID;
56

@@ -44,7 +45,7 @@ public void configure() throws Exception {
4445
simpleF("username=%s&password=%s&grant_type=%s", operationsAppConfig.username, operationsAppConfig.password,
4546
"password"))
4647
.setHeader("Authorization", constant("Basic Y2xpZW50Og=="))
47-
.setHeader("Platform-TenantId", simple("${exchangeProperty." + TENANT_ID + "}"))
48+
.setHeader(HEADER_PLATFORM_TENANT_ID, simple("${exchangeProperty." + TENANT_ID + "}"))
4849
.toD(operationsAppConfig.authUrl + "?bridgeEndpoint=true").log(LoggingLevel.INFO, "Auth response: \n\n ${body}");
4950

5051
/**

0 commit comments

Comments
 (0)