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