use of org.mifos.framework.util.helpers.PreviousRequestValues in project head by mifos.
the class MifosRequestProcessor method processActionPerform.
/**
* This method is overridden because in case of exception we need to
* populate the request with the old values so that when the user goes back
* to the previous page it has all the values in the request.For this we
* create an object which will store the values of previous request in case
* the request is successful and if there is an exception it reads values
* from that object and context and dups all in the request.
*/
@Override
protected ActionForward processActionPerform(HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping) throws IOException, ServletException {
ActivityContext activityContext = null;
ActionForward forward = null;
HttpSession session = request.getSession();
// gets the object where we will store values from request.
PreviousRequestValues previousRequestValues = (PreviousRequestValues) session.getAttribute(Constants.PREVIOUS_REQUEST);
if (null == previousRequestValues) {
previousRequestValues = new PreviousRequestValues();
session.setAttribute(Constants.PREVIOUS_REQUEST, previousRequestValues);
}
// getting the activity context from the session
activityContext = (ActivityContext) session.getAttribute("ActivityContext");
try {
String currentFlowKey = request.getParameter(Constants.CURRENTFLOWKEY);
if (currentFlowKey != null) {
previousRequestValues.getPreviousRequestValueMap().put(Constants.CURRENTFLOWKEY, currentFlowKey);
}
forward = (action.execute(mapping, form, request, response));
String method = request.getParameter("method");
if (method.equals(ClientConstants.METHOD_RETRIEVE_PICTURE)) {
forward = mapping.findForward("get_success");
}
// set the last forward in the activity context
if (activityContext != null) {
activityContext.setLastForward(forward);
}
// read the request and add the values to the PreviousRequestValues
// object. this will set every thing in the request apart from
// context and value object.
Enumeration requestAttributes = request.getAttributeNames();
while (requestAttributes.hasMoreElements()) {
String nextName = (String) requestAttributes.nextElement();
if (nextName.startsWith(Constants.STORE_ATTRIBUTE) || nextName.equalsIgnoreCase(Constants.CURRENTFLOWKEY)) {
logger.debug(nextName + "=" + request.getAttribute(nextName));
previousRequestValues.getPreviousRequestValueMap().put(nextName, request.getAttribute(nextName));
}
}
} catch (Exception e) {
// processException logs an error (see MifosExceptionHandler)
forward = (processException(request, response, e, form, mapping));
// set the last forward in the activity context
if (activityContext != null) {
activityContext.setLastForward(forward);
}
populateTheRequestFromPreviousValues(request, previousRequestValues);
} finally {
try {
session.removeAttribute(SecurityConstants.SECURITY_PARAM);
} catch (Exception e) {
// FIXME: yikes, what is being swallowed here?
}
}
if (null != forward) {
logger.info("forward.path=" + forward.getPath());
}
return forward;
}
use of org.mifos.framework.util.helpers.PreviousRequestValues in project head by mifos.
the class DynamicAuthorizationVoter method vote.
@Override
public int vote(Authentication authentication, Object object, Collection attributes) {
Object principal = authentication.getPrincipal();
for (Object configAttribute : attributes) {
if (supports((ConfigAttribute) configAttribute)) {
}
}
FilterInvocation filter = (FilterInvocation) object;
String fullUrl = filter.getFullRequestUrl();
HttpServletRequest request = filter.getHttpRequest();
HttpSession session = request.getSession();
PreviousRequestValues previousRequestValues = (PreviousRequestValues) session.getAttribute(Constants.PREVIOUS_REQUEST);
if (null == previousRequestValues) {
previousRequestValues = new PreviousRequestValues();
session.setAttribute(Constants.PREVIOUS_REQUEST, previousRequestValues);
}
return ACCESS_GRANTED;
}
use of org.mifos.framework.util.helpers.PreviousRequestValues in project head by mifos.
the class MifosRequestProcessor method processRoles.
@Override
protected boolean processRoles(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws IOException, ServletException {
HttpSession session = request.getSession();
PreviousRequestValues previousRequestValues = (PreviousRequestValues) session.getAttribute(Constants.PREVIOUS_REQUEST);
if (null == previousRequestValues) {
previousRequestValues = new PreviousRequestValues();
session.setAttribute(Constants.PREVIOUS_REQUEST, previousRequestValues);
}
if (!checkProcessRoles(request, response, mapping)) {
ActionErrors error = new ActionErrors();
error.add(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED, new ActionMessage(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED));
request.setAttribute(Globals.ERROR_KEY, error);
ActivityContext activityContext = (ActivityContext) request.getSession().getAttribute("ActivityContext");
populateTheRequestFromPreviousValues(request, previousRequestValues);
processForwardConfig(request, response, activityContext.getLastForward());
return false;
}
return true;
}
Aggregations