cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/servlet CocoonServlet.java
Date Fri, 20 Jul 2001 09:03:30 GMT
cziegeler    01/07/20 02:03:30

  Modified:    .        build.xml
               src/org/apache/cocoon/environment/http RequestWrapper22.java
                        RequestWrapper23.java
               src/org/apache/cocoon/servlet CocoonServlet.java
  Added:       src/org/apache/cocoon/environment/http
                        RequestWrapperMaybeUpload22.java
                        RequestWrapperMaybeUpload23.java
  Log:
  MaybeUpload is now optional
  
  Revision  Changes    Path
  1.37      +24 -3     xml-cocoon2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/build.xml,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- build.xml	2001/07/19 20:11:56	1.36
  +++ build.xml	2001/07/20 09:03:29	1.37
  @@ -272,6 +272,9 @@
       <available property="weblogic.present" classname="weblogic.servlet.internal.ServletContextImpl">
         <classpath refid="classpath"/>
       </available>
  +    <available property="maybeupload.present" classname="uk.co.weft.maybeupload.MaybeUploadRequestWrapper">
  +      <classpath refid="classpath"/>
  +    </available>
     </target>
   
     <!-- =================================================================== -->
  @@ -289,7 +292,7 @@
       <mkdir dir="${build.dest}"/>
       <copy todir="${build.src}" filtering="on">
         <fileset dir="${src.dir}">
  -        <exclude name="**/http/RequestWrapper2*.java"/>
  +        <exclude name="**/http/RequestWrapper*.java"/>
           <exclude name="**/Ora*.java" unless="ora.driver.present"/>
           <exclude name="**/Sendmail*.java" unless="mail.present"/>
           <exclude name="**/LDAPTransformer*.java" unless="naming.present"/>
  @@ -300,18 +303,36 @@
     </target>
   
     <!-- =================================================================== -->
  +  <!-- Prepares the servlet 2.3 source code if maybeupload is present      -->
  +  <!-- =================================================================== -->
  +  <target name="prepare-src-23-maybeupload" depends="prepare-src-main" if="maybeupload.present">
  +    <copy file="${src.dir}/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload23.java"
  +        tofile="${build.src}/org/apache/cocoon/environment/http/RequestWrapper.java"
  +        filtering="on"/>
  +  </target>
  +
  +  <!-- =================================================================== -->
     <!-- Prepares the servlet 2.3 source code                                -->
     <!-- =================================================================== -->
  -  <target name="prepare-src-23" depends="prepare-src-main" if="servlet23.present">
  +  <target name="prepare-src-23" depends="prepare-src-23-maybeupload,prepare-src-main"
if="servlet23.present" unless="maybeupload.present">
       <copy file="${src.dir}/org/apache/cocoon/environment/http/RequestWrapper23.java"
           tofile="${build.src}/org/apache/cocoon/environment/http/RequestWrapper.java"
           filtering="on"/>
     </target>
   
     <!-- =================================================================== -->
  +  <!-- Prepares the servlet 2.2 source code if maybeupload is present      -->
  +  <!-- =================================================================== -->
  +  <target name="prepare-src-22-maybeupload" depends="prepare-src-main" if="maybeupload.present"
unless="servlet23.present">
  +    <copy file="${src.dir}/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload22.java"
  +        tofile="${build.src}/org/apache/cocoon/environment/http/RequestWrapper.java"
  +        filtering="on"/>
  +  </target>
  +
  +  <!-- =================================================================== -->
     <!-- Prepares the servlet 2.2 source code                                -->
     <!-- =================================================================== -->
  -  <target name="prepare-src-22" depends="prepare-src-23" unless="servlet23.present">
  +  <target name="prepare-src-22" depends="prepare-src-22-maybeupload,prepare-src-23"
unless="servlet23.present, maybeupload.present">
       <copy file="${src.dir}/org/apache/cocoon/environment/http/RequestWrapper22.java"
           tofile="${build.src}/org/apache/cocoon/environment/http/RequestWrapper.java"
           filtering="on"/>
  
  
  
  1.5       +37 -13    xml-cocoon2/src/org/apache/cocoon/environment/http/RequestWrapper22.java
  
  Index: RequestWrapper22.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/http/RequestWrapper22.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RequestWrapper22.java	2001/06/14 11:07:41	1.4
  +++ RequestWrapper22.java	2001/07/20 09:03:29	1.5
  @@ -7,30 +7,54 @@
    *****************************************************************************/
   package org.apache.cocoon.environment.http;
   
  -import java.io.BufferedReader;
   import java.io.File;
  -import java.io.IOException;
  -import java.io.UnsupportedEncodingException;
  -import java.util.Enumeration;
  -import java.util.Locale;
   import java.util.Vector;
  -import javax.servlet.RequestDispatcher;
   import javax.servlet.http.HttpServletRequest;
  -import javax.servlet.http.HttpSession;
  -import org.apache.cocoon.environment.Request;
  -import uk.co.weft.maybeupload.MaybeUploadRequestWrapper;
   
   /**
    *
    * Implements the {@link javax.servlet.http.HttpServletRequest} interface
    * to provide request information for HTTP servlets.
  + *
  + * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  + * @version CVS $Revision: 1.5 $ $Date: 2001/07/20 09:03:29 $
    */
   
  -public class RequestWrapper extends MaybeUploadRequestWrapper {
  +public final class RequestWrapper {
   
  -    public RequestWrapper(HttpServletRequest httpservletrequest, boolean flag1, File file,
boolean flag2, boolean flag3, int size)
  -        throws Exception {
  -        super(httpservletrequest, flag1, file, flag2, flag3, size);
  +    /**
  +     * Return a wrapped request object
  +     */
  +    public static HttpServletRequest getServletRequest(HttpServletRequest request,
  +                                                       boolean saveUploadedFilesToDisk,
  +                                                       File    uploadDirectory,
  +                                                       boolean allowOverwrite,
  +                                                       boolean silentlyRename,
  +                                                       int     maxUploadSize) {
  +        return request;
       }
   
  +    /**
  +     * Implementation of the get method
  + */
  +    public static Object get(HttpServletRequest request, String name) {
  +        String[] values = request.getParameterValues(name);
  +
  +        if (values == null) return null;
  +
  +        if (values.length == 1) {
  +            return values[0];
  +    }
  +
  +        if (values.length > 1) {
  +            Vector vect = new Vector(values.length);
  +
  +            for (int i = 0; i < values.length; i++) {
  +                vect.add(values[i]);
  +            }
  +
  +            return vect;
  +        }
  +        return null;
  +    }
   }
  
  
  
  1.5       +31 -21    xml-cocoon2/src/org/apache/cocoon/environment/http/RequestWrapper23.java
  
  Index: RequestWrapper23.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/http/RequestWrapper23.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RequestWrapper23.java	2001/06/14 11:07:43	1.4
  +++ RequestWrapper23.java	2001/07/20 09:03:29	1.5
  @@ -7,45 +7,55 @@
    *****************************************************************************/
   package org.apache.cocoon.environment.http;
   
  -import java.io.BufferedReader;
   import java.io.File;
  -import java.io.IOException;
  -import java.io.UnsupportedEncodingException;
  -import java.util.Enumeration;
  -import java.util.Locale;
   import java.util.Vector;
  -import javax.servlet.RequestDispatcher;
   import javax.servlet.http.HttpServletRequest;
  -import javax.servlet.http.HttpSession;
  -import org.apache.cocoon.environment.Request;
  -import uk.co.weft.maybeupload.MaybeUploadRequestWrapper;
   
   /**
    *
    * Implements the {@link javax.servlet.http.HttpServletRequest} interface
    * to provide request information for HTTP servlets.
  + *
  + * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  + * @version CVS $Revision: 1.5 $ $Date: 2001/07/20 09:03:29 $
    */
   
  -public class RequestWrapper extends MaybeUploadRequestWrapper implements HttpServletRequest
{
  +public final class RequestWrapper {
   
  -    public RequestWrapper(HttpServletRequest httpservletrequest, boolean flag1, File file,
boolean flag2, boolean flag3, int size)
  -        throws Exception {
  -        super(httpservletrequest, flag1, file, flag2, flag3, size);
  +    /**
  +     * Return a wrapped request object
  +     */
  +    public static HttpServletRequest getServletRequest(HttpServletRequest request,
  +                                                       boolean saveUploadedFilesToDisk,
  +                                                       File    uploadDirectory,
  +                                                       boolean allowOverwrite,
  +                                                       boolean silentlyRename,
  +                                                       int     maxUploadSize) {
  +        return request;
       }
   
  -    public java.util.Map getParameterMap() {
  -        // FIXME:
  -        return null;
  -    }
  +    /**
  +     * Implementation of the get method
  +     */
  +    public static Object get(HttpServletRequest request, String name) {
  +        String[] values = request.getParameterValues(name);
   
  +        if (values == null) return null;
   
  -    public void setCharacterEncoding(java.lang.String s) {
  -        // FIXME:
  +        if (values.length == 1) {
  +            return values[0];
       }
   
  +        if (values.length > 1) {
  +            Vector vect = new Vector(values.length);
   
  -    public java.lang.StringBuffer getRequestURL() {
  -        // FIXME:
  +            for (int i = 0; i < values.length; i++) {
  +                vect.add(values[i]);
  +    }
  +
  +            return vect;
  +        }
           return null;
       }
  +
   }
  
  
  
  1.2       +92 -0     xml-cocoon2/src/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload22.java
  
  
  
  
  1.2       +108 -0    xml-cocoon2/src/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload23.java
  
  
  
  
  1.22      +7 -27     xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- CocoonServlet.java	2001/07/20 07:26:53	1.21
  +++ CocoonServlet.java	2001/07/20 09:03:29	1.22
  @@ -61,7 +61,7 @@
    * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.21 $ $Date: 2001/07/20 07:26:53 $
  + * @version CVS $Revision: 1.22 $ $Date: 2001/07/20 09:03:29 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -385,31 +385,6 @@
           }
       }
   
  -    private HttpServletRequest getServletRequest(HttpServletRequest request) {
  -        HttpServletRequest req = request;
  -        String contentType = req.getContentType();
  -
  -        if (contentType == null) {
  -            contentType = "application/x-www-form-urlencoded";
  -        }
  -
  -        if (contentType.startsWith("multipart/form-data")) {
  -            try {
  -                req = new RequestWrapper(request,
  -                                         CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK,
  -                                         this.uploadDir,
  -                                         CocoonServlet.ALLOW_OVERWRITE,
  -                                         CocoonServlet.SILENTLY_RENAME,
  -                                         CocoonServlet.MAX_UPLOAD_SIZE);
  -            } catch (Exception e) {
  -                log.warn("Could not create RequestWrapper", e);
  -                req = request;
  -            }
  -        }
  -
  -        return req;
  -    }
  -
       /**
        * Handle the "force-load" parameter.  This overcomes limits in
        * many classpath issues.  One of the more notorious ones is a
  @@ -458,7 +433,12 @@
   
           // This is more scalable
           long start = new Date().getTime();
  -        HttpServletRequest request = this.getServletRequest(req);
  +        HttpServletRequest request = RequestWrapper.getServletRequest(req,
  +                                         CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK,
  +                                         this.uploadDir,
  +                                         CocoonServlet.ALLOW_OVERWRITE,
  +                                         CocoonServlet.SILENTLY_RENAME,
  +                                         CocoonServlet.MAX_UPLOAD_SIZE);
   
           this.cocoon = getCocoon(request.getPathInfo(), request.getParameter(Constants.RELOAD_PARAM));
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message