Search in sources :

Example 6 with FlowManager

use of org.mifos.framework.util.helpers.FlowManager in project head by mifos.

the class BaseAction method createToken.

private void createToken(HttpServletRequest request) {
    String flowKey = String.valueOf(new DateTimeService().getCurrentDateTime().getMillis());
    FlowManager flowManager = (FlowManager) request.getSession().getAttribute(Constants.FLOWMANAGER);
    if (flowManager == null) {
        flowManager = new FlowManager();
        request.getSession(false).setAttribute(Constants.FLOWMANAGER, flowManager);
    }
    flowManager.addFLow(flowKey, new Flow(), this.clazz.getName());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
}
Also used : FlowManager(org.mifos.framework.util.helpers.FlowManager) DateTimeService(org.mifos.framework.util.DateTimeService) Flow(org.mifos.framework.util.helpers.Flow)

Example 7 with FlowManager

use of org.mifos.framework.util.helpers.FlowManager in project head by mifos.

the class BaseAction method joinToken.

private void joinToken(HttpServletRequest request) throws PageExpiredException {
    String flowKey = request.getParameter(Constants.CURRENTFLOWKEY);
    if (null == flowKey) {
        flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    }
    FlowManager flowManager = (FlowManager) request.getSession().getAttribute(Constants.FLOWMANAGER);
    if (flowKey == null || !flowManager.isFlowValid(flowKey)) {
        throw new PageExpiredException("no flow for key " + flowKey);
    }
}
Also used : FlowManager(org.mifos.framework.util.helpers.FlowManager) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException)

Example 8 with FlowManager

use of org.mifos.framework.util.helpers.FlowManager in project head by mifos.

the class BaseAction method postHandleTransaction.

protected void postHandleTransaction(HttpServletRequest request, TransactionDemarcate annotation) throws SystemException {
    if (null != annotation && annotation.validateAndResetToken()) {
        FlowManager flowManager = (FlowManager) request.getSession().getAttribute(Constants.FLOWMANAGER);
        flowManager.removeFlow((String) request.getAttribute(Constants.CURRENTFLOWKEY));
        request.setAttribute(Constants.CURRENTFLOWKEY, null);
    }
}
Also used : FlowManager(org.mifos.framework.util.helpers.FlowManager)

Example 9 with FlowManager

use of org.mifos.framework.util.helpers.FlowManager in project head by mifos.

the class AddGroupMembershipActionStrutsTest method setUp.

@Before
public void setUp() throws Exception {
    UserContext userContext = TestObjectFactory.getContext();
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
    request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
    FlowManager flowManager = new FlowManager();
    request.getSession(false).setAttribute(Constants.FLOWMANAGER, flowManager);
    request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
    flowKey = createFlow(request, AddGroupMembershipAction.class);
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
}
Also used : FlowManager(org.mifos.framework.util.helpers.FlowManager) UserContext(org.mifos.security.util.UserContext) Before(org.junit.Before)

Example 10 with FlowManager

use of org.mifos.framework.util.helpers.FlowManager in project head by mifos.

the class OfficeActionStrutsTest method ignore_testFlowFailure.

public void ignore_testFlowFailure() throws Exception {
    setRequestPathInfo("/offAction.do");
    addRequestParameter("method", Methods.load.toString());
    addRequestParameter("officeLevel", "5");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.load_success.toString());
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    FlowManager fm = (FlowManager) SessionUtils.getAttribute(Constants.FLOWMANAGER, request.getSession());
    Assert.assertEquals(true, fm.isFlowValid(flowKey));
    setRequestPathInfo("/offAction.do");
    addRequestParameter("method", Methods.preview.toString());
    addRequestParameter("officeName", "abcd");
    addRequestParameter("shortName", "abcd");
    addRequestParameter("officeLevel", "5");
    addRequestParameter("parentOfficeId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyInputForward();
    fm = (FlowManager) SessionUtils.getAttribute(Constants.FLOWMANAGER, request.getSession());
    Assert.assertEquals(true, fm.isFlowValid(flowKey));
    setRequestPathInfo("/offAction.do");
    addRequestParameter("method", Methods.create.toString());
    addRequestParameter("officeName", "abcd");
    addRequestParameter("shortName", "abcd");
    addRequestParameter("officeLevel", "5");
    addRequestParameter("parentOfficeId", "1");
    addRequestParameter("address.line1", "123");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.create_success.toString());
    fm = (FlowManager) SessionUtils.getAttribute(Constants.FLOWMANAGER, request.getSession());
    Assert.assertEquals(false, fm.isFlowValid(flowKey));
    setRequestPathInfo("/offAction.do");
    addRequestParameter("method", Methods.create.toString());
    addRequestParameter("officeName", "abcd");
    addRequestParameter("shortName", "abcd");
    addRequestParameter("officeLevel", "5");
    addRequestParameter("parentOfficeId", "1");
    addRequestParameter("address.line1", "123");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyActionErrors(new String[] { "exception.framework.PageExpiredException" });
    verifyForwardPath("/pages/framework/jsp/pageexpirederror.jsp");
}
Also used : FlowManager(org.mifos.framework.util.helpers.FlowManager)

Aggregations

FlowManager (org.mifos.framework.util.helpers.FlowManager)13 HttpSession (javax.servlet.http.HttpSession)4 Flow (org.mifos.framework.util.helpers.Flow)4 UserContext (org.mifos.security.util.UserContext)4 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)3 DateTimeService (org.mifos.framework.util.DateTimeService)3 JspException (javax.servlet.jsp.JspException)2 XmlBuilder (org.mifos.framework.struts.tags.XmlBuilder)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 Random (java.util.Random)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ActionErrors (org.apache.struts.action.ActionErrors)1 ActionMessage (org.apache.struts.action.ActionMessage)1 Before (org.junit.Before)1 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)1 FeeDto (org.mifos.accounts.fees.business.FeeDto)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1