Search in sources :

Example 1 with PageExpiredException

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

the class SavingsActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    String method = request.getParameter("method");
    ActionErrors errors = new ActionErrors();
    String mandatoryAmount = getLocalizedMessage(SavingsConstants.MANDATORY_AMOUNT_FOR_DEPOSIT_KEY);
    request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
    if (method.equals("getPrdOfferings") || method.equals("create") || method.equals("edit") || method.equals("update") || method.equals("get") || method.equals("validate")) {
    } else {
        errors.add(super.validate(mapping, request));
        if (method.equals("preview") || method.equals("editPreview")) {
            try {
                SavingsOfferingBO savingsOffering = (SavingsOfferingBO) SessionUtils.getAttribute(SavingsConstants.PRDOFFERING, request);
                if (savingsOffering.getSavingsType().getId().equals(SavingsType.MANDATORY.getValue()) && StringUtils.isBlank(getRecommendedAmount())) {
                    // check for mandatory amount
                    errors.add(SavingsConstants.MANDATORY, new ActionMessage(SavingsConstants.MANDATORY, mandatoryAmount));
                }
                if (StringUtils.isNotBlank(getRecommendedAmount())) {
                    if (savingsOffering.getSavingsType().equals(SavingsType.MANDATORY)) {
                        validateAmount(getRecommendedAmount(), SavingsConstants.MANDATORY_AMOUNT_FOR_DEPOSIT_KEY, errors);
                    } else {
                        validateAmount(getRecommendedAmount(), SavingsConstants.RECOMMENDED_AMOUNT_FOR_DEPOSIT_KEY, errors);
                    }
                }
                validateCustomFields(request, errors);
            } catch (PageExpiredException e) {
                errors.add(SavingsConstants.MANDATORY, new ActionMessage(SavingsConstants.MANDATORY, mandatoryAmount));
            }
        }
    }
    if (!errors.isEmpty()) {
        request.setAttribute(Globals.ERROR_KEY, errors);
        request.setAttribute("methodCalled", method);
    }
    return errors;
}
Also used : SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) ActionMessage(org.apache.struts.action.ActionMessage) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) ActionErrors(org.apache.struts.action.ActionErrors)

Example 2 with PageExpiredException

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

the class MultipleLoanAccountsCreationActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    logger.debug("Inside validate method");
    String method = request.getParameter(Methods.method.toString());
    ActionErrors errors = new ActionErrors();
    try {
        if (method.equals(Methods.get.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            checkValidationForLoad(errors, getUserContext(request), (Short) SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request));
        } else if (method.equals(Methods.create.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            validateLoanAmounts(errors, this.getUserContext(request).getPreferredLocale(), clientDetails);
            checkValidationForCreate(errors, request);
        } else if (method.equals(Methods.getLoanOfficers.toString())) {
            checkValidationForBranchOffice(errors, getUserContext(request));
        } else if (method.equals(Methods.getCenters.toString())) {
            checkValidationForBranchOffice(errors, getUserContext(request));
            checkValidationForLoanOfficer(errors);
        } else if (method.equals(Methods.getPrdOfferings.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            checkValidationForBranchOffice(errors, getUserContext(request));
            checkValidationForLoanOfficer(errors);
            checkValidationForCenter(errors, getUserContext(request), (Short) SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request));
        }
    } catch (PageExpiredException e) {
        errors.add(ExceptionConstants.PAGEEXPIREDEXCEPTION, new ActionMessage(ExceptionConstants.PAGEEXPIREDEXCEPTION));
    } catch (ServiceException e) {
        errors.add(ExceptionConstants.SERVICEEXCEPTION, new ActionMessage(ExceptionConstants.SERVICEEXCEPTION));
    }
    if (!errors.isEmpty()) {
        request.setAttribute("methodCalled", method);
    }
    logger.debug("outside validate method");
    return errors;
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 3 with PageExpiredException

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

the class TableTag method doStartTag.

/**
     * Function to render the tag
     */
@Override
public int doStartTag() throws JspException {
    // call the helper method to display the result.
    try {
        // Value of the list which we are getting from the Cache
        List list = getList();
        if (list == null) {
            return super.doStartTag();
        }
        if (list.size() == 0) {
            JspWriter out = pageContext.getOut();
            XmlBuilder result;
            result = noResults((String) SessionUtils.getAttribute(Constants.OFFICE_NAME, (HttpServletRequest) pageContext.getRequest()), (String) SessionUtils.getAttribute(Constants.BRANCH_ID, (HttpServletRequest) pageContext.getRequest()), (String) SessionUtils.getAttribute(Constants.SEARCH_STRING, (HttpServletRequest) pageContext.getRequest()));
            out.write(result.getOutput());
            return super.doStartTag();
        }
        getTableData(list);
    } catch (TableTagException tte) {
        throw new JspException(tte);
    } catch (TableTagParseException ttpe) {
        throw new JspException(ttpe);
    } catch (TableTagTypeParserException tttpe) {
        throw new JspException(tttpe);
    } catch (IOException ioe) {
        throw new JspException(ioe);
    } catch (HibernateSearchException hse) {
        throw new JspException(hse);
    } catch (PageExpiredException e) {
        throw new JspException(e);
    }
    return super.doStartTag();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TableTagException(org.mifos.framework.exceptions.TableTagException) JspException(javax.servlet.jsp.JspException) TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) TableTagTypeParserException(org.mifos.framework.exceptions.TableTagTypeParserException)

Example 4 with PageExpiredException

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

the class TableTag method doStartTag.

@SuppressWarnings("unchecked")
@Override
public int doStartTag() throws JspException {
    try {
        table = TableTagParser.getInstance().parser(moduleName + "/" + xmlFileName);
        Column[] column = table.getRow().getColumn();
        for (int i = 0; i < column.length; ++i) {
            if (column[i].getLinkDetails() != null) {
                if (randomNUm == null || currentFlowKey == null) {
                    column[i] = null;
                    if (i < column.length - 1) {
                        int j = i;
                        for (; j < column.length - 1; ++j) {
                            column[j] = column[j + 1];
                        }
                    }
                    column = Arrays.copyOf(column, column.length - 1);
                    table.getRow().setColumn(column);
                } else {
                    LinkDetails linkDetails = column[i].getLinkDetails();
                    for (ActionParam param : linkDetails.getActionParam()) {
                        if (param.getValueType().equalsIgnoreCase(TableTagConstants.INBUILD)) {
                            if (param.getName().equalsIgnoreCase("randomNUm")) {
                                param.setValue(randomNUm);
                            } else if (param.getName().equalsIgnoreCase("currentFlowKey")) {
                                param.setValue(currentFlowKey);
                            } else if (param.getName().equalsIgnoreCase("accountId")) {
                                param.setValue(accountId);
                            } else if (param.getName().equalsIgnoreCase("globalAccountNum")) {
                                param.setValue(globalAccountNum);
                            }
                        }
                    }
                }
            }
        }
        tableInfo = new StringBuilder();
        if (source == null || scope == null) {
            throw new JspException();
        }
        List obj = null;
        if (scope.equalsIgnoreCase("session")) {
            obj = (List) pageContext.getSession().getAttribute(source);
        } else if (scope.equalsIgnoreCase("request")) {
            obj = (List) pageContext.getRequest().getAttribute(source);
        }
        if (obj == null) {
            try {
                obj = (List) SessionUtils.getAttribute(source, (HttpServletRequest) pageContext.getRequest());
            } catch (PageExpiredException e) {
            }
        }
        if (obj == null || obj.isEmpty()) {
            return super.doStartTag();
        }
        if (passLocale != null && passLocale.equalsIgnoreCase("true")) {
            UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USER_CONTEXT_KEY);
            populateLocale(userContext);
        }
        table.getTable(source, tableInfo, obj, locale, mfiLocale, pageContext, getResourcebundleName(), glMode);
    } catch (TableTagParseException ex) {
        throw new JspException(ex);
    }
    try {
        pageContext.getOut().print(tableInfo.toString());
    } catch (IOException e) {
        throw new JspException(e);
    }
    return super.doStartTag();
}
Also used : JspException(javax.servlet.jsp.JspException) TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) UserContext(org.mifos.security.util.UserContext) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) List(java.util.List) IOException(java.io.IOException)

Example 5 with PageExpiredException

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

the class LoanAccountActionStrutsTest method testManageWithoutFlow.

/*
     * this test appears to be confirming that an unauthenticated user gets a
     * "page expired" exception, but the catch() block doesn't appear to be
     * reached.
     */
@Test
public void testManageWithoutFlow() throws Exception {
    try {
        request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
        Date startDate = new Date(System.currentTimeMillis());
        accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
        LoanBO loan = (LoanBO) accountBO;
        SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
        setRequestPathInfo("/loanAccountAction.do");
        addRequestParameter("method", "manage");
        addRequestParameter("customerId", accountBO.getCustomer().getCustomerId().toString());
        addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
        actionPerform();
    // I'd normally expect to see a call to JUnit 3's fail() here
    } catch (PageExpiredException pe) {
        Assert.assertTrue(true);
        Assert.assertEquals(ExceptionConstants.PAGEEXPIREDEXCEPTION, pe.getKey());
    }
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) Date(java.util.Date) Test(org.junit.Test)

Aggregations

PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)23 ArrayList (java.util.ArrayList)9 List (java.util.List)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 ActionMessage (org.apache.struts.action.ActionMessage)6 IOException (java.io.IOException)5 JspException (javax.servlet.jsp.JspException)5 ActionErrors (org.apache.struts.action.ActionErrors)4 Test (org.junit.Test)4 FeeBO (org.mifos.accounts.fees.business.FeeBO)4 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)4 FeeDto (org.mifos.accounts.fees.business.FeeDto)3 Date (java.sql.Date)2 Date (java.util.Date)2 JspWriter (javax.servlet.jsp.JspWriter)2 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)2 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)2 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)2 TableTagParseException (org.mifos.framework.exceptions.TableTagParseException)2 Flow (org.mifos.framework.util.helpers.Flow)2