EditDomainAction.java

00001 
00026 package org.objectweb.jonas.webapp.jonasadmin.domain;
00027 
00028 import java.io.IOException;
00029 import java.util.ArrayList;
00030 import java.util.Collections;
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.webapp.jonasadmin.JonasBaseAction;
00042 import org.objectweb.jonas.webapp.jonasadmin.common.BeanComparator;
00043 import org.objectweb.jonas.webapp.jonasadmin.common.ObjectNameItem;
00044 
00049 public class EditDomainAction extends JonasBaseAction {
00050 
00051 // --------------------------------------------------------- Public Methods
00052 
00053     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00054         , HttpServletRequest p_Request, HttpServletResponse p_Response)
00055         throws IOException, ServletException {
00056 
00057         // Force the node selected in tree
00058         m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_DOMAIN), true);
00059         // Get servers running in this domain
00060         ObjectName onDomain = m_WhereAreYou.getCurrentDomain();
00061         ObjectName onCurrentServer = m_WhereAreYou.getCurrentJonasServer();
00062         String [] serversOn = (String[]) JonasManagementRepr.getAttribute(onDomain, "servers");
00063         ArrayList al = new ArrayList();
00064         try {
00065             String sOn = null;
00066             for (int i = 0; i < serversOn.length; i++) {
00067                 sOn = serversOn[i];
00068                 ObjectName onServer = ObjectName.getInstance(sOn);
00069                 if (!onServer.equals(onCurrentServer)) {
00070                     al.add(new ObjectNameItem(onServer));
00071                 }
00072             }
00073             Collections.sort(al, new BeanComparator(new String[] {
00074                 "name"}));
00075             p_Request.setAttribute("listServers", al);
00076             p_Request.setAttribute("currentServer", new ObjectNameItem(onCurrentServer));
00077         } catch (Throwable t) {
00078             addGlobalError(t);
00079             saveErrors(p_Request, m_Errors);
00080             return (p_Mapping.findForward("Global Error"));
00081         }
00082         // Forward to the jsp.
00083         return (p_Mapping.findForward("Domain"));
00084     }
00085 
00086 }

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