From: markt Date: Tue, 17 Nov 2009 02:41:55 +0000 (+0000) Subject: Update throws declaration for Servlet 3 file upload X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=cc968ecd3819cfa3463b8d8ff8f7feef8f0b1d3b;p=tomcat7.0 Update throws declaration for Servlet 3 file upload Do the easy part of the implementation git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@881109 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/javax/servlet/http/HttpServletRequest.java b/java/javax/servlet/http/HttpServletRequest.java index 2589b8ff6..813484dda 100644 --- a/java/javax/servlet/http/HttpServletRequest.java +++ b/java/javax/servlet/http/HttpServletRequest.java @@ -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 getParts() throws IOException, ServletException; + public Collection 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; } diff --git a/java/javax/servlet/http/HttpServletRequestWrapper.java b/java/javax/servlet/http/HttpServletRequestWrapper.java index 832fd5d13..2d9454aee 100644 --- a/java/javax/servlet/http/HttpServletRequestWrapper.java +++ b/java/javax/servlet/http/HttpServletRequestWrapper.java @@ -294,15 +294,20 @@ public class HttpServletRequestWrapper extends ServletRequestWrapper implements * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public Collection getParts() throws IOException, ServletException { + public Collection 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); } diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java index 29d9c745d..f0a1fb3fb 100644 --- a/java/org/apache/catalina/connector/Request.java +++ b/java/org/apache/catalina/connector/Request.java @@ -2380,13 +2380,22 @@ public class Request null, null, null); } - public Collection getParts() { + public Collection 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 parts = getParts(); + Iterator iterator = parts.iterator(); + while (iterator.hasNext()) { + Part part = iterator.next(); + if (name.equals(part.getName())) { + return part; + } + } return null; } diff --git a/java/org/apache/catalina/connector/RequestFacade.java b/java/org/apache/catalina/connector/RequestFacade.java index 476fa714a..f3ed48bd0 100644 --- a/java/org/apache/catalina/connector/RequestFacade.java +++ b/java/org/apache/catalina/connector/RequestFacade.java @@ -996,11 +996,13 @@ public class RequestFacade implements HttpServletRequest { request.logout(); } - public Collection getParts() { + public Collection 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); }