Search in sources :

Example 1 with BadlyFormattedFlowExecutionKeyException

use of org.springframework.webflow.execution.repository.BadlyFormattedFlowExecutionKeyException in project cas by apereo.

the class FlowExecutionExceptionResolver method resolveException.

@Override
public ModelAndView resolveException(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final Exception exception) {
    /*
         * Since FlowExecutionRepositoryException is a common ancestor to these exceptions and other
         * error cases we would likely want to hide from the user, it seems reasonable to check for
         * FlowExecutionRepositoryException.
         *
         * BadlyFormattedFlowExecutionKeyException is specifically ignored by this handler
         * because redirecting to the requested URI with this exception may cause an infinite
         * redirect loop (i.e. when invalid "execution" parameter exists as part of the query string
         */
    if (!(exception instanceof FlowExecutionRepositoryException) || exception instanceof BadlyFormattedFlowExecutionKeyException) {
        LOGGER.debug("Ignoring the received exception due to a type mismatch", exception);
        return null;
    }
    final String urlToRedirectTo = request.getRequestURI() + (request.getQueryString() != null ? '?' + request.getQueryString() : StringUtils.EMPTY);
    LOGGER.debug("Error getting flow information for URL [{}]", urlToRedirectTo, exception);
    final Map<String, Object> model = new HashMap<>();
    model.put(this.modelKey, StringEscapeUtils.escapeHtml4(exception.getMessage()));
    return new ModelAndView(new RedirectView(urlToRedirectTo), model);
}
Also used : FlowExecutionRepositoryException(org.springframework.webflow.execution.repository.FlowExecutionRepositoryException) HashMap(java.util.HashMap) BadlyFormattedFlowExecutionKeyException(org.springframework.webflow.execution.repository.BadlyFormattedFlowExecutionKeyException) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView)

Aggregations

HashMap (java.util.HashMap)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 RedirectView (org.springframework.web.servlet.view.RedirectView)1 BadlyFormattedFlowExecutionKeyException (org.springframework.webflow.execution.repository.BadlyFormattedFlowExecutionKeyException)1 FlowExecutionRepositoryException (org.springframework.webflow.execution.repository.FlowExecutionRepositoryException)1