001    package hirondelle.web4jtools.webmaster.diagnostics;
002    
003    import hirondelle.web4j.action.ActionImpl;
004    import hirondelle.web4j.request.RequestParser;
005    import hirondelle.web4j.action.ResponsePage;
006    import hirondelle.web4j.Controller;
007    
008    /**
009    * Remove the {@link hirondelle.web4j.webmaster.TroubleTicket} held in application scope.
010    * 
011    * <P>When a <tt>TroubleTicket</tt> occurs, it is placed in application scope. 
012    * There, it may be later retrieved and examined. Once it has been 
013    * investigated and resolved, it should be removed from application scope, using this <tt>Action</tt>.
014    * 
015    * <P>Only one <tt>TroubleTicket</tt> at a time is stored in application scope. 
016    * If a new one occurs, it overwrites any existing <tt>TroubleTicket</tt>, if any.
017    */
018    public final class ClearTroubleTicket extends ActionImpl {
019      
020      /** Constructor. */
021      public ClearTroubleTicket(RequestParser aRequestParser){
022        super(REDIRECT, aRequestParser);
023      }
024      
025      /** 
026      * Remove the {@link hirondelle.web4j.webmaster.TroubleTicket} from application scope, 
027      * and re-display the diagnostics page using {@link ShowDiagnostics}.
028      * 
029      * Uses {@link hirondelle.web4j.Controller#MOST_RECENT_TROUBLE_TICKET} as key. 
030      */
031      public ResponsePage execute() {
032        getRequestParser().getRequest().getSession().getServletContext().removeAttribute(Controller.MOST_RECENT_TROUBLE_TICKET); 
033        return getResponsePage();
034      }
035      
036      // PRIVATE //
037      private static final ResponsePage REDIRECT = new ResponsePage("ShowDiagnostics.do");
038    }