KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > api > VModuleAuthAction


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

5
6 package com.raptus.owxv3.api;
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 import org.apache.struts.util.MessageResources;
15
16 import com.raptus.owxv3.*;
17 import com.raptus.owxv3.api.usermgr.User;
18
19 /**
20  *
21  * <hr>
22  * <table width="100%" border="0">s
23  * <tr>
24  * <td width="24%"><b>Filename</b></td><td width="76%">VModuleAuthAction.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%">19th 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 VModuleAuthAction extends OmniaWebAction
42 {
43     /**
44      * Process the specified HTTP request, and create the corresponding HTTP
45      * response (or forward to another web component that will create it).
46      * Return an <code>ActionForward</code> instance describing where and how
47      * control should be forwarded, or <code>null</code> if the response has
48      * already been completed.
49      *
50      * @param mapping The ActionMapping used to select this instance
51      * @param actionForm The optional ActionForm bean for this request (if any)
52      * @param request The HTTP request we are processing
53      * @param response The HTTP response we are creating
54      *
55      * @exception IOException if an input/output error occurs
56      * @exception ServletException if a servlet exception occurs
57      */

58     public ActionForward perform(ActionMapping mapping,
59                  ActionForm form,
60                  HttpServletRequest request,
61                  HttpServletResponse response)
62     throws IOException JavaDoc, ServletException JavaDoc
63     {
64         String JavaDoc element = getSelectedElement(form, request);
65         if(element == null || element.length() == 0)
66         {
67             LoggingManager.log("Parameter <element> not specified. Displaying " +
68                                "error screen.", this);
69             return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT);
70         }
71
72         String JavaDoc vmid = getSelectedVModule(form, request);
73         if(vmid == null || vmid.length() == 0)
74         {
75             LoggingManager.log("Parameter <vmodule> not specified. Element was " + element
76                                + Constants.DEFAULT_SPACER + " Displaying error screen.", this);
77             return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNVMODULE);
78         }
79
80         HttpSession session = request.getSession();
81         User user= checkForUserInSession(session);
82         if(user == null)
83         {
84             LoggingManager.log("Cannot find user in session. Displaying login screen.", this);
85             return mapping.findForward(Constants.SCREEN_LOGIN);
86         }
87
88         VModule vm = null;
89         //jancsi
90
/* if(user.checkAccess(vmid))
91         {
92             vm = cachedVModuleAccess(session, vmid);
93             if(vm == null)
94             {
95                 LoggingManager.log("FAILED to retrieve a valid virtual module from session.", this);
96                 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNVMODULE);
97             }
98         }
99         else
100             LoggingManager.log("Access to virtual module " + vmid + " denied for user " +
101                                user.getIdentification(), this);
102 */

103         if(vm == null)
104             return mapping.findForward(Constants.SCREEN_ERROR_ACCESSDENIED);
105
106         // put the titletag for the selected section/vmodule/element into the request session
107
MessageResources msgRes = MessageResources.getMessageResources(Constants.OWXRESOURCES);
108         if(msgRes != null)
109         {
110             String JavaDoc bid = "base"; // for all virtuals
111
if(vm.isVirtual())
112                 bid = vm.getIdentification();
113             
114             String JavaDoc key = "module" + bid + Constants.VMODULE_SECTION_ELEMENT_PREFIX +
115                          element + ".titletag"; // will cause problems with non standard elements!
116

117             String JavaDoc titleTag = msgRes.getMessage(user.getLocale(),key);
118             if(titleTag != null)
119                 request.setAttribute(Constants.SESSIONKEY_TITLETAG, titleTag);
120         }
121
122         // now pass control to an eventual subclass
123
String JavaDoc fwdTo = dispatchVModuleElement(request, element, form, vm, user);
124         if(fwdTo == null)
125         {
126             LoggingManager.log("Dispatcher wasn't able to dispatch element " + element, this);
127             return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT);
128         }
129
130         return mapping.findForward(vm.getIdentification() + Constants.DEFAULT_SPACER + fwdTo);
131     }
132
133     /**
134      * Override just this method in your virtual module implementations ...
135      */

136     public String JavaDoc dispatchVModuleElement(HttpServletRequest request,
137                                          String JavaDoc element,
138                                          ActionForm form,
139                                          VModule vm,
140                                          User user)
141     {
142         return null;
143     }
144
145 }
146
Popular Tags