use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class CustomerApplyAdjustmentAction method loadAdjustment.
@TransactionDemarcate(joinToken = true)
public ActionForward loadAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
resetActionFormFields(applyAdjustmentActionForm);
String globalCustNum = applyAdjustmentActionForm.getGlobalCustNum();
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_LOAD_ADJUSTMENT);
if (null == customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate()) {
request.setAttribute("isDisabled", "true");
throw new ApplicationException(AccountExceptionConstants.ZEROAMNTADJUSTMENT);
}
return mapping.findForward(CustomerConstants.METHOD_LOAD_ADJUSTMENT_SUCCESS);
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class EditCustomerStatusAction method updateStatus.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
EditCustomerStatusActionForm editStatusActionForm = (EditCustomerStatusActionForm) form;
CustomerBO customerBOInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
if (customerBOInSession.isBlackListed() && customerBOInSession.getStatus().getValue() == CustomerConstants.CLIENT_CLOSED) {
try {
this.clientServiceFacade.removeFromBlacklist(customerBOInSession.getCustomerId());
customerBOInSession.setVersionNo(customerBOInSession.getVersionNo() + 1);
} catch (AccessDeniedException e) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
try {
this.centerServiceFacade.updateCustomerStatus(customerBOInSession.getCustomerId(), customerBOInSession.getVersionNo(), editStatusActionForm.getFlagId(), editStatusActionForm.getNewStatusId(), editStatusActionForm.getNotes());
createClientQuestionnaire.saveResponses(request, editStatusActionForm, customerBOInSession.getCustomerId());
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e);
}
return mapping.findForward(getDetailAccountPage(form));
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class CustomerActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
}
ActionErrors errors = null;
try {
errors = validateFields(request, method);
} catch (ApplicationException ae) {
errors = new ActionErrors();
errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
}
if (null != errors && !errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
errors.add(super.validate(mapping, request));
return errors;
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleAccountStateObjectsForSavings.
private List<AccountStateEntity> retrieveNextPossibleAccountStateObjectsForSavings(StateEntity accountStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleAccountStateObjectsForSavings()");
List<AccountStateEntity> stateEntityList = new ArrayList<AccountStateEntity>();
try {
List<StateEntity> stateList = statesMapForSavings.get(accountStateEntityObj);
if (null != stateList) {
for (StateEntity accountStateEntity : stateList) {
for (AccountStateEntity accountStateEnty : accountStateEntityListForSavings) {
if (accountStateEntity.sameId(accountStateEnty)) {
stateEntityList.add(accountStateEnty);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice.
@Test
public void shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice() throws Exception {
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
DateTime tomorrow = new DateTime().plusDays(1);
HolidayDetails holidayDetails = new HolidayBuilder().withName("areaOffice2Holiday").from(tomorrow).to(tomorrow).buildDto();
IntegrationTestObjectMother.createHoliday(holidayDetails, Arrays.asList(areaOffice2.getOfficeId()));
HolidayDetails branchOnlyHolidayDetails = new HolidayBuilder().withName("branchOnlyHoliday").from(tomorrow).to(tomorrow).buildDto();
IntegrationTestObjectMother.createHoliday(branchOnlyHolidayDetails, Arrays.asList(branch1.getOfficeId()));
// refetch
branch1 = IntegrationTestObjectMother.findOfficeById(branch1.getOfficeId());
// exercise test
try {
holidayDao.validateNoExtraFutureHolidaysApplicableOnParentOffice(branch1.getParentOffice().getOfficeId(), areaOffice2.getOfficeId());
fail("shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(OfficeConstants.ERROR_REPARENT_NOT_ALLOWED_AS_FUTURE_APPLICABLE_HOLIDAYS_ARE_DIFFERENT_ON_PREVIOUS_AND_NEW_PARENT));
}
}
Aggregations