You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by vo...@apache.org on 2021/01/17 21:42:23 UTC

[fineract] branch develop updated (8c52097 -> ce825c9)

This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git.


    from 8c52097  clean up (mechanical) SchedulerJobsTestResults (re. FINERACT-924; but not fixing that)
     new e43be71  FINERACT-1157:UnsupportedOperationException at InteropServiceImpl
     new ce825c9  FINERACT-1157:UnsupportedOperationException at InteropServiceImpl

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../interoperation/service/InteropServiceImpl.java | 36 ++++++++++++----------
 1 file changed, 20 insertions(+), 16 deletions(-)


[fineract] 01/02: FINERACT-1157:UnsupportedOperationException at InteropServiceImpl

Posted by vo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit e43be716ae26e5ae11179dcb61a9a61b4333cace
Author: Wandji Collins <co...@gmail.com>
AuthorDate: Tue Dec 15 09:32:49 2020 +0100

    FINERACT-1157:UnsupportedOperationException at InteropServiceImpl
---
 .../interoperation/service/InteropServiceImpl.java | 32 ++++++++++++----------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java
index a2e3676..78351a6 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java
@@ -97,11 +97,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.http.HttpStatus;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.HttpClientErrorException;
 
 @Service
 public class InteropServiceImpl implements InteropService {
@@ -246,7 +248,7 @@ public class InteropServiceImpl implements InteropService {
             String subIdOrType) {
         InteropIdentifier identifier = findIdentifier(idType, idValue, subIdOrType);
         if (identifier == null) {
-            throw new UnsupportedOperationException(
+            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST,
                     "Account not found for identifier " + idType + "/" + idValue + (subIdOrType == null ? "" : ("/" + subIdOrType)));
         }
 
@@ -279,7 +281,7 @@ public class InteropServiceImpl implements InteropService {
             String subIdOrType) {
         InteropIdentifier identifier = findIdentifier(idType, idValue, subIdOrType);
         if (identifier == null) {
-            throw new UnsupportedOperationException(
+            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST,
                     "Account not found for identifier " + idType + "/" + idValue + (subIdOrType == null ? "" : ("/" + subIdOrType)));
         }
 
@@ -329,7 +331,7 @@ public class InteropServiceImpl implements InteropService {
         if (transactionType.isDebit()) {
             fee = savingsAccount.calculateWithdrawalFee(request.getAmount().getAmount());
             if (MathUtil.isLessThan(savingsAccount.getWithdrawableBalance(), request.getAmount().getAmount().add(fee))) {
-                throw new UnsupportedOperationException("Not enough balance amount for requested amount plus fees!");
+                throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Not enough balance amount for requested amount plus fees!");
             }
         } else {
             fee = BigDecimal.ZERO;
@@ -362,10 +364,10 @@ public class InteropServiceImpl implements InteropService {
             BigDecimal total = calculateTotalTransferAmount(request, savingsAccount);
 
             if (MathUtil.isLessThan(savingsAccount.getWithdrawableBalance(), total)) {
-                throw new UnsupportedOperationException("Not enough balance amount for requested amount plus fees!");
+                throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Not enough balance amount for requested amount plus fees!");
             }
             if (findTransaction(savingsAccount, transferCode, AMOUNT_HOLD.getValue()) != null) {
-                throw new UnsupportedOperationException("Transfer amount was already put on hold " + transferCode);
+                throw new HttpClientErrorException(HttpStatus.TOO_MANY_REQUESTS, "Transfer amount was already put on hold " + transferCode);
             }
 
             PaymentDetail paymentDetail = instance(findPaymentType(), savingsAccount.getExternalId(), null, getRoutingCode(), transferCode,
@@ -398,7 +400,7 @@ public class InteropServiceImpl implements InteropService {
         String transferCode = request.getTransferCode();
 
         if (findTransaction(savingsAccount, transferCode, (isDebit ? WITHDRAWAL : DEPOSIT).getValue()) != null) {
-            throw new UnsupportedOperationException("Transfer was already committed with code: " + transferCode);
+            throw new HttpClientErrorException(HttpStatus.TOO_MANY_REQUESTS, "Transfer was already committed with code: " + transferCode);
         }
 
         LocalDateTime transactionDateTime = DateUtils.getLocalDateTimeOfTenant();
@@ -409,16 +411,17 @@ public class InteropServiceImpl implements InteropService {
         if (isDebit) {
             SavingsAccountTransaction holdTransaction = findTransaction(savingsAccount, transferCode, AMOUNT_HOLD.getValue());
             if (holdTransaction == null) {
-                throw new UnsupportedOperationException("Missing onhold transaction for transfer: " + transferCode);
+                throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Missing onhold transaction for transfer: " + transferCode);
             }
 
             BigDecimal totalTransferAmount = calculateTotalTransferAmount(request, savingsAccount);
             if (holdTransaction.getAmount().compareTo(totalTransferAmount) != 0) {
-                throw new UnsupportedOperationException("Transfer request amount plus fees does not match with onhold amount!");
+                throw new HttpClientErrorException(HttpStatus.BAD_REQUEST,
+                        "Transfer request amount plus fees does not match with onhold amount!");
             }
 
             if (MathUtil.isLessThan(savingsAccount.getWithdrawableBalance().add(holdTransaction.getAmount()), totalTransferAmount)) {
-                throw new UnsupportedOperationException("Not enough balance amount!");
+                throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Not enough balance amount!");
             }
 
             if (holdTransaction.getReleaseIdOfHoldAmountTransaction() == null) {
@@ -473,7 +476,8 @@ public class InteropServiceImpl implements InteropService {
 
             savingsAccountRepository.save(savingsAccount);
         } else {
-            throw new UnsupportedOperationException("No active onhold transaction exists with transferCode " + request.getTransferCode());
+            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST,
+                    "No active onhold transaction exists with transferCode " + request.getTransferCode());
         }
 
         return InteropTransferResponseData.build(command.commandId(), request.getTransactionCode(), InteropActionState.ACCEPTED,
@@ -494,7 +498,7 @@ public class InteropServiceImpl implements InteropService {
 
             return InteropKycResponseData.build(accountKyc);
         } catch (final EmptyResultDataAccessException e) {
-            throw new UnsupportedOperationException("Error in retrieving KYC information: " + e);
+            throw new HttpClientErrorException(HttpStatus.NO_CONTENT, "Error in retrieving KYC information: " + e);
         }
     }
 
@@ -524,7 +528,7 @@ public class InteropServiceImpl implements InteropService {
     private Loan validateAndGetLoan(String accountId) {
         Loan loan = loanRepository.findNonClosedLoanByAccountNumber(accountId);
         if (loan == null) {
-            throw new UnsupportedOperationException("Loan not found for the given account No: " + accountId);
+            throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Loan not found for the given account No: " + accountId);
         }
         return loan;
     }
@@ -536,12 +540,12 @@ public class InteropServiceImpl implements InteropService {
 
         ApplicationCurrency requestCurrency = currencyRepository.findOneByCode(request.getAmount().getCurrency());
         if (!savingsAccount.getCurrency().getCode().equals(requestCurrency.getCode())) {
-            throw new UnsupportedOperationException("Account and request has different currencies!");
+            throw new HttpClientErrorException(HttpStatus.CONFLICT, "Account and request has different currencies!");
         }
 
         SavingsAccountTransactionType transactionType = request.getTransactionRole().getTransactionType();
         if (!savingsAccount.isTransactionAllowed(transactionType, request.getExpirationLocalDate())) {
-            throw new UnsupportedOperationException("Transaction not allowed on account!");
+            throw new HttpClientErrorException(HttpStatus.NOT_ACCEPTABLE, "Transaction not allowed on account!");
         }
 
         request.normalizeAmounts(savingsAccount.getCurrency());


[fineract] 02/02: FINERACT-1157:UnsupportedOperationException at InteropServiceImpl

Posted by vo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit ce825c912d6ba760f36a8c393623c284579674d0
Author: Wandji Collins <co...@gmail.com>
AuthorDate: Sun Jan 17 17:04:06 2021 +0100

    FINERACT-1157:UnsupportedOperationException at InteropServiceImpl
---
 .../apache/fineract/interoperation/service/InteropServiceImpl.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java
index 78351a6..89eccab 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java
@@ -558,7 +558,7 @@ public class InteropServiceImpl implements InteropService {
         MoneyData requestFee = request.getFspFee();
         if (requestFee != null) {
             if (!savingsAccount.getCurrency().getCode().equals(requestFee.getCurrency())) {
-                throw new UnsupportedOperationException();
+                throw new HttpClientErrorException(HttpStatus.resolve(400));
             }
             // TODO: compare with calculated quote fee
             total = MathUtil.add(total, requestFee.getAmount());
@@ -566,7 +566,7 @@ public class InteropServiceImpl implements InteropService {
         MoneyData requestCommission = request.getFspCommission();
         if (requestCommission != null) {
             if (!savingsAccount.getCurrency().getCode().equals(requestCommission.getCurrency())) {
-                throw new UnsupportedOperationException();
+                throw new HttpClientErrorException(HttpStatus.resolve(400));
             }
             // TODO: compare with calculated quote commission
             total = MathUtil.subtractToZero(total, requestCommission.getAmount());