001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: EditMimePartMailFactoryAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.mail;
027:
028: import java.io.IOException;
029:
030: import javax.management.ObjectName;
031: import javax.servlet.ServletException;
032: import javax.servlet.http.HttpServletRequest;
033: import javax.servlet.http.HttpServletResponse;
034:
035: import org.apache.struts.action.ActionForm;
036: import org.apache.struts.action.ActionForward;
037: import org.apache.struts.action.ActionMapping;
038: import org.objectweb.jonas.jmx.J2eeObjectName;
039: import org.objectweb.jonas.mail.MailServiceImpl;
040: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
041:
042: /**
043: * Action for management of a MimePartDatasource Mail Factory
044: * @author Adriana Danes
045: */
046: public class EditMimePartMailFactoryAction extends
047: EditMailFactoryAction {
048:
049: public ActionForward executeAction(ActionMapping p_Mapping,
050: ActionForm p_Form, HttpServletRequest p_Request,
051: HttpServletResponse p_Response) throws IOException,
052: ServletException {
053:
054: // Mail factory to edit
055: String sName = p_Request.getParameter("name");
056:
057: // Form used
058: MailFactoryForm oForm = null;
059: if (sName != null) {
060: // Editing a new
061: oForm = new MailFactoryForm();
062: oForm.reset(p_Mapping, p_Request);
063: m_Session.setAttribute("mailFactoryForm", oForm);
064: oForm.setMailFactoryName(sName);
065: } else {
066: // Editing the one in current session
067: oForm = (MailFactoryForm) m_Session
068: .getAttribute("mailFactoryForm");
069: }
070:
071: // Force the node selected in tree
072: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
073: + WhereAreYou.NODE_SEPARATOR + "services"
074: + WhereAreYou.NODE_SEPARATOR + "mail"
075: + WhereAreYou.NODE_SEPARATOR + "mimepart"
076: + WhereAreYou.NODE_SEPARATOR
077: + oForm.getMailFactoryName(), true);
078:
079: // Populate
080: try {
081: if (sName != null) {
082: String domainName = m_WhereAreYou
083: .getCurrentDomainName();
084: String serverName = m_WhereAreYou
085: .getCurrentJonasServerName();
086: // if ()
087: ObjectName oObjectName = J2eeObjectName
088: .JavaMailResource(domainName, oForm
089: .getMailFactoryName(), serverName,
090: MailServiceImpl.MIMEPART_PROPERTY_TYPE);
091: populate(oObjectName, oForm, serverName);
092: setMimePartProps(oObjectName, oForm, serverName);
093: }
094: } catch (Throwable t) {
095: addGlobalError(t);
096: saveErrors(p_Request, m_Errors);
097: return (p_Mapping.findForward("Global Error"));
098: }
099:
100: // Forward to the jsp.
101: return (p_Mapping.findForward("MimePart Factory"));
102: }
103: }
|