KickJava   Java API By Example, From Geeks To Geeks.

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


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: FindMailUserAction.java,v $
31  * Revision 1.3 2005/04/10 20:10:08 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:20:01 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:51:18 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.8 2004/12/31 18:27:44 colinmacleod
45  * Added MaskFactory to constructor of MaskAction.
46  *
47  * Revision 1.7 2004/12/23 21:01:34 colinmacleod
48  * Updated Struts to v1.2.4.
49  * Changed base classes to use ivata masks.
50  *
51  * Revision 1.6 2004/11/12 18:19:16 colinmacleod
52  * Change action and form classes to extend MaskAction, MaskForm respectively.
53  *
54  * Revision 1.5 2004/11/12 15:57:25 colinmacleod
55  * Removed dependencies on SSLEXT.
56  * Moved Persistence classes to ivata masks.
57  *
58  * Revision 1.4 2004/11/03 15:31:52 colinmacleod
59  * Change method interfaces to remove log.
60  *
61  * Revision 1.3 2004/07/13 19:48:12 colinmacleod
62  * Moved project to POJOs from EJBs.
63  * Applied PicoContainer to services layer (replacing session EJBs).
64  * Applied Hibernate to persistence layer (replacing entity EJBs).
65  *
66  * Revision 1.2 2004/03/21 21:16:39 colinmacleod
67  * Shortened name to ivata op.
68  *
69  * Revision 1.1.1.1 2004/01/27 20:59:59 colinmacleod
70  * Moved ivata openportal to SourceForge..
71  *
72  * Revision 1.3 2003/10/28 13:27:51 jano
73  * commiting webmail,
74  * still fixing compile and building openGroupware project
75  *
76  * Revision 1.2 2003/10/15 14:11:33 colin
77  * fixing for XDoclet
78  * -----------------------------------------------------------------------------
79  */

80 package com.ivata.groupware.business.mail.struts;
81
82 import java.util.Vector JavaDoc;
83
84 import javax.servlet.http.HttpServletRequest JavaDoc;
85 import javax.servlet.http.HttpServletResponse JavaDoc;
86 import javax.servlet.http.HttpSession JavaDoc;
87
88 import org.apache.struts.action.ActionErrors;
89 import org.apache.struts.action.ActionForm;
90 import org.apache.struts.action.ActionMapping;
91
92 import com.ivata.groupware.admin.security.Security;
93 import com.ivata.groupware.admin.setting.Settings;
94 import com.ivata.groupware.business.addressbook.AddressBook;
95 import com.ivata.groupware.business.addressbook.person.PersonDO;
96 import com.ivata.groupware.business.addressbook.right.AddressBookRights;
97 import com.ivata.groupware.business.addressbook.struts.FindPersonAction;
98 import com.ivata.groupware.business.mail.Mail;
99 import com.ivata.groupware.business.mail.session.MailSession;
100 import com.ivata.groupware.util.SettingDateFormatter;
101 import com.ivata.mask.MaskFactory;
102 import com.ivata.mask.util.StringHandling;
103 import com.ivata.mask.util.SystemException;
104 import com.ivata.mask.web.struts.MaskAuthenticator;
105
106
107 /**
108  * <p>Extends the find person action from the standard address book class to add
109  * in user alias and other mail user settings.</p>
110  *
111  * <p>To use this class rather than the standard AddressBook class, you need to
112  * change the struts config file to specify this class instead of
113  * <code>FindPersonAction</code>.</p>
114  *
115  * TODO: this class needs to be substituted for the FindPersonAction in the
116  * struts file.
117  * @author Colin MacLeod
118  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
119  */

120 public class FindMailUserAction extends FindPersonAction {
121     AddressBook addressBook;
122     Mail mail;
123     Security security;
124     /**
125      * TODO
126      * @param addressBook
127      * @param addressBookRights
128      * @param mail
129      * @param dateFormatter
130      * @param security
131      * @param settings
132      * @param maskFactory This factory is needed to access the masks and groups
133      * of masks.
134      * @param authenticator used to confirm whether or not the
135      * user should be allowed to continue, in the <code>execute</code> method.
136      */

137     public FindMailUserAction(AddressBook addressBook, AddressBookRights
138             addressBookRights, Mail mail, SettingDateFormatter dateFormatter,
139             Security security, Settings settings,
140             MaskFactory maskFactory, MaskAuthenticator authenticator) {
141         super(addressBook, addressBookRights, dateFormatter, security, settings,
142                 maskFactory, authenticator);
143         this.addressBook = addressBook;
144         this.mail = mail;
145         this.security = security;
146     }
147
148     /**
149      * <p>Overridden to set the vacation message and user aliases.</p>
150      *
151      * @see com.ivata.mask.web.struts.MaskAction#execute
152      */

153     public String JavaDoc execute(final ActionMapping mapping,
154             final ActionErrors errors,
155             final ActionForm form,
156             final HttpServletRequest JavaDoc request,
157             final HttpServletResponse JavaDoc response,
158             final HttpSession JavaDoc session) throws SystemException {
159         String JavaDoc returnValue = super.execute(mapping, errors, form, request,
160                 response, session);
161
162         MailUserForm mailUserForm = (MailUserForm) session.getAttribute(
163                 "addressBookPersonForm");
164
165         // set up the user
166
String JavaDoc id = request.getParameter("id");
167
168         if (id == null) {
169             throw new SystemException("ERROR in FindPersonAction: id is null",
170                 null);
171         }
172
173         PersonDO person;
174         MailSession mailSession = (MailSession) session.getAttribute("securitySession");
175         person = addressBook.findPersonByPrimaryKey(mailSession, id);
176
177         String JavaDoc userNameSet = person.getUser().getName();
178
179         // only get the email aliases and vacation message if the user name is
180
// set to something
181
if (!StringHandling.isNullOrEmpty(userNameSet)) {
182             mailUserForm.setUserAliases(new Vector JavaDoc(mail.getUserAliases(
183                 mailSession, userNameSet)));
184             mailUserForm.setVacationMessage(mail.getVacationMessage(
185                 mailSession, userNameSet));
186         }
187
188         mailUserForm.setUserName(userNameSet);
189         mailUserForm.setEnableUser((userNameSet != null) &&
190             security.isUserEnabled(mailSession, userNameSet));
191
192         return returnValue;
193     }
194 }
195
Popular Tags