KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > library > struts > TopicAction


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: TopicAction.java,v $
31  * Revision 1.3 2005/04/10 20:31:58 colinmacleod
32  * Added new themes.
33  * Changed id type to String.
34  * Changed i tag to em and b tag to strong.
35  * Improved PicoContainerFactory with NanoContainer scripts.
36  *
37  * Revision 1.2 2005/04/09 17:19:46 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:52:05 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.11 2004/12/31 18:27:44 colinmacleod
45  * Added MaskFactory to constructor of MaskAction.
46  *
47  * Revision 1.10 2004/12/23 21:01:29 colinmacleod
48  * Updated Struts to v1.2.4.
49  * Changed base classes to use ivata masks.
50  *
51  * Revision 1.9 2004/11/12 18:19:15 colinmacleod
52  * Change action and form classes to extend MaskAction, MaskForm respectively.
53  *
54  * Revision 1.8 2004/11/12 15:57:16 colinmacleod
55  * Removed dependencies on SSLEXT.
56  * Moved Persistence classes to ivata masks.
57  *
58  * Revision 1.7 2004/11/03 15:31:51 colinmacleod
59  * Change method interfaces to remove log.
60  *
61  * Revision 1.6 2004/07/29 20:51:04 colinmacleod
62  * Commented out topic rights amendment.
63  *
64  * Revision 1.5 2004/07/13 19:47:29 colinmacleod
65  * Moved project to POJOs from EJBs.
66  * Applied PicoContainer to services layer (replacing session EJBs).
67  * Applied Hibernate to persistence layer (replacing entity EJBs).
68  *
69  * Revision 1.4 2004/03/21 21:16:29 colinmacleod
70  * Shortened name to ivata op.
71  *
72  * Revision 1.3 2004/02/10 19:57:24 colinmacleod
73  * Changed email address.
74  *
75  * Revision 1.2 2004/02/01 22:07:31 colinmacleod
76  * Added full names to author tags
77  *
78  * Revision 1.1.1.1 2004/01/27 20:58:42 colinmacleod
79  * Moved ivata openportal to SourceForge..
80  *
81  * Revision 1.3 2003/10/28 13:16:14 jano
82  * commiting library,
83  * still fixing compile and building openGroupware project
84  *
85  * Revision 1.2 2003/10/15 14:16:53 colin
86  * fixing for XDoclet
87  *
88  * Revision 1.3 2003/08/21 13:29:43 jano
89  * we have new structure of userGroups
90  * and
91  * another frontend for maintan rights for item in topics
92  * Revision 1.2 2003/03/03 16:57:12 colin
93  * converted localization to automatic paths
94  * added labels
95  * added mandatory fieldName attribute
96  *
97  * Revision 1.1 2003/02/24 19:09:24 colin
98  * moved to business
99  * -----------------------------------------------------------------------------
100  */

101 package com.ivata.groupware.business.library.struts;
102
103 import javax.servlet.http.HttpServletRequest JavaDoc;
104 import javax.servlet.http.HttpServletResponse JavaDoc;
105 import javax.servlet.http.HttpSession JavaDoc;
106
107 import org.apache.struts.action.ActionErrors;
108 import org.apache.struts.action.ActionForm;
109 import org.apache.struts.action.ActionMapping;
110
111 import com.ivata.groupware.admin.security.server.SecuritySession;
112 import com.ivata.groupware.business.library.Library;
113 import com.ivata.groupware.business.library.right.LibraryRights;
114 import com.ivata.groupware.business.library.topic.TopicDO;
115 import com.ivata.mask.MaskFactory;
116 import com.ivata.mask.util.SystemException;
117 import com.ivata.mask.web.struts.MaskAction;
118 import com.ivata.mask.web.struts.MaskAuthenticator;
119
120
121 /**
122  * <p><code>Action</code> invoked whenever
123  * <code>/library/topicModify.jsp</code> is submitted.</p>
124  *
125  *
126  * @since 2002-11-22
127  * @author Jan Boros <janboros@sourceforge.net>
128  * @version $Revision: 1.3 $
129  */

130 public class TopicAction extends MaskAction {
131     Library library;
132     LibraryRights libraryRights;
133
134     /**
135      * TODO
136      * @param library
137      * @param libraryRights
138      * @param maskFactory This factory is needed to access the masks and groups
139      * of masks.
140      * @param authenticator used to confirm whether or not the
141      * user should be allowed to continue, in the <code>execute</code> method.
142      */

143     public TopicAction(Library library, LibraryRights libraryRights,
144             MaskFactory maskFactory, MaskAuthenticator authenticator) {
145         super(maskFactory, authenticator);
146         this.library = library;
147         this.libraryRights = libraryRights;
148     }
149     /**
150      * <p>This method is called if the ok or apply buttons are
151      * pressed.</p>
152      *
153      * @param mapping current action mapping from <em>Struts</em> config.
154      * @param log valid logging object to write messages to.
155      * @param errors valid errors object to append errors to. If there are
156      * any errors, the action will return to the input.
157      * @param form optional ActionForm bean for this request (if any)
158      * @param request non-HTTP request we are processing
159      * @param response The non-HTTP response we are creating
160      * @param session returned from the <code>request</code> parameter.
161      * @param userName valid, non-null user name from session.
162      * @param settings valid, non-null settings from session.
163      * @param ok <code>true</code> if the ok button was pressed, otherwise
164      * <code>false</code> if the apply button was pressed.
165      * @exception SystemException if there is any problem which
166      * prevents processing. It will result in the webapp being forwarded
167      * to
168      * the standard error page.
169      * @return this method returns the string used to identify the correct
170      * <em>Struts</em> <code>ActionForward</code> which should follow this
171      * page, or <code>null</code> if it should return to the input.
172      *
173      */

174     public String JavaDoc onConfirm(final ActionMapping mapping,
175             final ActionErrors errors,
176             final ActionForm form,
177             final HttpServletRequest JavaDoc request,
178             final HttpServletResponse JavaDoc response,
179             final HttpSession JavaDoc session,
180             final String JavaDoc defaultForward) throws SystemException {
181         TopicForm topicForm = (TopicForm) form;
182         TopicDO topic = topicForm.getTopic();
183         SecuritySession securitySession = (SecuritySession) session.getAttribute("securitySession");
184
185         // if I have not ID , so it's new TOPIC
186
if (topic.getId() == null) {
187             topic = library.addTopic(securitySession, topic);
188         } else {
189             topic = library.amendTopic(securitySession, topic);
190         }
191
192         // amend RIGHTS for TOPIC
193
/* TODO
194         try {
195             libraryRights.amendViewRightsForTopic(securitySession, topic.getId(),
196                 new java.util.Vector(java.util.Arrays.asList(
197                         topicForm.getRightsView())));
198             libraryRights.amendAmendRightsForTopic(securitySession, topic.getId(),
199                 new java.util.Vector(java.util.Arrays.asList(
200                         topicForm.getRightsAmend())));
201             libraryRights.amendRemoveRightsForTopic(securitySession, topic.getId(),
202                 new java.util.Vector(java.util.Arrays.asList(
203                         topicForm.getRightsRemove())));
204         } catch (SystemException e) {
205             throw new SystemException(e);
206         }
207         */

208         request.setAttribute("openerPage",
209             "/library/topicItems.jsp?topicId=" + topic.getId());
210
211         return defaultForward;
212     }
213
214     /**
215      * <p>This method is called if the delete (confirm, not warn) button
216      * is pressed.</p>
217      * @param mapping current action mapping from <em>Struts</em> config.
218      * @param errors valid errors object to append errors to. If there are
219      * any errors, the action will return to the input.
220      * @param form optional ActionForm bean for this request (if any)
221      * @param request non-HTTP request we are processing
222      * @param response The non-HTTP response we are creating
223      * @param session returned from the <code>request</code> parameter.
224      * @param log valid logging object to write messages to.
225      * @param userName valid, non-null user name from session.
226      * @param settings valid, non-null settings from session.
227      *
228      * @exception SystemException if there is any problem which
229      * prevents processing. It will result in the webapp being forwarded
230      * to
231      * the standard error page.
232      * @return this method returns the string used to identify the correct
233      * <em>Struts</em> <code>ActionForward</code> which should follow this
234      * page, or <code>null</code> if it should return to the input.
235      *
236      */

237     public String JavaDoc onDelete(final ActionMapping mapping,
238             final ActionErrors errors,
239             final ActionForm form,
240             final HttpServletRequest JavaDoc request,
241             final HttpServletResponse JavaDoc response,
242             final HttpSession JavaDoc session, final String JavaDoc defaultForward) throws SystemException {
243         TopicForm topicForm = (TopicForm) form;
244         TopicDO topic = topicForm.getTopic();
245         SecuritySession securitySession = (SecuritySession) session.getAttribute("securitySession");
246
247         library.removeTopic(securitySession, topic);
248         request.setAttribute("openerPage", "/library/topic.jsp");
249
250         return null;
251     }
252
253     /**
254      * <p>Called when the clear button is pressed, or after an ok or
255      * delete button, where the session should be restored to its default
256      * state.</p>
257      *
258      * @param mapping The ActionMapping used to select this instance.
259      * @param log valid logging object to write messages to.
260      * @param errors valid errors object to append errors to. If there are
261      * any errors, the action will return to the input.
262      * @param form optional ActionForm bean for this request (if any)
263      * @param request non-HTTP request we are processing
264      * @param response The non-HTTP response we are creating
265      * @param session returned from the <code>request</code> parameter.
266      * @param userName valid, non-null user name from session.
267      * @param settings valid, non-null settings from session.
268      * @exception SystemException if there is any problem which
269      * prevents processing. It will result in the webapp being forwarded
270      * to
271      * the standard error page.
272      */

273     public void clear(final ActionMapping mapping,
274             final ActionErrors errors,
275             final ActionForm form,
276             final HttpServletRequest JavaDoc request,
277             final HttpServletResponse JavaDoc response,
278             final HttpSession JavaDoc session)
279             throws SystemException {
280         session.removeAttribute("topicTab_activeTab");
281         session.removeAttribute("libraryTopicForm");
282     }
283 }
284
Popular Tags