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) {
}
}
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) {
}
}
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);
}
}
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);
}
}
}
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);
}
}
Aggregations