001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: TopicForm.java,v $
031: * Revision 1.3 2005/04/10 20:31:58 colinmacleod
032: * Added new themes.
033: * Changed id type to String.
034: * Changed i tag to em and b tag to strong.
035: * Improved PicoContainerFactory with NanoContainer scripts.
036: *
037: * Revision 1.2 2005/04/09 17:19:46 colinmacleod
038: * Changed copyright text to GPL v2 explicitly.
039: *
040: * Revision 1.1.1.1 2005/03/10 17:52:01 colinmacleod
041: * Restructured ivata op around Hibernate/PicoContainer.
042: * Renamed ivata groupware.
043: *
044: * Revision 1.7 2004/12/23 21:01:29 colinmacleod
045: * Updated Struts to v1.2.4.
046: * Changed base classes to use ivata masks.
047: *
048: * Revision 1.6 2004/11/12 18:19:15 colinmacleod
049: * Change action and form classes to extend MaskAction, MaskForm respectively.
050: *
051: * Revision 1.5 2004/07/13 19:47:29 colinmacleod
052: * Moved project to POJOs from EJBs.
053: * Applied PicoContainer to services layer (replacing session EJBs).
054: * Applied Hibernate to persistence layer (replacing entity EJBs).
055: *
056: * Revision 1.4 2004/03/21 21:16:29 colinmacleod
057: * Shortened name to ivata op.
058: *
059: * Revision 1.3 2004/02/10 19:57:24 colinmacleod
060: * Changed email address.
061: *
062: * Revision 1.2 2004/02/01 22:07:31 colinmacleod
063: * Added full names to author tags
064: *
065: * Revision 1.1.1.1 2004/01/27 20:58:42 colinmacleod
066: * Moved ivata openportal to SourceForge..
067: *
068: * Revision 1.2 2003/10/15 14:16:53 colin
069: * fixing for XDoclet
070: *
071: * Revision 1.3 2003/08/21 13:29:43 jano
072: * we have new structure of userGroups
073: * and
074: * another frontend for maintan rights for item in topics
075: * Revision 1.2 2003/03/03 16:57:12 colin
076: * converted localization to automatic paths
077: * added labels
078: * added mandatory fieldName attribute
079: *
080: * Revision 1.1 2003/02/24 19:09:24 colin
081: * moved to business
082: *
083: * Revision 1.9 2003/02/04 17:43:50 colin
084: * copyright notice
085: *
086: * Revision 1.8 2003/01/08 10:39:39 jano
087: * we changed interface of libraryBeans, we are using libraryRightBean for amending rights and for finding out
088: * -----------------------------------------------------------------------------
089: */
090: package com.ivata.groupware.business.library.struts;
091:
092: import javax.servlet.http.HttpServletRequest;
093: import javax.servlet.http.HttpSession;
094:
095: import org.apache.struts.action.ActionMapping;
096:
097: import com.ivata.groupware.admin.security.server.SecuritySession;
098: import com.ivata.groupware.business.library.Library;
099: 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: * <p>Contains details of a topic which is being changed, or where the
106: * user (group) rights are being altered..</p>
107: *
108: * @since 2002-11-22
109: * @author Jan Boros <janboros@sourceforge.net>
110: * @version $Revision: 1.3 $
111: */
112: public class TopicForm extends DialogForm {
113: /**
114: * <p>
115: * Defines the base class of all objects in the value object list.
116: * </p>
117: */
118: private Class baseClass;
119:
120: /**
121: * Library - used in validation.
122: */
123: private Library library;
124:
125: /**
126: * <p>
127: * Mask containing all the field definitions for this list.
128: * </p>
129: */
130: private Mask mask;
131: /**
132: * <p>Contains an array of all of the group ids for groups who have
133: * the right to <strong>add</strong> library items to this topic.</p>
134: */
135: private Integer[] rightsAddItem;
136:
137: /**
138: * <p>Contains an array of all of the group ids for groups who have
139: * the right to <strong>amend</strong> this topic.</p>
140: */
141: private Integer[] rightsAmend;
142:
143: /**
144: * <p>Contains an array of all of the group ids for groups who have
145: * the right to <strong>amend</strong> library items which have this topic.</p>
146: */
147: private Integer[] rightsAmendItem;
148:
149: /**
150: * <p>Contains an array of all of the group ids for groups who have
151: * the right to <strong>remove</strong> this topic.</p>
152: */
153: private Integer[] rightsRemove;
154:
155: /**
156: * <p>Contains an array of all of the group ids for groups who have
157: * the right to <strong>remove</strong> library items with this topic.</p>
158: */
159: private Integer[] rightsRemoveItem;
160: /**
161: * <p>Contains an array of all of the group ids for groups who have
162: * the right to <strong>view</strong> this topic.</p>
163: */
164: private Integer[] rightsView;
165:
166: /**
167: * <p>Contains an array of all of the group ids for groups who have
168: * the right to <strong>view</strong> library items with this topic.</p>
169: */
170: private Integer[] rightsViewItem;
171:
172: /**
173: * <p>Contains details of the topic which is currently being modified.</p>
174: */
175: private TopicDO topic;
176:
177: /**
178: * <p>which TAB is active.</p>
179: */
180: private Integer topicTab_activeTab;
181:
182: public TopicForm(final Library libraryParam) {
183: this .library = libraryParam;
184: }
185:
186: /**
187: * TODO
188: *
189: * @see com.ivata.mask.web.struts.MaskForm#clear()
190: */
191: protected void clear() {
192: rightsAddItem = new Integer[] {};
193: rightsAmend = new Integer[] {};
194: rightsAmendItem = new Integer[] {};
195: rightsRemove = new Integer[] {};
196: rightsRemoveItem = new Integer[] {};
197: rightsView = new Integer[] {};
198: rightsViewItem = new Integer[] {};
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 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[] 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[] 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[] 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[] 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[] 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[] 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[] 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 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 request) {
323: // I have to clear arrays because STRUTS is not doing that
324: // meybe we neew to CHAGE tree select tag
325: Integer[] tmpRights = {};
326: int tab = ((this .topicTab_activeTab == null) ? 0
327: : this .topicTab_activeTab.intValue());
328:
329: if ((tab == 1)
330: && (request.getParameterValues("rightsView") == null)) {
331: this .setRightsView(tmpRights);
332: } else if ((tab == 2)
333: && (request.getParameterValues("rightsAmend") == null)) {
334: this .setRightsAmend(tmpRights);
335: } else if ((tab == 3)
336: && (request.getParameterValues("rightsRemove") == null)) {
337: this .setRightsRemove(tmpRights);
338: }
339:
340: // if you didn't click delete butoon so don't show delete message if user want to delete topic
341: if (request.getParameterValues("deleteWarn") == null) {
342: this .setDeleteWarn(null);
343: }
344: }
345:
346: /**
347: * <p>Contains an array of all of the group ids for groups who have
348: * the right to <strong>add</strong> library items to this topic.</p>
349: *
350: * @param rightsAddItem the new value of rightsAddItem.
351: */
352: public final void setRightsAddItem(final Integer[] rightsAddItem) {
353: this .rightsAddItem = rightsAddItem;
354: }
355:
356: /**
357: * <p>Contains an array of all of the group ids for groups who have
358: * the right to <strong>amend</strong> library items which have this topic.</p>
359: *
360: * @param rightsAmend the new value of rightsAmend.
361: */
362: public final void setRightsAmend(final Integer[] rightsAmend) {
363: this .rightsAmend = rightsAmend;
364: }
365:
366: /**
367: * <p>Contains an array of all of the group ids for groups who have
368: * the right to <strong>amend</strong> library items which have this topic.</p>
369: *
370: * @param rightsAmendItem the new value of rightsAmendItem.
371: */
372: public final void setRightsAmendItem(final Integer[] rightsAmendItem) {
373: this .rightsAmendItem = rightsAmendItem;
374: }
375:
376: /**
377: * <p>Contains an array of all of the group ids for groups who have
378: * the right to <strong>remove</strong> library items with this topic.</p>
379: *
380: * @param rightsRemove the new value of groups who can remove from
381: * this topic.
382: */
383: public final void setRightsRemove(final Integer[] rightsRemove) {
384: this .rightsRemove = rightsRemove;
385: }
386:
387: /**
388: * <p>Contains an array of all of the group ids for groups who have
389: * the right to <strong>remove</strong> library items with this topic.</p>
390: *
391: * @param rightsRemoveItem the new value of rightsRemoveItem.
392: */
393: public final void setRightsRemoveItem(
394: final Integer[] rightsRemoveItem) {
395: this .rightsRemoveItem = rightsRemoveItem;
396: }
397:
398: /**
399: * <p>Contains an array of all of the group ids for groups who have
400: * the right to <strong>view</strong> library items with this topic.</p>
401: *
402: * @param rightsView the new value of groups who can view this topic.
403: */
404: public final void setRightsView(final Integer[] rightsView) {
405: this .rightsView = rightsView;
406: }
407:
408: /**
409: * <p>Contains an array of all of the group ids for groups who have
410: * the right to <strong>view</strong> library items with this topic.</p>
411: *
412: * @param rightsViewItem the new value of rightsViewItem.
413: */
414: public final void setRightsViewItem(final Integer[] rightsViewItem) {
415: this .rightsViewItem = rightsViewItem;
416: }
417:
418: /**
419: * <p>Contains details of the topic which is currently being modified.</p>
420: *
421: * @param topic the new value of topic.
422: */
423: public final void setTopic(final TopicDO topic) {
424: this .topic = topic;
425: }
426:
427: /**
428: * <p>which TAB is active.</p>
429: *
430: * @param topicTab_activeTab the new value of topicTab_activeTab.
431: */
432: public final void setTopicTab_activeTab(
433: final Integer topicTab_activeTab) {
434: this .topicTab_activeTab = topicTab_activeTab;
435: }
436:
437: /**
438: * <p>Call the corresponding server-side validation, handle possible
439: * exceptions and return any errors generated.</p>
440: *
441: * @param mapping The mapping used to select this instance
442: * @param request The servlet request we are processing
443: * @return <code>ActionMessages</code> collection containing all
444: * validation errors, or <code>null</code> if there were no errors.
445: * @see com.ivata.mask.web.struts.MaskForm#validate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession)
446: */
447: public ValidationErrors validate(final HttpServletRequest request,
448: final HttpSession session) {
449: SecuritySession securitySession = (SecuritySession) session
450: .getAttribute("securitySession");
451: return library.validate(securitySession, topic);
452: }
453: }
|