001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2004 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: EditRegistryAction.java 9764 2006-10-19 07:53:13Z durieuxp $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.jonasserver;
025:
026: import java.io.IOException;
027: import java.util.List;
028: import java.util.Vector;
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.webapp.jonasadmin.JonasAdminJmx;
039: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
040:
041: /**
042: * @author Adriana Danes <br>
043: */
044: public class EditRegistryAction extends JonasBaseAction {
045:
046: /**
047: * Execute action for registry management
048: * @param pMapping mapping info
049: * @param pForm form object
050: * @param pRequest HTTP request
051: * @param pResponse HTTP response
052: *
053: * @return An <code>ActionForward</code> instance or <code>null</code>
054: *
055: * @exception IOException if an input/output error occurs
056: * @exception ServletException if a servlet exception occurs
057: */
058: public ActionForward executeAction(ActionMapping pMapping,
059: ActionForm pForm, HttpServletRequest pRequest,
060: HttpServletResponse pResponse) throws IOException,
061: ServletException {
062:
063: // Force the node selected in tree
064: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER),
065: true);
066:
067: // Selected resource
068: String sObjectName = pRequest.getParameter("select");
069: if (sObjectName != null) {
070: try {
071: ObjectName on = ObjectName.getInstance(sObjectName);
072: JndiResourceForm oForm = new JndiResourceForm();
073: oForm
074: .setRegistryProtocol(getStringAttribute(on,
075: "Name"));
076: pRequest.setAttribute("jndiResourceForm", oForm);
077: // test if the resource corresponds to the CMI protocol
078: // in this case, the resource name is 'cmi'
079: // and we have a CMI type MBean
080: String sDomainName = m_WhereAreYou
081: .getCurrentDomainName();
082: String sServerName = m_WhereAreYou
083: .getCurrentJonasServerName();
084: boolean cmi = false;
085: ObjectName cmiOn = new ObjectName(sDomainName
086: + ":type=CMI,J2EEServer="
087: + m_WhereAreYou.getCurrentJonasServerName()
088: + ",name=CMI");
089: if (JonasAdminJmx.hasMBeanName(cmiOn, sServerName)) {
090: cmi = true;
091: }
092: if (cmi && "cmi".equals(on.getKeyProperty("name"))) {
093: List namesAndNodes = CmiRegistryResource
094: .getCmiRegistry(cmiOn, sServerName);
095: oForm.setVector(namesAndNodes);
096: } else {
097: oForm.setListNames(getListAttribute(on, "Names"));
098: }
099: } catch (Throwable t) {
100: addGlobalError(t);
101: saveErrors(pRequest, m_Errors);
102: return (pMapping.findForward("Global Error"));
103: }
104: }
105:
106: // Forward to the jsp.
107: return (pMapping.findForward("List Registry"));
108: }
109: }
|