You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/09/01 18:58:12 UTC

cvs commit: jakarta-turbine-3/src/java/org/apache/turbine/services/rundata RunDataFactory.java

jvanzyl     01/09/01 09:58:12

  Modified:    src/java/org/apache/turbine Turbine.java
               src/java/org/apache/turbine/modules ModuleLoader.java
               src/java/org/apache/turbine/modules/actions
                        AccessController.java LoginUser.java
                        LogoutUser.java TemplateSessionValidator.java
               src/java/org/apache/turbine/pipeline ClassicPipeline.java
                        Renderer.java
               src/java/org/apache/turbine/services/rundata
                        RunDataFactory.java
  Added:       src/java/org/apache/turbine DynamicURI.java Log.java
                        RelativeDynamicURI.java TurbineConfig.java
  Log:
  - moving last of the utility classes to the top level package where
    they will become part of the turbine API.
  
  - made changes in the rest of the classes to reflect that change.
  
  Revision  Changes    Path
  1.3       +4 -6      jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java
  
  Index: Turbine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Turbine.java	2001/08/31 08:10:44	1.2
  +++ Turbine.java	2001/09/01 16:58:11	1.3
  @@ -70,16 +70,14 @@
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  -import org.apache.turbine.modules.ModuleLoader;
  -import org.apache.turbine.util.Log;
  -import org.apache.turbine.util.TurbineConfig;
  -import org.apache.turbine.services.rundata.RunDataFactory;
   import org.apache.commons.util.StringUtils;
   import org.apache.commons.util.http.HttpUtils;
  +import org.apache.commons.collections.ExtendedProperties;
   import org.apache.fulcrum.ServiceManager;
   import org.apache.fulcrum.TurbineServices;
  -import org.apache.commons.collections.ExtendedProperties;
   import org.apache.log4j.Category;
  +import org.apache.turbine.modules.ModuleLoader;
  +import org.apache.turbine.services.rundata.RunDataFactory;
   
   /**
    * Turbine is the main servlet for the entire system. It is <code>final</code>
  @@ -113,7 +111,7 @@
    * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
  - * @version $Id: Turbine.java,v 1.2 2001/08/31 08:10:44 jvanzyl Exp $
  + * @version $Id: Turbine.java,v 1.3 2001/09/01 16:58:11 jvanzyl Exp $
    */
   public class Turbine
       extends HttpServlet
  
  
  
  1.1                  jakarta-turbine-3/src/java/org/apache/turbine/DynamicURI.java
  
  Index: DynamicURI.java
  ===================================================================
  package org.apache.turbine;
  
  /* ====================================================================
   * 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import org.apache.turbine.RunData;
  import java.net.URLEncoder;
  import java.util.Enumeration;
  import java.util.Vector;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.turbine.Turbine;
  import org.apache.turbine.ParameterParser;
  
  /**
   * This creates a Dynamic URI for use within the Turbine system
   *
   * <p>If you use this class to generate all of your href tags as well
   * as all of your URI's, then you will not need to worry about having
   * session data setup for you or using HttpServletRequest.encodeUrl()
   * since this class does everything for you.
   *
   * <code><pre>
   * DynamicURI dui = new DynamicURI (data, "UserScreen" );
   * dui.setName("Click Here").addPathInfo("user","jon");
   * dui.getA();
   * </pre></code>
   *
   * The above call to getA() would return the String:
   *
   * &lt;A HREF="http://www.server.com:80/servlets/Turbine/screen=UserScreen&amp;amp;user=jon"&gt;Click Here&lt;/A&gt;
   *
   * @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a>
   * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
   * @version $Id: DynamicURI.java,v 1.1 2001/09/01 16:58:11 jvanzyl Exp $
   */
  public class DynamicURI
  {
      /** HTTP protocol. */
      public static final String HTTP = "http";
  
      /** HTTPS protocol. */
      public static final String HTTPS = "https";
  
      /** The RunData object. */
      protected RunData data = null;
  
      // Used with RunData constructors to provide a way around a JServ
      // 1.0 bug.
  
      /** Servlet response interface. */
      public HttpServletResponse res = null;
  
      /** A Vector that contains all the path info if any. */
      protected Vector pathInfo = null;
  
      /** A Vectory that contains all the query data if any. */
      protected Vector queryData = null;
  
      /**
       * Fast shortcut to determine if there is any data in the path
       * info.
       */
      protected boolean hasPathInfo = false;
  
      /**
       * Fast shortcut to determine if there is any data in the query
       * data.
       */
      protected boolean hasQueryData = false;
  
      /** Whether we want to redirect or not. */
      protected boolean redirect = false;
  
      /** P = 0 for path info. */
      protected static final int PATH_INFO = 0;
  
      /** Q = 1 for query data. */
      protected static final int QUERY_DATA = 1;
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       */
      public DynamicURI( RunData data )
      {
          init(data);
      }
  
      /**
       * Default constructor - one of the init methods must be called
       * before use.
       */
      public DynamicURI()
      {
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param screen A String with the name of a screen.
       */
      public DynamicURI( RunData data,
                         String screen )
      {
          this(data);
          setScreen(screen);
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param screen A String with the name of a screen.
       * @param action A String with the name of an action.
       */
      public DynamicURI( RunData data,
                         String screen,
                         String action )
      {
          this( data, screen );
          setAction(action);
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param screen A String with the name of a screen.
       * @param action A String with the name of an action.
       * @param redirect True if it should redirect.
       */
      public DynamicURI( RunData data,
                         String screen,
                         String action,
                         boolean redirect )
      {
          this( data, screen, action );
          this.redirect = redirect;
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param screen A String with the name of a screen.
       * @param redirect True if it should redirect.
       */
      public DynamicURI( RunData data,
                         String screen,
                         boolean redirect )
      {
          this( data, screen );
          this.redirect = redirect;
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param redirect True if it should redirect.
       */
      public DynamicURI( RunData data,
                         boolean redirect )
      {
          this( data );
          this.redirect = redirect;
      }
  
      /**
       * Initialize with a RunData object
       *
       * @param RunData
       */
      public void init( RunData data )
      {
          this.data = data;
          this.res = data.getResponse();
          init();
      }
  
      /**
       * <p>If the type is P (0), then add name/value to the pathInfo
       * hashtable.
       *
       * <p>If the type is Q (1), then add name/value to the queryData
       * hashtable.
       *
       * @param type Type (P or Q) of insertion.
       * @param name A String with the name to add.
       * @param value A String with the value to add.
       */
      protected void add ( int type,
                         String name,
                         String value )
      {
          Object[] tmp = new Object[2];
          tmp[0] = (Object) data.getParameters().convertAndTrim(name);
          tmp[1] = (Object) value;
          switch (type)
          {
          case PATH_INFO:
              this.pathInfo.addElement ( tmp );
              this.hasPathInfo = true;
              break;
          case QUERY_DATA:
              this.queryData.addElement ( tmp );
              this.hasQueryData = true;
              break;
          }
      }
  
      /**
       * Method for a quick way to add all the parameters in a
       * ParameterParser.
       *
       * <p>If the type is P (0), then add name/value to the pathInfo
       * hashtable.
       *
       * <p>If the type is Q (1), then add name/value to the queryData
       * hashtable.
       *
       * @param type Type (P or Q) of insertion.
       * @param pp A ParameterParser.
       */
      protected void add( int type,
                        ParameterParser pp )
      {
          Enumeration e = pp.keys();
          while ( e.hasMoreElements() )
          {
              String key = (String)e.nextElement();
              if ( !key.equalsIgnoreCase("action") &&
                   !key.equalsIgnoreCase("screen") &&
                   !key.equalsIgnoreCase("template") )
              {
                  String[] values = pp.getStrings(key);
                  for ( int i=0; i<values.length; i++ )
                  {
                      add( type, key, values[i] );
                  }
              }
          }
      }
  
      /**
       * Adds a name=value pair to the path_info string.
       *
       * @param name A String with the name to add.
       * @param value An Object with the value to add.
       */
      public DynamicURI addPathInfo ( String name, Object value )
      {
          add ( PATH_INFO, name, value.toString() );
          return this;
      }
  
      /**
       * Adds a name=value pair to the path_info string.
       *
       * @param name A String with the name to add.
       * @param value A String with the value to add.
       */
      public DynamicURI addPathInfo ( String name, String value )
      {
          add ( PATH_INFO, name, value );
          return this;
      }
  
      /**
       * Adds a name=value pair to the path_info string.
       *
       * @param name A String with the name to add.
       * @param value A double with the value to add.
       */
      public DynamicURI addPathInfo ( String name, double value )
      {
          add ( PATH_INFO, name, Double.toString(value) );
          return this;
      }
  
      /**
       * Adds a name=value pair to the path_info string.
       *
       * @param name A String with the name to add.
       * @param value An int with the value to add.
       */
      public DynamicURI addPathInfo ( String name, int value )
      {
          add ( PATH_INFO, name, new Integer(value).toString() );
          return this;
      }
  
      /**
       * Adds a name=value pair to the path_info string.
       *
       * @param name A String with the name to add.
       * @param value A long with the value to add.
       */
      public DynamicURI addPathInfo ( String name, long value )
      {
          add ( PATH_INFO, name, new Long(value).toString() );
          return this;
      }
  
      /**
       * Adds a name=value pair for every entry in a ParameterParser
       * object to the path_info string.
       *
       * @param pp A ParameterParser.
       */
      public DynamicURI addPathInfo ( ParameterParser pp )
      {
          add ( PATH_INFO, pp );
          return this;
      }
  
      /**
       * Adds a name=value pair to the query string.
       *
       * @param name A String with the name to add.
       * @param value An Object with the value to add.
       */
      public DynamicURI addQueryData ( String name, Object value )
      {
          add ( QUERY_DATA, name, value.toString() );
          return this;
      }
  
      /**
       * Adds a name=value pair to the query string.
       *
       * @param name A String with the name to add.
       * @param value A String with the value to add.
       */
      public DynamicURI addQueryData ( String name, String value )
      {
          add ( QUERY_DATA, name, value );
          return this;
      }
  
      /**
       * Adds a name=value pair to the query string.
       *
       * @param name A String with the name to add.
       * @param value A double with the value to add.
       */
      public DynamicURI addQueryData ( String name, double value )
      {
          add ( QUERY_DATA, name, Double.toString(value) );
          return this;
      }
  
      /**
       * Adds a name=value pair to the query string.
       *
       * @param name A String with the name to add.
       * @param value An int with the value to add.
       */
      public DynamicURI addQueryData ( String name, int value )
      {
          add ( QUERY_DATA, name, new Integer(value).toString() );
          return this;
      }
  
      /**
       * Adds a name=value pair to the query string.
       *
       * @param name A String with the name to add.
       * @param value A long with the value to add.
       */
      public DynamicURI addQueryData ( String name, long value )
      {
          add ( QUERY_DATA, name, new Long(value).toString() );
          return this;
      }
  
      /**
       * Adds a name=value pair for every entry in a ParameterParser
       * object to the query string.
       *
       * @param pp A ParameterParser.
       */
      public DynamicURI addQueryData ( ParameterParser pp )
      {
          add ( QUERY_DATA, pp );
          return this;
      }
  
      /**
       * Create an anchor object.  This call to getA():
       *
       * <code><pre>
       * DynamicURI dui = new DynamicURI (data, "UserScreen" );
       * dui.setName("Click Here").addPathInfo("user","jon");
       * dui.getA();
       * </pre></code>
       *
       * would return the String:
       *
       * <p>&lt;A HREF="http://www.server.com:80/servlets/Turbine/screen=UserScreen&amp;amp;user=jon"&gt;Click Here&lt;/A&gt;
       *
       * @param name A String with the name for the anchor.
       * @return The anchor as a &lt;A HREF=""&gt;name&lt;/A&gt;.
       */
      public String getA( String name )
      {
          return new StringBuffer("<a href=\"")
              .append(this.toString())
              .append("\">")
              .append(name)
              .append("</a>")
              .toString();
          //return new A(this.toString(), name).toString();
      }
  
      /**
       * Gets the script name (/servlets/Turbine).
       *
       * @return A String with the script name.
       */
      public String getScriptName ()
      {
          return data.getScriptName();
      }
  
      /**
       * Gets the server name.
       *
       * @return A String with the server name.
       */
      public String getServerName ()
      {
          return data.getServerName();
      }
  
      /**
       * Gets the server port.
       *
       * @return A String with the server port.
       */
      public int getServerPort ()
      {
          return data.getServerPort();
      }
  
      /**
       * Gets the server scheme (HTTP or HTTPS).
       *
       * @return A String with the server scheme.
       */
      public String getServerScheme()
      {
          return data.getServerScheme();
      }
  
      /**
       * Initializes some common variables.
       */
      protected void init()
      {
          this.pathInfo = new Vector();
          this.queryData = new Vector();
      }
  
      /**
       * <p>If the type is P (0), then remove name/value from the
       * pathInfo hashtable.
       *
       * <p>If the type is Q (1), then remove name/value from the
       * queryData hashtable.
       *
       * @param type Type (P or Q) of removal.
       * @param name A String with the name to be removed.
       */
      protected void remove ( int type,
                            String name )
      {
          try
          {
              switch (type)
              {
              case PATH_INFO:
                  for (Enumeration e = this.pathInfo.elements() ;
                       e.hasMoreElements() ;)
                  {
                      Object[] tmp = (Object[]) e.nextElement();
                      if ( data.getParameters().convertAndTrim(name)
                           .equals ( (String)tmp[0] ) )
                      {
                          this.pathInfo.removeElement ( tmp );
                      }
                  }
                  if ( hasPathInfo && this.pathInfo.size() == 0 )
                  {
                      this.hasPathInfo = false;
                  }
                  break;
              case QUERY_DATA:
                  for (Enumeration e = this.queryData.elements() ;
                       e.hasMoreElements() ;)
                  {
                      Object[] tmp = (Object[]) e.nextElement();
                      if ( data.getParameters().convertAndTrim(name)
                           .equals ( (String)tmp[0] ) )
                      {
                          this.queryData.removeElement ( tmp );
                      }
                  }
                  if ( hasQueryData && this.queryData.size() == 0 )
                  {
                      this.hasQueryData = false;
                  }
                  break;
              }
          }
          catch ( Exception e )
          {
          }
      }
  
      /**
       * Removes all the path info elements.
       */
      public void removePathInfo ()
      {
          this.pathInfo.removeAllElements();
          this.hasPathInfo = false;
      }
  
      /**
       * Removes a name=value pair from the path info.
       *
       * @param name A String with the name to be removed.
       */
      public void removePathInfo ( String name )
      {
          remove ( PATH_INFO, name );
      }
  
      /**
       * Removes all the query string elements.
       */
      public void removeQueryData ()
      {
          this.queryData.removeAllElements();
          this.hasQueryData = false;
      }
  
      /**
       * Removes a name=value pair from the query string.
       *
       * @param name A String with the name to be removed.
       */
      public void removeQueryData ( String name )
      {
          remove ( QUERY_DATA, name );
      }
  
      /**
       * This method takes a Vector of key/value arrays and converts it
       * into a URL encoded querystring format.
       *
       * @param data A Vector of key/value arrays.
       * @return A String with the URL encoded data.
       */
      protected String renderPathInfo ( Vector data )
      {
          String key = null;
          String value = null;
          String tmp = null;
          StringBuffer out = new StringBuffer();
          Enumeration keys = data.elements();
          while(keys.hasMoreElements())
          {
              Object[] stuff = (Object[]) keys.nextElement();
              key = URLEncoder.encode((String)stuff[0]);
              tmp = (String) stuff[1];
              if (tmp == null || tmp.length() == 0)
              {
                  value = "null";
              }
              else
              {
                  value = URLEncoder.encode(tmp);
              }
  
              if (out.length() > 0)
              {
                  out.append ( "/" );
              }
              out.append ( key );
              out.append ( "/" );
              out.append ( value );
          }
          return out.toString();
      }
  
      /**
       * This method takes a Vector of key/value arrays and converts it
       * into a URL encoded querystring format.
       *
       * @param data A Vector of key/value arrays.
       * @return A String with the URL encoded data.
       */
      protected String renderQueryString ( Vector data )
      {
          String key = null;
          String value = null;
          String tmp = null;
          StringBuffer out = new StringBuffer();
          Enumeration keys = data.elements();
          while(keys.hasMoreElements())
          {
              Object[] stuff = (Object[]) keys.nextElement();
              key   = URLEncoder.encode((String) stuff[0]);
              tmp = (String) stuff[1];
              if (tmp == null || tmp.length() == 0)
              {
                  value = "null";
              }
              else
              {
                  value = URLEncoder.encode(tmp);
              }
  
              if ( out.length() > 0)
              {
                  out.append ( "&" );
              }
              out.append ( key );
              out.append ( "=" );
              out.append ( value );
          }
          return out.toString();
      }
  
      /**
       * Sets the action= value for this URL.
       *
       * <p>By default it adds the information to the path_info instead
       * of the query data.
       *
       * @param action A String with the action value.
       * @return A DynamicURI (self).
       */
      public DynamicURI setAction ( String action )
      {
          add ( PATH_INFO, "action", action );
          return this;
      }
  
      /**
       * Sets the screen= value for this URL.
       *
       * <p>By default it adds the information to the path_info instead
       * of the query data.
       *
       * @param action A String with the screen value.
       * @return A DynamicURI (self).
       */
      public DynamicURI setScreen ( String screen )
      {
          add ( PATH_INFO, "screen", screen );
          return this;
      }
  
      /**
       * Method to specify that a URI should use SSL.  Whether or not it
       * does is determined from TurbineResources.properties.  Port
       * number is 443.
       *
       * @return A DynamicURI (self).
       */
      public DynamicURI setSecure()
      {
          return setSecure(443);
      }
  
      /**
       * Method to specify that a URI should use SSL.  Whether or not it
       * does is determined from TurbineResources.properties.
       *
       * @param port An int with the port number.
       * @return A DynamicURI (self).
       */
      public DynamicURI setSecure(int port)
      {
          boolean isSSL = Turbine.getConfiguration().getBoolean("use.ssl", true);
          if (isSSL)
          {
              data.setServerScheme(DynamicURI.HTTPS);
              data.setServerPort(port);
          }
          return this;
      }
  
      /**
       * Builds the URL with all of the data URL-encoded as well as
       * encoded using HttpServletResponse.encodeUrl().
       *
       * <p>
       * <code><pre>
       * DynamicURI dui = new DynamicURI (data, "UserScreen" );
       * dui.addPathInfo("user","jon");
       * dui.toString();
       * </pre></code>
       *
       *  The above call to toString() would return the String:
       *
       * <p>
       * http://www.server.com/servlets/Turbine/screen/UserScreen/user/jon
       *
       * @return A String with the built URL.
       */
      public String toString()
      {
          StringBuffer output = new StringBuffer();
          output.append ( getServerScheme() );
          output.append ( "://" );
          output.append ( getServerName() );
          if ( (getServerScheme().equals(HTTP) && getServerPort() != 80)
              || (getServerScheme().equals(HTTPS) && getServerPort() != 443)
             )
          {
              output.append (":");
              output.append ( getServerPort() );
          }
          output.append ( getScriptName() );
          if ( this.hasPathInfo )
          {
              output.append ( "/" );
              output.append ( renderPathInfo(this.pathInfo) );
          }
          if ( this.hasQueryData )
          {
              output.append ( "?" );
              output.append ( renderQueryString(this.queryData) );
          }
  
          // There seems to be a bug in Apache JServ 1.0 where the
          // session id is not appended to the end of the url when a
          // cookie has not been set.
          if ( this.res != null )
          {
              if ( this.redirect )
                  return res.encodeRedirectUrl (output.toString());
              else
                  return res.encodeUrl (output.toString());
          }
          else
          {
              return output.toString();
          }
      }
  
      /**
       * Given a RunData object, get a URI for the request.  This is
       * necessary sometimes when you want the exact URL and don't want
       * DynamicURI to be too smart and remove actions, screens, etc.
       * This also returns the Query Data where DynamicURI normally
       * would not.
       *
       * @param data A Turbine RunData object.
       * @return A String with the URL representing the RunData.
       */
      public static String toString(RunData data)
      {
          StringBuffer output = new StringBuffer();
          HttpServletRequest request = data.getRequest();
  
          output.append ( data.getServerScheme() );
          output.append ( "://" );
          output.append ( data.getServerName() );
  
          if ( (data.getServerScheme().equals(HTTP) &&
                data.getServerPort() != 80) ||
               (data.getServerScheme().equals(HTTPS) &&
                data.getServerPort() != 443) )
          {
              output.append (":");
              output.append ( data.getServerPort() );
          }
  
          output.append ( data.getScriptName() );
  
          if ( request.getPathInfo() != null )
          {
              output.append( request.getPathInfo() );
          }
  
          if ( request.getQueryString() != null )
          {
              output.append ( "?" );
              output.append ( request.getQueryString() );
          }
          return output.toString();
      }
  }
  
  
  
  1.1                  jakarta-turbine-3/src/java/org/apache/turbine/Log.java
  
  Index: Log.java
  ===================================================================
  package org.apache.turbine;
  
  /* ====================================================================
   * 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Properties;
  import org.apache.log4j.Category;
  import org.apache.log4j.Priority;
  import org.apache.log4j.PropertyConfigurator;
  
  /**
   * A facade for logging with log4j in Turbine.
   *
   * @author <a href="jvanzyl@apache.org">Jason van Zyl</a>
   */
  public class Log
  {
      /**
       * Properties used to initialized log4j
       */
      public static Properties properties;
  
      /**
       * This is the default logger.
       */
      private static Category defaultLogger;
  
      /**
       * This is a collection of log4j categories.
       */
      private static Hashtable loggers;
  
      /**
       * The name of the category that will be
       * used for default logging.
       */
      private static final String DEFAULT_CATEGORY = "default";
  
      /**
       * Set the properties so that log4j can do
       * it's thing.
       */
      public static void setProperties(Properties p)
      {
          properties = p;
      }
  
      /**
       * Initialize our logging facade.
       */
      public static void init()
      {
          loggers = new Hashtable();
          PropertyConfigurator.configure(properties);
  
          // Get all the configured categories.
          Enumeration e =
              Category.getDefaultHierarchy().getCurrentCategories();
  
          // Create catagories for logging.
          while (e.hasMoreElements())
          {
              Category c = (Category) e.nextElement();
              loggers.put(c.getName(), c);
          }
  
          // Set up our default logger. This will be used
          // when a specific category is not specified.
          defaultLogger = Category.getInstance(DEFAULT_CATEGORY);
      }
  
      /**
       * Retrieve a category from our configured set
       * of Categories.
       *
       * @param String logger name
       * @return Category
       */
      public static Category getLogger(String logger)
      {
          return (Category) loggers.get(logger);
      }
  
      /**
       * This is a log method with logLevel == DEBUG, printing is done by
       * the default logger
       */
      public static void debug(String message)
      {
          defaultLogger.debug(message);
      }
  
      /**
       * This is a log method with logLevel == DEBUG, printing is done by
       * the default logger
       */
      public static void debug(String message, Throwable t)
      {
          defaultLogger.debug(message,t);
      }
  
      /**
       * This is a log method with logLevel == DEBUG, printing is done by
       * the given logger
       */
      public static void debug(String logName, String message)
      {
          Category logger = getLogger(logName);
  
          if (logger == null)
          {
              debug(message);
          }
          else
          {
              logger.debug(message);
          }
      }
  
      /**
       * This is a log method with logLevel == DEBUG, printing is done by
       * the given logger
       */
      public static void debug(String logName ,String message, Throwable t)
      {
          Category logger = getLogger(logName);
  
          if (logger == null)
          {
              debug(message,t);
          }
          else
          {
              logger.debug(message,t);
          }
      }
  
      /**
       * This is a log method with logLevel == INFO, printing is done by
       * the default logger
       */
      public static void info(String message)
      {
          defaultLogger.info(message);
      }
  
      /**
       * This is a log method with logLevel == INFO, printing is done by
       * the default logger
       */
      public static void info(String message, Throwable t)
      {
          defaultLogger.info(message,t);
      }
  
      /**
       * This is a log method with logLevel == INFO, printing is done by
       * the given logger
       */
      public static void info(String logName, String message)
      {
          Category logger = getLogger(logName);
  
          if (logger == null)
          {
              info(message);
          }
          else
          {
              logger.info(message);
          }
      }
  
      /**
       * This is a log method with logLevel == INFO, printing is done by
       * the given logger
       */
      public static void info(String logName, String message, Throwable t)
      {
          Category logger = getLogger(logName);
  
          if (logger == null)
          {
              info(message,t);
          }
          else
          {
              logger.info(message,t);
          }
      }
  
      /**
       * This is a log method with logLevel == WARN, printing is done by
       * the default logger
       */
      public static void warn(String message)
      {
          defaultLogger.warn(message);
      }
  
      /**
       * This is a log method with logLevel == WARN, printing is done by
       * the default logger
       */
      public static void warn(String message, Throwable t)
      {
          defaultLogger.warn(message,t);
      }
  
      /**
       * This is a log method with logLevel == WARN, printing is done by
       * the given logger
       */
      public static void warn(String logName, String message)
      {
          Category logger = getLogger(logName);
  
          if (logger == null)
          {
              warn(message);
          }
          else
          {
              logger.warn(message);
          }
      }
  
      /**
       * This is a log method with logLevel == WARN, printing is done by
       * the given logger
       */
      public static void warn(String logName, String message, Throwable t)
      {
          Category logger = getLogger(logName);
  
          if (logger == null)
          {
              warn(message,t);
          }
          else
          {
              logger.warn(message,t);
          }
      }
  
      /**
       * This is a log method with logLevel == ERROR, printing is done by
       * the default logger
       */
      public static void error(String message)
      {
          defaultLogger.error(message);
      }
  
      /**
       * This is a log method with logLevel == ERROR, printing is done by
       * the default logger
       */
      public static void error(String message, Throwable t)
      {
          defaultLogger.error(message,t);
      }
  
      /**
       * This is a log method with logLevel == ERROR, printing is done by
       * the given logger
       */
      public static void error(String logName, String message)
      {
          Category logger = getLogger(logName);
  
          if (logger == null)
          {
              error(message);
          }
          else
          {
              logger.error(message);
          }
      }
  
      /**
       * This is a log method with logLevel == ERROR, printing is done by
       * the given logger
       */
      public static void error(String logName, String message, Throwable t)
      {
          Category logger = getLogger(logName);
  
          if (logger == null)
          {
              error(message,t);
          }
          else
          {
              logger.error(message,t);
          }
      }
  
      /**
       * This is a log method with logLevel == ERROR, printing is done by
       * the default logger
       */
      public static void error(Throwable e)
      {
          error("", e);
      }
  
      public static Hashtable getLoggers()
      {
          return loggers;
      }
  }
  
  
  
  1.1                  jakarta-turbine-3/src/java/org/apache/turbine/RelativeDynamicURI.java
  
  Index: RelativeDynamicURI.java
  ===================================================================
  package org.apache.turbine;
  
  /* ====================================================================
   * 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import java.util.Vector;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.turbine.RunData;
  
  /**
   * This creates a Dynamic URI for use within the Turbine system
   *
   * <p>If you use this class to generate all of your href tags as well
   * as all of your URI's, then you will not need to worry about having
   * session data setup for you or using HttpServletRequest.encodeUrl()
   * since this class does everything for you.
   * This class generates relative URI's which can be used in environments with
   * firewalls and gateways for outgoing connections.
   *
   * <code><pre>
   * RelativeDynamicURI dui = new RelativeDynamicURI (data, "UserScreen" );
   * dui.setName("Click Here").addPathInfo("user","jon");
   * dui.getA();
   * </pre></code>
   *
   * The above call to getA() would return the String:
   *
   * &lt;AHREF="/servlets/Turbine/screen=UserScreen&amp;amp;user=jon"&gt;ClickHere&lt;/A&gt;
   *
   * @author <a href="mailto:dfaller@raleigh.ibm.com">David S. Faller</a>
   */
  public class RelativeDynamicURI
      extends DynamicURI
  {
      /**
       * Default constructor - one of the init methods must be called
       * before use.
       */
      public RelativeDynamicURI()
      {
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       */
      public RelativeDynamicURI( RunData data )
      {
          super(data);
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param screen A String with the name of a screen.
       */
      public RelativeDynamicURI( RunData data,
                                 String screen )
      {
          super(data, screen);
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param screen A String with the name of a screen.
       * @param action A String with the name of an action.
       */
      public RelativeDynamicURI( RunData data,
                                 String screen,
                                 String action )
      {
          super(data, screen, action);
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param screen A String with the name of a screen.
       * @param action A String with the name of an action.
       * @param redirect True if it should redirect.
       */
      public RelativeDynamicURI( RunData data,
                                 String screen,
                                 String action,
                                 boolean redirect )
      {
          super(data, screen, action, redirect);
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param screen A String with the name of a screen.
       * @param redirect True if it should redirect.
       */
      public RelativeDynamicURI( RunData data,
                                 String screen,
                                 boolean redirect )
      {
          super(data, screen, redirect);
      }
  
      /**
       * Constructor sets up some variables.
       *
       * @param data A Turbine RunData object.
       * @param redirect True if it should redirect.
       */
      public RelativeDynamicURI( RunData data,
                                 boolean redirect )
      {
          super(data, redirect);
      }
  
      /**
       * Builds the relative URL with all of the data URL-encoded as well as
       * encoded using HttpServletResponse.encodeUrl().
       *
       * <p>
       * <code><pre>
       * RelativeDynamicURI dui = new RelativeDynamicURI (data, "UserScreen" );
       * dui.addPathInfo("user","jon");
       * dui.toString();
       * </pre></code>
       *
       *  The above call to toString() would return the String:
       *
       * <p>
       * /servlets/Turbine/screen/UserScreen/user/jon
       *
       * @return A String with the built relative URL.
       */
      public String toString()
      {
          StringBuffer output = new StringBuffer();
          output.append ( getScriptName() );
          if ( this.hasPathInfo )
          {
              output.append ( "/" );
              output.append ( renderPathInfo(this.pathInfo) );
          }
          if ( this.hasQueryData )
          {
              output.append ( "?" );
              output.append ( renderQueryString(this.queryData) );
          }
  
          // There seems to be a bug in Apache JServ 1.0 where the
          // session id is not appended to the end of the url when a
          // cookie has not been set.
          if ( this.res != null )
          {
              if ( this.redirect )
                  return res.encodeRedirectUrl (output.toString());
              else
                  return res.encodeUrl (output.toString());
          }
          else
          {
              return output.toString();
          }
      }
  
      /**
       * Given a RunData object, get a relative URI for the request.  This is
       * necessary sometimes when you want the relative URL and don't want
       * RelativeDynamicURI to be too smart and remove actions, screens, etc.
       * This also returns the Query Data where RelativeDynamicURI normally
       * would not.
       *
       * @param data A Turbine RunData object.
       * @return A String with the relative URL.
       */
      public static String toString(RunData data)
      {
          StringBuffer output = new StringBuffer();
          HttpServletRequest request = data.getRequest();
  
          output.append ( data.getScriptName() );
  
          if ( request.getPathInfo() != null )
          {
              output.append( request.getPathInfo() );
          }
  
          if ( request.getQueryString() != null )
          {
              output.append ( "?" );
              output.append ( request.getQueryString() );
          }
          return output.toString();
      }
  }
  
  
  
  
  
  1.1                  jakarta-turbine-3/src/java/org/apache/turbine/TurbineConfig.java
  
  Index: TurbineConfig.java
  ===================================================================
  package org.apache.turbine;
  
  /* ====================================================================
   * 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import java.io.BufferedInputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.InputStream;
  import java.io.PrintStream;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.Collection;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Set;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.Servlet;
  import javax.servlet.ServletConfig;
  import javax.servlet.ServletContext;
  import org.apache.turbine.Turbine;
  import org.apache.turbine.RunData;
  
  /**
   * A class used for initalization of Turbine without a servlet container.
   *
   * If you need to use Turbine outside of a servlet container, you can
   * use this class for initalization of the Turbine servlet.<br>
   *
   * <blockquote><code><pre>
   * TurbineConfig config = new TurbineConfig(".", "/conf/TurbineResources.properties");
   * </pre></code></blockquote>
   *
   * All paths referenced in TurbineResources.properties and the path to
   * the properties file itself (the second argument) will be resolved
   * relative to the directory given as the first argument of the constructor,
   * here - the directory where application was started. Don't worry about
   * discarding the references to objects created above. They are not needed,
   * once everything is initialized.
   *
   * In order to initialize the Services Framework outside of the Turbine Servlet,
   * you need to call the <code>init()</code> method. By default, this will
   * initialize the Resource and Logging Services and any other services you
   * have defined in your TurbineResources.properties file.
   *
   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
   * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
   * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
   * @version $Id: TurbineConfig.java,v 1.1 2001/09/01 16:58:11 jvanzyl Exp $
   */
  public class TurbineConfig implements ServletConfig, ServletContext
  {
      /**
       * Servlet initialization parameter name for the path to the
       * TurbineResources.properties file (<code>properties</code>).
       */
      public static final String PROPERTIES_KEY = "properties";
  
      /** Enables output of debug messages (compile time option). */
      private final static boolean DEBUG = false;
  
      /** Filenames are looked up in this directory. */
      private File root;
  
      /** Servlet container (or emulator) attributes. */
      private Map attributes;
  
      /** Turbine servlet initialization parameters. */
      private Map initParams;
  
      /** The Turbine servlet instance used for initialization. */
      private Turbine turbine;
  
      /**
       * Constructs a new TurbineConfig.
       *
       * This is the general form of the constructor. You can provide
       * a path to search for files, and a name-value map of init
       * parameters.
       *
       * <p> For the list of recognized init parameters, see
       * {@link org.apache.turbine.Turbine} class.
       *
       * @param path The web application root (i.e. the path for file lookup).
       * @param attributes Servlet container (or emulator) attributes.
       * @param initParams initialization parameters.
       */
      public TurbineConfig(String path, Map attributes, Map initParams)
      {
          root = new File(path);
          this.attributes = attributes;
          this.initParams = initParams;
      }
  
      /**
       * @see #TurbineConfig(String path, Map attributes, Map initParams)
       */
      public TurbineConfig(String path, Map initParams)
      {
          this(path, new HashMap(0), initParams);
      }
  
      /**
       * Constructs a TurbineConfig.
       *
       * This is a specialized constructor that allows to configure
       * Turbine easiliy in the common setups.
       *
       * @param path The web application root (i.e. the path for file lookup).
       * @param properties the relative path to TurbineResources.properties file
       */
      public TurbineConfig(String path, String properties)
      {
          this(path, new HashMap(1));
          initParams.put(PROPERTIES_KEY, properties);
      }
  
      /**
       * Causes this class to initialize itself which in turn initializes
       * all of the Turbine Services that need to be initialized.
       */
      public void init()
      {
          try
          {
              turbine = new Turbine();
              turbine.init(this);
          }
          catch (Exception e)
          {
              Log.error("TurbineConfig: Initialization failed", e);
          }
      }
  
      /**
       * Initialization requiring a HTTP <code>GET</code> request.
       */
      public void init(RunData data)
      {
          if (turbine != null)
          {
              turbine.init(data);
          }
      }
  
      /**
       * Returns a reference to the object cast onto ServletContext type.
       *
       * @return a ServletContext reference
       */
      public ServletContext getServletContext()
      {
          return this;
      }
  
      /**
       * Translates a path relative to the web application root into an
       * absolute path.
       *
       * @param path A path relative to the web application root.
       * @return An absolute version of the supplied path, or <code>null</code>
       * if the translated path doesn't map to a file or directory.
       */
      public String getRealPath( String path )
      {
          File f = new File(root, path);
          if (DEBUG)
          {
              System.err.println("TurbineConfig.getRealPath: path '" + path +
                                 "' translated to '" + f.getPath() + "' " +
                                 (f.exists() ? "" : "not ") + "found");
          }
          return (f.exists() ? f.getPath() : null);
      }
  
      /**
       * Retrieves an initialization parameter.
       *
       * @param name the name of the parameter.
       * @return the value of the parameter.
       */
      public String getInitParameter(String name)
      {
          return (String)initParams.get(name);
      }
  
      /**
       * Retrieves an Enumeration of initialization parameter names.
       *
       * @return an Enumeration of initialization parameter names.
       */
      public Enumeration getInitParameterNames()
      {
          return new Vector(initParams.keySet()).elements();
      }
  
      /**
       * Returns the servlet name.
       *
       * Fixed value "Turbine" is returned.
       *
       * @return the servlet name.
       */
      public String getServletName()
      {
          return "Turbine";
      }
  
      /**
       * Returns the context name.
       *
       * Fixed value "Turbine" is returned
       *
       * @return the context name
       */
      public String getServletContextName()
      {
          return "Turbine";
      }
  
      /**
       * Returns a URL to the resource that is mapped to a specified
       * path. The path must begin with a "/" and is interpreted
       * as relative to the current context root.
       *
       * @param s the path to the resource
       * @return a URL pointing to the resource
       * @exception MalformedURLException
       */
      public URL getResource( String s )
          throws MalformedURLException
      {
          return new URL("file://" + getRealPath(s));
      }
  
      /**
       * Returns the resource located at the named path as
       * an <code>InputStream</code> object.
       *
       * @param s the path to the resource
       * @return an InputStream object from which the resource can be read
       */
      public InputStream getResourceAsStream( String s )
      {
          try
          {
              FileInputStream fis = new FileInputStream(getRealPath(s));
              return new BufferedInputStream(fis);
          }
          catch(FileNotFoundException e)
          {
              return null;
          }
      }
  
      /**
       * Logs an error message.
       *
       * @param e an Exception.
       * @param m a message.
       * @deprecated
       */
      public void log(Exception e, String m)
      {
          // cannot use Turbine logging yet.
          System.err.println(m);
          e.printStackTrace();
      }
  
      /**
       * Logs a message.
       *
       * @param m a message.
       */
      public void log(String m)
      {
          // cannot use Turbine logging yet.
          System.out.println(m);
      }
  
      /**
       * Logs an error message.
       *
       * @param t a Throwable object.
       * @param m a message.
       */
      public void log( String m, Throwable t )
      {
          // cannot use Turbine logging yet.
          System.err.println(m);
          t.printStackTrace();
      }
  
      /**
       * Returns the servlet container attribute with the given name, or
       * null if there is no attribute by that name.
       */
      public Object getAttribute(String s)
      {
          return attributes.get(s);
      }
  
      /**
       * Returns an Enumeration containing the attribute names available
       * within this servlet context.
       */
      public Enumeration getAttributeNames()
      {
          return new Vector(attributes.keySet()).elements();
      }
  
      // Unimplemented methods follow
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public ServletContext getContext(String s)
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public int getMajorVersion()
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public String getMimeType(String s)
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public int getMinorVersion()
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public RequestDispatcher getNamedDispatcher( String s)
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public RequestDispatcher getRequestDispatcher( String s )
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       * @deprecated
       */
      public Set getResourcePaths()
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       * @deprecated
       */
      public Set getResourcePaths(String s)
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public String getServerInfo()
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       * @deprecated
       */
      public Servlet getServlet(String s)
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       * @deprecated
       */
      public Enumeration getServletNames()
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       * @deprecated
       */
      public Enumeration getServlets()
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public void removeAttribute( String s )
      {
          throw new UnsupportedOperationException();
      }
  
      /**
       * Not implemented.
       *
       * A method in ServletConfig or ServletContext interface that is not
       * implemented and will throw <code>UnsuportedOperationException</code>
       * upon invocation
       */
      public void setAttribute( String s, Object o )
      {
          throw new UnsupportedOperationException();
      }
  }
  
  
  
  1.2       +2 -2      jakarta-turbine-3/src/java/org/apache/turbine/modules/ModuleLoader.java
  
  Index: ModuleLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/modules/ModuleLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ModuleLoader.java	2001/08/16 04:41:35	1.1
  +++ ModuleLoader.java	2001/09/01 16:58:11	1.2
  @@ -65,13 +65,13 @@
   import org.apache.commons.collections.FastArrayList;
   import org.apache.commons.collections.FastHashMap;
   import org.apache.commons.collections.ExtendedProperties;
  -import org.apache.turbine.util.Log;
  +import org.apache.turbine.Log;
   
   /**
    * Load modules for use in the view pipeline.
    *
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
  - * @version $Id: ModuleLoader.java,v 1.1 2001/08/16 04:41:35 jvanzyl Exp $
  + * @version $Id: ModuleLoader.java,v 1.2 2001/09/01 16:58:11 jvanzyl Exp $
    */
   public class ModuleLoader
   {
  
  
  
  1.2       +2 -2      jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/AccessController.java
  
  Index: AccessController.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/AccessController.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AccessController.java	2001/08/16 04:41:35	1.1
  +++ AccessController.java	2001/09/01 16:58:11	1.2
  @@ -56,7 +56,7 @@
   
   import org.apache.turbine.RunData;
   import org.apache.turbine.modules.Action;
  -import org.apache.turbine.util.Log;
  +import org.apache.turbine.Log;
   import org.apache.fulcrum.security.TurbineSecurity;
   import org.apache.fulcrum.security.util.AccessControlList;
   
  @@ -91,7 +91,7 @@
    *
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
  - * @version $Id: AccessController.java,v 1.1 2001/08/16 04:41:35 jvanzyl Exp $
  + * @version $Id: AccessController.java,v 1.2 2001/09/01 16:58:11 jvanzyl Exp $
    */
   public class AccessController
       extends Action
  
  
  
  1.2       +2 -2      jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/LoginUser.java
  
  Index: LoginUser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/LoginUser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoginUser.java	2001/08/16 04:41:36	1.1
  +++ LoginUser.java	2001/09/01 16:58:11	1.2
  @@ -59,7 +59,7 @@
   import org.apache.turbine.modules.Action;
   import org.apache.fulcrum.security.TurbineSecurity;
   import org.apache.fulcrum.security.entity.User;
  -import org.apache.turbine.util.Log;
  +import org.apache.turbine.Log;
   import org.apache.fulcrum.security.util.DataBackendException;
   import org.apache.fulcrum.security.util.TurbineSecurityException;
   
  @@ -69,7 +69,7 @@
    * that users last login time will be updated.
    *
    * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
  - * @version $Id: LoginUser.java,v 1.1 2001/08/16 04:41:36 jvanzyl Exp $
  + * @version $Id: LoginUser.java,v 1.2 2001/09/01 16:58:11 jvanzyl Exp $
    */
   public class LoginUser
       extends Action
  
  
  
  1.2       +2 -2      jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/LogoutUser.java
  
  Index: LogoutUser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/LogoutUser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogoutUser.java	2001/08/16 04:41:36	1.1
  +++ LogoutUser.java	2001/09/01 16:58:11	1.2
  @@ -59,7 +59,7 @@
   import org.apache.turbine.modules.Action;
   import org.apache.fulcrum.security.entity.User;
   import org.apache.fulcrum.security.TurbineSecurity;
  -import org.apache.turbine.util.Log;
  +import org.apache.turbine.Log;
   import org.apache.fulcrum.security.util.AccessControlList;
   
   /**
  @@ -67,7 +67,7 @@
    * the User object in the session.
    *
    * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
  - * @version $Id: LogoutUser.java,v 1.1 2001/08/16 04:41:36 jvanzyl Exp $
  + * @version $Id: LogoutUser.java,v 1.2 2001/09/01 16:58:11 jvanzyl Exp $
    */
   public class LogoutUser
       extends Action
  
  
  
  1.2       +2 -2      jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/TemplateSessionValidator.java
  
  Index: TemplateSessionValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/modules/actions/TemplateSessionValidator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TemplateSessionValidator.java	2001/08/16 04:41:36	1.1
  +++ TemplateSessionValidator.java	2001/09/01 16:58:11	1.2
  @@ -57,7 +57,7 @@
   import org.apache.turbine.Turbine;
   import org.apache.turbine.RunData;
   import org.apache.fulcrum.security.TurbineSecurity;
  -import org.apache.turbine.util.Log;
  +import org.apache.turbine.Log;
   
   /**
    * SessionValidator for use with the Template Service, the
  @@ -71,7 +71,7 @@
    * @see TemplateSecureSessionValidator
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
  - * @version $Id: TemplateSessionValidator.java,v 1.1 2001/08/16 04:41:36 jvanzyl Exp $
  + * @version $Id: TemplateSessionValidator.java,v 1.2 2001/09/01 16:58:11 jvanzyl Exp $
    */
   public class TemplateSessionValidator
       extends SessionValidator
  
  
  
  1.3       +2 -2      jakarta-turbine-3/src/java/org/apache/turbine/pipeline/ClassicPipeline.java
  
  Index: ClassicPipeline.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/ClassicPipeline.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassicPipeline.java	2001/08/17 06:02:01	1.2
  +++ ClassicPipeline.java	2001/09/01 16:58:11	1.3
  @@ -62,8 +62,8 @@
   import org.apache.turbine.TemplateContext;
   import org.apache.turbine.modules.Module;
   import org.apache.turbine.modules.ModuleLoader;
  -import org.apache.turbine.util.Log;
  -import org.apache.turbine.util.DynamicURI;
  +import org.apache.turbine.Log;
  +import org.apache.turbine.DynamicURI;
   import org.apache.turbine.modules.actions.SessionValidator;
   import org.apache.turbine.modules.actions.AccessController;
   import org.apache.fulcrum.security.util.AccessControlList;
  
  
  
  1.2       +1 -1      jakarta-turbine-3/src/java/org/apache/turbine/pipeline/Renderer.java
  
  Index: Renderer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/Renderer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Renderer.java	2001/08/16 04:41:37	1.1
  +++ Renderer.java	2001/09/01 16:58:11	1.2
  @@ -58,7 +58,7 @@
   import org.apache.turbine.RunData;
   import org.apache.turbine.modules.Module;
   import org.apache.turbine.TurbineException;
  -import org.apache.turbine.util.Log;
  +import org.apache.turbine.Log;
   
   public class Renderer
   {
  
  
  
  1.2       +2 -2      jakarta-turbine-3/src/java/org/apache/turbine/services/rundata/RunDataFactory.java
  
  Index: RunDataFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/services/rundata/RunDataFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RunDataFactory.java	2001/08/16 04:41:47	1.1
  +++ RunDataFactory.java	2001/09/01 16:58:12	1.2
  @@ -65,7 +65,7 @@
   import org.apache.fulcrum.pool.PoolService;
   import org.apache.fulcrum.util.parser.DefaultCookieParser;
   import org.apache.turbine.ParameterParser;
  -import org.apache.turbine.util.Log;
  +import org.apache.turbine.Log;
   import org.apache.turbine.services.rundata.RunDataService;
   import org.apache.turbine.services.rundata.TurbineRunData;
   import org.apache.turbine.services.rundata.DefaultTurbineRunData;
  @@ -77,7 +77,7 @@
    * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
    * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
  - * @version $Id: RunDataFactory.java,v 1.1 2001/08/16 04:41:47 jvanzyl Exp $
  + * @version $Id: RunDataFactory.java,v 1.2 2001/09/01 16:58:12 jvanzyl Exp $
    */
   public class RunDataFactory
   {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org