KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > eadmin > EAMenuAction


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.eadmin;
7
8 import java.io.IOException JavaDoc;
9
10 import javax.servlet.ServletException JavaDoc;
11 import javax.servlet.http.*;
12
13 import org.apache.struts.action.*;
14
15 import com.raptus.owxv3.*;
16 import com.raptus.owxv3.api.*;
17
18 /**
19  * Handles the menufunctions and its bean.
20  *
21  * <hr>
22  * <table width="100%" border="0">
23  * <tr>
24  * <td width="24%"><b>Filename</b></td><td width="76%">EAMenuAction.java</td>
25  * </tr>
26  * <tr>
27  * <td width="24%"><b>Author</b></td><td width="76%">Guy Z�rcher (gzuercher@raptus.com)</td>
28  * </tr>
29  * <tr>
30  * <td width="24%"><b>Date</b></td><td width="76%">17th of April 2001</td>
31  * </tr>
32  * </table>
33  * <hr>
34  * <table width="100%" border="0">
35  * <tr>
36  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
37  * </tr>
38  * </table>
39  * <hr>
40  */

41 //public class EAMenuAction extends OmniaWebAction
42
public class EAMenuAction extends VModuleRoleAction
43 {
44     // --------------------------------------------------------- Public Methods
45

46     /**
47      * Process the specified HTTP request, and create the corresponding HTTP
48      * response (or forward to another web component that will create it).
49      * Return an <code>ActionForward</code> instance describing where and how
50      * control should be forwarded, or <code>null</code> if the response has
51      * already been completed.
52      *
53      * @param mapping The ActionMapping used to select this instance
54      * @param actionForm The optional ActionForm bean for this request (if any)
55      * @param request The HTTP request we are processing
56      * @param response The HTTP response we are creating
57      *
58      * @exception IOException if an input/output error occurs
59      * @exception ServletException if a servlet exception occurs
60      */

61     public ActionForward perform(ActionMapping mapping,
62                  ActionForm form,
63                  HttpServletRequest request,
64                  HttpServletResponse response)
65     throws IOException JavaDoc, ServletException JavaDoc
66     {
67         LoggingManager.log("Loading user from session:"+request.getSession().getId(),this);
68         HttpSession session = request.getSession();
69         com.raptus.owxv3.api.usermgr.User user= checkForUserInSession(session);
70         /*if(user == null)
71         {
72             LoggingManager.log("WOOOOOOPS, iser is null!!!!");
73             SecurityMgrIF securityManager = SecurityMgrFactory.getInstance().createSecurityManager(request);
74             user = new User();
75             user.setLocale(securityManager.getLocale());
76             //throw new RuntimeException("asdadasd");
77         }*/

78         if(user == null)
79         {
80             LoggingManager.log("User is null, forwarding to login screen");
81             return mapping.findForward(Constants.SCREEN_LOGIN);
82         }
83         LoggingManager.log("User locale is "+user.getLocale(),this);
84         MenuBean owaf = (MenuBean) form;
85         String JavaDoc element = request.getParameter(Constants.HTTPGET_PARAM_ELEMENT);
86         if(element == null || element.length() == 0)
87             element = owaf.getElement();
88         if(element != null && element.length() > 0)
89         {
90             if(element.compareToIgnoreCase("welcome") == 0) // GET
91
{
92                 return performWelcome(mapping, owaf, request, response, user);
93             }
94             else if(element.compareToIgnoreCase("vmodule") == 0) // POST
95
{
96                 return performVModule(mapping, owaf, request, response, user);
97             }
98             else if(element.compareToIgnoreCase("function") == 0) // POST
99
{
100                 return performFunction(mapping, owaf, request, response, user);
101             }
102         }
103         LoggingManager.log("Unkown element " + element + " requested", this);
104         return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT);
105     }
106
107     /**
108      * The EAMenuBean must be always in scope session. So it has just to
109      * be correctly initialized. This is done via the EAMenuManager.
110      */

111     public ActionForward performWelcome(ActionMapping mapping,
112                         MenuBean form,
113                         HttpServletRequest request,
114                         HttpServletResponse response,
115                                         com.raptus.owxv3.api.usermgr.User user)
116     throws IOException JavaDoc, ServletException JavaDoc
117     {
118         if(form.isEmpty())
119         {
120             MenuManager eamm = new MenuManager(user, Constants.SECTION_EADMIN);
121             eamm.prepareMenuBean(form);
122             LoggingManager.log("EAMenuBean for user " + user.getUsername() + " initialized", this);
123         }
124         return mapping.findForward(Constants.SCREEN_WELCOME);
125     }
126
127     /**
128      *
129      */

130     public ActionForward performVModule(ActionMapping mapping,
131                         MenuBean form,
132                         HttpServletRequest request,
133                         HttpServletResponse response,
134                                         com.raptus.owxv3.api.usermgr.User user)
135     throws IOException JavaDoc, ServletException JavaDoc
136     {
137         String JavaDoc selectedVM = form.getSelectedVM();
138         if(selectedVM != null)
139         {
140             String JavaDoc uri = form.selectVModule(selectedVM);
141             if(uri != null)
142             {
143 // LoggingManager.log("Redirecting via GET inside eAdmin to URI " + uri, this);
144
response.sendRedirect(uri);
145                 return null;
146             }
147             else
148                 LoggingManager.log("Cannot perform vmodule because the uri is empty!", this);
149         }
150         else
151             LoggingManager.log("Cannot perform vmodule because selectedVM is empty", this);
152
153         return mapping.findForward(Constants.SCREEN_WELCOME); // default to this
154
}
155
156     /**
157      *
158      */

159     public ActionForward performFunction(ActionMapping mapping,
160                          MenuBean form,
161                          HttpServletRequest request,
162                          HttpServletResponse response,
163                                          com.raptus.owxv3.api.usermgr.User user)
164     throws IOException JavaDoc, ServletException JavaDoc
165     {
166         String JavaDoc selectedFunc = form.getSelectedFunc();
167         if(selectedFunc != null)
168         {
169 // LoggingManager.log("Redirecting via GET inside eAdmin to URI " + selectedFunc, this);
170
response.sendRedirect(selectedFunc);
171             return null;
172         }
173         else
174             LoggingManager.log("Cannot perform vmodule because selectedFunc is empty!", this);
175
176         return mapping.findForward(Constants.SCREEN_WELCOME); // default to this
177
}
178
179 }
180
181 // eof
182
Popular Tags