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: ItemForm.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.6 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.5 2004/11/12 18:19:15 colinmacleod
049: * Change action and form classes to extend MaskAction, MaskForm respectively.
050: *
051: * Revision 1.4 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.3 2004/03/21 21:16:29 colinmacleod
057: * Shortened name to ivata op.
058: *
059: * Revision 1.2 2004/02/01 22:07:31 colinmacleod
060: * Added full names to author tags
061: *
062: * Revision 1.1.1.1 2004/01/27 20:58:41 colinmacleod
063: * Moved ivata openportal to SourceForge..
064: *
065: * Revision 1.3 2003/11/13 16:11:08 jano
066: * commitng everything to CVS
067: * can deploy and application is ruuning, can login into
068: *
069: * Revision 1.2 2003/10/15 14:16:53 colin
070: * fixing for XDoclet
071: *
072: * Revision 1.11 2003/07/11 15:08:12 peter
073: * version control comment added
074: * Revision 1.10 2003/06/20 13:22:15 jano
075: * we want deleteFile button in list of attached files
076: *
077: * Revision 1.9 2003/05/20 08:29:40 jano
078: * maintaing attaching files to libray item
079: *
080: * Revision 1.8 2003/05/13 15:41:00 jano
081: * new methods in DriveBean
082: *
083: * Revision 1.7 2003/05/07 14:01:59 jano
084: * we want findFilesByPath
085: *
086: * Revision 1.6 2003/03/21 15:40:36 peter
087: * fixed delete - super.reset was not called
088: *
089: * Revision 1.5 2003/03/12 14:14:48 jano
090: * renaming newHeading -> newPoint
091: * fixing problem arround that
092: *
093: * Revision 1.4 2003/03/03 20:55:19 colin
094: * skipped validation if clear button pressed
095: *
096: * Revision 1.3 2003/02/28 09:37:13 jano
097: * RuntimeException(e) -> IntrnetRuntimeException
098: *
099: * Revision 1.2 2003/02/28 07:30:22 colin
100: * implemented editing/displaying of faqs & notes
101: *
102: * Revision 1.1 2003/02/24 19:09:24 colin
103: * moved to business
104: * -----------------------------------------------------------------------------
105: */
106: package com.ivata.groupware.business.library.struts;
107:
108: import java.util.HashMap;
109: import java.util.List;
110: import java.util.Map;
111: import java.util.Set;
112: import java.util.Vector;
113:
114: import javax.servlet.http.HttpServletRequest;
115: import javax.servlet.http.HttpSession;
116:
117: import org.apache.struts.action.ActionMapping;
118:
119: import com.ivata.groupware.admin.security.server.SecuritySession;
120: import com.ivata.groupware.business.library.Library;
121: import com.ivata.groupware.business.library.item.LibraryItemDO;
122: import com.ivata.mask.Mask;
123: import com.ivata.mask.MaskFactory;
124: import com.ivata.mask.util.StringHandling;
125: import com.ivata.mask.validation.ValidationError;
126: import com.ivata.mask.validation.ValidationErrors;
127:
128: /**
129: * <p>This form is used both to display and to submit a library
130: * item</p>
131: *
132: * @since 2003-02-19
133: * @author Colin MacLeod
134: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
135: * @version $Revision: 1.3 $
136: */
137: public class ItemForm extends LibraryForm {
138: /**
139: * <p>Version control comment</p>
140: */
141: private String comment;
142:
143: /**
144: * <p>Button for deleting attached files to item.</p>
145: */
146: private String deleteFileButton;
147:
148: /**
149: * <p>Page to include with extra fields for this document type, on
150: * display.</p>
151: */
152: private String displayIncludePage;
153: /**
154: * <p>If in display mode, indicates the page number to currently
155: * show.</p>
156: */
157: private int displayPage;
158:
159: /**
160: * <p>Defines list of DriveFileDO with are attached with this
161: * item (if any).</p>
162: */
163: private List fileList = new Vector();
164:
165: /**
166: * <p>Contains all of the information about the current library
167: * item</p>
168: */
169: private LibraryItemDO item;
170:
171: private Library library;
172:
173: /**
174: * <p>Defines the page to link to. This varies depending on
175: * whether the item is being submitted or displayed.</p>
176: */
177: private String linkPage;
178:
179: /**
180: * <p>If non-<code>null</code>, indicates a new page should be
181: * addes for DOCUMENT, new heading for MEETING, new FAQ category for
182: * FAQs.</p>
183: */
184: private String newPage;
185:
186: /**
187: * <p>TRICK
188: *
189: * storing index of button which was click in submiting page of
190: * Meeting or Faq.
191: * index is store in first field of array.
192: *
193: * for MEETING it's creating new AgendaPoin in heading with that
194: * index.
195: * for FAQ it's creating new Question in faq category with that
196: * index.</p>
197: */
198: private String[] newPoint;
199:
200: /**
201: * <p>Link to link the next page to, or the empty string if there is
202: * no next
203: * page.</p>
204: */
205: private String nextPageLink;
206:
207: /**
208: * <p>Contains the links with appear to the top right of displayed
209: * items.</p>
210: */
211: private String pageLinks;
212:
213: /**
214: * <p>Link to link the previous page to, or the empty string if there
215: * is no
216: * previous page.</p>
217: */
218: private String previousPageLink;
219:
220: /**
221: * <p>All Ids of selected files by user from list of attached files.
222: * We need maped propertties.</p>
223: */
224: private Map selectedAttachedFilesIds;
225:
226: /**
227: * <p>All Ids of selected files by user from list of new files.</p>
228: */
229: private String[] selectedNewFilesIds;
230:
231: /**
232: * <p>Page to include with extra fields for this document type, on
233: * submission</p>
234: */
235: private String submitIncludePage;
236:
237: /**
238: * <p>Key to the localized text for the summary field (submit
239: * mode).</p>
240: */
241: private String summaryPromptKey;
242:
243: /**
244: * <p>Specifies the theme name for the document summary section.</p>
245: */
246: private String summaryThemeName;
247:
248: /**
249: * <p>Key to the localized text for the summary window (submit
250: * mode).</p>
251: */
252: private String summaryTitleKey;
253:
254: /**
255: * <p>Specifies the theme name for the body of the document.</p>
256: */
257: private String themeName;
258:
259: /**
260: * <p>In submit mode, stores all of the captions of the topics we are
261: * allowed to see.</p>
262: */
263: private Map topicCaptions;
264:
265: /**
266: * <p>In submit mode, stores all of the unique identifiers of the
267: * topics we are allowed to see.</p>
268: */
269: private Set topicIds;
270:
271: /**
272: * <p>In submit mode, stores all of the image filenames of the topics
273: * we are allowed to see.</p>
274: */
275: private Map topicImages;
276:
277: /**
278: * <p>Defines list of FileDO with are goint to attch with this
279: * item.</p>
280: */
281: private List uploadingFileList;
282: private Mask mask;
283:
284: /**
285: *
286: * @param library
287: * @param maskParam
288: * Refer to {@link #getMask}.
289: * @param baseClassParam
290: * Refer to {@link #getBaseClass}.
291: */
292: public ItemForm(final Library library, final MaskFactory maskFactory) {
293: this .library = library;
294: mask = maskFactory.getMask(LibraryItemDO.class);
295: }
296:
297: /**
298: * TODO
299: *
300: * @see com.ivata.mask.web.struts.MaskForm#clear()
301: */
302: protected void clear() {
303: comment = null;
304: deleteFileButton = null;
305: displayIncludePage = null;
306: displayPage = -1;
307: // TODO
308: fileList = new Vector();
309: item = null;
310: linkPage = null;
311: newPage = null;
312: newPoint = new String[] {};
313: nextPageLink = "";
314: pageLinks = "";
315: previousPageLink = "";
316: selectedAttachedFilesIds = null;
317: selectedNewFilesIds = null;
318: submitIncludePage = null;
319: summaryPromptKey = null;
320: summaryThemeName = null;
321: summaryTitleKey = null;
322: themeName = null;
323: topicCaptions = null;
324: topicIds = null;
325: topicImages = null;
326: uploadingFileList = null;
327: }
328:
329: /**
330: <p>Version control comment</p>
331: @return the comment
332:
333: */
334: public final String getComment() {
335: return comment;
336: }
337:
338: /**
339: * <p>Button for deleting attached files to item.</p>
340: *
341: * @return the current value of deleteFileButton.
342: */
343: public final String getDeleteFileButton() {
344: return this .deleteFileButton;
345: }
346:
347: /**
348: * <p>Page to include with extra fields for this document type, on
349: * display.</p>
350: *
351: * @return the current value of displayIncludePage.
352: */
353: public final String getDisplayIncludePage() {
354: return displayIncludePage;
355: }
356:
357: /**
358: * <p>If in display mode, indicates the page number to currently
359: * show.</p>
360: *
361: * @return the current value of displayPage.
362: */
363: public final int getDisplayPage() {
364: return displayPage;
365: }
366:
367: /**
368: * <p>Defines list of files DO's with are attched with this
369: * item.</p>
370: *
371: * @return the current value of fileList.
372: */
373: public List getFileList() {
374: return this .fileList;
375: }
376:
377: /**
378: * <p>Contains all of the information about the current library
379: * item</p>
380: *
381: * @return the current value of item.
382: */
383: public final LibraryItemDO getItem() {
384: return item;
385: }
386:
387: /**
388: * <p>Defines the page to link to. This varies depending on
389: * whether the item is being submitted or displayed.</p>
390: *
391: * @return the current value of linkPage.
392: */
393: public final String getLinkPage() {
394: return linkPage;
395: }
396:
397: /**
398: * <p>If non-<code>null</code>, indicates a new page should be
399: * addes.</p>
400: *
401: * @return the current value of newPage.
402: */
403: public final String getNewPage() {
404: return newPage;
405: }
406:
407: /**
408: * <p> TRICK
409: * storing index of button which was click in submiting page of
410: * Meeting or Faq.
411: * return first field of array, ther is a index of click button.
412: *
413: * for MEETING it's creating new AgendaPoin in heading with that
414: * index.
415: * for FAQ it's creating new Question in faq category with that
416: * index.</p>
417: *
418: * @return the current index of newPoint
419: */
420: public final String getNewPoint(final int index) {
421: // it's should return value of field from arrray with that index
422: // look to setter
423: return this .newPoint[0];
424: }
425:
426: /**
427: * <p>Link to link the next page to, or the empty string if there is
428: * no next
429: * page.</p>
430: *
431: * @return the current value of nextPageLink.
432: */
433: public final String getNextPageLink() {
434: return nextPageLink;
435: }
436:
437: /**
438: * <p>Contains the links with appear to the top right of displayed
439: * items.</p>
440: *
441: * @return the current value of pageLinks.
442: */
443: public final String getPageLinks() {
444: return pageLinks;
445: }
446:
447: /**
448: * <p>Link to link the previous page to, or the empty string if there
449: * is no
450: * previous page.</p>
451: *
452: * @return the current value of previoustPageLink.
453: */
454: public final String getPreviousPageLink() {
455: return previousPageLink;
456: }
457:
458: /**
459: * <p>Geting selected file ID from maped properties.</p>
460: *
461: * @param key - which checkBox is selected
462: */
463: public final Object getSelectedAttachedFilesIds(final String key) {
464: return this .selectedAttachedFilesIds.get(key);
465: }
466:
467: /**
468: * <p>All Ids of selected files by user from list of new files.</p>
469: *
470: * @return the current value of selectedNewFilesIds.
471: */
472: public final String[] getSelectedNewFilesIds() {
473: return this .selectedNewFilesIds;
474: }
475:
476: /**
477: * <p>Page to include with extra fields for this document type, on
478: * submission</p>
479: *
480: * @return the current value of submitIncludePage.
481: */
482: public final String getSubmitIncludePage() {
483: return submitIncludePage;
484: }
485:
486: /**
487: * <p>Key to the localized text for the summary field (submit
488: * mode).</p>
489: *
490: * @return the current value of summaryPromptKey.
491: */
492: public final String getSummaryPromptKey() {
493: return summaryPromptKey;
494: }
495:
496: /**
497: * <p>Specifies the theme name for the document summary section.</p>
498: *
499: * @return the current value of summaryThemeName.
500: */
501: public final String getSummaryThemeName() {
502: return summaryThemeName;
503: }
504:
505: /**
506: * <p>Key to the localized text for the summary window (submit
507: * mode).</p>
508: *
509: * @return the current value of summaryTitleKey.
510: */
511: public final String getSummaryTitleKey() {
512: return summaryTitleKey;
513: }
514:
515: /**
516: * <p>Specifies the theme name for the body of the document.</p>
517: *
518: * @return the current value of themeName.
519: */
520: public final String getThemeName() {
521: return themeName;
522: }
523:
524: /**
525: * <p>In submit mode, stores all of the captions of the topics we are
526: * allowed to see.</p>
527: *
528: * @return the current value of topicCaptions.
529: */
530: public final Map getTopicCaptions() {
531: return topicCaptions;
532: }
533:
534: /**
535: * <p>In submit mode, stores all of the unique identifiers of the
536: * topics we are allowed to see.</p>
537: *
538: * @return the current value of topicIds.
539: */
540: public final Set getTopicIds() {
541: return topicIds;
542: }
543:
544: /**
545: * <p>In submit mode, stores all of the image filenames of the topics
546: * we are allowed to see.</p>
547: *
548: * @return the current value of topicImages.
549: */
550: public final Map getTopicImages() {
551: return topicImages;
552: }
553:
554: /**
555: * <p>Defines list of files DO's with are goint to attch with this
556: * item.</p>
557: *
558: * @return the current value of uploadingFileList.
559: */
560: public List getUploadingFileList() {
561: return this .uploadingFileList;
562: }
563:
564: /**
565: * <p>Reset all bean properties to their default state. This method
566: * is called before the properties are repopulated by the controller
567: * servlet.</p>
568: *
569: * @param mapping The mapping used to select this instance
570: * @param request The servlet request we are processing
571: *
572: */
573: public void reset(final ActionMapping mapping,
574: final HttpServletRequest request) {
575: super .reset(mapping, request);
576: setEdit(null);
577: newPage = null;
578: comment = null;
579:
580: // remember only index of click button of new Point or new Question
581: newPoint = new String[1];
582:
583: if (this .selectedAttachedFilesIds == null) {
584: this .selectedAttachedFilesIds = new HashMap();
585: } else {
586: this .selectedAttachedFilesIds.clear();
587: }
588:
589: this .selectedNewFilesIds = new String[0];
590:
591: /*
592: if (item != null) {
593: // make this one larger than it needs to be, in case a new
594: // category is added!
595: if (item.getType().equals(LibraryItemConstants.ITEM_MEETING)) {
596: newPoint = null;
597: } else if (item.getType().equals(LibraryItemConstants.ITEM_FAQ)) {
598: newPoint = new String[item.getFaqCategories().size() + 1];
599:
600: } else {
601: newPoint = null;
602: }
603: }
604: */
605: }
606:
607: /**
608: <p>Version control comment</p>
609: @param comment the comment
610:
611: */
612: public final void setComment(final String comment) {
613: this .comment = comment;
614: }
615:
616: /**
617: * <p>Button for deleting attached files to item.</p>
618: *
619: * @param deleteFileButton the new value of deleteFileButton.
620: */
621: public final void setDeleteFileButton(final String deleteFileButton) {
622: this .deleteFileButton = deleteFileButton;
623: }
624:
625: /**
626: * <p>Page to include with extra fields for this document type, on
627: * display.</p>
628: *
629: * @param displayIncludePage the new value of displayIncludePage.
630: */
631: public final void setDisplayIncludePage(
632: final String displayIncludePage) {
633: this .displayIncludePage = displayIncludePage;
634: }
635:
636: /**
637: * <p>If in display mode, indicates the page number to currently
638: * show.</p>
639: *
640: * @param displayPage the new value of displayPage.
641: */
642: public final void setDisplayPage(final int displayPage) {
643: this .displayPage = displayPage;
644: }
645:
646: /**
647: * <p>Defines list of files DO's with are attched with this
648: * item.</p>
649: *
650: * @param fileList the new value of fileList.
651: */
652: public final void setFileList(final List fileList) {
653: this .fileList = fileList;
654: }
655:
656: /**
657: * <p>Contains all of the information about the current library
658: * item</p>
659: *
660: * @param item the new value of item.
661: */
662: public final void setItem(final LibraryItemDO item) {
663: this .item = item;
664: }
665:
666: /**
667: * <p>Defines the page to link to. This varies depending on
668: * whether the item is being submitted or displayed.</p>
669: *
670: * @param linkPage the new value of linkPage.
671: */
672: public final void setLinkPage(final String linkPage) {
673: this .linkPage = linkPage;
674: }
675:
676: /**
677: * <p>If non-<code>null</code>, indicates a new page should be
678: * addes.</p>
679: *
680: * @param newPage the new value of newPage.
681: */
682: public final void setNewPage(final String newPage) {
683: this .newPage = newPage;
684: }
685:
686: /**
687: * <p>TRICK
688: * storing index of button which was click in submiting page of
689: * Meeting or Faq.
690: * set first field of array
691: *
692: * for MEETING it's creating new AgendaPoin in heading with that
693: * index.
694: * for FAQ it's creating new Question in faq category with that
695: * index.</p>
696: *
697: * @param index is the index of heading or faq category
698: * @param value is the value of button
699: */
700: public final void setNewPoint(final int index, final String value) {
701: this .newPoint[0] = String.valueOf(index);
702: }
703:
704: /**
705: * <p>Link to link the next page to, or the empty string if there is
706: * no next
707: * page.</p>
708: *
709: * @param nextPageLink the new value of nextPageLink.
710: */
711: public final void setNextPageLink(final String nextPageLink) {
712: this .nextPageLink = nextPageLink;
713: }
714:
715: /**
716: * <p>Contains the links with appear to the top right of displayed
717: * items.</p>
718: *
719: * @param pageLinks the new value of pageLinks.
720: */
721: public final void setPageLinks(final String pageLinks) {
722: this .pageLinks = pageLinks;
723: }
724:
725: /**
726: * <p>Link to link the previous page to, or the empty string if there
727: * is no
728: * previous page.</p>
729: *
730: * @param previoustPageLink the new value of previoustPageLink.
731: */
732: public final void setPreviousPageLink(final String previousPageLink) {
733: this .previousPageLink = previousPageLink;
734: }
735:
736: /**
737: * <p>Seting selected file ID to maped properties.</p>
738: *
739: * @param key - which checkBox is selected
740: * @param value - value which is setTo haspMap with that key
741: */
742: public final void setSelectedAttachedFilesIds(final String key,
743: final Object value) {
744: this .selectedAttachedFilesIds.put(key, value);
745: }
746:
747: /**
748: * <p>All Ids of selected files by user from list of new files.</p>
749: *
750: * @param selectedNewFilesIds the new value of selectedNewFilesIds.
751: */
752: public final void setSelectedNewFilesIds(
753: final String[] selectedNewFilesIds) {
754: this .selectedNewFilesIds = selectedNewFilesIds;
755: }
756:
757: /**
758: * <p>Page to include with extra fields for this document type, on
759: * submission</p>
760: *
761: * @param submitIncludePage the new value of submitIncludePage.
762: */
763: public final void setSubmitIncludePage(
764: final String submitIncludePage) {
765: this .submitIncludePage = submitIncludePage;
766: }
767:
768: /**
769: * <p>Key to the localized text for the summary field (submit
770: * mode).</p>
771: *
772: * @param summaryPromptKey the new value of summaryPromptKey.
773: */
774: public final void setSummaryPromptKey(final String summaryPromptKey) {
775: this .summaryPromptKey = summaryPromptKey;
776: }
777:
778: /**
779: * <p>Specifies the theme name for the document summary section.</p>
780: *
781: * @param summaryThemeName the new value of summaryThemeName.
782: */
783: public final void setSummaryThemeName(final String summaryThemeName) {
784: this .summaryThemeName = summaryThemeName;
785: }
786:
787: /**
788: * <p>Key to the localized text for the summary window (submit
789: * mode).</p>
790: *
791: * @param summaryTitleKey the new value of summaryTitleKey.
792: */
793: public final void setSummaryTitleKey(final String summaryTitleKey) {
794: this .summaryTitleKey = summaryTitleKey;
795: }
796:
797: /**
798: * <p>Specifies the theme name for the body of the document.</p>
799: *
800: * @param themeName the new value of themeName.
801: */
802: public final void setThemeName(final String themeName) {
803: this .themeName = themeName;
804: }
805:
806: /**
807: * <p>In submit mode, stores all of the captions of the topics we are
808: * allowed to see.</p>
809: *
810: * @param topicCaptions the new value of topicCaptions.
811: */
812: public final void setTopicCaptions(final Map topicCaptions) {
813: this .topicCaptions = topicCaptions;
814: }
815:
816: /**
817: * <p>In submit mode, stores all of the unique identifiers of the
818: * topics we are allowed to see.</p>
819: *
820: * @param topicIds the new value of topicIds.
821: */
822: public final void setTopicIds(final Set topicIds) {
823: this .topicIds = topicIds;
824: }
825:
826: /**
827: * <p>In submit mode, stores all of the image filenames of the topics
828: * we are allowed to see.</p>
829: *
830: * @param topicImages the new value of topicImages.
831: */
832: public final void setTopicImages(final Map topicImages) {
833: this .topicImages = topicImages;
834: }
835:
836: /**
837: * <p>Defines list of files DO's with are goint to attch with this
838: * item.</p>
839: *
840: * @param uploadingFileList the new value of uploadingFileList.
841: */
842: public final void setUploadingFileList(final List uploadingFileList) {
843: this .uploadingFileList = uploadingFileList;
844: }
845:
846: /**
847: * Validate the properties that have been set for this HTTP request,
848: * and return an <code>ActionMessages</code> object that encapsulates
849: * any
850: * validation errors that have been found. If no errors are found,
851: * return <code>null</code> or an <code>ActionMessages</code> object
852: * with
853: * no recorded error messages.
854: * <p>
855: * The default ipmlementation performs no validation and returns
856: * <code>null</code>. Subclasses must override this method to provide
857: * any validation they wish to perform.
858: *
859: * @param request The servlet request we are processing.
860: * @param session The sessuib we are processing.
861: * @see com.ivata.mask.web.struts.MaskForm#validate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession)
862: */
863: public ValidationErrors validate(final HttpServletRequest request,
864: final HttpSession session) {
865: ValidationErrors errors = new ValidationErrors();
866:
867: // if there is no item yet, or clear was pressed, just get out
868: if ((item == null) || !StringHandling.isNullOrEmpty(getClear())) {
869: return null;
870: }
871:
872: // if a topic was specified make sure it is valid
873: if ((item.getTopic() == null)
874: || (item.getTopic().getId().equals(new Integer(-1)))) {
875: errors.add(new ValidationError("submit",
876: Library.BUNDLE_PATH, mask.getField("topicId"),
877: "errors.library.item.submit.noTopic"));
878: }
879:
880: // if there is no ok/cancel, just report the topic error
881: if (StringHandling.isNullOrEmpty(getOk())) {
882: return errors;
883: }
884:
885: // if it gets here - ok was pressed. validate on the server side
886: SecuritySession securitySession = (SecuritySession) session
887: .getAttribute("securitySession");
888: ValidationErrors libraryErrors = library.validate(
889: securitySession, item);
890: if (libraryErrors != null) {
891: errors.addAll(libraryErrors);
892: }
893:
894: return errors;
895: }
896: }
|