Update throws declaration for Servlet 3 file upload
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 17 Nov 2009 02:41:55 +0000 (02:41 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 17 Nov 2009 02:41:55 +0000 (02:41 +0000)
Do the easy part of the implementation

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@881109 13f79535-47bb-0310-9956-ffa450edef68

java/javax/servlet/http/HttpServletRequest.java
java/javax/servlet/http/HttpServletRequestWrapper.java
java/org/apache/catalina/connector/Request.java
java/org/apache/catalina/connector/RequestFacade.java

index 2589b8f..813484d 100644 (file)
@@ -697,21 +697,27 @@ public interface HttpServletRequest extends ServletRequest {
     
     
     /**
-     * 
+     * Return a collection of all uploaded Parts.
      * @return
+     * @throws IOException           if an I/O error occurs
+     * @throws IllegalStateException if size limits are exceeded
+     * @throws ServletException      if the request is not multipart/form-data
      * @since Servlet 3.0
-     * TODO SERVLET3 - Add comments
      */
-    public Collection<Part> getParts() throws IOException, ServletException;
+    public Collection<Part> getParts() throws IOException,
+            IllegalStateException, ServletException;
     
     
     /**
-     * 
+     * Gets the named Part or null if the Part does not exist. Triggers upload
+     * of all Parts. 
      * @param name
      * @return
-     * @throws IllegalArgumentException
+     * @throws IOException           if an I/O error occurs
+     * @throws IllegalStateException if size limits are exceeded
+     * @throws ServletException      if the request is not multipart/form-data
      * @since Servlet 3.0
-     * TODO SERVLET3 - Add comments
      */
-    public Part getPart(String name);
+    public Part getPart(String name) throws IOException, IllegalStateException,
+            ServletException; 
 }
index 832fd5d..2d9454a 100644 (file)
@@ -294,15 +294,20 @@ public class HttpServletRequestWrapper extends ServletRequestWrapper implements
      * @since Servlet 3.0
      * TODO SERVLET3 - Add comments
      */
-    public Collection<Part> getParts() throws IOException, ServletException {
+    public Collection<Part> getParts() throws IllegalStateException,
+            IOException, ServletException {
         return this._getHttpServletRequest().getParts();
     }
 
     /**
+     * @throws ServletException 
+     * @throws IOException 
+     * @throws IllegalStateException 
      * @since Servlet 3.0
      * TODO SERVLET3 - Add comments
      */
-    public Part getPart(String name) {
+    public Part getPart(String name) throws IllegalStateException, IOException,
+            ServletException {
         return this._getHttpServletRequest().getPart(name);
     }
 
index 29d9c74..f0a1fb3 100644 (file)
@@ -2380,13 +2380,22 @@ public class Request
                 null, null, null);
     }
     
-    public Collection<Part> getParts() {
+    public Collection<Part> getParts() throws IOException, IllegalStateException,
+            ServletException {
         // TODO SERVLET3 - file upload
         return null;
     }
     
-    public Part getPart(String name) throws IllegalArgumentException {
-        // TODO SERVLET3 - file upload
+    public Part getPart(String name) throws IOException, IllegalStateException,
+            ServletException {
+        Collection<Part> parts = getParts();
+        Iterator<Part> iterator = parts.iterator();
+        while (iterator.hasNext()) {
+            Part part = iterator.next();
+            if (name.equals(part.getName())) {
+                return part;
+            }
+        }
         return null;
     }
 
index 476fa71..f3ed48b 100644 (file)
@@ -996,11 +996,13 @@ public class RequestFacade implements HttpServletRequest {
         request.logout();
     }
     
-    public Collection<Part> getParts() {
+    public Collection<Part> getParts() throws IllegalStateException,
+            IOException, ServletException {
         return request.getParts();
     }
     
-    public Part getPart(String name) {
+    public Part getPart(String name) throws IllegalStateException, IOException,
+            ServletException {
         return request.getPart(name);
     }