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: */package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
021:
022: import java.io.IOException;
023: import java.util.ArrayList;
024: import java.util.Collections;
025: import java.util.Iterator;
026: import java.util.List;
027:
028: import javax.management.ObjectName;
029: import javax.servlet.ServletException;
030: import javax.servlet.http.HttpServletRequest;
031: import javax.servlet.http.HttpServletResponse;
032:
033: import org.apache.struts.action.ActionForm;
034: import org.apache.struts.action.ActionForward;
035: import org.apache.struts.action.ActionMapping;
036: import org.objectweb.jonas.jmx.JonasManagementRepr;
037: import org.objectweb.jonas.jmx.JoramObjectName;
038: import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
039: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
040:
041: /**
042: * @author Frederic MAISTRE
043: * @author Adriana Danes
044: */
045:
046: public class EditJoramLocalServerAction extends EditJoramBaseAction {
047:
048: // --------------------------------------------------------- Public Methods
049:
050: public ActionForward executeAction(ActionMapping pMapping,
051: ActionForm pForm, HttpServletRequest pRequest,
052: HttpServletResponse pResponse) throws IOException,
053: ServletException {
054:
055: // Current JOnAS server
056: String serverName = m_WhereAreYou.getCurrentJonasServerName();
057:
058: String id = pRequest.getParameter("id");
059:
060: // Get reference on EJB container service in order to determine dependencies
061: // between the deployed EJBs and JMS destinations
062: initRefs(serverName);
063:
064: // Force the node selected in tree
065: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_DOMAIN)
066: + WhereAreYou.NODE_SEPARATOR + "joramplatform"/* + WhereAreYou.NODE_SEPARATOR
067: + "joramlocalserver"*/, true);
068:
069: try {
070: ObjectName joramAdapterON = (ObjectName) JonasManagementRepr
071: .queryNames(JoramObjectName.joramAdapter(),
072: serverName).iterator().next();
073: boolean isAdapterLoaded = JonasManagementRepr.isRegistered(
074: joramAdapterON, serverName);
075: ObjectName joramAdminON = JoramObjectName.joramAdmin();
076:
077: ArrayList destinationsArray = new ArrayList();
078: Iterator destinationsList = ((List) JonasManagementRepr
079: .getAttribute(joramAdminON, "Destinations",
080: serverName)).iterator();
081: for (; destinationsList.hasNext();) {
082: String destinationString = (String) destinationsList
083: .next();
084: ItemDestination destinationItem = getDestinationItem(
085: destinationString, serverName);
086: ObjectName destOn = destinationItem.getOn();
087: if (destOn != null) {
088: destinationsArray.add(destinationItem);
089: //printDestination(destinationItem);
090: }
091: }
092: Iterator usersList = ((List) JonasManagementRepr
093: .getAttribute(joramAdapterON, "LocalUsers",
094: serverName)).iterator();
095: for (; usersList.hasNext();) {
096: String destinationString = (String) usersList.next();
097: }
098:
099: Collections.sort(destinationsArray,
100: new ItemDestinationByName());
101: m_Session.setAttribute("destinations", destinationsArray);
102: } catch (Throwable t) {
103: return (treatError(t, pMapping, pRequest));
104: }
105:
106: // Forward to the jsp.
107: return (pMapping.findForward("JoramLocalDestinations"));
108: }
109:
110: }
|