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: *
021: * --------------------------------------------------------------------------
022: * $Id: RemoveConfirmDestinationsAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
025:
026: import java.util.Set;
027:
028: import javax.management.InstanceNotFoundException;
029: import javax.management.ObjectName;
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.deploy.BaseDeployAction;
039:
040: /**
041: * @author Adriana Danes
042: */
043: public class RemoveConfirmDestinationsAction extends BaseDeployAction {
044:
045: public ActionForward executeAction(ActionMapping pMapping,
046: ActionForm pForm, HttpServletRequest pRequest,
047: HttpServletResponse pResponse) {
048:
049: // Current JOnAS server
050: String jonasServerName = m_WhereAreYou
051: .getCurrentJonasServerName();
052:
053: // Form used
054: RemoveDestinationsForm oForm = (RemoveDestinationsForm) m_Session
055: .getAttribute("removeDestinationsForm");
056: String localId = (String) m_Session.getAttribute("localId"); // Joram server to which client admin is connected
057: String currentId = (String) m_Session.getAttribute("currentId"); // Joram server currently being managed
058: try {
059: String destinationName = null;
060: Set adapterOns = JonasManagementRepr.queryNames(
061: JoramObjectName.joramAdapter(), jonasServerName);
062: if (adapterOns.isEmpty()) {
063: throw new InstanceNotFoundException();
064: }
065: ObjectName joramAdapterON = (ObjectName) adapterOns
066: .iterator().next();
067: ObjectName destinationObjectName = null;
068: for (int i = 0; i < oForm.getSelectedItems().length; i++) {
069: destinationName = oForm.getSelectedItems()[i];
070: if (currentId.equals(localId)) {
071: String[] asParam = { destinationName };
072: String[] asSignature = { "java.lang.String" };
073: JonasManagementRepr.invoke(joramAdapterON,
074: "removeDestination", asParam, asSignature,
075: jonasServerName);
076: } else {
077: destinationObjectName = JoramObjectName
078: .joramQueue(destinationName);
079: if (JonasManagementRepr.isRegistered(
080: destinationObjectName, jonasServerName)) {
081: // the destination is a queue
082: JonasManagementRepr.invoke(
083: destinationObjectName, "delete", null,
084: null, jonasServerName);
085: } else {
086: destinationObjectName = JoramObjectName
087: .joramTopic(destinationName);
088: if (JonasManagementRepr.isRegistered(
089: destinationObjectName, jonasServerName)) {
090: // the destination is a topic
091: JonasManagementRepr.invoke(
092: destinationObjectName, "delete",
093: null, null, jonasServerName);
094: }
095: }
096: }
097: }
098: // refresh tree
099: refreshJoramTree(pRequest, currentId);
100:
101: } catch (Throwable t) {
102: addGlobalError(t);
103: saveErrors(pRequest, m_Errors);
104: return (pMapping.findForward("Global Error"));
105: }
106:
107: // Forward to action
108: return (pMapping.findForward("ActionEditJoramServer"));
109: }
110: }
|