KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.raptus.owxv3.*;
13 import com.raptus.owxv3.api.*;
14
15
16 /**
17  *
18  * <hr>
19  * <table width="100%" border="0">
20  * <tr>
21  * <td width="24%"><b>Filename</b></td><td width="76%">EAFileMgrAssignedAction.java</td>
22  * </tr>
23  * <tr>
24  * <td width="24%"><b>Author</b></td><td width="76%">REEA</td>
25  * </tr>
26  * <tr>
27  * <td width="24%"><b>Date</b></td><td width="76%">25th of September 2001</td>
28  * </tr>
29  * </table>
30  * <hr>
31  * <table width="100%" border="0">
32  * <tr>
33  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
34  * </tr>
35  * </table>
36  * <hr>
37  *<table width="100%" border="0">
38  * <tr>
39  * <td> This class is called when displaying the 'Assigned file list' screen</td>
40  * </tr>
41  * </table>
42  * <hr>
43  */

44 //public class EAFileMgrAssignedAction extends VModuleAuthAction
45
public class EAFileMgrAssignedAction extends VModuleRoleAction
46 {
47     /**
48      * Method overwritten from <code>VModuleAuthAction</code>
49      * This Action can be envoked to:
50      * <p>list the file assigments between vmodules
51      *<p> to unlink a file assigment
52      */

53     public String JavaDoc dispatchVModuleElement(HttpServletRequest JavaDoc request,
54                                          String JavaDoc element,
55                                          org.apache.struts.action.ActionForm form,
56                                          VModule vm,
57                                          com.raptus.owxv3.api.usermgr.User user)
58     {
59
60         if(element.compareToIgnoreCase(FileMgrConstants.ELEMENT_ASSIGNED) == 0)
61         {
62
63             EAFileMgrAssignedBean assignedbean=(EAFileMgrAssignedBean)form;
64
65             /**
66              *Checking what kind of action should perform: list or unlink
67              */

68             String JavaDoc action=request.getParameter(FileMgrConstants.HTTPGET_PARAM_ACTION);
69
70             /**
71              *the default action is list
72              */

73             if (action==null) action=FileMgrConstants.VMODULE_ACTION_LIST;
74             
75             /**
76              *Checking parameter filter
77              */

78             String JavaDoc filter=assignedbean.getFilter();
79             if(filter==null) filter="";
80
81             if(action.compareToIgnoreCase(FileMgrConstants.VMODULE_ACTION_UNLINK)==0){
82
83                 /**
84                  *we are at action unlink
85                  */

86                 int linkid=0;
87                 /*
88                  *we need the linkid of the file assigment that we want to delete (unlink)
89                  */

90                 try
91                 {
92                    if(request.getParameter(FileMgrConstants.HTTPGET_PARAM_LINKID)!=null)
93                        linkid=Integer.parseInt( request.getParameter(FileMgrConstants.HTTPGET_PARAM_LINKID) );
94
95                    if(linkid!=0){
96                        /**
97                         *WE will create a <code>FileMgrUnlinkObject</code> that will <br>
98                         *delete (unlink) the file assigment using the <code>GlobalResources</code>
99                         *class.
100                         */

101
102                        GlobalResources gres=new GlobalResources();
103                        FileMgrUnlinkObject unlinkobj=new FileMgrUnlinkObject(gres);
104                        unlinkobj.unLink(linkid);
105
106                        /*
107                         *we have unlinked a file we should reload the list
108                         */

109                        assignedbean.setList(gres.loadFileLinks(filter));
110                    }
111                 }catch(NumberFormatException JavaDoc nfe)
112                 {
113                     LoggingManager.log("Wrong number supplied as linkid for deleting:"+nfe.getMessage(), this);
114                 }catch(SQLException JavaDoc sqle){
115                     LoggingManager.log("Could not delete flink from database"+sqle.getMessage(), this);
116                 }
117
118             }//end action==unlink
119

120             /**
121              *Checking if the <code>EAFileMgrAssignedBean</code> has a valid list of file assigments,<br>
122              *if not we will provide the list using the <code>loadFileLinks()</code> method of GlobalResources
123              */

124             
125             //since the bean in in request there is no way that the list to be loaded already
126

127             //if ( ! assignedbean.isListLoaded() ){
128
try{
129                    GlobalResources gres=new GlobalResources();
130                    assignedbean.setList(gres.loadFileLinks(filter));
131
132                 }catch(SQLException JavaDoc e){LoggingManager.log("Error while calling loadFiles() from GlobalResources"+e.getMessage(), this);}
133             //}//end if
134

135             return Constants.SECTION_EADMIN + Constants.DEFAULT_SPACER + element;
136         }//end bigif
137

138
139         /**
140          *returning null beacuse the Action was invoked with invalid element name
141          */

142         return null;
143     }
144
145 }
146
147 // eof
148
Popular Tags