You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2010/12/05 14:08:00 UTC
svn commit: r1042345 [3/3] - in
/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util: io/ upload/
Modified: wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletFileUpload.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletFileUpload.java?rev=1042345&r1=1042344&r2=1042345&view=diff
==============================================================================
--- wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletFileUpload.java (original)
+++ wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletFileUpload.java Sun Dec 5 13:08:00 2010
@@ -16,11 +16,11 @@
*/
package org.apache.wicket.util.upload;
+import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
-
/**
* <p>
* High level API for processing file uploads.
@@ -65,7 +65,16 @@ public class ServletFileUpload extends F
{
return false;
}
- return FileUploadBase.isMultipartContent(new ServletRequestContext(request));
+ String contentType = request.getContentType();
+ if (contentType == null)
+ {
+ return false;
+ }
+ if (contentType.toLowerCase().startsWith(MULTIPART))
+ {
+ return true;
+ }
+ return false;
}
@@ -73,8 +82,10 @@ public class ServletFileUpload extends F
/**
- * Constructs an uninitialized instance of this class. A factory must be configured, using
+ * Constructs an uninitialised instance of this class. A factory must be configured, using
* <code>setFileItemFactory()</code>, before attempting to parse requests.
+ *
+ * @see FileUpload#FileUpload(FileItemFactory)
*/
public ServletFileUpload()
{
@@ -86,7 +97,9 @@ public class ServletFileUpload extends F
* Constructs an instance of this class which uses the supplied factory to create
* <code>FileItem</code> instances.
*
+ * @see FileUpload#FileUpload()
* @param fileItemFactory
+ * The factory to use for creating file items.
*/
public ServletFileUpload(final FileItemFactory fileItemFactory)
{
@@ -107,11 +120,34 @@ public class ServletFileUpload extends F
* @return A list of <code>FileItem</code> instances parsed from the request, in the order that
* they were transmitted.
*
- * @exception FileUploadException
+ * @throws FileUploadException
* if there are problems reading/parsing the request or storing files.
*/
public List<FileItem> parseRequest(final HttpServletRequest request) throws FileUploadException
{
return parseRequest(new ServletRequestContext(request));
}
+
+
+ /**
+ * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> compliant
+ * <code>multipart/form-data</code> stream.
+ *
+ * @param request
+ * The servlet request to be parsed.
+ *
+ * @return An iterator to instances of <code>FileItemStream</code> parsed from the request, in
+ * the order that they were transmitted.
+ *
+ * @throws FileUploadException
+ * if there are problems reading/parsing the request or storing files.
+ * @throws IOException
+ * An I/O error occurred. This may be a network error while communicating with the
+ * client or a problem while storing the uploaded content.
+ */
+ public FileItemIterator getItemIterator(HttpServletRequest request) throws FileUploadException,
+ IOException
+ {
+ return super.getItemIterator(new ServletRequestContext(request));
+}
}
Modified: wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletRequestContext.java?rev=1042345&r1=1042344&r2=1042345&view=diff
==============================================================================
--- wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletRequestContext.java (original)
+++ wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletRequestContext.java Sun Dec 5 13:08:00 2010
@@ -21,7 +21,6 @@ import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
-
/**
* <p>
* Provides access to the request information needed for a request made to an HTTP servlet.
@@ -57,6 +56,16 @@ public class ServletRequestContext imple
// --------------------------------------------------------- Public Methods
/**
+ * Retrieve the character encoding for the request.
+ *
+ * @return The character encoding for the request.
+ */
+ public String getCharacterEncoding()
+ {
+ return request.getCharacterEncoding();
+ }
+
+ /**
* Retrieve the content type of the request.
*
* @return The content type of the request.
@@ -95,7 +104,6 @@ public class ServletRequestContext imple
@Override
public String toString()
{
- return "ContentLength=" + this.getContentLength() + ", ContentType=" +
- this.getContentType();
+ return "ContentLength=" + getContentLength() + ", ContentType=" + getContentType();
}
}