KickJava   Java API By Example, From Geeks To Geeks.

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


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 EAUserMgrListAction 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
66         if(element.compareToIgnoreCase(UserMgrConstants.ELEMENT_LISTUSER) == 0)
67         {
68             EAUserMgrListBean listbean=(EAUserMgrListBean)form;
69
70             /**
71              *Checking what kind of action should perform: list or delete
72              */

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

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

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

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

92                if(request.getParameter(UserMgrConstants.HTTPGET_PARAM_USERID)!=null)
93                    userid=request.getParameter(UserMgrConstants.HTTPGET_PARAM_USERID);
94
95                if(userid!=null)
96                {
97                    com.raptus.owxv3.api.usermgr.User u = UserMgrFactory.getInstance().createUserManager(null).getUser(userid);
98                    if(u==null)
99                    {
100                        LoggingManager.log("User "+userid+" not found",this);
101                    }
102                    if(! UserMgrFactory.getInstance().createUserManager(null).removeUser(u,null ))
103                    {
104                        LoggingManager.log("Error removing user!",this);
105                        /**
106                         * the delete was not succesful, probabily usageCount>0
107                         */

108                        ActionErrors errors=new ActionErrors();
109                        errors.add( ActionErrors.GLOBAL_ERROR, new ActionError(UserMgrConstants.VMODULE_LIST_ERROR_INVALIDDELETE) );
110                        saveErrors(request,errors);
111                    }
112                }
113             }//end action==delete
114

115             /**
116              *Checking if the <code>EAFileMgrListBean</code> has a valid list of files,<br>
117              *if not we will provide the list using the <code>loadFiles()</code> of GlobalResources
118              */

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

132         return null;
133     }
134
135 }
136
137 // eof
138
Popular Tags