Search in sources :

Example 46 with BusinessRuleException

use of org.mifos.service.BusinessRuleException 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));
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) EditCustomerStatusActionForm(org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm) CustomerBO(org.mifos.customers.business.CustomerBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 47 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class PersonAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm personActionForm = (PersonActionForm) form;
    CreateOrUpdatePersonnelInformation perosonnelInfo = translateFormToCreatePersonnelInformationDto(request, personActionForm);
    try {
        UserDetailDto userDetails = this.personnelServiceFacade.createPersonnelInformation(perosonnelInfo);
        String globalPersonnelNum = userDetails.getSystemId();
        Name name = new Name(personActionForm.getFirstName(), personActionForm.getMiddleName(), personActionForm.getSecondLastName(), personActionForm.getLastName());
        request.setAttribute("displayName", name.getDisplayName());
        request.setAttribute("globalPersonnelNum", globalPersonnelNum);
        createGroupQuestionnaire.saveResponses(request, personActionForm, userDetails.getId());
        return mapping.findForward(ActionForwards.create_success.toString());
    } catch (BusinessRuleException e) {
        throw new PersonnelException(e.getMessageKey(), e, e.getMessageValues());
    }
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) BusinessRuleException(org.mifos.service.BusinessRuleException) CreateOrUpdatePersonnelInformation(org.mifos.dto.domain.CreateOrUpdatePersonnelInformation) UserDetailDto(org.mifos.dto.domain.UserDetailDto) PersonnelException(org.mifos.customers.personnel.exceptions.PersonnelException) Name(org.mifos.framework.business.util.Name) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 48 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class HolidayBO method validateFromDateAgainstThruDate.

private void validateFromDateAgainstThruDate(final Date fromDate, final Date thruDate) {
    LocalDate fromLocalDate = new LocalDate(fromDate);
    LocalDate thruLocalDate = new LocalDate(thruDate);
    if (fromLocalDate.isAfter(thruLocalDate)) {
        throw new BusinessRuleException(HolidayConstants.INVALIDTHRUDATE);
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) LocalDate(org.joda.time.LocalDate)

Example 49 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class HolidayBO method validateFromDateAgainstCurrentDate.

private void validateFromDateAgainstCurrentDate(final Date fromDate) {
    LocalDate currentDate = new LocalDate();
    LocalDate fromLocalDate = new LocalDate(fromDate);
    if (!fromLocalDate.isAfter(currentDate)) {
        throw new BusinessRuleException(HolidayConstants.INVALIDFROMDATE);
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) LocalDate(org.joda.time.LocalDate)

Example 50 with BusinessRuleException

use of org.mifos.service.BusinessRuleException in project head by mifos.

the class NewFundPreviewController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") FundFormBean formBean, BindingResult result, SessionStatus status) {
    ModelAndView mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
    if (StringUtils.isNotBlank(edit)) {
        mav = new ModelAndView("editFunds");
        mav.addObject("formBean", formBean);
        mav.addObject("previewView", "newFundPreview");
    } else if (StringUtils.isNotBlank(cancel)) {
        mav = new ModelAndView(REDIRECT_TO_VIEW_FUNDS);
        status.setComplete();
    } else if (result.hasErrors()) {
        mav = new ModelAndView("newFundPreview");
    } else {
        FundCodeDto codeDto = new FundCodeDto();
        codeDto.setId(formBean.getCodeId());
        codeDto.setValue(formBean.getCodeValue());
        FundDto fundDto = new FundDto();
        fundDto.setCode(codeDto);
        fundDto.setId(formBean.getId());
        fundDto.setName(formBean.getName());
        try {
            this.fundServiceFacade.createFund(fundDto);
            status.setComplete();
        } catch (BusinessRuleException e) {
            ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
            result.addError(error);
            mav.setViewName("newFundPreview");
            mav.addObject("formBean", formBean);
        }
    }
    return mav;
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ObjectError(org.springframework.validation.ObjectError) ModelAndView(org.springframework.web.servlet.ModelAndView) FundDto(org.mifos.accounts.fund.servicefacade.FundDto) FundCodeDto(org.mifos.accounts.fund.servicefacade.FundCodeDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BusinessRuleException (org.mifos.service.BusinessRuleException)140 MifosRuntimeException (org.mifos.core.MifosRuntimeException)68 UserContext (org.mifos.security.util.UserContext)63 MifosUser (org.mifos.security.MifosUser)61 AccountException (org.mifos.accounts.exceptions.AccountException)46 PersistenceException (org.mifos.framework.exceptions.PersistenceException)43 ApplicationException (org.mifos.framework.exceptions.ApplicationException)33 LocalDate (org.joda.time.LocalDate)31 ServiceException (org.mifos.framework.exceptions.ServiceException)30 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)26 ArrayList (java.util.ArrayList)23 CustomerBO (org.mifos.customers.business.CustomerBO)22 Money (org.mifos.framework.util.helpers.Money)22 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)20 CustomerException (org.mifos.customers.exceptions.CustomerException)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)18 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)16 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)16 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)16 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)16