1 16 17 package info.jtrac.web; 18 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.http.HttpServletResponse ; 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 import org.springframework.web.servlet.HandlerExceptionResolver; 24 import org.springframework.web.servlet.ModelAndView; 25 import org.springframework.webflow.execution.repository.NoSuchFlowExecutionException; 26 import org.springframework.webflow.execution.repository.PermissionDeniedFlowExecutionAccessException; 27 import org.springframework.webflow.executor.support.FlowExecutorArgumentExtractionException; 28 29 33 public class FlowExceptionResolver implements HandlerExceptionResolver { 34 35 protected final Log logger = LogFactory.getLog(getClass()); 36 37 public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object o, Exception e) { 38 logger.debug("exception type: " + e.getClass() + ", message: " + e.getMessage()); 39 if (e instanceof NoSuchFlowExecutionException 40 || e instanceof FlowExecutorArgumentExtractionException) { 41 logger.debug("session must have expired in the middle of a flow, redirecting to dashboard"); 42 return new ModelAndView("redirect:/app"); 43 } else if (e instanceof PermissionDeniedFlowExecutionAccessException) { 44 logger.debug("user must have hit browser back button, trying to handle gracefully"); 45 return new ModelAndView("exception_flow"); 46 } else { 47 return null; } 49 } 50 51 } 52 | Popular Tags |