Skip to content

Commit d5ab3b3

Browse files
authored
Merge pull request #15 from ankita10r/newZeebeWorker
Adding intl remittance worker,logs and updating the tenants
2 parents b614507 + e5c188b commit d5ab3b3

File tree

11 files changed

+141
-24
lines changed

11 files changed

+141
-24
lines changed

.DS_Store

6 KB
Binary file not shown.

src/main/java/org/mifos/connector/ams/interop/AccountsRouteBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.beans.factory.annotation.Value;
1111
import org.springframework.stereotype.Component;
12-
1312
import java.util.List;
1413

1514
import static org.mifos.connector.ams.camel.config.CamelProperties.CLIENT_ID;

src/main/java/org/mifos/connector/ams/interop/AmsCommonService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import org.apache.camel.component.cxf.common.message.CxfConstants;
55
import org.mifos.connector.ams.camel.cxfrs.CxfrsUtil;
66
import org.mifos.connector.ams.tenant.TenantService;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
79
import org.springframework.beans.factory.annotation.Autowired;
810
import org.springframework.beans.factory.annotation.Value;
911
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@@ -41,6 +43,8 @@ public class AmsCommonService {
4143
@Autowired
4244
private CxfrsUtil cxfrsUtil;
4345

46+
private Logger logger = LoggerFactory.getLogger(this.getClass());
47+
4448
public void getLocalQuote(Exchange e) {
4549
Map<String, Object> headers = new HashMap<>();
4650
headers.put(CXF_TRACE_HEADER, true);
@@ -66,7 +70,7 @@ public void sendTransfer(Exchange e) {
6670
headers.put(CXF_TRACE_HEADER, true);
6771
headers.put(HTTP_METHOD, "POST");
6872
headers.put(HTTP_PATH, amsInteropTransfersPath);
69-
73+
logger.info("Send Transfer Body: {}", e.getIn().getBody());
7074
Map<String, String> queryMap = new LinkedHashMap<>();
7175
queryMap.put("action", e.getProperty(TRANSFER_ACTION, String.class));
7276
headers.put(CxfConstants.CAMEL_CXF_RS_QUERY_MAP, queryMap);

src/main/java/org/mifos/connector/ams/interop/AmsService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.mifos.connector.ams.interop;
22

33
import org.apache.camel.Exchange;
4+
import org.springframework.stereotype.Service;
45

6+
@Service
57
public interface AmsService {
68

79
void getLocalQuote(Exchange e);

src/main/java/org/mifos/connector/ams/interop/InteroperationRouteBuilder.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public void configure() {
102102
.log(LoggingLevel.INFO, "Get externalAccount with identifierType: ${exchangeProperty." + PARTY_ID_TYPE + "} with value: ${exchangeProperty."
103103
+ PARTY_ID + "}")
104104
.process(amsService::getExternalAccount)
105+
.log("Test 1: ${body}")
105106
.unmarshal().json(JsonLibrary.Jackson, PartyFspResponseDTO.class)
106107
.process(e -> e.setProperty(EXTERNAL_ACCOUNT_ID, e.getIn().getBody(PartyFspResponseDTO.class).getAccountId()));
107108

@@ -123,6 +124,7 @@ public void configure() {
123124
.process(prepareTransferRequest)
124125
.process(pojoToString)
125126
.process(amsService::sendTransfer)
127+
.log("Process type: ${exchangeProperty." + PROCESS_TYPE + "}")
126128
.choice()
127129
.when(exchange -> exchange.getProperty(PROCESS_TYPE)!=null && exchange.getProperty(PROCESS_TYPE).equals("api"))
128130
.process(exchange -> {
@@ -144,8 +146,18 @@ public void configure() {
144146

145147
logger.error(errorMsg);
146148
} else {
149+
Map<String, Object> variables = new HashMap<>();
150+
JSONObject responseJson = new JSONObject(exchange.getIn().getBody(String.class));
151+
variables.put(TRANSFER_PREPARE_FAILED,false);
152+
variables.put(TRANSFER_CREATE_FAILED,false);
153+
variables.put("payeeTenantId", exchange.getProperty("payeeTenantId"));
154+
variables.put(TRANSFER_CODE,responseJson.getString("transferCode"));
147155
logger.info("API call successful. Response Body: " + exchange.getIn().getBody(String.class));
156+
zeebeClient.newCompleteCommand(exchange.getProperty(ZEEBE_JOB_KEY, Long.class))
157+
.variables(variables)
158+
.send();
148159
}
160+
logger.info("End of process in send-transfers");
149161
})
150162
.otherwise()
151163
.process(transfersResponseProcessor)
@@ -303,4 +315,4 @@ public void configure() {
303315
.to("direct:send-transfers");
304316

305317
}
306-
}
318+
}

src/main/java/org/mifos/connector/ams/interop/PrepareTransferRequest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,16 @@ public class PrepareTransferRequest implements Processor {
3939

4040
@Override
4141
public void process(Exchange exchange) throws Exception {
42+
String initiator = zeebeVariable(exchange, "initiator", String.class);
43+
String initiatorType = zeebeVariable(exchange, "initiatorType", String.class);
44+
String scenario = zeebeVariable(exchange, "scenario", String.class);
45+
46+
logger.info("Preparing transfer request for initiator: {}, initiatorType: {}, scenario: {}", initiator, initiatorType, scenario);
47+
4248
TransactionType transactionType = new TransactionType();
43-
transactionType.setInitiator(TransactionRole.valueOf(zeebeVariable(exchange, "initiator", String.class)));
44-
transactionType.setInitiatorType(InitiatorType.valueOf(zeebeVariable(exchange, "initiatorType", String.class)));
45-
transactionType.setScenario(Scenario.valueOf(zeebeVariable(exchange, "scenario", String.class)));
49+
transactionType.setInitiator(TransactionRole.valueOf(initiator));
50+
transactionType.setInitiatorType(InitiatorType.valueOf(initiatorType));
51+
transactionType.setScenario(Scenario.valueOf(scenario));
4652

4753
String note = zeebeVariable(exchange, "note", String.class);
4854
FspMoneyData amount = zeebeVariable(exchange, "amount", FspMoneyData.class);
@@ -52,8 +58,10 @@ public void process(Exchange exchange) throws Exception {
5258
String existingTransferCode = exchange.getProperty(TRANSFER_CODE, String.class);
5359
String transferCode;
5460
if (existingTransferCode != null) {
61+
logger.info("Existing code not null");
5562
transferCode = existingTransferCode;
5663
} else {
64+
logger.info("Existing code null");
5765
transferCode = UUID.randomUUID().toString();
5866
exchange.setProperty(TRANSFER_CODE, transferCode);
5967
}

src/main/java/org/mifos/connector/ams/interop/TransfersResponseProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@ public void process(Exchange exchange) {
7575
zeebeClient.newCompleteCommand(exchange.getProperty(ZEEBE_JOB_KEY, Long.class))
7676
.variables(variables)
7777
.send();
78+
logger.info("Completed job with key: {}", exchange.getProperty(ZEEBE_JOB_KEY, Long.class));
7879
}
7980
}

src/main/java/org/mifos/connector/ams/tenant/TenantService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.mifos.connector.ams.properties.Tenant;
88
import org.mifos.connector.ams.properties.TenantProperties;
99
import org.mifos.connector.common.ams.dto.LoginFineractCnResponseDTO;
10+
import org.slf4j.Logger;
11+
import org.slf4j.LoggerFactory;
1012
import org.springframework.beans.factory.annotation.Autowired;
1113
import org.springframework.beans.factory.annotation.Value;
1214
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@@ -31,7 +33,9 @@ public class TenantService {
3133
public static final String USER_HEADER = "User";
3234
public static final String FINERACT_PLATFORM_TENANT_ID_HEADER = "Fineract-Platform-TenantId";
3335

34-
@Autowired
36+
37+
private Logger logger = LoggerFactory.getLogger(this.getClass());
38+
3539
private ProducerTemplate producerTemplate;
3640

3741
@Autowired
@@ -46,6 +50,7 @@ public class TenantService {
4650
private final Map<String, CachedTenantAuth> cachedTenantAuths = new ConcurrentHashMap<>();
4751

4852
public Map<String, Object> getHeaders(String tenantName) {
53+
logger.info("Getting headers for tenant: {}", tenantName);
4954
Tenant tenant = tenantProperties.getTenant(tenantName);
5055
Map<String, Object> headers = new HashMap<>();
5156

@@ -100,4 +105,4 @@ private boolean isAccessTokenExpired(Date accessTokenExpiration) {
100105
Date fiveMinsFromNow = new Date(System.currentTimeMillis() + 300 * 1000);
101106
return accessTokenExpiration.before(fiveMinsFromNow);
102107
}
103-
}
108+
}

0 commit comments

Comments
 (0)