KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > logging > EditLoggingJonasAction


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: EditLoggingJonasAction.java,v 1.9 2005/04/19 13:01:41 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.logging;
27
28 import java.io.IOException JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.Arrays JavaDoc;
31
32 import javax.management.ObjectName JavaDoc;
33 import javax.servlet.ServletException JavaDoc;
34 import javax.servlet.http.HttpServletRequest JavaDoc;
35 import javax.servlet.http.HttpServletResponse JavaDoc;
36
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.jmx.JonasManagementRepr;
41 import org.objectweb.jonas.jmx.JonasObjectName;
42 import org.objectweb.jonas.webapp.jonasadmin.Jlists;
43 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
44 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
45
46 /**
47  * @author Michel-Ange ANTON
48  */

49
50 public class EditLoggingJonasAction extends JonasBaseAction {
51
52 // --------------------------------------------------------- Public Methods
53

54     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
55         , HttpServletRequest JavaDoc p_Request, HttpServletResponse JavaDoc p_Response)
56         throws IOException JavaDoc, ServletException JavaDoc {
57
58         // Force the node selected in tree
59
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
60                 + WhereAreYou.NODE_SEPARATOR
61                 + "logging"
62                 + WhereAreYou.NODE_SEPARATOR
63                 + LoggerItem.LOGGER_JONAS, true);
64
65         // Form used
66
LoggingJonasForm oForm = (LoggingJonasForm) p_Form;
67         try {
68             ObjectName JavaDoc oObjectName = null;
69             oObjectName = JonasObjectName.logService("trace");
70             String JavaDoc[] asTopic = (String JavaDoc[]) JonasManagementRepr.getAttribute(oObjectName, "Topics");
71
72             ArrayList JavaDoc alTopic = new ArrayList JavaDoc(Arrays.asList(asTopic));
73             int iPos = alTopic.indexOf("root");
74             if (iPos > -1) {
75                 alTopic.remove(iPos);
76                 alTopic.add(0, "root");
77                 Object JavaDoc[] ao = alTopic.toArray();
78                 for (int i = 0; i < ao.length; i++) {
79                     asTopic[i] = ao[i].toString();
80                 }
81             }
82
83             // Search the level of each topic
84
String JavaDoc[] asParam = new String JavaDoc[1];
85             String JavaDoc[] asSignature = new String JavaDoc[1];
86             asSignature[0] = "java.lang.String";
87             String JavaDoc sLevel = null;
88             ArrayList JavaDoc al = new ArrayList JavaDoc();
89             String JavaDoc[] asLevel = new String JavaDoc[asTopic.length];
90             for (int i = 0; i < asTopic.length; i++) {
91                 asParam[0] = asTopic[i];
92                 sLevel = (String JavaDoc) JonasManagementRepr.invoke(oObjectName, "getTopicLevel", asParam
93                     , asSignature);
94                 asLevel[i] = sLevel;
95                 al.add(new TopicLevel(asTopic[i], sLevel));
96             }
97             oForm.setTopicLevelList(al);
98             oForm.setTopics(asTopic);
99             oForm.setLoggerJonasLevels(Jlists.getLoggerJonasLevels());
100         }
101         catch (Throwable JavaDoc t) {
102             addGlobalError(t);
103             saveErrors(p_Request, m_Errors);
104             return (p_Mapping.findForward("Global Error"));
105         }
106         // Forward to the jsp.
107
return (p_Mapping.findForward("Logging Jonas"));
108     }
109 }
110
Popular Tags