Search in sources :

Example 36 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class RolesPermissionsBusinessServiceTest method testInvalidConnectionInGetRoles.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetRoles() throws PersistenceException {
    try {
        when(rolesPermissionsPersistence.getRoles()).thenThrow(new PersistenceException("some exception"));
        service.getRoles();
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 37 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class RolesPermissionsBusinessServiceTest method testInvalidConnectionInGetActivities.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetActivities() throws PersistenceException {
    try {
        when(rolesPermissionsPersistence.getActivities()).thenThrow(new PersistenceException("some exception"));
        service.getActivities();
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 38 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class BranchReportService method getBranchReportHeaderDTO.

@Override
public BranchReportHeaderDTO getBranchReportHeaderDTO(Integer branchId, String runDate) throws ServiceException {
    Short officeId = convertIntegerToShort(branchId);
    PersonnelBO branchManager = CollectionUtils.first(personnelBusinessService.getActiveBranchManagersUnderOffice(officeId));
    try {
        return new BranchReportHeaderDTO(officeBusinessService.getOffice(officeId), branchManager == null ? null : branchManager.getDisplayName(), ReportUtils.parseReportDate(runDate));
    } catch (ParseException e) {
        throw new ServiceException(e);
    }
}
Also used : BranchReportHeaderDTO(org.mifos.reports.business.dto.BranchReportHeaderDTO) ServiceException(org.mifos.framework.exceptions.ServiceException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ParseException(java.text.ParseException) NumberUtils.convertIntegerToShort(org.mifos.framework.util.helpers.NumberUtils.convertIntegerToShort)

Example 39 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class BranchReportLoanArrearsAgingHelper method populateLoanArrearsAging.

public void populateLoanArrearsAging() throws BatchJobException {
    LoanArrearsAgingPeriod[] values = LoanArrearsAgingPeriod.values();
    for (LoanArrearsAgingPeriod period : values) {
        try {
            BranchReportLoanArrearsAgingBO loanArrears = branchReportService.extractLoanArrearsAgingInfoInPeriod(branchReport.getBranchId(), period, branchReportConfigService.getCurrency());
            branchReport.addLoanArrearsAging(loanArrears);
        } catch (ServiceException e) {
            throw new BatchJobException(e);
        }
    }
}
Also used : BranchReportLoanArrearsAgingBO(org.mifos.reports.branchreport.BranchReportLoanArrearsAgingBO) LoanArrearsAgingPeriod(org.mifos.reports.branchreport.LoanArrearsAgingPeriod) BatchJobException(org.mifos.framework.components.batchjobs.exceptions.BatchJobException) ServiceException(org.mifos.framework.exceptions.ServiceException)

Example 40 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class CenterServiceFacadeWebTier method waiveChargesDue.

@Override
public void waiveChargesDue(Integer accountId, Integer waiveType) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        AccountBO account = new AccountBusinessService().getAccount(accountId);
        account.updateDetails(userContext);
        PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
        WaiveEnum waiveEnum = WaiveEnum.fromInt(waiveType);
        if (account.getPersonnel() != null) {
            new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
        } else {
            new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
        }
        try {
            this.transactionHelper.startTransaction();
            if (account instanceof LoanBO) {
                ((LoanBO) account).waiveAmountDue(waiveEnum);
            } else if (account instanceof SavingsBO) {
                ((SavingsBO) account).waiveNextDepositAmountDue(loggedInUser);
            } else {
                ((CustomerAccountBO) account).waiveAmountDue();
            }
            this.customerDao.save(account);
            this.transactionHelper.commitTransaction();
        } catch (Exception e) {
            this.transactionHelper.rollbackTransaction();
            throw new BusinessRuleException(account.getAccountId().toString(), e);
        } finally {
            this.transactionHelper.closeSession();
        }
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    } catch (ApplicationException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : WaiveEnum(org.mifos.accounts.util.helpers.WaiveEnum) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountException(org.mifos.accounts.exceptions.AccountException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) ServiceException(org.mifos.framework.exceptions.ServiceException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) BusinessRuleException(org.mifos.service.BusinessRuleException) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ServiceException(org.mifos.framework.exceptions.ServiceException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ServiceException (org.mifos.framework.exceptions.ServiceException)93 PersistenceException (org.mifos.framework.exceptions.PersistenceException)46 MifosRuntimeException (org.mifos.core.MifosRuntimeException)39 Test (org.junit.Test)34 ExpectedException (org.springframework.test.annotation.ExpectedException)29 ArrayList (java.util.ArrayList)24 UserContext (org.mifos.security.util.UserContext)19 AccountBO (org.mifos.accounts.business.AccountBO)17 MifosUser (org.mifos.security.MifosUser)16 LoanBO (org.mifos.accounts.loan.business.LoanBO)15 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)14 AccountException (org.mifos.accounts.exceptions.AccountException)13 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)13 BusinessRuleException (org.mifos.service.BusinessRuleException)11 Date (java.util.Date)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 BigDecimal (java.math.BigDecimal)6 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)6 DateTimeService (org.mifos.framework.util.DateTimeService)6 LocalDate (org.joda.time.LocalDate)5