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: EditResourceAdapterAOAction.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.Properties;
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 EditResourceAdapterAOAction 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: ResourceAdapterAOForm 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 ResourceAdapterAOForm();
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
083: .setListProperties((Properties) JonasManagementRepr
084: .getAttribute(oObjectName,
085: "properties", serverName));
086: }
087: m_Session.setAttribute("resourceAdapterAOForm", oForm);
088: } catch (Throwable t) {
089: addGlobalError(t);
090: saveErrors(p_Request, m_Errors);
091: return (p_Mapping.findForward("Global Error"));
092: }
093: } else {
094: // Used last form in session
095: oForm = (ResourceAdapterAOForm) m_Session
096: .getAttribute("resourceAdapterAOForm");
097: }
098:
099: ResourceAdapterForm raForm = (ResourceAdapterForm) m_Session
100: .getAttribute("resourceAdapterForm");
101:
102: // Force the node selected in tree
103: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
104: + WhereAreYou.NODE_SEPARATOR + "services"
105: + WhereAreYou.NODE_SEPARATOR + "resourceAdapter"
106: + WhereAreYou.NODE_SEPARATOR + raForm.getFile(), true);
107:
108: // Forward to the jsp.
109: return (p_Mapping.findForward("Resource AdapterAO"));
110: }
111: }
|