cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r164225 - in /cocoon/trunk/src/java/org/apache/cocoon: core/CoreUtil.java servlet/CocoonServlet.java servlet/multipart/MultipartHttpServletRequest.java servlet/multipart/MultipartParser.java servlet/multipart/PartInMemory.java servlet/multipart/PartOnDisk.java servlet/multipart/TokenStream.java
Date Fri, 22 Apr 2005 12:11:58 GMT
Author: cziegeler
Date: Fri Apr 22 05:11:58 2005
New Revision: 164225

URL: http://svn.apache.org/viewcvs?rev=164225&view=rev
Log:
2.2 is based on 2.3 of the servlet spec

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
    cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
    cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
    cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
    cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartInMemory.java
    cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartOnDisk.java
    cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/TokenStream.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java?rev=164225&r1=164224&r2=164225&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/CoreUtil.java Fri Apr 22 05:11:58 2005
@@ -96,6 +96,11 @@
     /** The time the cocoon instance was created. */
     protected long creationTime;
 
+    /**
+     * Setup a new instance.
+     * @param environment The hook back to the environment.
+     * @throws Exception
+     */
     public CoreUtil(BootstrapEnvironment environment)
     throws Exception {
         this.env = environment;

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java?rev=164225&r1=164224&r2=164225&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java Fri Apr 22 05:11:58
2005
@@ -226,7 +226,7 @@
             }
         }
 
-        this.containerEncoding = getInitParameter("container-encoding", "ISO-8859-1");
+        this.containerEncoding = this.getInitParameter("container-encoding", "ISO-8859-1");
         this.requestFactory = new RequestFactory(coreUtil.getCore().getSettings().isAutosaveUploads(),
                                                  new File(coreUtil.getCore().getSettings().getUploadDirectory()),
                                                  coreUtil.getCore().getSettings().isAllowOverwrite(),

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java?rev=164225&r1=164224&r2=164225&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
Fri Apr 22 05:11:58 2005
@@ -15,43 +15,32 @@
  */
 package org.apache.cocoon.servlet.multipart;
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.Principal;
 import java.util.Enumeration;
 import java.util.Hashtable;
-import java.util.Locale;
-import java.util.Map;
 import java.util.Vector;
 
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpServletRequestWrapper;
 
 /**
  * Servlet request wrapper for multipart parser.
  *
  * @author <a href="mailto:j.tervoorde@home.nl">Jeroen ter Voorde</a>
  * @author Stefano Mazzocchi
- * @version CVS $Id: MultipartHttpServletRequest.java,v 1.7 2004/03/05 13:02:58 bdelacretaz
Exp $
+ * @version CVS $Id$
  */
-public class MultipartHttpServletRequest implements HttpServletRequest {
-
-    /** The wrapped request */
-    private HttpServletRequest request = null;
+public class MultipartHttpServletRequest extends HttpServletRequestWrapper {
 
     /** The submitted parts */
-    private Hashtable values = null;
+    private Hashtable values;
 
     /**
      * Create this wrapper around the given request and including the given
      * parts.
      */
     public MultipartHttpServletRequest(HttpServletRequest request, Hashtable values) {
-        this.request = request;
+        super(request);
         this.values = values;
     }
 
@@ -86,12 +75,11 @@
             if (result instanceof Vector) {
                 if (((Vector) result).size() == 1) {
                     return ((Vector) result).elementAt(0);
-                } else {
-                    return result;
                 }
+                return result;
             }
         } else {
-            String[] array = request.getParameterValues(name);
+            String[] array = this.getRequest().getParameterValues(name);
             Vector vec = new Vector();
 
             if (array != null) {
@@ -117,9 +105,8 @@
     public Enumeration getParameterNames() {
         if (values != null) {
             return values.keys();
-        } else {
-            return request.getParameterNames();
         }
+        return this.getRequest().getParameterNames();
     }
 
     /**
@@ -161,417 +148,13 @@
                     }
                     return results;
 
-                } else {
-                    return new String[]{value.toString()};
                 }
+                return new String[]{value.toString()};
             }
 
             return null;
-        } else {
-            return request.getParameterValues(name);
         }
+        return this.getRequest().getParameterValues(name);
     }
-
-    /**
-     * Method getAttribute
-     *
-     * @param name
-     *
-     */
-    public Object getAttribute(String name) {
-        return request.getAttribute(name);
-    }
-
-    /**
-     * Method getAttributeNames
-     *
-     */
-    public Enumeration getAttributeNames() {
-        return request.getAttributeNames();
-    }
-
-    /**
-     * Method getCharacterEncoding
-     *
-     */
-    public String getCharacterEncoding() {
-        return request.getCharacterEncoding();
-    }
-
-    /**
-     * Method getContentLength
-     *
-     */
-    public int getContentLength() {
-        return request.getContentLength();
-    }
-
-    /**
-     * Method getContentType
-     *
-     */
-    public String getContentType() {
-        return request.getContentType();
-    }
-
-    /**
-     * Method getInputStream
-     *
-     *
-     * @throws IOException
-     */
-    public ServletInputStream getInputStream() throws IOException {
-        return request.getInputStream();
-    }
-
-    /**
-     * Method getProtocol
-     *
-     */
-    public String getProtocol() {
-        return request.getProtocol();
-    }
-
-    /**
-     * Method getScheme
-     *
-     */
-    public String getScheme() {
-        return request.getScheme();
-    }
-
-    /**
-     * Method getServerName
-     *
-     */
-    public String getServerName() {
-        return request.getServerName();
-    }
-
-    /**
-     * Method getServerPort
-     *
-     */
-    public int getServerPort() {
-        return request.getServerPort();
-    }
-
-    /**
-     * Method getReader
-     *
-     *
-     * @throws IOException
-     */
-    public BufferedReader getReader() throws IOException {
-        return request.getReader();
-    }
-
-    /**
-     * Method getRemoteAddr
-     *
-     */
-    public String getRemoteAddr() {
-        return request.getRemoteAddr();
-    }
-
-    /**
-     * Method getRemoteHost
-     *
-     */
-    public String getRemoteHost() {
-        return request.getRemoteHost();
-    }
-
-    /**
-     * Method setAttribute
-     *
-     * @param name
-     * @param o
-     */
-    public void setAttribute(String name, Object o) {
-        request.setAttribute(name, o);
-    }
-
-    /**
-     * Method removeAttribute
-     *
-     * @param name
-     */
-    public void removeAttribute(String name) {
-        request.removeAttribute(name);
-    }
-
-    /**
-     * Method getLocale
-     *
-     */
-    public Locale getLocale() {
-        return request.getLocale();
-    }
-
-    /**
-     * Method getLocales
-     *
-     */
-    public Enumeration getLocales() {
-        return request.getLocales();
-    }
-
-    /**
-     * Method isSecure
-     *
-     */
-    public boolean isSecure() {
-        return request.isSecure();
-    }
-
-    /**
-     * Method getRequestDispatcher
-     *
-     * @param path
-     *
-     */
-    public RequestDispatcher getRequestDispatcher(String path) {
-        return request.getRequestDispatcher(path);
-    }
-
-    /**
-     * Method getRealPath
-     *
-     * @param path
-     *
-     */
-    public String getRealPath(String path) {
-        return request.getRealPath(path);
-    }
-
-    /**
-     * Method getAuthType
-     *
-     */
-    public String getAuthType() {
-        return request.getAuthType();
-    }
-
-    /**
-     * Method getCookies
-     *
-     */
-    public Cookie[] getCookies() {
-        return request.getCookies();
-    }
-
-    /**
-     * Method getDateHeader
-     *
-     * @param name
-     *
-     */
-    public long getDateHeader(String name) {
-        return request.getDateHeader(name);
-    }
-
-    /**
-     * Method getHeader
-     *
-     * @param name
-     *
-     */
-    public String getHeader(String name) {
-        return request.getHeader(name);
-    }
-
-    /**
-     * Method getHeaders
-     *
-     * @param name
-     *
-     */
-    public Enumeration getHeaders(String name) {
-        return request.getHeaders(name);
-    }
-
-    /**
-     * Method getHeaderNames
-     *
-     */
-    public Enumeration getHeaderNames() {
-        return request.getHeaderNames();
-    }
-
-    /**
-     * Method getIntHeader
-     *
-     * @param name
-     *
-     */
-    public int getIntHeader(String name) {
-        return request.getIntHeader(name);
-    }
-
-    /**
-     * Method getMethod
-     *
-     */
-    public String getMethod() {
-        return request.getMethod();
-    }
-
-    /**
-     * Method getPathInfo
-     *
-     */
-    public String getPathInfo() {
-        return request.getPathInfo();
-    }
-
-    /**
-     * Method getPathTranslated
-     *
-     */
-    public String getPathTranslated() {
-        return request.getPathTranslated();
-    }
-
-    /**
-     * Method getContextPath
-     *
-     */
-    public String getContextPath() {
-        return request.getContextPath();
-    }
-
-    /**
-     * Method getQueryString
-     *
-     */
-    public String getQueryString() {
-        return request.getQueryString();
-    }
-
-    /**
-     * Method getRemoteUser
-     *
-     */
-    public String getRemoteUser() {
-        return request.getRemoteUser();
-    }
-
-    /**
-     * Method isUserInRole
-     *
-     * @param role
-     *
-     */
-    public boolean isUserInRole(String role) {
-        return request.isUserInRole(role);
-    }
-
-    /**
-     * Method getUserPrincipal
-     *
-     */
-    public Principal getUserPrincipal() {
-        return request.getUserPrincipal();
-    }
-
-    /**
-     * Method getRequestedSessionId
-     *
-     */
-    public String getRequestedSessionId() {
-        return request.getRequestedSessionId();
-    }
-
-    /**
-     * Method getRequestURI
-     *
-     */
-    public String getRequestURI() {
-        return request.getRequestURI();
-    }
-
-    /**
-     * Method getServletPath
-     *
-     */
-    public String getServletPath() {
-        return request.getServletPath();
-    }
-
-    /**
-     * Method getSession
-     *
-     * @param create
-     *
-     */
-    public HttpSession getSession(boolean create) {
-        return request.getSession(create);
-    }
-
-    /**
-     * Method getSession
-     *
-     */
-    public HttpSession getSession() {
-        return request.getSession();
-    }
-
-    /**
-     * Method isRequestedSessionIdValid
-     *
-     */
-    public boolean isRequestedSessionIdValid() {
-        return request.isRequestedSessionIdValid();
-    }
-
-    /**
-     * Method isRequestedSessionIdFromCookie
-     *
-     */
-    public boolean isRequestedSessionIdFromCookie() {
-        return request.isRequestedSessionIdFromCookie();
-    }
-
-    /**
-     * Method isRequestedSessionIdFromURL
-     *
-     */
-    public boolean isRequestedSessionIdFromURL() {
-        return request.isRequestedSessionIdFromURL();
-    }
-
-    /**
-     * Method isRequestedSessionIdFromUrl
-     * @deprecated use {@link #isRequestedSessionIdFromURL()} instead
-     */
-    public boolean isRequestedSessionIdFromUrl() {
-        return request.isRequestedSessionIdFromURL();
-    }
-
-	/* (non-Javadoc)
-	 * @see javax.servlet.http.HttpServletRequest#getRequestURL()
-	 */
-	public StringBuffer getRequestURL() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletRequest#getParameterMap()
-	 */
-	public Map getParameterMap() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
-	 */
-	public void setCharacterEncoding(String arg0)
-		throws UnsupportedEncodingException {
-		// TODO Auto-generated method stub
-
-	}
 
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java?rev=164225&r1=164224&r2=164225&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java Fri Apr
22 05:11:58 2005
@@ -39,7 +39,7 @@
  * FilePart: file part
  *
  * @author <a href="mailto:j.tervoorde@home.nl">Jeroen ter Voorde</a>
- * @version CVS $Id: MultipartParser.java,v 1.8 2004/03/11 18:21:48 joerg Exp $
+ * @version CVS $Id$
  */
 public class MultipartParser {
 
@@ -317,9 +317,8 @@
         int start = hdr.toLowerCase().indexOf("boundary=");
         if (start > -1) {
             return "--" + hdr.substring(start + 9);
-        } else {
-            return null;
         }
+        return null;
     }
 
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartInMemory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartInMemory.java?rev=164225&r1=164224&r2=164225&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartInMemory.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartInMemory.java Fri Apr 22
05:11:58 2005
@@ -65,9 +65,8 @@
     public InputStream getInputStream() throws Exception {
         if (this.in != null) {
             return this.in;
-        } else {
-            throw new IllegalStateException("This part has already been disposed.");
         }
+        throw new IllegalStateException("This part has already been disposed.");
     }
     
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartOnDisk.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartOnDisk.java?rev=164225&r1=164224&r2=164225&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartOnDisk.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/PartOnDisk.java Fri Apr 22 05:11:58
2005
@@ -24,7 +24,7 @@
  * This class represents a file part parsed from a http post stream.
  *
  * @author <a href="mailto:j.tervoorde@home.nl">Jeroen ter Voorde</a>
- * @version CVS $Id: PartOnDisk.java,v 1.4 2004/03/05 13:02:58 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class PartOnDisk extends Part {
 
@@ -77,9 +77,8 @@
     public InputStream getInputStream() throws Exception {
         if (this.file != null) {
             return new FileInputStream(file);
-        } else {
-            throw new IllegalStateException("This part has already been disposed.");
         }
+        throw new IllegalStateException("This part has already been disposed.");
     }
 
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/TokenStream.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/TokenStream.java?rev=164225&r1=164224&r2=164225&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/TokenStream.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/multipart/TokenStream.java Fri Apr 22
05:11:58 2005
@@ -24,7 +24,7 @@
  *
  * A newline is espected after each boundary and is parsed away.
  * @author <a href="mailto:j.tervoorde@home.nl">Jeroen ter Voorde</a>
- * @version CVS $Id: TokenStream.java,v 1.4 2004/03/05 13:02:58 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 class TokenStream extends PushbackInputStream {
 
@@ -178,17 +178,17 @@
                     state = STATE_ENDOFSTREAM;
                 }
                 return written;
-            } else {                                   // did not match boundary
-                // bytes skipped, write first skipped byte, push back the rest
-                if (b != -1) {                         // b may be -1
-                    in.unread(b);                      // the non-matching byte
-                }
-                in.unread(boundary, 1,
-                        boundaryIndex - 1);          // unread skipped boundary data
-                out[written++] = boundary[0];
-                if (written == out.length) {
-                    return written;
-                }
+            }
+            // did not match boundary
+            // bytes skipped, write first skipped byte, push back the rest
+            if (b != -1) {                         // b may be -1
+                in.unread(b);                      // the non-matching byte
+            }
+            in.unread(boundary, 1,
+                    boundaryIndex - 1);          // unread skipped boundary data
+            out[written++] = boundary[0];
+            if (written == out.length) {
+                return written;
             }
             b = in.read();
         }
@@ -252,8 +252,7 @@
 
         if (read == 0) {
             return -1;
-        } else {
-            return buf[0];
         }
+        return buf[0];
     }
 }



Mime
View raw message