manveen 02/03/15 01:44:18 Modified: webapps/admin/WEB-INF struts-config.xml webapps/admin/WEB-INF/classes/org/apache/webapp/admin ApplicationResources_en.properties ApplicationResources_es.properties Lists.java TomcatTreeBuilder.java webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host DeleteHostsAction.java webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger LoggerForm.java Added: webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger EditLoggerAction.java SaveLoggerAction.java webapps/admin/logger logger.jsp Removed: webapps/admin logger.jsp webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger LoggerAction.java SetUpLoggerAction.java Log: refactored logger, the way "service" and "host" are handled. "edit" loggers (FileLogger, SystemErr, SystemOutLogger) in place. created a separate directory for logger jsp's. Revision Changes Path 1.36 +50 -36 jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml Index: struts-config.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- struts-config.xml 14 Mar 2002 08:49:40 -0000 1.35 +++ struts-config.xml 15 Mar 2002 09:44:17 -0000 1.36 @@ -27,10 +27,6 @@ <form-bean name="contextForm" type="org.apache.webapp.admin.context.ContextForm"/> - <!-- Logger form bean --> - <form-bean name="loggerForm" - type="org.apache.webapp.admin.logger.LoggerForm"/> - <!-- Set Locale form bean --> <form-bean name="setLocaleForm" type="org.apache.webapp.admin.SetLocaleForm"/> @@ -68,6 +64,14 @@ <form-bean name="hostsForm" type="org.apache.webapp.admin.host.HostsForm"/> + <!-- ============= Logger Module ============= --> + + <form-bean name="loggerForm" + type="org.apache.webapp.admin.logger.LoggerForm"/> + + <form-bean name="loggersForm" + type="org.apache.webapp.admin.logger.LoggersForm"/> + <!-- ========== User Database Module ========== --> <form-bean name="databaseForm" @@ -124,19 +128,7 @@ <forward name="Connector" path="/connector.jsp" redirect="false"/> - - <forward name="Host" - path="/host/host.jsp" - redirect="false"/> - <forward name="Add Host" - path="/host/addHost.jsp" - redirect="false"/> - - <forward name="Delete Host" - path="/host/deleteHost.jsp" - redirect="false"/> - <forward name="Context" path="/context.jsp" redirect="false"/> @@ -149,10 +141,6 @@ path="/blank.jsp" redirect="false"/> - <forward name="Logger" - path="/logger.jsp" - redirect="false"/> - <forward name="User" path="/user.jsp" redirect="false"/> @@ -173,7 +161,6 @@ path="/realm/userDBRealm.jsp" redirect="false"/> - <!-- ============ Service Module ============== --> <forward name="Service" @@ -194,6 +181,17 @@ path="/host/hosts.jsp" redirect="false"/> + <!-- ============ Logger Module ============== --> + + <forward name="Logger" + path="/logger/logger.jsp" + redirect="false"/> + + <forward name="Loggers" + path="/logger/loggers.jsp" + redirect="false"/> + + <!-- ========== User Database Module ========== --> <forward name="Group" @@ -291,13 +289,6 @@ scope="session"> </action> - <!-- Set up Logger datastructure --> - <action path="/setUpLogger" - type="org.apache.webapp.admin.logger.SetUpLoggerAction" - name="loggerForm" - scope="session"> - </action> - <!-- Set up Memory Realm datastructure --> <action path="/setUpMemoryRealm" type="org.apache.webapp.admin.realm.SetUpMemoryRealmAction" @@ -358,14 +349,6 @@ input="/context.jsp"> </action> - <!-- Process a logger change --> - <action path="/logger" - type="org.apache.webapp.admin.logger.LoggerAction" - name="loggerForm" - scope="session" - input="/logger.jsp"> - </action> - <!-- Process a set-locale action --> <action path="/setLocale" type="org.apache.webapp.admin.SetLocaleAction" @@ -465,6 +448,37 @@ type="org.apache.webapp.admin.host.SaveHostAction" name="hostForm" input="/host/host.jsp" + scope="session"/> + + <!-- ============= Logger Module ============== --> + + <!-- Set up Add Logger transaction --> + <action path="/AddLogger" + type="org.apache.webapp.admin.logger.AddLoggerAction"> + </action> + + <!-- Set up Delete Loggers transaction --> + <action path="/DeleteLogger" + type="org.apache.webapp.admin.logger.DeleteLoggerAction" + name="loggersForm" + scope="request"/> + + <!-- Perform Delete Loggers transaction --> + <action path="/DeleteLoggers" + type="org.apache.webapp.admin.logger.DeleteLoggersAction" + name="loggersForm" + scope="request"/> + + <!-- Set up Edit Logger transaction --> + <action path="/EditLogger" + type="org.apache.webapp.admin.logger.EditLoggerAction"> + </action> + + <!-- Perform Save Logger transaction --> + <action path="/SaveLogger" + type="org.apache.webapp.admin.logger.SaveLoggerAction" + name="loggerForm" + input="/logger/logger.jsp" scope="session"/> <!-- ========== User Database Module ========== --> 1.34 +5 -3 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_en.properties Index: ApplicationResources_en.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_en.properties,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- ApplicationResources_en.properties 14 Mar 2002 08:49:40 -0000 1.33 +++ ApplicationResources_en.properties 15 Mar 2002 09:44:18 -0000 1.34 @@ -80,8 +80,10 @@ actions.hosts.delete=Delete This Host actions.hosts.deletes=Delete Existing Hosts actions.hosts.edit=Edit Existing Host -actions.logger.create=Create New Logger -actions.logger.delete=Delete Loggers +actions.loggers.create=Create New Logger +actions.loggers.delete=Delete This Logger +actions.loggers.deletes=Delete Existing Loggers +actions.loggers.edit=Edit Existing Logger actions.requestfilter.create=Create New Request Filter actions.requestfilter.delete=Delete Request Filters actions.user.create=Create New User @@ -94,7 +96,6 @@ actions.alias.create=Create New Aliases actions.alias.delete=Delete Aliases actions.thiscontext.delete=Delete This Context -actions.thislogger.delete=Delete This Logger connector.type=Type connector.accept.count=Accept Count connector.connection.timeout=Connection Timeout @@ -145,6 +146,7 @@ logger.suffix=Suffix logger.timestamp=Timestamp logger.filelogger.properties=Filelogger specific Properties +error.loggerName.bad=Invalid logger name {0} error.directory.required=<li>Directory cannot be empty.</li> error.prefix.required=<li>Prefix cannot be empty.</li> error.suffix.required=<li>Suffix cannot be empty.</li> 1.29 +5 -3 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_es.properties Index: ApplicationResources_es.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_es.properties,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- ApplicationResources_es.properties 14 Mar 2002 08:49:40 -0000 1.28 +++ ApplicationResources_es.properties 15 Mar 2002 09:44:18 -0000 1.29 @@ -80,8 +80,10 @@ actions.hosts.delete=Eliminar este Host actions.hosts.deletes=Eliminar Hosts actions.hosts.edit=Corrija existente el Host -actions.logger.create=Crear Nuevo (Logger) Registrador -actions.logger.delete=Eliminar (Logger) Registradores +actions.loggers.create=Crear Nuevo (Logger) Registrador +actions.loggers.delete=Eliminar este Logger +actions.loggers.deletes=Eliminar (Logger) Registradores +actions.loggers.edit=Corrija existente el Logger actions.requestfilter.create=Cree El Filtro Nuevo de la Petici\u00f3n actions.requestfilter.delete=Filtros de la Petici\u00f3n de la Cancelaci\u00f3n actions.user.create=Crear Nuevo Utilizador @@ -95,7 +97,6 @@ actions.alias.create=Cree Los Nuevos Pseudonimos actions.alias.delete=Pseudonimos De la Cancelacion actions.thiscontext.delete=Suprima Este Contexto -actions.thislogger.delete=Suprima Este Logger connector.type=Tipo connector.accept.count=Valide La Cuenta connector.connection.timeout=Descanso De la Conexi\u00f3n @@ -145,6 +146,7 @@ logger.suffix=Sufijo logger.timestamp=Timestamp logger.filelogger.properties=Propiedades especificas del FileLogger +error.loggerName.bad=Invalid logger name {0} error.directory.required=<li>El directorio no puede ser vacio.</li> error.prefix.required=<li>El prefijo no puede ser vacio.</li> error.suffix.required=<li>El sufijo no puede ser vacio.</li> 1.4 +28 -5 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java Index: Lists.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Lists.java 14 Mar 2002 08:49:40 -0000 1.3 +++ Lists.java 15 Mar 2002 09:44:18 -0000 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java,v 1.3 2002/03/14 08:49:40 manveen Exp $ - * $Revision: 1.3 $ - * $Date: 2002/03/14 08:49:40 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java,v 1.4 2002/03/15 09:44:18 manveen Exp $ + * $Revision: 1.4 $ + * $Date: 2002/03/15 09:44:18 $ * * ==================================================================== * @@ -77,7 +77,7 @@ * is returned. * * @author Craig R. McClanahan - * @version $Revision: 1.3 $ $Date: 2002/03/14 08:49:40 $ + * @version $Revision: 1.4 $ $Date: 2002/03/15 09:44:18 $ */ public class Lists { @@ -114,6 +114,19 @@ } /** + * Precomputed list of verbosity level labels and values. + */ + private static List verbosityLevels = new ArrayList(); + + static { + verbosityLevels.add(new LabelValueBean("0", "0")); + verbosityLevels.add(new LabelValueBean("1", "1")); + verbosityLevels.add(new LabelValueBean("2", "2")); + verbosityLevels.add(new LabelValueBean("3", "3")); + verbosityLevels.add(new LabelValueBean("4", "4")); + } + + /** * Precomputed list of (true,false) labels and values. */ private static List booleanValues = new ArrayList(); @@ -122,7 +135,7 @@ booleanValues.add(new LabelValueBean("True", "true")); booleanValues.add(new LabelValueBean("False", "false")); } - + // --------------------------------------------------------- Public Methods @@ -133,6 +146,16 @@ public static List getDebugLevels() { return (debugLevels); + + } + + /** + * Return a <code>List</code> of {@link LabelValueBean}s for the legal + * settings for <code>verbosity</code> properties. + */ + public static List getVerbosityLevels() { + + return (verbosityLevels); } 1.20 +5 -5 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java Index: TomcatTreeBuilder.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- TomcatTreeBuilder.java 14 Mar 2002 08:49:40 -0000 1.19 +++ TomcatTreeBuilder.java 15 Mar 2002 09:44:18 -0000 1.20 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v 1.19 2002/03/14 08:49:40 manveen Exp $ - * $Revision: 1.19 $ - * $Date: 2002/03/14 08:49:40 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v 1.20 2002/03/15 09:44:18 manveen Exp $ + * $Revision: 1.20 $ + * $Date: 2002/03/15 09:44:18 $ * * ==================================================================== * @@ -96,7 +96,7 @@ * * @author Jazmin Jonson * @author Manveen Kaur - * @version $Revision: 1.19 $ $Date: 2002/03/14 08:49:40 $ + * @version $Revision: 1.20 $ $Date: 2002/03/15 09:44:18 $ */ @@ -344,7 +344,7 @@ new TreeControlNode(loggerName, "folder_16_pad.gif", nodeLabel, - "setUpLogger.do?select=" + + "EditLogger.do?select=" + URLEncoder.encode(loggerName) + "&nodeLabel=" + URLEncoder.encode(nodeLabel), 1.2 +4 -5 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host/DeleteHostsAction.java Index: DeleteHostsAction.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host/DeleteHostsAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DeleteHostsAction.java 15 Mar 2002 01:16:29 -0000 1.1 +++ DeleteHostsAction.java 15 Mar 2002 09:44:18 -0000 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host/DeleteHostsAction.java,v 1.1 2002/03/15 01:16:29 manveen Exp $ - * $Revision: 1.1 $ - * $Date: 2002/03/15 01:16:29 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host/DeleteHostsAction.java,v 1.2 2002/03/15 09:44:18 manveen Exp $ + * $Revision: 1.2 $ + * $Date: 2002/03/15 09:44:18 $ * * ==================================================================== * @@ -93,7 +93,7 @@ * transactions. * * @author Manveen Kaur - * @version $Revision: 1.1 $ $Date: 2002/03/15 01:16:29 $ + * @version $Revision: 1.2 $ $Date: 2002/03/15 09:44:18 $ */ public class DeleteHostsAction extends Action { @@ -193,7 +193,6 @@ } } catch (Exception e) { - e.printStackTrace(); getServlet().log (resources.getMessage(locale, "users.error.invoke", operation), e); 1.2 +146 -81 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/LoggerForm.java Index: LoggerForm.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/LoggerForm.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LoggerForm.java 13 Feb 2002 21:37:44 -0000 1.1 +++ LoggerForm.java 15 Mar 2002 09:44:18 -0000 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/LoggerForm.java,v 1.1 2002/02/13 21:37:44 manveen Exp $ - * $Revision: 1.1 $ - * $Date: 2002/02/13 21:37:44 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/LoggerForm.java,v 1.2 2002/03/15 09:44:18 manveen Exp $ + * $Revision: 1.2 $ + * $Date: 2002/03/15 09:44:18 $ * * ==================================================================== * @@ -67,23 +67,28 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import java.net.InetAddress; -import java.util.ArrayList; +import java.util.List; /** * Form bean for the logger page. * * @author Manveen Kaur - * @version $Revision: 1.1 $ $Date: 2002/02/13 21:37:44 $ + * @version $Revision: 1.2 $ $Date: 2002/03/15 09:44:18 $ */ public final class LoggerForm extends ActionForm { // ----------------------------------------------------- Instance Variables - + /** - * The text for the debug level. + * The administrative action represented by this form. */ - private String debugLvl = "0"; + private String adminAction = "Edit"; + + /** + * The object name of the Logger this bean refers to. + */ + private String objectName = null; /** * The text for the logger name, used to retrieve @@ -96,28 +101,18 @@ * Specifies if it is a FileLogger, or SysErr or SysOut Logger. */ private String loggerType = null; - - /** - * The text for the verbosity. - */ - private String verbosityLvl = null; - + /** - * Set of valid values for debug level. + * The text for the debug level. */ - private ArrayList debugLvlVals = null; + private String debugLvl = "0"; /** - * Set of valid values for verbosity level. + * The text for the verbosity. */ - private ArrayList verbosityLvlVals = null; - - /* - * Represent boolean (true, false) values for timestamp. - */ - private ArrayList booleanVals = null; + private String verbosityLvl = null; - /** + /** * The text for the directory. */ private String directory = null; @@ -142,9 +137,50 @@ */ private String nodeLabel = null; + private List debugLvlVals = null; + private List verbosityLvlVals = null; + private List booleanVals = null; // ------------------------------------------------------------- Properties + /** + * Return the administrative action represented by this form. + */ + public String getAdminAction() { + + return this.adminAction; + + } + + + /** + * Set the administrative action represented by this form. + */ + public void setAdminAction(String adminAction) { + + this.adminAction = adminAction; + + } + + /** + * Return the object name of the Logger this bean refers to. + */ + public String getObjectName() { + + return this.objectName; + + } + + + /** + * Set the object name of the Logger this bean refers to. + */ + public void setObjectName(String objectName) { + + this.objectName = objectName; + + } + /** * Return the Logger Name. */ @@ -198,44 +234,7 @@ this.verbosityLvl = verbosityLvl; } - - /** - * Return the debugVals. - */ - public ArrayList getDebugLvlVals() { - - return this.debugLvlVals; - - } - - /** - * Set the debugVals. - */ - public void setDebugLvlVals(ArrayList debugLvlVals) { - - this.debugLvlVals = debugLvlVals; - - } - - - /** - * Return the verbosityLvl Vals. - */ - public ArrayList getVerbosityLvlVals() { - - return this.verbosityLvlVals; - - } - - /** - * Set the verbosityLvl Vals. - */ - public void setVerbosityLvlVals(ArrayList verbosityLvlVals) { - - this.verbosityLvlVals = verbosityLvlVals; - } - /** * Return the Debug Level Text. */ @@ -255,24 +254,6 @@ } /** - * Return the booleanVals. - */ - public ArrayList getBooleanVals() { - - return this.booleanVals; - - } - - /** - * Set the debugVals. - */ - public void setBooleanVals(ArrayList booleanVals) { - - this.booleanVals = booleanVals; - - } - - /** * Return the directory. */ public String getDirectory() { @@ -361,6 +342,61 @@ } + /** + * Return the debugVals. + */ + public List getDebugLvlVals() { + + return this.debugLvlVals; + + } + + /** + * Set the debugVals. + */ + public void setDebugLvlVals(List debugLvlVals) { + + this.debugLvlVals = debugLvlVals; + + } + + + /** + * Return the verbosity level values. + */ + public List getVerbosityLvlVals() { + + return this.verbosityLvlVals; + + } + + /** + * Set the verbosity level values. + */ + public void setVerbosityLvlVals(List verbosityLvlVals) { + + this.verbosityLvlVals = verbosityLvlVals; + + } + + /** + * Return the booleanVals. + */ + public List getBooleanVals() { + + return this.booleanVals; + + } + + /** + * Set the booleanVals. + */ + public void setBooleanVals(List booleanVals) { + + this.booleanVals = booleanVals; + + } + // --------------------------------------------------------- Public Methods /** @@ -371,10 +407,11 @@ */ public void reset(ActionMapping mapping, HttpServletRequest request) { - //FIX ME -- is this needed for debug and verbosity? + this.objectName = null; + this.loggerName = null; + this.loggerType = null; this.debugLvl = "0"; - this.verbosityLvl = "0"; - + this.verbosityLvl = "0"; this.directory = null; this.prefix = null; this.suffix = null; @@ -382,6 +419,34 @@ } + /** + * Render this object as a String. + */ + public String toString() { + + StringBuffer sb = new StringBuffer("LoggerForm[adminAction="); + sb.append(adminAction); + sb.append(",debugLvl="); + sb.append(debugLvl); + sb.append("verbosityLvl,="); + sb.append(verbosityLvl); + sb.append(",directory="); + sb.append(directory); + sb.append(",prefix='"); + sb.append(prefix); + sb.append(",suffix='"); + sb.append(suffix); + sb.append(",loggerType='"); + sb.append(loggerType); + sb.append("',objectName='"); + sb.append(objectName); + sb.append("',loggerName="); + sb.append(loggerName); + sb.append("]"); + return (sb.toString()); + + } + /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/EditLoggerAction.java Index: EditLoggerAction.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/EditLoggerAction.java,v 1.1 2002/03/15 09:44:18 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/03/15 09:44:18 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.webapp.admin.logger; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.Action; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; import javax.management.MBeanServer; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.JMException; import org.apache.webapp.admin.ApplicationServlet; import org.apache.webapp.admin.LabelValueBean; import org.apache.webapp.admin.Lists; import org.apache.webapp.admin.TomcatTreeBuilder; /** * The <code>Action</code> that sets up <em>Edit Logger</em> transactions. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/03/15 09:44:18 $ */ public class EditLoggerAction extends Action { /** * The MBeanServer we will be interacting with. */ private MBeanServer mBServer = null; /** * The MessageResources we will be retrieving messages from. */ private MessageResources resources = null; // --------------------------------------------------------- Public Methods /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Acquire the resources that we need HttpSession session = request.getSession(); Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY); if (resources == null) { resources = getServlet().getResources(); } // Acquire a reference to the MBeanServer containing our MBeans try { mBServer = ((ApplicationServlet) getServlet()).getServer(); } catch (Throwable t) { throw new ServletException ("Cannot acquire MBeanServer reference", t); } // Set up the object names of the MBeans we are manipulating ObjectName lname = null; StringBuffer sb = null; try { lname = new ObjectName(request.getParameter("select")); } catch (Exception e) { String message = resources.getMessage("error.loggerName.bad", request.getParameter("select")); getServlet().log(message); response.sendError(HttpServletResponse.SC_BAD_REQUEST, message); return (null); } // Fill in the form values for display and editing LoggerForm loggerFm = new LoggerForm(); session.setAttribute("loggerForm", loggerFm); loggerFm.setAdminAction("Edit"); loggerFm.setObjectName(lname.toString()); sb = new StringBuffer("Logger ("); // FIX ME sb.append(lname.getKeyProperty("className")); sb.append(")"); loggerFm.setNodeLabel(sb.toString()); // FIX ME loggerFm.setLoggerName("Logger"); loggerFm.setDebugLvlVals(Lists.getDebugLevels()); loggerFm.setVerbosityLvlVals(Lists.getVerbosityLevels()); loggerFm.setBooleanVals(Lists.getBooleanValues()); String attribute = null; try { // Copy scalar properties // Calculate the type of logger we are managing attribute = "className"; String className = (String) mBServer.getAttribute(lname, attribute); int period = className.lastIndexOf('.'); String loggerType = className.substring(period + 1); loggerFm.setLoggerType(loggerType); attribute = "debug"; loggerFm.setDebugLvl (((Integer) mBServer.getAttribute(lname, attribute)).toString()); attribute = "verbosity"; loggerFm.setVerbosityLvl (((Integer) mBServer.getAttribute(lname, attribute)).toString()); if ("FileLogger".equals(loggerType)) { // Initialize rest of variables. attribute = "directory"; loggerFm.setDirectory ((String) mBServer.getAttribute(lname, attribute)); attribute = "prefix"; loggerFm.setPrefix ((String) mBServer.getAttribute(lname, attribute)); attribute = "suffix"; loggerFm.setSuffix ((String) mBServer.getAttribute(lname, attribute)); attribute = "timestamp"; loggerFm.setTimestamp (((Boolean) mBServer.getAttribute(lname, attribute)).toString()); } } catch (Throwable t) { getServlet().log (resources.getMessage(locale, "users.error.attribute.get", attribute), t); response.sendError (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, resources.getMessage(locale, "users.error.attribute.get", attribute)); return (null); } // Forward to the logger display page return (mapping.findForward("Logger")); } } 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/SaveLoggerAction.java Index: SaveLoggerAction.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/logger/SaveLoggerAction.java,v 1.1 2002/03/15 09:44:18 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/03/15 09:44:18 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.webapp.admin.logger; import java.net.URLEncoder; import java.util.Iterator; import java.util.Locale; import java.io.IOException; import javax.management.Attribute; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.QueryExp; import javax.management.Query; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.JMException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; import org.apache.webapp.admin.ApplicationServlet; import org.apache.webapp.admin.TomcatTreeBuilder; import org.apache.webapp.admin.TreeControl; import org.apache.webapp.admin.TreeControlNode; /** * The <code>Action</code> that completes <em>Add Logger</em> and * <em>Edit Logger</em> transactions. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/03/15 09:44:18 $ */ public final class SaveLoggerAction extends Action { // ----------------------------------------------------- Instance Variables /** * Signature for the <code>createStandardLogger</code> operation. */ private String createStandardLoggerTypes[] = { "java.lang.String", // parent "java.lang.String", // name }; /** * The MBeanServer we will be interacting with. */ private MBeanServer mBServer = null; /** * The MessageResources we will be retrieving messages from. */ private MessageResources resources = null; // --------------------------------------------------------- Public Methods /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Acquire the resources that we need HttpSession session = request.getSession(); Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY); if (resources == null) { resources = getServlet().getResources(); } // Acquire a reference to the MBeanServer containing our MBeans try { mBServer = ((ApplicationServlet) getServlet()).getServer(); } catch (Throwable t) { throw new ServletException ("Cannot acquire MBeanServer reference", t); } // Identify the requested action LoggerForm lform = (LoggerForm) form; String adminAction = lform.getAdminAction(); String lObjectName = lform.getObjectName(); // Perform a "Create Logger" transaction (if requested) if ("Create".equals(adminAction)) { String operation = null; String values[] = null; try { // Ensure that the requested logger name is unique ObjectName oname = new ObjectName(TomcatTreeBuilder.LOGGER_TYPE + ",className=" + lform.getLoggerName()); if (mBServer.isRegistered(oname)) { ActionErrors errors = new ActionErrors(); errors.add("loggerName", new ActionError("error.loggerName.exists")); saveErrors(request, errors); return (new ActionForward(mapping.getInput())); } // Look up our MBeanFactory MBean ObjectName fname = new ObjectName(TomcatTreeBuilder.FACTORY_TYPE); // Create a new StandardLogger object values = new String[2]; values[0] = TomcatTreeBuilder.SERVER_TYPE; values[1] = lform.getLoggerName(); operation = "createStandardLogger"; lObjectName = (String) mBServer.invoke(fname, operation, values, createStandardLoggerTypes); // Add the new Logger to our tree control node TreeControl control = (TreeControl) session.getAttribute("treeControlTest"); if (control != null) { String parentName = TomcatTreeBuilder.SERVER_TYPE; TreeControlNode parentNode = control.findNode(parentName); if (parentNode != null) { String nodeLabel = "Logger (" + lform.getLoggerName() + ")"; String encodedName = URLEncoder.encode(lObjectName); TreeControlNode childNode = new TreeControlNode(lObjectName, "folder_16_pad.gif", nodeLabel, "EditLogger.do?select=" + encodedName, "content", true); parentNode.addChild(childNode); // FIXME - force a redisplay } else { getServlet().log ("Cannot find parent node '" + parentName + "'"); } } else { getServlet().log ("Cannot find TreeControlNode!"); } } catch (Exception e) { getServlet().log (resources.getMessage(locale, "users.error.invoke", operation), e); response.sendError (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, resources.getMessage(locale, "users.error.invoke", operation)); return (null); } } // Perform attribute updates as requested String attribute = null; try { ObjectName loname = new ObjectName(lObjectName); attribute = "debug"; int debug = 0; try { debug = Integer.parseInt(lform.getDebugLvl()); } catch (Throwable t) { debug = 0; } mBServer.setAttribute(loname, new Attribute("debug", new Integer(debug))); attribute = "debug"; int verbosity = 0; try { verbosity = Integer.parseInt(lform.getVerbosityLvl()); } catch (Throwable t) { verbosity = 0; } mBServer.setAttribute(loname, new Attribute("verbosity", new Integer(verbosity))); String loggerType = lform.getLoggerType(); if("FileLogger".equalsIgnoreCase(loggerType)) { attribute = "directory"; mBServer.setAttribute(loname, new Attribute("directory", lform.getDirectory())); attribute = "prefix"; mBServer.setAttribute(loname, new Attribute("prefix", lform.getPrefix())); attribute = "suffix"; mBServer.setAttribute(loname, new Attribute("suffix", lform.getSuffix())); attribute = "timestamp"; /* String timestamp = "false"; try { timestamp = lform.getTimestamp(); } catch (Throwable t) { timestamp = "false"; } */ mBServer.setAttribute(loname, new Attribute("timestamp", new Boolean(lform.getTimestamp())));; } } catch (Exception e) { getServlet().log (resources.getMessage(locale, "users.error.attribute.set", attribute), e); response.sendError (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, resources.getMessage(locale, "users.error.attribute.set", attribute)); return (null); } // Forward to the success reporting page session.removeAttribute(mapping.getAttribute()); return (mapping.findForward("Save Successful")); } } 1.1 jakarta-tomcat-4.0/webapps/admin/logger/logger.jsp Index: logger.jsp =================================================================== <!-- Standard Struts Entries --> <%@ page language="java" import="java.net.URLEncoder" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/controls.tld" prefix="controls" %> <html:html locale="true"> <%@ include file="../users/header.jsp" %> <!-- Body --> <body bgcolor="white"> <!--Form --> <html:errors/> <html:form method="POST" action="/SaveLogger"> <bean:define id="loggerName" name="loggerForm" property="loggerName"/> <bean:define id="thisObjectName" type="java.lang.String" name="loggerForm" property="objectName"/> <html:hidden property="adminAction"/> <html:hidden property="objectName"/> <html:hidden property="loggerType"/> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="7171A5"> <td width="81%"> <div class="page-title-text" align="left"> <logic:equal name="loggerForm" property="adminAction" value="Create"> <bean:message key="actions.loggers.create"/> </logic:equal> <logic:equal name="loggerForm" property="adminAction" value="Edit"> <bean:message key="actions.loggers.edit"/> </logic:equal> </div> </td> <td width="19%"> <div align="right"> <controls:actions> <controls:action selected="true"> ----<bean:message key="actions.available.actions"/>---- </controls:action> <controls:action disabled="true"> --------------------------------- </controls:action> <%-- <controls:action url='<%= "/DeleteLogger.do?select=" + URLEncoder.encode(thisObjectName) %>'> <bean:message key="actions.loggers.delete"/> </controls:action> --%> </controls:actions> </div> </td> </tr> </table> <%@ include file="../buttons.jsp" %> <br> <table class="back-table" border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> <controls:table tableStyle="front-table" lineStyle="line-row"> <controls:row header="true" labelStyle="table-header-text" dataStyle="table-header-text"> <controls:label><bean:message key="service.property"/></controls:label> <controls:data><bean:message key="service.value"/></controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="connector.type"/>:</controls:label> <controls:data> <bean:write name="loggerForm" property="loggerType" scope="session"/> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="server.debuglevel"/>:</controls:label> <controls:data> <html:select property="debugLvl"> <bean:define id="debugLvlVals" name="loggerForm" property="debugLvlVals"/> <html:options collection="debugLvlVals" property="value" labelProperty="label"/> </html:select> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label>Verbosity Level:</controls:label> <controls:data> <html:select property="verbosityLvl"> <bean:define id="verbosityLvlVals" name="loggerForm" property="verbosityLvlVals"/> <html:options collection="verbosityLvlVals" property="value" labelProperty="label"/> </html:select> </controls:data> </controls:row> </controls:table> </td> </tr> </table> <%-- Display the following fields only if it is a FileLogger --%> <%-- These are the properties specific to a FileLogger --%> <logic:equal name="loggerForm" property="loggerType" scope="session" value="FileLogger"> <br> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> <div class="table-title-text"> <bean:message key="logger.filelogger.properties"/> </div> </td> </tr> </table> <table class="back-table" border="0" cellspacing="0" cellpadding="1" width="100%"> <tr> <td> <controls:table tableStyle="front-table" lineStyle="line-row"> <controls:row header="true" labelStyle="table-header-text" dataStyle="table-header-text"> <controls:label><bean:message key="service.property"/></controls:label> <controls:data><bean:message key="service.value"/></controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="logger.directory"/>:</controls:label> <controls:data> <html:text property="directory" size="25"/> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="logger.prefix"/>:</controls:label> <controls:data> <html:text property="prefix" size="25"/> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="logger.suffix"/>:</controls:label> <controls:data> <html:text property="suffix" size="15"/> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="logger.timestamp"/>:</controls:label> <controls:data> <html:select property="timestamp"> <bean:define id="booleanVals" name="loggerForm" property="booleanVals"/> <html:options collection="booleanVals" property="value" labelProperty="label"/> </html:select> </controls:data> </controls:row> </controls:table> </td> </tr> </table> </logic:equal> <%@ include file="../buttons.jsp" %> <br> </html:form> <p> </p> </body> </html:html>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>