KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > joramplatform > RemoveConfirmDestinationsAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: RemoveConfirmDestinationsAction.java,v 1.2 2005/06/27 11:43:02 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
27
28 import javax.management.ObjectName JavaDoc;
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30 import javax.servlet.http.HttpServletResponse JavaDoc;
31
32 import org.apache.struts.action.ActionForm;
33 import org.apache.struts.action.ActionForward;
34 import org.apache.struts.action.ActionMapping;
35 import org.objectweb.jonas.jmx.JonasManagementRepr;
36 import org.objectweb.jonas.jmx.JonasObjectName;
37 import org.objectweb.jonas.jmx.JoramObjectName;
38 import org.objectweb.jonas.webapp.jonasadmin.deploy.BaseDeployAction;
39
40 /**
41  * @author Adriana Danes
42  */

43 public class RemoveConfirmDestinationsAction extends BaseDeployAction {
44
45     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
46         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse) {
47
48         // Form used
49
RemoveDestinationsForm oForm = (RemoveDestinationsForm) m_Session.getAttribute("removeDestinationsForm");
50         String JavaDoc localId = (String JavaDoc) m_Session.getAttribute("localId"); // Joram server to which client admin is connected
51
String JavaDoc currentId = (String JavaDoc) m_Session.getAttribute("currentId"); // Joram server currently being managed
52
try {
53             String JavaDoc destinationName = null;
54             ObjectName JavaDoc joramAdapterON = (ObjectName JavaDoc) JonasManagementRepr.queryNames(JoramObjectName.joramAdapter()).iterator().next();
55             ObjectName JavaDoc destinationObjectName = null;
56             for (int i = 0; i < oForm.getSelectedItems().length; i++) {
57                 destinationName = oForm.getSelectedItems()[i];
58                 if (currentId.equals(localId)) {
59                     String JavaDoc[] asParam = {
60                             destinationName
61                     };
62                     String JavaDoc[] asSignature = {
63                             "java.lang.String"
64                     };
65                     JonasManagementRepr.invoke(joramAdapterON, "removeDestination", asParam, asSignature);
66                 } else {
67                     destinationObjectName = JoramObjectName.joramQueue(destinationName);
68                     if (JonasManagementRepr.isRegistered(destinationObjectName)) {
69                         // the destination is a queue
70
JonasManagementRepr.invoke(destinationObjectName, "delete", null, null);
71                     } else {
72                         destinationObjectName = JoramObjectName.joramTopic(destinationName);
73                         if (JonasManagementRepr.isRegistered(destinationObjectName)) {
74                             // the destination is a topic
75
JonasManagementRepr.invoke(destinationObjectName, "delete", null, null);
76                         }
77                     }
78                 }
79             }
80             // refresh tree
81
refreshJoramTree(pRequest);
82
83         } catch (Throwable JavaDoc t) {
84             addGlobalError(t);
85             saveErrors(pRequest, m_Errors);
86             return (pMapping.findForward("Global Error"));
87         }
88
89         // Forward to action
90
return (pMapping.findForward("ActionEditJoramServer"));
91     }
92 }
93
Popular Tags