EditResourceAdapterAction.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: EditResourceAdapterAction.java,v 1.4 2004/03/19 14:31:50 sauthieg Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.service.container;
00027 
00028 import java.io.IOException;
00029 import java.net.URL;
00030 import java.util.Properties;
00031 
00032 import javax.management.ObjectName;
00033 import javax.servlet.ServletException;
00034 import javax.servlet.http.HttpServletRequest;
00035 import javax.servlet.http.HttpServletResponse;
00036 
00037 import org.apache.struts.action.ActionForm;
00038 import org.apache.struts.action.ActionForward;
00039 import org.apache.struts.action.ActionMapping;
00040 import org.objectweb.jonas.jmx.JonasManagementRepr;
00041 import org.objectweb.jonas.jmx.JonasObjectName;
00042 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
00043 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
00044 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
00045 
00050 public class EditResourceAdapterAction extends JonasBaseAction {
00051 
00052 // --------------------------------------------------------- Public Methods
00053 
00054     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00055         , HttpServletRequest p_Request, HttpServletResponse p_Response)
00056         throws IOException, ServletException {
00057 
00058         // Selected resource adapter
00059         String sName = p_Request.getParameter("name");
00060         if (sName == null) {
00061             sName = (String) p_Request.getAttribute("name");
00062         }
00063 
00064         // Form used
00065         ResourceAdapterForm oForm = null;
00066         // Build a new form
00067         if (sName != null) {
00068             oForm = new ResourceAdapterForm();
00069             oForm.reset(p_Mapping, p_Request);
00070             m_Session.setAttribute("resourceAdapterForm", oForm);
00071             oForm.setName(sName);
00072         }
00073         else {
00074             // Used last form in session
00075             oForm = (ResourceAdapterForm) m_Session.getAttribute("resourceAdapterForm");
00076         }
00077 
00078         // Force the node selected in tree
00079         m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR
00080             + "services" + WhereAreYou.NODE_SEPARATOR + "resourceAdapter"
00081             + WhereAreYou.NODE_SEPARATOR + oForm.getName(), true);
00082 
00083         // Populate
00084         try {
00085             if (sName != null) {
00086                 // Object name used
00087                 ObjectName oObjectName = JonasObjectName.resourceAdapter(oForm.getName());
00088                 oForm.setPath(getStringAttribute(oObjectName, "Filename"));
00089                 oForm.setFile(JonasAdminJmx.extractFilename(oForm.getPath()));
00090                 oForm.setInEar(getBooleanAttribute(oObjectName, "InEarCase"));
00091                 oForm.setEarPath((URL) JonasManagementRepr.getAttribute(oObjectName, "EarURL"));
00092                 oForm.setListProperties((Properties) JonasManagementRepr.getAttribute(oObjectName
00093                     , "Properties"));
00094             }
00095         }
00096         catch (Throwable t) {
00097             addGlobalError(t);
00098             saveErrors(p_Request, m_Errors);
00099             return (p_Mapping.findForward("Global Error"));
00100         }
00101         // Forward to the jsp.
00102         return (p_Mapping.findForward("Resource Adapter"));
00103     }
00104 }

Generated on Tue Feb 15 15:05:31 2005 for JOnAS by  doxygen 1.3.9.1