org.makumba.devel
Class ErrorControllerHandler

java.lang.Object
  extended by org.makumba.commons.ControllerHandler
      extended by org.makumba.devel.ErrorControllerHandler

public class ErrorControllerHandler
extends ControllerHandler

This handler lets the request go to the filter chain and then catches all kind of exceptions after it. The exceptions are then handled by the ErrorFormatter. It should be the first one of the filter handlers. If disabled, the "raw" exception is thrown. TODO the login should not be triggered directly in here, but somewhere else

Version:
$Id: ErrorFilter.java,v 1.1 12.10.2007 18:17:00 Manuel Exp $
Author:
Manuel Gay, Rudolf Mayer, Filip Kis

Field Summary
static String ORIGINAL_REQUEST
           
 
Constructor Summary
ErrorControllerHandler()
           
 
Method Summary
 boolean beforeFilter(ServletRequest request, ServletResponse response, FilterConfig conf, ServletObjects httpServletObjects)
          Performs an operation before the doFilterChain() method is called
static String getLoginPage(HttpServletRequest req, String servletPath)
          Computes the login page from a servletPath
static String getPage(HttpServletRequest req, String servletPath, String pageName)
          Computes any page from a servletPath, used to compute login, error or any other default page
protected static boolean login(HttpServletRequest req, HttpServletResponse resp)
          Finds the closest login.jsp and forwards to it
 boolean onError(ServletRequest request, ServletResponse response, Throwable e, FilterConfig conf)
          Performs an operation when an error occurs
 void setWasException(HttpServletRequest req)
          Signals that there was an exception during the request, so some operations can be skipped
 void treatException(Throwable t, HttpServletRequest req, HttpServletResponse resp, FilterConfig conf)
          Treats an exception that occurred during the request.
 boolean wasException(HttpServletRequest req)
          Tests if there was an exception during the request
 
Methods inherited from class org.makumba.commons.ControllerHandler
afterBeforeFilter, afterFilter, finalize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORIGINAL_REQUEST

public static final String ORIGINAL_REQUEST
See Also:
Constant Field Values
Constructor Detail

ErrorControllerHandler

public ErrorControllerHandler()
Method Detail

beforeFilter

public boolean beforeFilter(ServletRequest request,
                            ServletResponse response,
                            FilterConfig conf,
                            ServletObjects httpServletObjects)
Description copied from class: ControllerHandler
Performs an operation before the doFilterChain() method is called

Overrides:
beforeFilter in class ControllerHandler
Returns:
true if the operation worked out successfully, false otherwise

onError

public boolean onError(ServletRequest request,
                       ServletResponse response,
                       Throwable e,
                       FilterConfig conf)
Description copied from class: ControllerHandler
Performs an operation when an error occurs

Overrides:
onError in class ControllerHandler
Returns:
true if this still is an error, false if it was handled

treatException

public void treatException(Throwable t,
                           HttpServletRequest req,
                           HttpServletResponse resp,
                           FilterConfig conf)
Treats an exception that occurred during the request. Displays the exception and sets an attribute corresponding to it. The exception is displayed either in custom "error.jsp" set by the user in the folder of the page that throw an exception or any parent root. In this case, three attributes (mak_error_title, mak_error_description , mak_error_realpath) are set so that the user can place use them in the custom page freely. If the custom page is not found the error is show in the TagExceptionFilter.

Parameters:
t - the Throwable corresponding to the exception
req - the http request corresponding to the access
resp - the http response corresponding to the access

getLoginPage

public static String getLoginPage(HttpServletRequest req,
                                  String servletPath)
Computes the login page from a servletPath

Parameters:
req - the http request corresponding to the current access
servletPath - the path of the servlet we are in
Returns:
A String containing the path to the login page

getPage

public static String getPage(HttpServletRequest req,
                             String servletPath,
                             String pageName)
Computes any page from a servletPath, used to compute login, error or any other default page

Parameters:
req - the http request corresponding to the current access
servletPath - the path of the servlet we are in
pageName - the name of the page we are looking for
Returns:

login

protected static boolean login(HttpServletRequest req,
                               HttpServletResponse resp)
Finds the closest login.jsp and forwards to it

Parameters:
req - the http request corresponding to the current access
resp - the http response corresponding to the current access

setWasException

public void setWasException(HttpServletRequest req)
Signals that there was an exception during the request, so some operations can be skipped

Parameters:
req - the http request corresponding to the current access

wasException

public boolean wasException(HttpServletRequest req)
Tests if there was an exception during the request

Parameters:
req - the http request corresponding to the current access
Returns:
true if there was an exception, false otherwise