KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > core > actions > DefaultDispatchAction


1 /*
2  */

3 package com.sslexplorer.core.actions;
4
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
7
8 import org.apache.struts.action.ActionForm;
9 import org.apache.struts.action.ActionForward;
10 import org.apache.struts.action.ActionMapping;
11 import org.apache.struts.action.ActionMessages;
12 import org.apache.struts.actions.DispatchAction;
13
14 import com.sslexplorer.boot.ContextHolder;
15 import com.sslexplorer.core.CoreUtil;
16 import com.sslexplorer.security.SessionInfo;
17
18 /**
19  * <p> Default dispatch action.
20  *
21  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
22  *
23  *
24  */

25 public abstract class DefaultDispatchAction extends DispatchAction implements CoreAction {
26
27     /*
28      * (non-Javadoc)
29      *
30      * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
31      * org.apache.struts.action.ActionForm,
32      * javax.servlet.http.HttpServletRequest,
33      * javax.servlet.http.HttpServletResponse)
34      */

35     public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
36                     throws Exception JavaDoc {
37         ActionForward fwd = checkIntercept(mapping, request, response);
38         if (fwd != null) {
39             return fwd;
40         }
41         if (isSetupMode()) {
42             if ((getNavigationContext(mapping, form, request, response) & SessionInfo.SETUP_CONSOLE_CONTEXT) == 0) {
43                 return mapping.findForward("setup");
44             }
45         }
46         return super.execute(mapping, form, request, response);
47     }
48
49     /**
50      * @return boolean
51      */

52     public boolean isSetupMode() {
53         return ContextHolder.getContext().isSetupMode();
54     }
55
56     /**
57      * @param mapping
58      * @param request
59      * @param response
60      * @return ActionForward
61      * @throws Exception
62      */

63     public ActionForward checkIntercept(ActionMapping mapping, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
64                     throws Exception JavaDoc {
65         return CoreUtil.checkIntercept(this, mapping, request, response);
66     }
67
68     /**
69      * Add request warnings
70      *
71      * @param request request
72      * @param warnings warnings
73      */

74     protected void addWarnings(HttpServletRequest JavaDoc request, ActionMessages warnings) {
75         CoreUtil.addWarnings(request, warnings);
76     }
77
78     /**
79      * Get the current warnings, creating them if none exists
80      *
81      * @return the warnings that already exist in the request, or a new ActionMessages object if empty.
82      * @param request The servlet request we are processing
83      */

84     protected ActionMessages getWarnings(HttpServletRequest JavaDoc request) {
85         return CoreUtil.getWarnings(request);
86     }
87
88     /**
89      * Save the specified warnings messages.
90      *
91      * @param request request
92      * @param warnings warnings
93      */

94     protected void saveWarnings(HttpServletRequest JavaDoc request, ActionMessages warnings) {
95         CoreUtil.saveWarnings(request, warnings);
96     }
97
98 }
99
Popular Tags