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