KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > service > mail > EditMimePartMailFactoryAction


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: EditMimePartMailFactoryAction.java,v 1.7 2004/03/19 14:31:49 sauthieg Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.service.mail;
27
28 import java.io.IOException JavaDoc;
29
30 import javax.management.ObjectName JavaDoc;
31 import javax.servlet.ServletException JavaDoc;
32 import javax.servlet.http.HttpServletRequest JavaDoc;
33 import javax.servlet.http.HttpServletResponse JavaDoc;
34
35 import org.apache.struts.action.ActionForm;
36 import org.apache.struts.action.ActionForward;
37 import org.apache.struts.action.ActionMapping;
38 import org.objectweb.jonas.jmx.J2eeObjectName;
39 import org.objectweb.jonas.mail.MailServiceImpl;
40 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
41
42 /**
43  * Action for management of a MimePartDatasource Mail Factory
44  * @author Adriana Danes
45  */

46 public class EditMimePartMailFactoryAction extends EditMailFactoryAction {
47
48     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
49         , HttpServletRequest JavaDoc p_Request, HttpServletResponse JavaDoc p_Response)
50         throws IOException JavaDoc, ServletException JavaDoc {
51
52         // Mail factory to edit
53
String JavaDoc sName = p_Request.getParameter("name");
54
55         // Form used
56
MailFactoryForm oForm = null;
57         if (sName != null) {
58             // Editing a new
59
oForm = new MailFactoryForm();
60             oForm.reset(p_Mapping, p_Request);
61             m_Session.setAttribute("mailFactoryForm", oForm);
62             oForm.setMailFactoryName(sName);
63         }
64         else {
65             // Editing the one in current session
66
oForm = (MailFactoryForm) m_Session.getAttribute("mailFactoryForm");
67         }
68
69         // Force the node selected in tree
70
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR
71             + "services" + WhereAreYou.NODE_SEPARATOR + "mail" + WhereAreYou.NODE_SEPARATOR
72             + "mimepart" + WhereAreYou.NODE_SEPARATOR + oForm.getMailFactoryName(), true);
73
74         // Populate
75
try {
76             if (sName != null) {
77                 String JavaDoc domainName = m_WhereAreYou.getCurrentDomainName();
78                 String JavaDoc serverName = m_WhereAreYou.getCurrentJonasServerName();
79                 // if ()
80
ObjectName JavaDoc oObjectName = J2eeObjectName.JavaMailResource(domainName
81                     , oForm.getMailFactoryName(), serverName
82                     , MailServiceImpl.MIMEPART_PROPERTY_TYPE);
83                 populate(oObjectName, oForm);
84                 setMimePartProps(oObjectName, oForm);
85             }
86         }
87         catch (Throwable JavaDoc t) {
88             addGlobalError(t);
89             saveErrors(p_Request, m_Errors);
90             return (p_Mapping.findForward("Global Error"));
91         }
92
93         // Forward to the jsp.
94
return (p_Mapping.findForward("MimePart Factory"));
95     }
96 }
97
Popular Tags