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: EditResourceAdapterASAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.resource;
027:
028: import java.io.IOException;
029: import java.util.List;
030:
031: import javax.management.ObjectName;
032: import javax.servlet.ServletException;
033: import javax.servlet.http.HttpServletRequest;
034: import javax.servlet.http.HttpServletResponse;
035:
036: import org.apache.struts.action.ActionForm;
037: import org.apache.struts.action.ActionForward;
038: import org.apache.struts.action.ActionMapping;
039: import org.objectweb.jonas.jmx.JonasManagementRepr;
040: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
041: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
042:
043: /**
044: * @author Michel-Ange ANTON
045: */
046:
047: public class EditResourceAdapterASAction extends JonasBaseAction {
048:
049: // --------------------------------------------------------- Public Methods
050:
051: public ActionForward executeAction(ActionMapping p_Mapping,
052: ActionForm p_Form, HttpServletRequest p_Request,
053: HttpServletResponse p_Response) throws IOException,
054: ServletException {
055:
056: // Selected resource adapter
057: String sObjectName = p_Request.getParameter("select");
058:
059: ObjectName oObjectName = null;
060: String domainName = null;
061: String serverName = null;
062:
063: // Form used
064: ResourceAdapterASForm oForm = null;
065: // Build a new form
066: if (sObjectName != null) {
067: try {
068: // Recreate ObjectName
069: oObjectName = ObjectName.getInstance(sObjectName);
070: domainName = oObjectName.getDomain();
071: serverName = oObjectName.getKeyProperty("J2EEServer");
072: // Build a new form
073: oForm = new ResourceAdapterASForm();
074: oForm.reset(p_Mapping, p_Request);
075: if (oObjectName != null) {
076: // Object name used
077: oForm.setOName(oObjectName);
078: oForm.setName(getStringAttribute(oObjectName,
079: "jndiName"));
080: oForm.setDescription(getStringAttribute(
081: oObjectName, "description"));
082: oForm.setListProperties((List) JonasManagementRepr
083: .getAttribute(oObjectName,
084: "propertiesList", serverName));
085: }
086: m_Session.setAttribute("resourceAdapterASForm", oForm);
087: } catch (Throwable t) {
088: addGlobalError(t);
089: saveErrors(p_Request, m_Errors);
090: return (p_Mapping.findForward("Global Error"));
091: }
092: } else {
093: // Used last form in session
094: oForm = (ResourceAdapterASForm) m_Session
095: .getAttribute("resourceAdapterASForm");
096: }
097:
098: ResourceAdapterForm raForm = (ResourceAdapterForm) m_Session
099: .getAttribute("resourceAdapterForm");
100:
101: // Force the node selected in tree
102: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
103: + WhereAreYou.NODE_SEPARATOR + "services"
104: + WhereAreYou.NODE_SEPARATOR + "resourceAdapter"
105: + WhereAreYou.NODE_SEPARATOR + raForm.getFile(), true);
106:
107: // Forward to the jsp.
108: return (p_Mapping.findForward("Resource AdapterAS"));
109: }
110: }
|