From d322e7064968cdaf245347d01e2378a72e0a3bc7 Mon Sep 17 00:00:00 2001 From: Madhukar Date: Wed, 27 Feb 2013 12:09:23 +0530 Subject: [PATCH] Handle exception for retrieving non existed resource for deposit product --- api-docs/apiLive.htm | 98 +++++++++++++++++-- .../api/DepositProductsApiResource.java | 4 - .../data/DepositProductData.java | 10 +- ...DepositProductReadPlatformServiceImpl.java | 19 ++-- 4 files changed, 101 insertions(+), 30 deletions(-) diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 1b7b3b4b1..9d1ba046c 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -1041,16 +1041,26 @@ Retrieve Audit Search Data - + depositproducts/template Retrieve Deposit Product Details Template - loanproducts/template + savingproducts/template Retrieve Saving Product Details Template + + depositaccounts/template + Retrieve Deposit + Account Details Template + + + savingaccounts/template + Retrieve Saving + Account Details Template + @@ -1102,14 +1112,6 @@ - - Work in Progress - - - - - - FIXED DEPOSITS depositaccounts @@ -11291,6 +11293,82 @@ Content-Type: application/json + + DEPOSIT PRODUCT + depositproducts + Create a Deposit product + List Deposit products + + + + + + depositproducts/{prodcutId} + + Retrieve a Deposit product + Update a Deposit product + Delete a Deposit product + + + SAVING PRODUCT + savingproducts + Create a Saving product + List Saving products + + + + + + savingproducts/{prodcutId} + + Retrieve a Saving procduct + Update a Saving product + Delete a Saving product + + + + FIXED DEPOSITS + depositaccounts + Create a New Deposit + Application + + + + + + + depositaccounts/{accountId} + Approve, Undo Approve, + Interest withdraw, Reject a Deposit Application or Withdraw a + Deposit Application + Retrieve a Deposit + Application + + Delete a Deposit + Application + + + + SAVING ACCOUNTS + savingaccounts + Create a New Saving + Application + + + + + + + savingaccounts/{accountId} + Approve, Undo Approve, + Interest withdraw, Reject a Saving Application or Withdraw a + Saving Application + Retrieve a Saving + Application + + Delete a Saving + Application +
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/api/DepositProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/api/DepositProductsApiResource.java index 46e1ff4e4..e7ef02f15 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/api/DepositProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/api/DepositProductsApiResource.java @@ -37,7 +37,6 @@ import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformServi import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingsDepositEnumerations; import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductData; -import org.mifosplatform.portfolio.savingsdepositproduct.exception.DepositProductNotFoundException; import org.mifosplatform.portfolio.savingsdepositproduct.service.DepositProductReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; @@ -133,9 +132,6 @@ public class DepositProductsApiResource { context.authenticatedUser().validateHasReadPermission(entityType); DepositProductData productData = this.depositProductReadPlatformService.retrieveDepositProductData(productId); - if (productData.isDeleted()) { - throw new DepositProductNotFoundException(productId); - } final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (settings.isTemplate()) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/data/DepositProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/data/DepositProductData.java index f50b59924..0f322c2b6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/data/DepositProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/data/DepositProductData.java @@ -45,7 +45,6 @@ public class DepositProductData { private final Collection currencyOptions; private final List interestCompoundedEveryPeriodTypeOptions; - private final Boolean isDeleted; public DepositProductData(final Long id, final String externalId, final String name, final String description, final String currencyCode, final Integer digitsAfterDecimal, @@ -54,7 +53,7 @@ public class DepositProductData { final BigDecimal maturityMaxInterestRate, final Integer interestCompoundedEvery, final EnumOptionData interestCompoundedEveryPeriodType, final boolean renewalAllowed, final boolean preClosureAllowed, final BigDecimal preClosureInterestRate, final boolean interestCompoundingAllowed, final boolean isLockinPeriodAllowed, - final Integer lockinPeriod, final EnumOptionData lockinPeriodType,final CurrencyData currencyData, final Boolean isDeleted) { + final Integer lockinPeriod, final EnumOptionData lockinPeriodType,final CurrencyData currencyData) { this.id = id; this.externalId = externalId; @@ -82,7 +81,6 @@ public class DepositProductData { this.currency = currencyData; this.currencyOptions = null; this.interestCompoundedEveryPeriodTypeOptions = null; - this.isDeleted = isDeleted; } public DepositProductData(final Collection currencyOptions, @@ -117,7 +115,6 @@ public class DepositProductData { this.currencyOptions = currencyOptions; this.interestCompoundedEveryPeriodTypeOptions = interestCompoundedEveryPeriodTypeOptions; - this.isDeleted = false; } public DepositProductData(final DepositProductData product, final Collection currencyOptions, @@ -156,7 +153,6 @@ public class DepositProductData { this.currency = product.currency; } - this.isDeleted = product.isDeleted; } public Long getId() { @@ -251,8 +247,4 @@ public class DepositProductData { return lockinPeriodType; } - public Boolean isDeleted() { - return this.isDeleted; - } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/service/DepositProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/service/DepositProductReadPlatformServiceImpl.java index dc89573e3..4fae2f47d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/service/DepositProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsdepositproduct/service/DepositProductReadPlatformServiceImpl.java @@ -20,7 +20,9 @@ import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingsDepositEnumerations; import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductData; import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductLookup; +import org.mifosplatform.portfolio.savingsdepositproduct.exception.DepositProductNotFoundException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Service; @@ -58,10 +60,14 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead @Override public DepositProductData retrieveDepositProductData(Long productId) { - DepositProductMapper depositProductMapper = new DepositProductMapper(); - String sql = "select " + depositProductMapper.depositProductSchema() + " where dp.id = ? "; - - return this.jdbcTemplate.queryForObject(sql, depositProductMapper, new Object[] { productId }); + try{ + this.context.authenticatedUser(); + DepositProductMapper depositProductMapper = new DepositProductMapper(); + String sql = "select " + depositProductMapper.depositProductSchema() + " where dp.id = ? and dp.is_deleted=0"; + return this.jdbcTemplate.queryForObject(sql, depositProductMapper, new Object[] { productId }); + } catch (EmptyResultDataAccessException e){ + throw new DepositProductNotFoundException(productId); + } } @Override @@ -84,7 +90,7 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead + "dp.maturity_min_interest_rate as maturityMinInterestRate, dp.maturity_max_interest_rate as maturityMaxInterestRate, " + "dp.is_renewal_allowed as canRenew, dp.is_preclosure_allowed as canPreClose, dp.pre_closure_interest_rate as preClosureInterestRate, " + "dp.is_lock_in_period_allowed as isLockinPeriodAllowed, dp.lock_in_period as lockinPeriod, dp.lock_in_period_type as lockinPeriodType, " - + "curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol, dp.is_deleted as isDeleted " + + "curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol " + "from m_product_deposit dp join m_currency curr on curr.code = dp.currency_code "; } @@ -126,12 +132,11 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead Integer lockinPeriod = JdbcSupport.getInteger(rs, "lockinPeriod"); Integer lockinPeriodTypeValue = JdbcSupport.getInteger(rs, "lockinPeriodType"); EnumOptionData lockinPeriodType = SavingsDepositEnumerations.interestCompoundingPeriodType(lockinPeriodTypeValue); - Boolean isDeleted = rs.getBoolean("isDeleted"); return new DepositProductData(id, exernalId, name, description, currencyCode, currencyDigits, minimumBalance, maximumBalance, tenureMonths, maturityDefaultInterestRate, maturityMinInterestRate, maturityMaxInterestRate, interestCompoundedEvery, interestCompoundedEveryPeriodType, canRenew, canPreClose, - preClosureInterestRate, interestCompoundingAllowed, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, currencyData,isDeleted); + preClosureInterestRate, interestCompoundingAllowed, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, currencyData); } }