01: package org.claros.mini.actions;
02:
03: import javax.servlet.http.HttpServletRequest;
04: import javax.servlet.http.HttpServletResponse;
05: import org.apache.struts.action.ActionForm;
06: import org.apache.struts.action.ActionForward;
07: import org.apache.struts.action.ActionMapping;
08:
09: import org.claros.commons.mail.models.Email;
10: import org.claros.commons.mail.utility.Utility;
11: import org.claros.mini.common.BaseLoggedAction;
12: import org.claros.mini.models.ComposeFormBean;
13:
14: /**
15: * @version 1.0
16: * @author Umut Gökbayrak
17: */
18: public class ReplyAction extends BaseLoggedAction {
19:
20: public ActionForward myExecute(ActionMapping mapping,
21: ActionForm form, HttpServletRequest request,
22: HttpServletResponse response) throws Exception {
23: // delete the previoue values
24: request.getSession().setAttribute("ComposeFormBean", null);
25: request.getSession().setAttribute("attachments", null);
26:
27: // now create a new one.
28: ComposeFormBean bean = new ComposeFormBean();
29: Email email = (Email) request.getSession()
30: .getAttribute("email");
31: String replyTo = Utility.addressArrToString(email
32: .getBaseHeader().getReplyTo());
33: if (replyTo == null || replyTo.trim().length() == 0) {
34: bean.setTo(email.getBaseHeader().getFromShown());
35: } else {
36: bean.setTo(replyTo);
37: }
38: bean.setSubject("Re: " + email.getBaseHeader().getSubject());
39:
40: String bd = email.getBodyText();
41: bd = "\n\n\nOn " + email.getBaseHeader().getDate().toString()
42: + ", " + email.getFrom() + " wrote\n" + bd;
43:
44: bean.setMessageBody(bd);
45:
46: request.getSession().setAttribute("ComposeFormBean", bean);
47: request.getSession().setAttribute("attachments", null);
48:
49: return mapping.findForward("success");
50: }
51: }
|