You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ma...@apache.org on 2003/04/27 19:49:34 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/upload CommonsMultipartRequestHandler.java
martinc 2003/04/27 10:49:34
Modified: src/share/org/apache/struts/upload
CommonsMultipartRequestHandler.java
Log:
Updates for new FileUpload changes, so that we're no longer using the
deprecated classes and methods.
Revision Changes Path
1.9 +13 -15 jakarta-struts/src/share/org/apache/struts/upload/CommonsMultipartRequestHandler.java
Index: CommonsMultipartRequestHandler.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/upload/CommonsMultipartRequestHandler.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CommonsMultipartRequestHandler.java 15 Feb 2003 12:39:23 -0000 1.8
+++ CommonsMultipartRequestHandler.java 27 Apr 2003 17:49:34 -0000 1.9
@@ -74,7 +74,7 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileUpload;
+import org.apache.commons.fileupload.DiskFileUpload;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -213,8 +213,8 @@
ModuleConfig ac = (ModuleConfig) request.getAttribute(
Globals.MODULE_KEY);
- // Create and configure a FileUpload instance.
- FileUpload upload = new FileUpload();
+ // Create and configure a DIskFileUpload instance.
+ DiskFileUpload upload = new DiskFileUpload();
// Set the maximum size before a FileUploadException will be thrown.
upload.setSizeMax((int) getSizeMax(ac));
// Set the maximum size that will be stored in memory.
@@ -231,15 +231,13 @@
List items = null;
try {
items = upload.parseRequest(request);
- } catch (FileUploadException e) {
+ } catch (DiskFileUpload.SizeLimitExceededException e) {
// Special handling for uploads that are too big.
- if (e.getMessage().endsWith("size exceeds allowed range")) {
- request.setAttribute(
- MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED,
- Boolean.TRUE);
- return;
- }
-
+ request.setAttribute(
+ MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED,
+ Boolean.TRUE);
+ return;
+ } catch (FileUploadException e) {
log.error("Failed to parse multipart request", e);
throw new ServletException(e);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org