KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > filemgr > EAFileMgrChangeAction


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

5
6 package com.raptus.owxv3.modules.filemgr;
7
8 import java.sql.SQLException JavaDoc;
9
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11
12 import org.apache.struts.action.ActionErrors;
13
14 import com.raptus.owxv3.*;
15 import com.raptus.owxv3.api.*;
16
17
18
19
20 /**
21  *
22  * <hr>
23  * <table width="100%" border="0">
24  * <tr>
25  * <td width="24%"><b>Filename</b></td><td width="76%">EAFileMgrChangeAction.java</td>
26  * </tr>
27  * <tr>
28  * <td width="24%"><b>Author</b></td><td width="76%">REEA</td>
29  * </tr>
30  * <tr>
31  * <td width="24%"><b>Date</b></td><td width="76%">25th of Septemeber 2001</td>
32  * </tr>
33  * </table>
34  * <hr>
35  * <table width="100%" border="0">
36  * <tr>
37  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
38  * </tr>
39  * </table>
40  * <hr>
41  * <table width="100%" border="0">
42  * <tr>
43  * <td>This class is called when displaying the 'Change file category' screen<br>
44  * or it is called from the 'All file list' for a single file.<br>
45  * This action can change the category of a file.</td>
46  * </tr>
47  * </table>
48  * <hr>
49  */

50 //public class EAFileMgrChangeAction extends VModuleAuthAction
51
public class EAFileMgrChangeAction extends VModuleRoleAction
52 {
53     /**
54      * Method overwritten from <code>VModuleAuthAction</code>
55      * This Action can be envoked to:
56      * <p>To change the category of a certain file
57      */

58     public String JavaDoc dispatchVModuleElement(HttpServletRequest JavaDoc request,
59                                          String JavaDoc element,
60                                          org.apache.struts.action.ActionForm form,
61                                          VModule vm,
62                                          com.raptus.owxv3.api.usermgr.User user)
63     {
64         if(element.compareToIgnoreCase(FileMgrConstants.ELEMENT_CHANGE) == 0)
65         {
66             EAFileMgrChangeBean changebean=(EAFileMgrChangeBean)form;
67             ActionErrors acterrors=changebean.validate(request);
68
69
70             if(acterrors!=null)
71                 if(acterrors.size()>0)
72                 {
73                     saveErrors(request,acterrors);
74                     return Constants.SECTION_EADMIN + Constants.DEFAULT_SPACER + element;
75                 }
76
77             /**
78              *Checking what kind of action should perform
79              */

80
81             String JavaDoc action="";
82             if(request.getParameter(FileMgrConstants.HTTPGET_PARAM_ACTION)!=null){
83                 action=request.getParameter(FileMgrConstants.HTTPGET_PARAM_ACTION);
84             }
85
86             if(action.compareToIgnoreCase(FileMgrConstants.VMODULE_ACTION_SAVE)==0)
87             {
88                 /**
89                  *saving file with changed category using the GlobalResources <br>
90                  *<code>saveFileCategory</code> method
91                  */

92
93                 GlobalResources gres=new GlobalResources();
94                 String JavaDoc cname=changebean.getCategoryName();
95                 try{
96                     gres.saveFileCategory( changebean.getFilelist(),cname );
97                     changebean.incChangedFileCount();
98                 }
99                 catch(SQLException JavaDoc e)
100                 {
101                     LoggingManager.log("Error saving changed category for a file"+e, this);
102                 }
103
104                 changebean.reset();
105
106             }
107
108             else if(request.getParameter(FileMgrConstants.HTTPGET_PARAM_FILEID)!=null)
109             {
110                 /**
111                  *we we called from the "all file list" element
112                  *setting the filelist to the selected fileid the rest of values to default
113                  */

114
115                 int filelist=Integer.parseInt( request.getParameter(FileMgrConstants.HTTPGET_PARAM_FILEID) );
116
117                 changebean.setFilelist(filelist);
118                 changebean.setCategorytype(FileMgrConstants.EXISTING_CATEGORY);
119                 changebean.setCatname("");
120                 changebean.setNewcatname("");
121
122             }
123
124             /**
125              *In the coresponding form-bean of our Action we should set a <code>FileSelector</code> object
126              *that be used will return the category list
127              */

128
129
130             try{
131                GlobalResources gres=new GlobalResources();
132                AllFileSelector fileselector=new AllFileSelector(gres);
133                changebean.setFileSelector(fileselector);
134
135             }catch(SQLException JavaDoc e){LoggingManager.log("Error while instantiating the FileSelector object", this);}
136
137             return Constants.SECTION_EADMIN + Constants.DEFAULT_SPACER + element;
138         }//end bigif
139
return null;
140     }
141
142 }
143
144 // eof
145
Popular Tags