1 21 22 package org.objectweb.jonas.webapp.jonasadmin.joramplatform; 23 24 import java.io.IOException ; 25 import java.util.ArrayList ; 26 import java.util.Collections ; 27 import java.util.Iterator ; 28 import java.util.List ; 29 30 import javax.management.ObjectName ; 31 import javax.servlet.ServletException ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 import org.apache.struts.action.ActionForm; 36 import org.apache.struts.action.ActionForward; 37 import org.apache.struts.action.ActionMapping; 38 import org.objectweb.jonas.jmx.JonasManagementRepr; 39 import org.objectweb.jonas.jmx.JoramObjectName; 40 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx; 41 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 42 43 46 47 public class EditJoramServerAction extends EditJoramBaseAction { 48 49 51 public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm 52 , HttpServletRequest pRequest, HttpServletResponse pResponse) 53 throws IOException , ServletException { 54 55 String id = pRequest.getParameter("id"); 57 if (id == null) { 58 id = (String ) m_Session.getAttribute("currentId"); 59 } else { 60 m_Session.setAttribute("currentId", id); 61 } 62 String localId = (String ) m_Session.getAttribute("localId"); 63 boolean isLocalServer; 64 if (localId.equals(id)) { 65 isLocalServer = true; 66 } else { 67 isLocalServer = false; 68 } 69 70 m_Session.setAttribute("isLocalServer", new Boolean (isLocalServer)); 71 initRefs(); 74 75 try { 76 ObjectName joramAdapterON = (ObjectName ) JonasManagementRepr.queryNames(JoramObjectName.joramAdapter()).iterator().next(); 77 boolean isAdapterLoaded = JonasManagementRepr.isRegistered(joramAdapterON); 78 ObjectName joramAdminON = JoramObjectName.joramAdmin(); 79 80 ArrayList destinationsArray = new ArrayList (); 81 ArrayList topicsArray = new ArrayList (); 82 Iterator destinationsList = ((List ) JonasManagementRepr.getAttribute(joramAdminON, "Destinations")).iterator(); 83 for (; destinationsList.hasNext(); ) { 84 String destinationString = (String ) destinationsList.next(); 85 ItemDestination destinationItem = getDestinationItem(destinationString); 86 if (destinationItem.getServerId().equals(id) && 87 destinationItem.getOn() != null) { 88 if (destinationItem.getType().equals("queue")) { 90 destinationsArray.add(destinationItem); 91 } else if (destinationItem.getType().equals("topic")) { 92 topicsArray.add(destinationItem); 93 } 94 } 96 } 97 Collections.sort(destinationsArray, new ItemDestinationByName()); 99 Collections.sort(topicsArray, new ItemDestinationByName()); 101 destinationsArray.addAll(topicsArray); 103 104 ArrayList usersArray = new ArrayList (); 105 Iterator usersList; 106 if (isLocalServer) { 107 usersList = ((List ) JonasManagementRepr.getAttribute(joramAdapterON, "LocalUsers")).iterator(); 108 } else { 109 usersList = ((List ) JonasManagementRepr.getAttribute(joramAdminON, "Users")).iterator(); 110 } 111 for (;usersList.hasNext();) { 112 String userString = (String ) usersList.next(); 113 ItemUser userItem = getUserItem(userString); 114 String name = userItem.getName(); 115 if (name != null) { 116 usersArray.add(userItem); 117 } 119 } 120 121 m_Session.setAttribute("destinations", destinationsArray); 122 m_Session.setAttribute("users", usersArray); 123 } catch (Throwable t) { 124 return (treatError(t, pMapping, pRequest)); 125 } 126 127 String nodeName = null; 129 if (isLocalServer) { 130 nodeName = getTreeBranchName(DEPTH_DOMAIN) + WhereAreYou.NODE_SEPARATOR 131 + "joramplatform" + WhereAreYou.NODE_SEPARATOR 132 + "joramlocalserver"; 133 } else { 134 nodeName = getTreeBranchName(DEPTH_DOMAIN) + WhereAreYou.NODE_SEPARATOR 135 + "joramplatform" + WhereAreYou.NODE_SEPARATOR 136 + "joramremoteserver" + id; 137 } 138 m_WhereAreYou.selectNameNode(nodeName, true); 139 140 return (pMapping.findForward("JoramDestinations")); 142 } 143 144 } 145 | Popular Tags |