KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > EditTopAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 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: EditTopAction.java,v 1.8 2005/05/13 12:34:44 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin;
27
28 import java.io.IOException JavaDoc;
29 import java.util.ArrayList JavaDoc;
30
31 import javax.servlet.ServletException JavaDoc;
32 import javax.servlet.http.HttpServletRequest JavaDoc;
33 import javax.servlet.http.HttpServletResponse JavaDoc;
34
35 import org.apache.struts.Globals;
36 import org.apache.struts.action.ActionErrors;
37 import org.apache.struts.action.ActionForm;
38 import org.apache.struts.action.ActionForward;
39 import org.apache.struts.action.ActionMapping;
40 import org.objectweb.jonas.common.Log;
41 import org.objectweb.jonas.jmx.JonasManagementRepr;
42 import org.objectweb.util.monolog.api.BasicLevel;
43 import org.objectweb.util.monolog.api.Logger;
44
45 /**
46  * Test <code>Action</code> that handles events from the tree control test
47  * page.
48  * @author Michel-Ange Anton (initial developer)<br>
49  * @author Florent Benoit (changes for struts 1.2.2)
50  */

51
52 public class EditTopAction extends JonasBaseAction {
53
54 // --------------------------------------------------------- Public Methods
55

56     /**
57      * Process the specified HTTP request, and create the corresponding HTTP
58      * response (or forward to another web component that will create it).
59      * Return an <code>ActionForward</code> instance describing where and how
60      * control should be forwarded, or <code>null</code> if the response has
61      * already been completed.
62      *
63      * @param mapping The ActionMapping used to select this instance
64      * @param actionForm The optional ActionForm bean for this request (if any)
65      * @param request The HTTP request we are processing
66      * @param response The HTTP response we are creating
67      *
68      * @exception IOException if an input/output error occurs
69      * @exception ServletException if a servlet exception occurs
70      */

71     public ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request
72         , HttpServletResponse JavaDoc response)
73         throws IOException JavaDoc, ServletException JavaDoc {
74
75         // Test if force to reload all the frames
76
ActionErrors oActionErrors = (ActionErrors) request.getAttribute(Globals.ERROR_KEY);
77         if (oActionErrors != null) {
78             request.setAttribute("errorServerSelect", new Boolean JavaDoc(true));
79         }
80         else {
81             String JavaDoc sFirstCall = request.getParameter("firstCall");
82             if (sFirstCall == null) {
83                 request.setAttribute("reloadAll", new Boolean JavaDoc(true));
84             }
85         }
86
87         // Form used
88
TopForm topFm = new TopForm();
89         request.setAttribute("topForm", topFm);
90         try {
91             topFm.setServerSelect(JonasManagementRepr.getCurrentRMIConnectorName());
92             ArrayList JavaDoc al = JonasAdminJmx.getListRemoteJonasServerItem(request);
93             request.setAttribute("serverList", al);
94         }
95         catch (Throwable JavaDoc t) {
96             String JavaDoc message = "Problem when accessing to JOnAS ! : " + t.getMessage();
97             //getServlet().log(message, t);
98
Logger logger = Log.getLogger(Log.JONAS_ADMIN_PREFIX);
99             if (logger.isLoggable(BasicLevel.DEBUG)) {
100                 logger.log(BasicLevel.DEBUG, message);
101             }
102             response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
103             return (null);
104         }
105
106         // Forward to the jsp.
107
return (mapping.findForward("Top"));
108     }
109
110 }
111
Popular Tags