manveen     02/04/04 13:52:25

  Modified:    webapps/admin/WEB-INF struts-config.xml
               webapps/admin/WEB-INF/classes/org/apache/webapp/admin
                        TomcatTreeBuilder.java
               webapps/admin/service service.jsp
  Added:       webapps/admin/WEB-INF/classes/org/apache/webapp/admin/server
                        EditServerAction.java SaveServerAction.java
                        ServerForm.java
               webapps/admin/server server.jsp
  Log:
  Refactored server to match service,host, connector...
  
  Revision  Changes    Path
  1.42      +27 -25    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.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- struts-config.xml 3 Apr 2002 00:27:30 -0000       1.41
  +++ struts-config.xml 4 Apr 2002 21:52:25 -0000       1.42
  @@ -15,14 +15,15 @@
   
     <form-beans>
   
  -    <!-- Server form bean -->
  -    <form-bean      name="serverForm"
  -                    type="org.apache.webapp.admin.ServerForm"/>
  -                    
       <!-- Set Locale form bean -->
       <form-bean      name="setLocaleForm"
                       type="org.apache.webapp.admin.SetLocaleForm"/>
   
  +    <!-- ============= Server Module ============= -->
  +
  +    <form-bean      name="serverForm"
  +                    type="org.apache.webapp.admin.server.ServerForm"/>
  +                    
       <!-- ============= Service Module ============= -->
   
       <form-bean      name="serviceForm"
  @@ -78,7 +79,7 @@
                       type="org.apache.webapp.admin.connector.ConnectorForm"/>
                       
       <form-bean      name="connectorsForm"
  -                    type="org.apache.webapp.admin.host.ConnectorsForm"/>
  +                    type="org.apache.webapp.admin.connector.ConnectorsForm"/>
   
       <!-- ========== User Database Module ========== -->
   
  @@ -128,11 +129,7 @@
       <forward        name="Tree Control Test"
                       path="/tree-control-test.jsp"
                   redirect="false"/>
  -
  -    <forward        name="Server"
  -                    path="/server.jsp"
  -                redirect="false"/>
  -                   
  +                  
       <forward        name="Save Successful"
                       path="/saved.jsp"
                   redirect="false"/>
  @@ -145,6 +142,12 @@
                       path="/user.jsp"
                   redirect="false"/>
   
  +    <!-- ============ Server Module ============== -->
  +
  +    <forward        name="Server"
  +                    path="/server/server.jsp"
  +                redirect="false"/>
  +    
       <!-- ============ Service Module ============== -->
   
       <forward        name="Service"
  @@ -303,13 +306,6 @@
                     redirect="true"/>
       </action>
   
  -    <!-- Set up Edit Server transaction -->
  -    <action    path="/setUpServer"
  -               type="org.apache.webapp.admin.SetUpServerAction"
  -               name="serverForm"
  -               scope="session">
  -    </action>
  -
       <!-- Log out of the application -->
       <action    path="/logOut"
                  type="org.apache.webapp.admin.LogOutAction">
  @@ -318,14 +314,6 @@
                     redirect="true"/>
       </action>
   
  -    <!-- Process a user server change -->
  -    <action    path="/server"
  -               type="org.apache.webapp.admin.ServerAction"
  -               name="serverForm"
  -              scope="session"
  -              input="/server.jsp">
  -    </action>
  -    
       <!-- Process a set-locale action -->
       <action    path="/setLocale"
                  type="org.apache.webapp.admin.SetLocaleAction"
  @@ -336,6 +324,20 @@
       <!-- Tree control test action -->
       <action    path="/treeControlTest"
                  type="org.apache.webapp.admin.TreeControlTestAction"/>
  +
  +   <!-- ============= Server Module ============== -->
  +
  +    <!-- Set up Edit Server transaction -->
  +    <action    path="/EditServer"
  +               type="org.apache.webapp.admin.server.EditServerAction">
  +    </action>
  +
  +    <!-- Perform Save Server transaction -->
  +    <action    path="/SaveServer"
  +               type="org.apache.webapp.admin.server.SaveServerAction"
  +               name="serverForm"
  +              input="/server/server.jsp"
  +               scope="session"/>
   
       <!-- ============= Service Module ============== -->
   
  
  
  
  1.25      +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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- TomcatTreeBuilder.java    3 Apr 2002 00:27:30 -0000       1.24
  +++ TomcatTreeBuilder.java    4 Apr 2002 21:52:25 -0000       1.25
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v
 1.24 2002/04/03 00:27:30 manveen Exp $
  - * $Revision: 1.24 $
  - * $Date: 2002/04/03 00:27:30 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v
 1.25 2002/04/04 21:52:25 manveen Exp $
  + * $Revision: 1.25 $
  + * $Date: 2002/04/04 21:52:25 $
    *
    * ====================================================================
    *
  @@ -93,7 +93,7 @@
    *
    * @author Jazmin Jonson
    * @author Manveen Kaur
  - * @version $Revision: 1.24 $ $Date: 2002/04/03 00:27:30 $
  + * @version $Revision: 1.25 $ $Date: 2002/04/04 21:52:25 $
    */
   
   
  @@ -164,7 +164,7 @@
                   new TreeControlNode(serverName,
                                       "folder_16_pad.gif",
                                       nodeLabel,
  -                                    "setUpServer.do?select=" +
  +                                    "EditServer.do?select=" +
                                       URLEncoder.encode(serverName) +
                                       "&nodeLabel=" +
                                       URLEncoder.encode(nodeLabel),
  
  
  
  1.1                  
jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/server/EditServerAction.java
  
  Index: EditServerAction.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/server/EditServerAction.java,v
 1.1 2002/04/04 21:52:25 manveen Exp $
   * $Revision: 1.1 $
   * $Date: 2002/04/04 21:52:25 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 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.server;
  
  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 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.management.modelmbean.ModelMBean;
  import javax.management.modelmbean.ModelMBeanInfo;
  
  import org.apache.struts.util.MessageResources;
  import org.apache.webapp.admin.LabelValueBean;
  import org.apache.webapp.admin.Lists;
  import org.apache.webapp.admin.TomcatTreeBuilder;
  import org.apache.webapp.admin.ApplicationServlet;
  
  /**
   * Test <code>Action</code> that handles events from the tree control test
   * page.
   *
   * @author Jazmin Jonson
   * @author Manveen Kaur
   * @version $Revision: 1.1 $ $Date: 2002/04/04 21:52:25 $
   */
  
  public class EditServerAction 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);
          }
  
          // label of the node that was clicked on.
          String nodeLabel = request.getParameter("nodeLabel");        
          
          ServerForm serverFm = new ServerForm();
          session.setAttribute("serverForm", serverFm);
          serverFm.setNodeLabel(nodeLabel);        
          serverFm.setDebugLvlVals(Lists.getDebugLevels());
          
          ObjectName sname = null;    
          try {
             sname = new ObjectName(TomcatTreeBuilder.SERVER_TYPE);
          } catch (Exception e) {
              String message =
                  resources.getMessage("error.serviceName.bad",
                                       request.getParameter("select"));
              getServlet().log(message);
              response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
              return (null);
          }
        
          String attribute = null;
          try {
              // Copy scalar properties
              attribute = "debug";
              serverFm.setDebugLvl
                  (((Integer) mBServer.getAttribute(sname, attribute)).toString());
              attribute = "port";
              serverFm.setPortNumberText
                  (((Integer) mBServer.getAttribute(sname, attribute)).toString());
              attribute = "shutdown";
              serverFm.setShutdownText
                  ((String) mBServer.getAttribute(sname, attribute));
  
              } 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 server jsp.
          return (mapping.findForward("Server"));        
      }
          
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/server/SaveServerAction.java
  
  Index: SaveServerAction.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/server/SaveServerAction.java,v
 1.1 2002/04/04 21:52:25 manveen Exp $
   * $Revision: 1.1 $
   * $Date: 2002/04/04 21:52:25 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 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.server;
  
  import java.util.Iterator;
  import java.util.Locale;
  import java.io.IOException;
  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 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 org.apache.webapp.admin.ApplicationServlet;
  import org.apache.webapp.admin.TomcatTreeBuilder;
  import org.apache.struts.util.MessageResources;
  
  /**
   * Implementation of <strong>Action</strong> that saves server properties.
   *
   * @author Jazmin Jonson
   * @author Manveen Kaur
   * @version $Revision: 1.1 $ $Date: 2002/04/04 21:52:25 $
   */
  
  public final class SaveServerAction 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);
          }
          
          ActionErrors errors = new ActionErrors();
          
          // Report any errors we have discovered back to the original form
          if (!errors.empty()) {
              saveErrors(request, errors);
              return (new ActionForward(mapping.getInput()));
          }
          
         // Acquire a reference to the Server MBean
          ObjectName soname = null;
          try {            
              soname = new ObjectName(TomcatTreeBuilder.SERVER_TYPE);
         } catch (Throwable t) {
              throw new ServletException
              ("Cannot acquire Server MBean reference ", t);
          }
          
          ServerForm sform = (ServerForm) form;
  
          // Perform attribute updates as requested
          String attribute = null;
          try{          
              attribute = "debug";
              int debug = 0;
              try {
                  debug = Integer.parseInt(sform.getDebugLvl());
              } catch (Throwable t) {
                  debug = 0;
              }
              mBServer.setAttribute(soname,
                                    new Attribute("debug", new Integer(debug)));
              attribute = "port";
              int port = 0;
              try {
                  port = Integer.parseInt(sform.getPortNumberText());
              } catch (Throwable t) {
                  port = 0;
              }
              mBServer.setAttribute(soname,
                                    new Attribute("port", new Integer(port)));        
              attribute = "shutdown";
              mBServer.setAttribute(soname,
                                    new Attribute("shutdown", 
sform.getShutdownText()));
              
          } 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/WEB-INF/classes/org/apache/webapp/admin/server/ServerForm.java
  
  Index: ServerForm.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/server/ServerForm.java,v
 1.1 2002/04/04 21:52:25 manveen Exp $
   * $Revision: 1.1 $
   * $Date: 2002/04/04 21:52:25 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 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.server;
  
  
  import javax.servlet.http.HttpServletRequest;
  import org.apache.struts.action.ActionError;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionMapping;
  import org.apache.webapp.admin.ApplicationServlet;
  import org.apache.webapp.admin.TomcatTreeBuilder;
  
  import java.util.List;
  
  /**
   * Form bean for the server form page.  
   * @author Patrick Luby
   * @author Manveen Kaur
   * @version $Revision: 1.1 $ $Date: 2002/04/04 21:52:25 $
   */
  
  public final class ServerForm extends ActionForm {
      
      // ----------------------------------------------------- Instance Variables
      
      /**
       * The text for the node label.
       */
      private String nodeLabel = null;
      
      /**
       * The text for the port number.
       */    
      private String portNumberText = "8080";
      
      /**
       * The text for the debug level.
       */
      private String debugLvl = "0";
  
      /**
       * The text for the shutdown text.
       */    
      private String shutdownText = null;
      
      private List debugLvlVals = null;
      
      // ------------------------------------------------------------- Properties
      /**
       * Return the label of the node that was clicked.
       */
      public String getNodeLabel() {
          
          return this.nodeLabel;
          
      }
      
      /**
       * Set the node label.
       */
      public void setNodeLabel(String nodeLabel) {
          
          this.nodeLabel = nodeLabel;
          
      }    
      
      /**
       * Return the debugVals.
       */
      public List getDebugLvlVals() {
          
          return this.debugLvlVals;
          
      }
      
      /**
       * Set the debugVals.
       */
      public void setDebugLvlVals(List debugLvlVals) {
          
          this.debugLvlVals = debugLvlVals;
          
      }
          
      /**
       * Return the portNumberText.
       */
      public String getPortNumberText() {
          
          return this.portNumberText;
          
      }
      
      /**
       * Set the portNumberText.
       */
      public void setPortNumberText(String portNumberText) {
          
          this.portNumberText = portNumberText;
          
      }
      
      /**
       * Return the Debug Level Text.
       */
      public String getDebugLvl() {
          
          return this.debugLvl;
          
      }
      
      /**
       * Set the Debug Level Text.
       */
      public void setDebugLvl(String debugLvl) {
          
          this.debugLvl = debugLvl;
          
      }
      
      /**
       * Return the Shutdown Text.
       */
      public String getShutdownText() {
          
          return this.shutdownText;
          
      }
      
      /**
       * Set the Shut down  Text.
       */
      public void setShutdownText(String shutdownText) {
          
          this.shutdownText = shutdownText;
          
      }
      
      // --------------------------------------------------------- Public Methods
      
      /**
       * Reset all properties to their default values.
       *
       * @param mapping The mapping used to select this instance
       * @param request The servlet request we are processing
       */
      public void reset(ActionMapping mapping, HttpServletRequest request) {
          
          this.portNumberText = null;
          this.debugLvl = "0";
          this.shutdownText = null;
          
      }
      
      
      /**
       * Validate the properties that have been set from this HTTP request,
       * and return an <code>ActionErrors</code> object that encapsulates any
       * validation errors that have been found.  If no errors are found, return
       * <code>null</code> or an <code>ActionErrors</code> object with no
       * recorded error messages.
       *
       * @param mapping The mapping used to select this instance
       * @param request The servlet request we are processing
       */
      public ActionErrors validate(ActionMapping mapping,
      HttpServletRequest request) {
          
          ActionErrors errors = new ActionErrors();
          
          String submit = request.getParameter("submit");
          if (submit != null) {
              
              // check for portNumber -- must not be blank, must be in
              // the range 1 to 65535.
              
              if ((portNumberText == null) || (portNumberText.length() < 1)) {
                  errors.add("portNumberText",
                  new ActionError("error.portNumber.required"));
              } else {
                  try {
                      int port = Integer.parseInt(portNumberText);
                      if ((port <= 0) || (port >65535 ))
                          errors.add("portNumberText", 
                              new ActionError("error.portNumber.range"));
                  } catch (NumberFormatException e) {
                      errors.add("portNumberText", 
                          new ActionError("error.portNumber.format"));
                  }
              }
          
              // shutdown text can be any non-empty string of atleast 6 characters.
              
              if ((shutdownText == null) || (shutdownText.length() < 7))
                  errors.add("shutdownText",
                  new ActionError("error.shutdownText.length"));
              
          }
          
          return errors;
          
      }
      
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/webapps/admin/server/server.jsp
  
  Index: server.jsp
  ===================================================================
  <!-- Standard Struts Entries -->
  
  <%@ page language="java" %>
  <%@ 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="/SaveServer" focus="portNumberText">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr class="page-title-row">
        <td align="left" nowrap>
          <div class="page-title-text">
             <bean:write name="serverForm" property="nodeLabel"/>
          </div>
        </td>
        <td align="right" nowrap> 
          <div class="page-title-text">
          <controls:actions>
            <controls:action selected="true">
              ----<bean:message key="actions.available.actions"/>----
            </controls:action>
            <controls:action>
              ---------------------------------
            </controls:action>
            <controls:action url="AddService.do">
              <bean:message key="actions.services.create"/>
            </controls:action>
            <controls:action url="DeleteService.do">
              <bean:message key="actions.services.deletes"/>
            </controls:action>
          </controls:actions>
          </div>
        </td>
      </tr>
    </table>
  
    <%@ include file="../buttons.jsp" %>
   <br>
  
    <table border="0" cellspacing="0" cellpadding="0" width="100%">
      <tr><td><div class="table-title-text">  
        <bean:message key="server.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="server.portnumber"/>:</controls:label>
              <controls:data>
                <html:text property="portNumberText" size="20" maxlength="20"/>
              </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="serverForm" 
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><bean:message key="server.shutdown"/>:</controls:label>
              <controls:data>
                 <html:text property="shutdownText" size="20" maxlength="20"/>
              </controls:data>
          </controls:row>
        </controls:table>
  
        </td>
      </tr>
    </table>
  
    <%@ include file="../buttons.jsp" %>
  
  </html:form>
  
  <!-- Standard Footer -->
  
  <%@ include file="../footer.jsp" %>
  
  </body>
  
  </html:html>
  
  
  
  1.11      +7 -5      jakarta-tomcat-4.0/webapps/admin/service/service.jsp
  
  Index: service.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/service/service.jsp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- service.jsp       24 Mar 2002 04:13:24 -0000      1.10
  +++ service.jsp       4 Apr 2002 21:52:25 -0000       1.11
  @@ -58,11 +58,13 @@
                 <controls:action>
                   -------------------------------------
                 </controls:action>
  -              <controls:action url="">
  -                <bean:message key="actions.connector.create"/>
  -              </controls:action>
  -              <controls:action url="">
  -                <bean:message key="actions.connector.delete"/>
  +              <controls:action url='<%= "/AddConnector.do?serviceName=" +
  +                                        serviceName %>'>  
  +                <bean:message key="actions.connectors.create"/>
  +              </controls:action>              
  +              <controls:action url='<%= "/DeleteConnector.do?serviceName=" +
  +                        serviceName %>'> 
  +                <bean:message key="actions.connectors.deletes"/>
                 </controls:action>
                 <controls:action>
                   -------------------------------------
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to