KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > mail > struts > IndexAction


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: IndexAction.java,v $
31  * Revision 1.3.2.1 2005/10/08 17:35:02 colinmacleod
32  * Backported HEAD version to add logging.
33  *
34  * Revision 1.6 2005/10/03 10:21:16 colinmacleod
35  * Fixed some style and javadoc issues.
36  *
37  * Revision 1.5 2005/10/02 14:08:59 colinmacleod
38  * Added/improved log4j logging.
39  *
40  * Revision 1.4 2005/09/14 16:16:52 colinmacleod
41  * Removed unused local and class variables.
42  * Added serialVersionUID.
43  *
44  * Revision 1.3 2005/04/10 19:26:05 colinmacleod
45  * Cosmetic changes.
46  *
47  * Revision 1.2 2005/04/09 17:20:01 colinmacleod
48  * Changed copyright text to GPL v2 explicitly.
49  *
50  * Revision 1.1.1.1 2005/03/10 17:51:17 colinmacleod
51  * Restructured ivata op around Hibernate/PicoContainer.
52  * Renamed ivata groupware.
53  *
54  * Revision 1.10 2004/12/31 18:27:44 colinmacleod
55  * Added MaskFactory to constructor of MaskAction.
56  *
57  * Revision 1.9 2004/11/12 18:19:16 colinmacleod
58  * Change action and form classes to extend MaskAction, MaskForm respectively.
59  *
60  * Revision 1.8 2004/11/12 15:57:25 colinmacleod
61  * Removed dependencies on SSLEXT.
62  * Moved Persistence classes to ivata masks.
63  *
64  * Revision 1.7 2004/11/03 15:31:52 colinmacleod
65  * Change method interfaces to remove log.
66  *
67  * Revision 1.6 2004/07/13 19:48:12 colinmacleod
68  * Moved project to POJOs from EJBs.
69  * Applied PicoContainer to services layer (replacing session EJBs).
70  * Applied Hibernate to persistence layer (replacing entity EJBs).
71  *
72  * Revision 1.5 2004/03/21 21:16:39 colinmacleod
73  * Shortened name to ivata op.
74  *
75  * Revision 1.4 2004/03/21 20:51:33 colinmacleod
76  * Change SecurityServer into interface.
77  * Added checking of mail server.
78  *
79  * Revision 1.3 2004/03/10 22:38:16 colinmacleod
80  * Added security server exception handling.
81  *
82  * Revision 1.2 2004/02/01 22:07:33 colinmacleod
83  * Added full names to author tags
84  *
85  * Revision 1.1.1.1 2004/01/27 20:59:59 colinmacleod
86  * Moved ivata openportal to SourceForge..
87  *
88  * Revision 1.5 2004/01/12 14:02:23 jano
89  * fixing bugs
90  *
91  * Revision 1.4 2003/12/12 13:24:34 jano
92  * fixing webmail functionality
93  *
94  * Revision 1.3 2003/10/28 13:27:51 jano
95  * commiting webmail,
96  * still fixing compile and building openGroupware project
97  *
98  * Revision 1.2 2003/10/15 14:11:33 colin
99  * fixing for XDoclet
100  *
101  * Revision 1.7 2003/06/04 11:22:03 peter
102  * fixed always setting the most recent sortDirection a messageList to session
103  *
104  * Revision 1.6 2003/06/03 13:13:10 peter
105  * fixed sorting
106  *
107  * Revision 1.5 2003/03/14 12:27:37 peter
108  * added logic for wrong folder name - defaults to inbox
109  *
110  * Revision 1.4 2003/03/03 16:57:12 colin
111  * converted localization to automatic paths
112  * added labels
113  * added mandatory fieldName attribute
114  *
115  * Revision 1.3 2003/02/28 13:32:41 jano
116  * clearing field movoTo after moveing messages to specifik folder
117  * and
118  * set false forwardMessages
119  *
120  * Revision 1.2 2003/02/25 11:53:33 colin
121  * bugfixes and minor restructuring
122  *
123  * Revision 1.1 2003/02/24 19:09:24 colin
124  * moved to business
125  *
126  * Revision 1.4 2003/02/04 17:39:10 colin
127  * updated for new MaskAction interface
128  *
129  * Revision 1.3 2003/01/27 07:28:17 colin
130  * cosmetic changes
131  *
132  * Revision 1.2 2003/01/18 20:27:25 colin
133  * added new mail action superclass
134  * many fixes
135  *
136  * Revision 1.1 2002/11/17 20:05:08 colin
137  * first version of struts mail index
138  * -----------------------------------------------------------------------------
139  */

140 package com.ivata.groupware.business.mail.struts;
141
142 import java.util.Arrays JavaDoc;
143 import java.util.HashSet JavaDoc;
144 import java.util.Iterator JavaDoc;
145 import java.util.List JavaDoc;
146 import java.util.Vector JavaDoc;
147
148 import javax.servlet.http.HttpServletRequest JavaDoc;
149 import javax.servlet.http.HttpServletResponse JavaDoc;
150 import javax.servlet.http.HttpSession JavaDoc;
151
152 import org.apache.log4j.Logger;
153 import org.apache.struts.action.ActionErrors;
154 import org.apache.struts.action.ActionForm;
155 import org.apache.struts.action.ActionMapping;
156 import org.picocontainer.PicoContainer;
157
158 import com.ivata.groupware.admin.security.server.SecurityServerException;
159 import com.ivata.groupware.admin.security.user.UserDO;
160 import com.ivata.groupware.admin.setting.Settings;
161 import com.ivata.groupware.business.mail.Mail;
162 import com.ivata.groupware.business.mail.MailConstants;
163 import com.ivata.groupware.business.mail.message.MessageDO;
164 import com.ivata.groupware.business.mail.server.NoMailServerException;
165 import com.ivata.groupware.business.mail.session.MailSession;
166 import com.ivata.groupware.container.PicoContainerFactory;
167 import com.ivata.mask.MaskFactory;
168 import com.ivata.mask.util.StringHandling;
169 import com.ivata.mask.util.SystemException;
170 import com.ivata.mask.util.ThrowableHandling;
171 import com.ivata.mask.web.struts.MaskAction;
172 import com.ivata.mask.web.struts.MaskAuthenticator;
173
174
175 /**
176  * <p>This <code>Action</code> is invoked when displaying the main
177  * listing of a mail folder.</p>
178  *
179  * @since 2002-11-14
180  * @author Colin MacLeod
181  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
182  * @version $Revision: 1.3.2.1 $
183  */

184 public class IndexAction extends MaskAction {
185     /**
186      * <copyDoc>Refer to {@link Logger}.</copyDoc>
187      */

188     private static final Logger logger = Logger.getLogger(IndexAction.class);
189     /**
190      * <copyDoc>Refer to {@link Index()}.</copyDoc>
191      */

192     private Mail mail;
193     /**
194      * <copyDoc>Refer to {@link Index()}.</copyDoc>
195      */

196     private Settings settings;
197     /**
198      * Construct the action.
199      *
200      * @param mailParam This object is used to retrieve all the messages.
201      * @param settingsParam Used to retrieve the names of common mail folders.
202      * @param maskFactory {@inheritDoc}
203      * @param authenticator {@inheritDoc}
204      */

205     public IndexAction(
206             final Mail mailParam,
207             final Settings settingsParam,
208             final MaskFactory maskFactory,
209             final MaskAuthenticator authenticator) {
210         super(maskFactory, authenticator);
211         this.mail = mailParam;
212         this.settings = settingsParam;
213     }
214
215     /**
216      * <p>Build the form for <code>/mail/index.jsp</code> to either list a
217      * new folder, go to the next page (remembering the selections) or
218      * react to user selections.</p>
219      *
220      * @param mapping {@inheritDoc}
221      * @param form {@inheritDoc}
222      * @param request {@inheritDoc}
223      * @param response {@inheritDoc}
224      * @param session {@inheritDoc}
225      * @return &quot;mailServerError&quot; if the mail server has not been
226      * set up correctly, &quot;mailCompose&quot; if some messages should
227      * be forwarded, otherwise &quot;mailIndex&quot;.
228      * @throws SystemException If the messages cannot be retrieved for any
229      * reason.
230      */

231     public String JavaDoc execute(final ActionMapping mapping,
232             final ActionErrors errors,
233             final ActionForm form,
234             final HttpServletRequest JavaDoc request,
235             final HttpServletResponse JavaDoc response,
236             final HttpSession JavaDoc session) throws SystemException {
237         if (logger.isDebugEnabled()) {
238             logger.debug("execute(ActionMapping mapping = " + mapping
239                     + ", ActionForm form = " + form
240                     + ", HttpServletRequest request = " + request
241                     + ", HttpServletResponse response = " + response
242                     + ", HttpSession session = " + session
243                     + ") - start");
244         }
245
246         IndexForm indexForm = (IndexForm) form;
247
248         MailSession mailSession;
249         try {
250             mailSession = (MailSession) session.getAttribute("securitySession");
251         } catch (ClassCastException JavaDoc e) {
252             logger.error("Class cast exception getting the mail security "
253                     + "session. This means we don't have a mail session.",
254                     e);
255
256             session.setAttribute("mailServerException",
257                 new NoMailServerException(e));
258
259             if (logger.isDebugEnabled()) {
260                 logger.debug("execute - end - return value = mailServerError");
261             }
262             return "mailServerError";
263         }
264         final String JavaDoc folderName = getFolderName(mailSession, indexForm);
265
266         // all the selected ids are stored in the session
267
HashSet JavaDoc selectedMessageIds = (HashSet JavaDoc) session.getAttribute(
268                 "selectedMessageIds");
269
270         // if there is no selected message ids in the session yet, make one now
271
if (selectedMessageIds == null) {
272             selectedMessageIds = new HashSet JavaDoc();
273             session.setAttribute("selectedMessageIds",
274                 selectedMessageIds);
275
276             // this flag is stored in index.jsp to say we should retain the
277
// selected messages
278
} else if (!indexForm.getRetainPrevious()) {
279             selectedMessageIds.clear();
280         }
281
282         // first add all message numbers in this page, subtract the selected
283
// ones. this gives us the unselected ones to subtract from our main
284
// list
285
HashSet JavaDoc removeIds = new HashSet JavaDoc();
286         removeIds.addAll(Arrays.asList(indexForm.getMessageIds()));
287
288         List JavaDoc selectedList = Arrays.asList(indexForm.getSelectedMessageIds());
289         removeIds.removeAll(selectedList);
290
291         // now set up all of the messages in this folder in the request
292
try {
293             // get the messages and save them for display
294
getIndexMessages(request, mailSession, folderName, indexForm);
295         } catch (SystemException e) {
296             String JavaDoc returnValue = handleMailIndexException(e, request,
297                     folderName);
298             if (logger.isDebugEnabled()) {
299                 logger.debug("execute() - end - returning "
300                         + returnValue);
301             }
302             return returnValue;
303         }
304
305         // must remove all unchecked ones, so we don't get them from before
306
selectedMessageIds.removeAll(removeIds);
307
308         // set the selected Ids in the form
309
indexForm.setSelectedMessageIds((String JavaDoc[]) selectedMessageIds.toArray(
310                 indexForm.getSelectedMessageIds()));
311
312         String JavaDoc forwardName = null;
313         if (!selectedMessageIds.isEmpty()) {
314             forwardName = processSelectedMessages(request, mailSession,
315                     folderName, indexForm, selectedMessageIds);
316         }
317
318         // if it gets down here, then it has all gone well :-)
319
if (forwardName == null) {
320             forwardName = "mailIndex";
321         }
322         if (logger.isDebugEnabled()) {
323             logger.debug("execute - end - return value = "
324                     + forwardName);
325         }
326         return forwardName;
327     }
328     /**
329      * Get the name of the folder we are currently processing.
330      *
331      * @param mailSession Current mail session for the user who is displaying
332      * the page.
333      * @param indexForm Form returned from the index page.
334      * @return The name of the folder.
335      * @throws SystemException If one of the system settings for standard
336      * folder names cannot be read.
337      */

338     private String JavaDoc getFolderName(
339             final MailSession mailSession,
340             final IndexForm indexForm)
341             throws SystemException {
342         if (logger.isDebugEnabled()) {
343             logger.debug("getFolderName(MailSession mailSession = "
344                     + mailSession + ", IndexForm indexForm = " + indexForm
345                     + ") - start");
346         }
347
348         // default to the inbox
349
String JavaDoc folderName = null;
350
351         if (indexForm.getFolderName() != null) {
352             folderName = indexForm.getFolderName().toLowerCase();
353         }
354
355         UserDO user = mailSession.getUser();
356         if (StringHandling.isNullOrEmpty(folderName)) {
357             folderName = settings.getStringSetting(
358                     mailSession,
359                     "emailFolderInbox",
360                     user);
361             indexForm.setFolderName(folderName);
362
363             // translate 'special' folder names
364
// done this way to keep the menu item names independent of IMAP
365
// implementation
366
} else if (folderName.equals("sent")) {
367             folderName = settings.getStringSetting(
368                     mailSession,
369                     "emailFolderSent",
370                     user);
371             indexForm.setFolderName(folderName);
372         } else if (folderName.equals("drafts")) {
373             folderName = settings.getStringSetting(
374                     mailSession,
375                     "emailFolderDrafts",
376                     user);
377             indexForm.setFolderName(folderName);
378         } else if (folderName.equals("trash")) {
379             folderName = settings.getStringSetting(
380                     mailSession,
381                     "emailFolderTrash",
382                     user);
383             indexForm.setFolderName(folderName);
384         } else {
385             folderName = settings.getStringSetting(
386                     mailSession,
387                     "emailFolderInbox",
388                     user);
389             indexForm.setFolderName(folderName);
390         }
391
392         if (logger.isDebugEnabled()) {
393             logger.debug("getFolderName() - end - return value = "
394                             + folderName);
395         }
396         return folderName;
397     }
398     /**
399      * This method actually gets the messages we will show, and saves them
400      * in the session.
401      *
402      * @param request Current request we are processing.
403      * @param mailSession Current mail session for the user who is displaying
404      * the page.
405      * @param folderName Name of the folder being displayed.
406      * @param indexForm Form returned from the index page.
407      * @throws SystemException Thrown by the mail subsystem if we cannot
408      * retrieve the messages.
409      */

410     private void getIndexMessages(
411             final HttpServletRequest JavaDoc request,
412             final MailSession mailSession,
413             final String JavaDoc folderName,
414             final IndexForm indexForm)
415             throws SystemException {
416         if (logger.isDebugEnabled()) {
417             logger.debug("getIndexMessages(HttpServletRequest request = "
418                     + request + ", MailSession mailSession = " + mailSession
419                     + ", String folderName = " + folderName
420                     + ", IndexForm indexForm = " + indexForm + ") - start");
421         }
422
423         HttpSession JavaDoc session = request.getSession();
424         List JavaDoc sessionMessages = null;
425
426         // if the mail folder is the same as the one in the session, and
427
// it has not been modified, retrieve it from the session
428
String JavaDoc sessionFolderName = (String JavaDoc) session.getAttribute(
429                 "mailIndexFolderName");
430         Integer JavaDoc sessionSortBy = (Integer JavaDoc) session.getAttribute(
431                 "mailIndexFolderSortBy");
432         Boolean JavaDoc sessionSortAscending = (Boolean JavaDoc) session.getAttribute(
433                 "mailIndexFolderSortAscending");
434         sessionMessages = (List JavaDoc) session.getAttribute("mailIndexMessages");
435
436         Integer JavaDoc sortBy = indexForm.getSortBy();
437         Boolean JavaDoc sortAscending = new Boolean JavaDoc(indexForm.getSortAscending());
438
439         boolean modified = true;
440
441         // this folder might not exist yet
442
// see if it is the same as before, as only then do we need to
443
// compare modified times
444
if (folderName.equals(sessionFolderName)
445                 || (sessionFolderName == null)) {
446             modified = mail.hasNewMessages(
447                     mailSession,
448                     mailSession.getUser().getName(),
449                     folderName);
450         }
451         // see if this is the same folder we indexed last time. If so, don't
452
// try to index it again.
453
if (modified
454                 || (sessionMessages == null)
455                 || !folderName.equals(sessionFolderName)
456                 || !sortBy.equals(sessionSortBy)) {
457             // if the folder doesn't exist, create it
458
if (!(folderName.equals(sessionFolderName)
459                     || mail.doesFolderExist(mailSession, folderName))) {
460                 mail.createFolder(mailSession, folderName);
461             }
462
463             // we'll have to get the messages from JavaMail
464
// set the current values to the session to retrieve again later
465
session.setAttribute("mailIndexFolderName", folderName);
466             session.setAttribute("mailIndexFolderSortBy", sortBy);
467             sessionMessages = mail.findMessagesInFolder(mailSession,
468                     folderName, sortBy, sortAscending.booleanValue());
469
470             // if it's just the direction has reversed, just do that here to
471
// save another server-side call
472
} else if (!sortAscending.equals(sessionSortAscending)) {
473             int end = sessionMessages.size();
474             int halfSize = end / 2;
475             Object JavaDoc tmp;
476
477             for (int start = 0; start < halfSize; ++start) {
478                 tmp = sessionMessages.get(--end);
479                 sessionMessages.set(end, sessionMessages.get(start));
480                 sessionMessages.set(start, tmp);
481             }
482         }
483
484         // the sorting direction must be always updated for flip-flop checks
485
session.setAttribute("mailIndexFolderSortAscending", sortAscending);
486
487         // setting the list back to the session (display)
488
session.setAttribute("mailIndexMessages", sessionMessages);
489
490         if (logger.isDebugEnabled()) {
491             logger.debug("getIndexMessages() - end");
492         }
493     }
494     /**
495      * Check any system exception we received to see if this means the mail
496      * server has not been installed properly.
497      *
498      * @param systemExceptionParam System Exception we received.
499      * @param request Current request we are processing.
500      * @param folderName Name of the folder being displayed.
501      * @return &quot;mailServerError&quot; if the server has not been installed
502      * properly.
503      * @throws SystemException Thrown if this exception doesn't match a server
504      * installation problem.
505      */

506     private String JavaDoc handleMailIndexException(
507             final SystemException systemExceptionParam,
508             final HttpServletRequest JavaDoc request,
509             final String JavaDoc folderName)
510             throws SystemException {
511         logger.warn("handleMailIndexException - Caught "
512                 + systemExceptionParam.getClass().getName()
513                 + " in IndexAction. Analysing cause.", systemExceptionParam);
514         Throwable JavaDoc eCause = ThrowableHandling.getCause(systemExceptionParam);
515         assert (eCause != null);
516         logger.warn("Exception cause: "
517                 + eCause.getClass().getName()
518                 + ".", eCause);
519
520         if (eCause instanceof NoMailServerException) {
521             NoMailServerException noMailServerException =
522                 (NoMailServerException) eCause;
523
524             // catch this exception - warn the user that the server is not
525
// set up correctly
526
logger.error("handleMailIndexException ("
527                 + noMailServerException.getClass().getName()
528                 + ") retrieving index for folder '"
529                 + folderName
530                 + "': "
531                 + noMailServerException.getCause().getMessage());
532             noMailServerException.printStackTrace();
533             request.setAttribute("mailServerException",
534                 noMailServerException);
535
536             if (logger.isDebugEnabled()) {
537                 logger.debug("handleMailIndexException - end - return value = "
538                         + "mailServerError");
539             }
540             return "mailServerError";
541         } else if (eCause instanceof SecurityServerException) {
542             SecurityServerException serverException =
543                 (SecurityServerException) eCause;
544
545             // catch this exception - warn the user that the server is not
546
// set up correctly
547
logger.error("handleMailIndexException ("
548                 + serverException.getClass().getName()
549                 + ") retrieving index for folder '"
550                 + folderName
551                 + "': "
552                 + serverException.getMessage());
553             serverException.printStackTrace();
554             request.setAttribute("mailServerException",
555                 serverException.getCause());
556
557             if (logger.isDebugEnabled()) {
558                 logger.debug("handleMailIndexException - end - return value = "
559                         + "mailServerError");
560             }
561             return "mailServerError";
562         }
563
564         // if it gets here, it is not an exception type we can handle
565
if (logger.isDebugEnabled()) {
566             logger.debug("handleMailIndexException - throwing system exception "
567                     + "again.", systemExceptionParam);
568         }
569         throw systemExceptionParam;
570     }
571     /**
572      * If some of the messages are selected, this method decides what to do
573      * with them.
574      *
575      * @param request Current request we are processing.
576      * @param mailSession Current mail session for the user who is displaying
577      * the page.
578      * @param folderName Name of the folder being displayed.
579      * @param indexForm Form returned from the index page.
580      * @param selectedMessageIds List of the unique identifiers of the messages
581      * with a checkbox beside them.
582      * @return &quot;mailCompose&quot; if control should be passed to the
583      * compose page, otherwise <code>null</code>
584      * @throws SystemException If the messages cannot be deleted, forwarded
585      * or moved as requested.
586      */

587     private String JavaDoc processSelectedMessages(
588             final HttpServletRequest JavaDoc request,
589             final MailSession mailSession,
590             final String JavaDoc folderName,
591             final IndexForm indexForm,
592             final HashSet JavaDoc selectedMessageIds)
593             throws SystemException {
594         if (logger.isDebugEnabled()) {
595             logger.debug("processSelectedMessages("
596                     + "HttpServletRequest request = "
597                     + request
598                     + ", MailSession mailSession = "
599                     + mailSession
600                     + ", String folderName = "
601                     + folderName
602                     + ", IndexForm indexForm = "
603                     + indexForm
604                     + ", List selectedMessageIds = "
605                     + selectedMessageIds
606                     + ") - start");
607         }
608
609         HttpSession JavaDoc session = request.getSession();
610         Integer JavaDoc sortBy = indexForm.getSortBy();
611         List JavaDoc sessionMessages;
612
613         // if we are told to delete the trash, do that
614
if (indexForm.getDeleteTrash()) {
615             mail.deleteMessagesFromTrash(mailSession,
616                 new Vector JavaDoc(selectedMessageIds));
617             selectedMessageIds.clear();
618             sessionMessages = mail.findMessagesInFolder(
619                     mailSession, folderName, sortBy,
620                     indexForm.getSortAscending());
621             session.setAttribute("mailIndexMessages",
622                 sessionMessages);
623
624             // if we are told to move selected messages to another folder,
625
// do that
626
} else if (!StringHandling.isNullOrEmpty(indexForm.getMoveTo())) {
627             mail.moveMessages(mailSession, indexForm.getFolderName(),
628                 new Vector JavaDoc(selectedMessageIds), indexForm.getMoveTo());
629             selectedMessageIds.clear();
630             sessionMessages = mail.findMessagesInFolder(
631                     mailSession, folderName, sortBy,
632                     indexForm.getSortAscending());
633             session.setAttribute("mailIndexMessages",
634                 sessionMessages);
635
636             //clear the hidden field
637
// javascript will set up
638
indexForm.setMoveTo("");
639         } else if (indexForm.getForwardMessages()) {
640             // we should forward the messages to someone else
641
PicoContainer picoContainer = PicoContainerFactory
642                 .getInstance().getGlobalContainer();
643             ComposeForm composeForm = (ComposeForm)
644                     picoContainer.getComponentInstance(ComposeForm.class);
645
646             MessageDO newMessage =
647                 mail.createThreadMessage(
648                     mailSession,
649                     indexForm.getFolderName(),
650                     new Vector JavaDoc(selectedMessageIds),
651                     MailConstants.THREAD_FORWARD);
652             composeForm.setMessage(newMessage);
653
654             request.setAttribute("mailComposeForm", composeForm);
655
656             indexForm.setForwardMessages(false);
657
658             if (logger.isDebugEnabled()) {
659                 logger.debug("execute - end - return value = mailCompose");
660             }
661             return "mailCompose";
662         } else {
663             sessionMessages = (List JavaDoc) session.getAttribute("mailIndexMessages");
664         }
665
666         if (logger.isDebugEnabled()) {
667             logger.debug("processSelectedMessages() - end - return value = "
668                     + null);
669         }
670         // if we're told to select all, do that
671
if (indexForm.getSelectAll()) {
672             for (Iterator JavaDoc i = sessionMessages.iterator(); i.hasNext();) {
673                 selectedMessageIds.add(((MessageDO) i.next()).getId());
674             }
675
676             // otherwise just select those checked on the new page
677
} else {
678             List JavaDoc selectedList =
679                 Arrays.asList(indexForm.getSelectedMessageIds());
680             selectedMessageIds.addAll(selectedList);
681         }
682
683         return null;
684     }
685 }
686
Popular Tags