KickJava   Java API By Example, From Geeks To Geeks.

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


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.Action;
9 import org.apache.struts.action.ActionForm;
10 import org.apache.struts.action.ActionForward;
11 import org.apache.struts.action.ActionMapping;
12 import org.apache.struts.action.ActionMessages;
13
14 import com.sslexplorer.boot.ContextHolder;
15 import com.sslexplorer.core.CoreUtil;
16 import com.sslexplorer.security.SessionInfo;
17
18 /**
19  * Default {@link com.sslexplorer.core.actions.CoreAction} implementation that
20  * extends the default struts {@link org.apache.struts.action.Action}. All
21  * visitors may use these actions (there is no logon requirement or restriction
22  * testing).
23  *
24  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
25  */

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

36     public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
37                     throws Exception JavaDoc {
38         ActionForward fwd = checkIntercept(mapping, request, response);
39         if (fwd == null) {
40             if (isInstallMode()) {
41                 if ((getNavigationContext(mapping, form, request, response) & SessionInfo.SETUP_CONSOLE_CONTEXT) == 0) {
42                     return mapping.findForward("setup");
43                 }
44             }
45             fwd = super.execute(mapping, form, request, response);
46             if(fwd == null) {
47                 /* TODO
48                  *
49                  * This is silly, it means we can't tell in any subclasses if a call
50                  * to super.execute() should NOT forward somewhere and continue
51                  * processing as normal
52                  */

53                 fwd = mapping.findForward("display");
54             }
55         }
56         return fwd;
57     }
58
59     /**
60      * Get if the server is in install mode.
61      *
62      * @return in install mode
63      */

64     public boolean isInstallMode() {
65         return ContextHolder.getContext().isSetupMode();
66     }
67
68     /**
69      * Check whether there are any page intercepts queue. The forward
70      * will be returned if there are, otherwise <code>null</code>.
71      *
72      * @param mapping mapping
73      * @param request request
74      * @param response response
75      * @return forward forward
76      * @throws Exception on any error
77      */

78     public ActionForward checkIntercept(ActionMapping mapping, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
79                     throws Exception JavaDoc {
80         return CoreUtil.checkIntercept(this, mapping, request, response);
81     }
82
83
84     /**
85      * Add request warnings
86      *
87      * @param request request
88      * @param warnings warnings
89      */

90     protected void addWarnings(HttpServletRequest JavaDoc request, ActionMessages warnings) {
91         CoreUtil.addWarnings(request, warnings);
92     }
93
94     /**
95      * Get the current warnings, creating them if none exists
96      *
97      * @return the warnings that already exist in the request, or a new ActionMessages object if empty.
98      * @param request The servlet request we are processing
99      */

100     protected ActionMessages getWarnings(HttpServletRequest JavaDoc request) {
101         return CoreUtil.getWarnings(request);
102     }
103
104     /**
105      * Save the specified warnings messages.
106      *
107      * @param request request
108      * @param warnings warnings
109      */

110     protected void saveWarnings(HttpServletRequest JavaDoc request, ActionMessages warnings) {
111         CoreUtil.saveWarnings(request, warnings);
112     }
113 }
Popular Tags