KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > usermgr > EAUserMgrListRoleAction


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

5
6 package com.raptus.owxv3.modules.usermgr;
7
8 import java.util.*;
9
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11
12 import org.apache.struts.action.*;
13
14 import com.raptus.owxv3.*;
15 import com.raptus.owxv3.api.VModuleRoleAction;
16 import com.raptus.owxv3.api.usermgr.UserMgrFactory;
17
18
19 /**
20  *
21  * <hr>
22  * <table width="100%" border="0">
23  * <tr>
24  * <td width="24%"><b>Filename</b></td><td width="76%">EAFileMgrListAction.java</td>
25  * </tr>
26  * <tr>
27  * <td width="24%"><b>Author</b></td><td width="76%">REEA</td>
28  * </tr>
29  * <tr>
30  * <td width="24%"><b>Date</b></td><td width="76%">25th of September 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  * <table width="100%" border="0">
41  * <tr>
42  * <td>
43  * This class is called when displaying the "All file list" screen.
44  * </td>
45  * </tr>
46  * </table>
47  * <hr>
48  */

49 //public class EAFileMgrListAction extends VModuleAuthAction
50
public class EAUserMgrListRoleAction extends VModuleRoleAction
51 {
52     /**
53      * Method overwritten from <code>VModuleAuthAction</code>
54      * This Action can be envoked to:
55      * <p>list the files currently uploaded
56      *<p> to delete a file
57      */

58
59     public String JavaDoc dispatchVModuleElement(HttpServletRequest JavaDoc request,
60                                          String JavaDoc element,
61                                          org.apache.struts.action.ActionForm form,
62                                          VModule vm,
63                                          com.raptus.owxv3.api.usermgr.User user)
64     {
65         if(element.compareToIgnoreCase(UserMgrConstants.ELEMENT_LISTROLE) == 0)
66         {
67             EAUserMgrListRoleBean listbean=(EAUserMgrListRoleBean)form;
68
69             /**
70              *Checking what kind of action should perform: list or delete
71              */

72             String JavaDoc action=request.getParameter(UserMgrConstants.HTTPGET_PARAM_ACTION);
73
74             /**
75              *The default action is list
76              */

77             if (action==null) action=UserMgrConstants.VMODULE_ACTION_LIST;
78             
79             /**
80              *Checking parameter filter
81              */

82             if(action.compareToIgnoreCase(UserMgrConstants.VMODULE_ACTION_DELETE)==0)
83             {
84                 /**
85                  *we are at action delete
86                  */

87                 String JavaDoc roleid=null;
88                 /**
89                  *We need the fileid of the file that should be deleted
90                  */

91                if(request.getParameter(UserMgrConstants.HTTPGET_PARAM_ROLEID)!=null)
92                    roleid=request.getParameter(UserMgrConstants.HTTPGET_PARAM_ROLEID);
93
94                if(roleid!=null)
95                {
96                    com.raptus.owxv3.api.usermgr.Role r = UserMgrFactory.getInstance().createUserManager(null).getRole(roleid);
97                    if(r==null)
98                    {
99                        LoggingManager.log("Role "+roleid+" not found!",this);
100                    }
101                    if(! UserMgrFactory.getInstance().createUserManager(null).removeRole(r))
102                    {
103                        LoggingManager.log("Error removing role!",this);
104                        ActionErrors errors=new ActionErrors();
105                        errors.add( ActionErrors.GLOBAL_ERROR, new ActionError(UserMgrConstants.VMODULE_LIST_ERROR_INVALIDDELETE) );
106                        saveErrors(request,errors);
107                    }
108                }
109             }//end action==delete
110

111             /**
112              *Checking if the <code>EAFileMgrListBean</code> has a valid list of files,<br>
113              *if not we will provide the list using the <code>loadFiles()</code> of GlobalResources
114              */

115             LoggingManager.log("Loading list of roles!",this);
116             //since the bean is in request there is no way that the list to be loaded
117
Iterator it = UserMgrFactory.getInstance().createUserManager(null).getAllRoles();
118             Vector v = new Vector();
119             while(it.hasNext())
120             {
121                 v.add(it.next());
122             }
123             listbean.setList(v);
124
125             return Constants.SECTION_EADMIN + Constants.DEFAULT_SPACER + element;
126         }//end bigif
127

128         return null;
129     }
130 }
131
132 // eof
133
Popular Tags