Repository: fineract Updated Branches: refs/heads/develop ee150b1a4 -> 6946f1c3f
Added general specific exceptions to accept errorCodes and exceptions Project: http://git-wip-us.apache.org/repos/asf/fineract/repo Commit: http://git-wip-us.apache.org/repos/asf/fineract/commit/cfd52da6 Tree: http://git-wip-us.apache.org/repos/asf/fineract/tree/cfd52da6 Diff: http://git-wip-us.apache.org/repos/asf/fineract/diff/cfd52da6 Branch: refs/heads/develop Commit: cfd52da659dc2c9c4753df728ba4efb69eeeb00f Parents: 18e8585 Author: ThisuraThejith <[email protected]> Authored: Thu Jun 29 18:22:49 2017 +0530 Committer: ThisuraThejith <[email protected]> Committed: Thu Jun 29 18:22:49 2017 +0530 ---------------------------------------------------------------------- .../exception/JournalEntryRuntimeException.java | 29 ++++++++++++++++++++ ...ryWritePlatformServiceJpaRepositoryImpl.java | 14 +++++++--- .../sms/exception/SmsRuntimeException.java | 28 +++++++++++++++++++ .../service/SmsCampaignDomainServiceImpl.java | 13 ++++++--- .../LoanAccrualWritePlatformServiceImpl.java | 5 ++-- 5 files changed, 79 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/fineract/blob/cfd52da6/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/exception/JournalEntryRuntimeException.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/exception/JournalEntryRuntimeException.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/exception/JournalEntryRuntimeException.java new file mode 100644 index 0000000..a0fa0a7 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/exception/JournalEntryRuntimeException.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.accounting.journalentry.exception; + + +import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; + +public class JournalEntryRuntimeException extends AbstractPlatformDomainRuleException { + + public JournalEntryRuntimeException(String errorCode, String errorMessage) { + super(errorCode, errorMessage); + } +} http://git-wip-us.apache.org/repos/asf/fineract/blob/cfd52da6/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java index b556014..ad18582 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java @@ -52,6 +52,8 @@ import org.apache.fineract.accounting.journalentry.domain.JournalEntryType; import org.apache.fineract.accounting.journalentry.exception.JournalEntriesNotFoundException; import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException; import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException.GL_JOURNAL_ENTRY_INVALID_REASON; + +import org.apache.fineract.accounting.journalentry.exception.JournalEntryRuntimeException; import org.apache.fineract.accounting.journalentry.serialization.JournalEntryCommandFromApiJsonDeserializer; import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioProductType; import org.apache.fineract.accounting.provisioning.domain.LoanProductProvisioningEntry; @@ -255,7 +257,9 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa } } } - if (credits.length != validCredits.length) { throw new RuntimeException("Invalid credits"); } + if (credits.length != validCredits.length) { + throw new JournalEntryRuntimeException("error.msg.glJournalEntry.invalid.credits", "Invalid Credits."); + } } if (debits != null && debits.length > 0) { @@ -268,9 +272,11 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa validDebits[i] = debit; } } - } - if (debits.length != validDebits.length) { throw new RuntimeException("Invalid debits"); } - } + } + if (debits.length != validDebits.length) { + throw new JournalEntryRuntimeException("error.msg.glJournalEntry.invalid.debits","Invalid Debits"); + } + } } private void checkDebitAndCreditAmounts(final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits) { http://git-wip-us.apache.org/repos/asf/fineract/blob/cfd52da6/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/exception/SmsRuntimeException.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/exception/SmsRuntimeException.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/exception/SmsRuntimeException.java new file mode 100644 index 0000000..7ae714b --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/exception/SmsRuntimeException.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.campaigns.sms.exception; + +import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; + +public class SmsRuntimeException extends AbstractPlatformDomainRuleException { + + public SmsRuntimeException(String errorCode, String errorMessage) { + super(errorCode, errorMessage); + } +} http://git-wip-us.apache.org/repos/asf/fineract/blob/cfd52da6/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/service/SmsCampaignDomainServiceImpl.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/service/SmsCampaignDomainServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/service/SmsCampaignDomainServiceImpl.java index 42d7b8b..3b0e0ae 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/service/SmsCampaignDomainServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/service/SmsCampaignDomainServiceImpl.java @@ -34,6 +34,7 @@ import javax.annotation.PostConstruct; import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType; import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaign; import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaignRepository; +import org.apache.fineract.infrastructure.campaigns.sms.exception.SmsRuntimeException; import org.apache.fineract.infrastructure.sms.domain.SmsMessage; import org.apache.fineract.infrastructure.sms.domain.SmsMessageRepository; import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobService; @@ -204,10 +205,12 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService { Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value)); if (campaignOffice .doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) { - throw new RuntimeException(); + throw new SmsRuntimeException("error.msg.no.office", + "Office not found for the id"); } } else { - throw new RuntimeException(); + throw new SmsRuntimeException("error.msg.no.id.attribute", + "Office Id attribute is notfound"); } } } @@ -258,10 +261,12 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService { if (key.equals("officeId")) { Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value)); if (campaignOffice.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) { - throw new RuntimeException(); + throw new SmsRuntimeException("error.msg.no.office", + "Office not found for the id"); } } else { - throw new RuntimeException(); + throw new SmsRuntimeException("error.msg.no.id.attribute", + "Office Id attribute is notfound"); } } } http://git-wip-us.apache.org/repos/asf/fineract/blob/cfd52da6/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java index 9fdde8f..cf7b641 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java @@ -51,6 +51,7 @@ import org.apache.fineract.useradministration.domain.AppUserRepositoryWrapper; import org.joda.time.Days; import org.joda.time.LocalDate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -266,7 +267,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat private void addAccrualAccounting(LoanScheduleAccrualData scheduleAccrualData, BigDecimal amount, BigDecimal interestportion, BigDecimal totalAccInterest, BigDecimal feeportion, BigDecimal totalAccFee, BigDecimal penaltyportion, - BigDecimal totalAccPenalty, final LocalDate accruedTill) throws Exception { + BigDecimal totalAccPenalty, final LocalDate accruedTill) throws DataAccessException { String transactionSql = "INSERT INTO m_loan_transaction (loan_id,office_id,is_reversed,transaction_type_enum,transaction_date,amount,interest_portion_derived," + "fee_charges_portion_derived,penalty_charges_portion_derived, submitted_on_date) VALUES (?, ?, 0, ?, ?, ?, ?, ?, ?, ?)"; this.jdbcTemplate.update(transactionSql, scheduleAccrualData.getLoanId(), scheduleAccrualData.getOfficeId(), @@ -485,7 +486,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat @Override @Transactional - public void addIncomeAndAccrualTransactions(Long loanId) throws Exception { + public void addIncomeAndAccrualTransactions(Long loanId) throws LoanNotFoundException { if (loanId != null) { Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId, true); if (loan == null) { throw new LoanNotFoundException(loanId); }
