KickJava   Java API By Example, From Geeks To Geeks.

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


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: TopicForm.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:01 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.7 2004/12/23 21:01:29 colinmacleod
45  * Updated Struts to v1.2.4.
46  * Changed base classes to use ivata masks.
47  *
48  * Revision 1.6 2004/11/12 18:19:15 colinmacleod
49  * Change action and form classes to extend MaskAction, MaskForm respectively.
50  *
51  * Revision 1.5 2004/07/13 19:47:29 colinmacleod
52  * Moved project to POJOs from EJBs.
53  * Applied PicoContainer to services layer (replacing session EJBs).
54  * Applied Hibernate to persistence layer (replacing entity EJBs).
55  *
56  * Revision 1.4 2004/03/21 21:16:29 colinmacleod
57  * Shortened name to ivata op.
58  *
59  * Revision 1.3 2004/02/10 19:57:24 colinmacleod
60  * Changed email address.
61  *
62  * Revision 1.2 2004/02/01 22:07:31 colinmacleod
63  * Added full names to author tags
64  *
65  * Revision 1.1.1.1 2004/01/27 20:58:42 colinmacleod
66  * Moved ivata openportal to SourceForge..
67  *
68  * Revision 1.2 2003/10/15 14:16:53 colin
69  * fixing for XDoclet
70  *
71  * Revision 1.3 2003/08/21 13:29:43 jano
72  * we have new structure of userGroups
73  * and
74  * another frontend for maintan rights for item in topics
75  * Revision 1.2 2003/03/03 16:57:12 colin
76  * converted localization to automatic paths
77  * added labels
78  * added mandatory fieldName attribute
79  *
80  * Revision 1.1 2003/02/24 19:09:24 colin
81  * moved to business
82  *
83  * Revision 1.9 2003/02/04 17:43:50 colin
84  * copyright notice
85  *
86  * Revision 1.8 2003/01/08 10:39:39 jano
87  * we changed interface of libraryBeans, we are using libraryRightBean for amending rights and for finding out
88  * -----------------------------------------------------------------------------
89  */

90 package com.ivata.groupware.business.library.struts;
91
92 import javax.servlet.http.HttpServletRequest JavaDoc;
93 import javax.servlet.http.HttpSession JavaDoc;
94
95 import org.apache.struts.action.ActionMapping;
96
97 import com.ivata.groupware.admin.security.server.SecuritySession;
98 import com.ivata.groupware.business.library.Library;
99 import com.ivata.groupware.business.library.topic.TopicDO;
100 import com.ivata.mask.Mask;
101 import com.ivata.mask.validation.ValidationErrors;
102 import com.ivata.mask.web.struts.DialogForm;
103
104
105 /**
106  * <p>Contains details of a topic which is being changed, or where the
107  * user (group) rights are being altered..</p>
108  *
109  * @since 2002-11-22
110  * @author Jan Boros <janboros@sourceforge.net>
111  * @version $Revision: 1.3 $
112  */

113 public class TopicForm extends DialogForm {
114     /**
115      * <p>
116      * Defines the base class of all objects in the value object list.
117      * </p>
118      */

119     private Class JavaDoc baseClass;
120
121     /**
122      * Library - used in validation.
123      */

124     private Library library;
125
126     /**
127      * <p>
128      * Mask containing all the field definitions for this list.
129      * </p>
130      */

131     private Mask mask;
132     /**
133      * <p>Contains an array of all of the group ids for groups who have
134      * the right to <strong>add</strong> library items to this topic.</p>
135      */

136     private Integer JavaDoc[] rightsAddItem;
137
138     /**
139      * <p>Contains an array of all of the group ids for groups who have
140      * the right to <strong>amend</strong> this topic.</p>
141      */

142     private Integer JavaDoc[] rightsAmend;
143
144     /**
145      * <p>Contains an array of all of the group ids for groups who have
146      * the right to <strong>amend</strong> library items which have this topic.</p>
147      */

148     private Integer JavaDoc[] rightsAmendItem;
149
150     /**
151      * <p>Contains an array of all of the group ids for groups who have
152      * the right to <strong>remove</strong> this topic.</p>
153      */

154     private Integer JavaDoc[] rightsRemove;
155
156     /**
157      * <p>Contains an array of all of the group ids for groups who have
158      * the right to <strong>remove</strong> library items with this topic.</p>
159      */

160     private Integer JavaDoc[] rightsRemoveItem;
161     /**
162      * <p>Contains an array of all of the group ids for groups who have
163      * the right to <strong>view</strong> this topic.</p>
164      */

165     private Integer JavaDoc[] rightsView;
166
167     /**
168      * <p>Contains an array of all of the group ids for groups who have
169      * the right to <strong>view</strong> library items with this topic.</p>
170      */

171     private Integer JavaDoc[] rightsViewItem;
172
173     /**
174      * <p>Contains details of the topic which is currently being modified.</p>
175      */

176     private TopicDO topic;
177
178     /**
179      * <p>which TAB is active.</p>
180      */

181     private Integer JavaDoc topicTab_activeTab;
182
183     public TopicForm(final Library libraryParam) {
184         this.library = libraryParam;
185     }
186     /**
187      * TODO
188      *
189      * @see com.ivata.mask.web.struts.MaskForm#clear()
190      */

191     protected void clear() {
192         rightsAddItem = new Integer JavaDoc[] { };
193         rightsAmend = new Integer JavaDoc[] { };
194         rightsAmendItem = new Integer JavaDoc[] { };
195         rightsRemove = new Integer JavaDoc[] { };
196         rightsRemoveItem = new Integer JavaDoc[] { };
197         rightsView = new Integer JavaDoc[] { };
198         rightsViewItem = new Integer JavaDoc[] { };
199         topic = new TopicDO();
200         topicTab_activeTab = null;
201     }
202
203     /**
204      * <p>
205      * Defines the base class of all objects in the value object list.
206      * </p>
207      *
208      * @return base class of all objects in the value object list.
209      */

210     public final Class JavaDoc getBaseClass() {
211         return baseClass;
212     }
213
214     /**
215      * <p>
216      * Mask containing all the field definitions for this list.
217      * </p>
218      *
219      * @return mask containing all the field definitions for this list.
220      */

221     public final Mask getMask() {
222         return mask;
223     }
224
225     /**
226      * <p>Contains an array of all of the group ids for groups who have
227      * the right to <strong>add</strong> library items to this topic.</p>
228      *
229      * @return the current value of rightsAddItem.
230      */

231     public final Integer JavaDoc[] getRightsAddItem() {
232         return this.rightsAddItem;
233     }
234
235     /**
236      * <p>Contains an array of all of the group ids for groups who have
237      * the right to <strong>amend</strong> library items which have this topic.</p>
238      *
239      * @return the current value of rightsAmend.
240      */

241     public final Integer JavaDoc[] getRightsAmend() {
242         return this.rightsAmend;
243     }
244
245     /**
246      * <p>Contains an array of all of the group ids for groups who have
247      * the right to <strong>amend</strong> library items which have this topic.</p>
248      *
249      * @return the current value of rightsAmendItem.
250      */

251     public final Integer JavaDoc[] getRightsAmendItem() {
252         return this.rightsAmendItem;
253     }
254
255     /**
256      * <p>Contains an array of all of the group ids for groups who have
257      * the right to <strong>remove</strong> library items with this topic.</p>
258      *
259      * @return the current value of groups who can remove from this topic.
260      */

261     public final Integer JavaDoc[] getRightsRemove() {
262         return this.rightsRemove;
263     }
264
265     /**
266      * <p>Contains an array of all of the group ids for groups who have
267      * the right to <strong>remove</strong> library items with this topic.</p>
268      *
269      * @return the current value of rightsRemoveItem.
270      */

271     public final Integer JavaDoc[] getRightsRemoveItem() {
272         return this.rightsRemoveItem;
273     }
274
275     /**
276      * <p>Contains an array of all of the group ids for groups who have
277      * the right to <strong>view</strong> library items with this topic.</p>
278      *
279      * @return the current value of groups who can view this topic.
280      */

281     public final Integer JavaDoc[] getRightsView() {
282         return rightsView;
283     }
284
285     /**
286      * <p>Contains an array of all of the group ids for groups who have
287      * the right to <strong>view</strong> library items with this topic.</p>
288      *
289      * @return the current value of rightsViewItem.
290      */

291     public final Integer JavaDoc[] getRightsViewItem() {
292         return this.rightsViewItem;
293     }
294
295     /**
296      * <p>Contains details of the topic which is currently being modified.</p>
297      *
298      * @return the current value of topic.
299      */

300     public final TopicDO getTopic() {
301         return topic;
302     }
303
304     /**
305      * <p>which TAB is active.</p>
306      *
307      * @return the current value of topicTab_activeTab.
308      */

309     public final Integer JavaDoc getTopicTab_activeTab() {
310         return this.topicTab_activeTab;
311     }
312
313     /**
314      * <p>Reset all bean properties to their default state. This method
315      * is called before the properties are repopulated by the controller
316      * servlet.<p>
317      *
318      * @param mapping The mapping used to select this instance
319      * @param request The servlet request we are processing
320      */

321     public void reset(final ActionMapping mapping,
322             final HttpServletRequest JavaDoc request) {
323         // I have to clear arrays because STRUTS is not doing that
324
// meybe we neew to CHAGE tree select tag
325
Integer JavaDoc[] tmpRights = { };
326         int tab = ((this.topicTab_activeTab == null) ? 0
327                                                      : this.topicTab_activeTab.intValue());
328
329         if ((tab == 1) && (request.getParameterValues("rightsView") == null)) {
330             this.setRightsView(tmpRights);
331         } else if ((tab == 2) &&
332                 (request.getParameterValues("rightsAmend") == null)) {
333             this.setRightsAmend(tmpRights);
334         } else if ((tab == 3) &&
335                 (request.getParameterValues("rightsRemove") == null)) {
336             this.setRightsRemove(tmpRights);
337         }
338
339         // if you didn't click delete butoon so don't show delete message if user want to delete topic
340
if (request.getParameterValues("deleteWarn") == null) {
341             this.setDeleteWarn(null);
342         }
343     }
344
345     /**
346      * <p>Contains an array of all of the group ids for groups who have
347      * the right to <strong>add</strong> library items to this topic.</p>
348      *
349      * @param rightsAddItem the new value of rightsAddItem.
350      */

351     public final void setRightsAddItem(final Integer JavaDoc[] rightsAddItem) {
352         this.rightsAddItem = rightsAddItem;
353     }
354
355     /**
356      * <p>Contains an array of all of the group ids for groups who have
357      * the right to <strong>amend</strong> library items which have this topic.</p>
358      *
359      * @param rightsAmend the new value of rightsAmend.
360      */

361     public final void setRightsAmend(final Integer JavaDoc[] rightsAmend) {
362         this.rightsAmend = rightsAmend;
363     }
364
365     /**
366      * <p>Contains an array of all of the group ids for groups who have
367      * the right to <strong>amend</strong> library items which have this topic.</p>
368      *
369      * @param rightsAmendItem the new value of rightsAmendItem.
370      */

371     public final void setRightsAmendItem(final Integer JavaDoc[] rightsAmendItem) {
372         this.rightsAmendItem = rightsAmendItem;
373     }
374
375     /**
376      * <p>Contains an array of all of the group ids for groups who have
377      * the right to <strong>remove</strong> library items with this topic.</p>
378      *
379      * @param rightsRemove the new value of groups who can remove from
380      * this topic.
381      */

382     public final void setRightsRemove(final Integer JavaDoc[] rightsRemove) {
383         this.rightsRemove = rightsRemove;
384     }
385
386     /**
387      * <p>Contains an array of all of the group ids for groups who have
388      * the right to <strong>remove</strong> library items with this topic.</p>
389      *
390      * @param rightsRemoveItem the new value of rightsRemoveItem.
391      */

392     public final void setRightsRemoveItem(final Integer JavaDoc[] rightsRemoveItem) {
393         this.rightsRemoveItem = rightsRemoveItem;
394     }
395
396     /**
397      * <p>Contains an array of all of the group ids for groups who have
398      * the right to <strong>view</strong> library items with this topic.</p>
399      *
400      * @param rightsView the new value of groups who can view this topic.
401      */

402     public final void setRightsView(final Integer JavaDoc[] rightsView) {
403         this.rightsView = rightsView;
404     }
405
406     /**
407      * <p>Contains an array of all of the group ids for groups who have
408      * the right to <strong>view</strong> library items with this topic.</p>
409      *
410      * @param rightsViewItem the new value of rightsViewItem.
411      */

412     public final void setRightsViewItem(final Integer JavaDoc[] rightsViewItem) {
413         this.rightsViewItem = rightsViewItem;
414     }
415
416     /**
417      * <p>Contains details of the topic which is currently being modified.</p>
418      *
419      * @param topic the new value of topic.
420      */

421     public final void setTopic(final TopicDO topic) {
422         this.topic = topic;
423     }
424
425     /**
426      * <p>which TAB is active.</p>
427      *
428      * @param topicTab_activeTab the new value of topicTab_activeTab.
429      */

430     public final void setTopicTab_activeTab(final Integer JavaDoc topicTab_activeTab) {
431         this.topicTab_activeTab = topicTab_activeTab;
432     }
433
434     /**
435      * <p>Call the corresponding server-side validation, handle possible
436      * exceptions and return any errors generated.</p>
437      *
438      * @param mapping The mapping used to select this instance
439      * @param request The servlet request we are processing
440      * @return <code>ActionMessages</code> collection containing all
441      * validation errors, or <code>null</code> if there were no errors.
442      * @see com.ivata.mask.web.struts.MaskForm#validate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession)
443      */

444     public ValidationErrors validate(final HttpServletRequest JavaDoc request,
445             final HttpSession JavaDoc session) {
446         SecuritySession securitySession = (SecuritySession)
447             session.getAttribute("securitySession");
448         return library.validate(securitySession, topic);
449     }
450 }
451
Popular Tags