KickJava   Java API By Example, From Geeks To Geeks.

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


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: EditSessionMailFactoryAction.java,v 1.6 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 Session Mail Factory
44  * @author Adriana Danes
45  */

46 public class EditSessionMailFactoryAction 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             + "session" + 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                 ObjectName JavaDoc oObjectName = J2eeObjectName.JavaMailResource(domainName
80                     , oForm.getMailFactoryName(), serverName, MailServiceImpl.SESSION_PROPERTY_TYPE);
81                 populate(oObjectName, oForm);
82             }
83         }
84         catch (Throwable JavaDoc t) {
85             addGlobalError(t);
86             saveErrors(p_Request, m_Errors);
87             return (p_Mapping.findForward("Global Error"));
88         }
89         // Forward to the jsp.
90
return (p_Mapping.findForward("Session Factory"));
91     }
92 }
93
Popular Tags