You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2003/03/03 07:23:40 UTC
cvs commit: jakarta-commons/fileupload/src/java/org/apache/commons/fileupload FileUpload.java
martinc 2003/03/02 22:23:39
Modified: fileupload/src/java/org/apache/commons/fileupload
FileUpload.java
Log:
New, more specific, exception types:
- FileUpload.InvalidContentTypeException
- FileUpload.UnknownSizeException
- FileUpload.SizeLimitExceededException
These all extend FileUploadException for convenience.
PR: 17106
Submitted by: Kevin Minshull
Revision Changes Path
1.17 +94 -8 jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java
Index: FileUpload.java
===================================================================
RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- FileUpload.java 1 Mar 2003 21:15:49 -0000 1.16
+++ FileUpload.java 3 Mar 2003 06:23:39 -0000 1.17
@@ -388,7 +388,8 @@
if ((null == contentType) || (!contentType.startsWith(MULTIPART)))
{
- throw new FileUploadException("the request doesn't contain a "
+ throw new InvalidContentTypeException(
+ "the request doesn't contain a "
+ MULTIPART_FORM_DATA
+ " or "
+ MULTIPART_MIXED
@@ -399,13 +400,14 @@
if (requestSize == -1)
{
- throw new FileUploadException("the request was rejected because "
- + "it's size is unknown");
+ throw new UnknownSizeException(
+ "the request was rejected because it's size is unknown");
}
if (sizeMax >= 0 && requestSize > sizeMax)
{
- throw new FileUploadException("the request was rejected because "
+ throw new SizeLimitExceededException(
+ "the request was rejected because "
+ "it's size exceeds allowed range");
}
@@ -767,6 +769,90 @@
String name)
{
return (String) headers.get(name.toLowerCase());
+ }
+
+
+ /**
+ * Thrown to indicate that the request is not a multipart request.
+ */
+ public class InvalidContentTypeException
+ extends FileUploadException
+ {
+ /**
+ * Constructs a <code>InvalidContentTypeException</code> with no
+ * detail message.
+ */
+ public InvalidContentTypeException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs an <code>InvalidContentTypeException</code> with
+ * the specified detail message.
+ *
+ * @param message The detail message.
+ */
+ public InvalidContentTypeException(String message)
+ {
+ super(message);
+ }
+ }
+
+
+ /**
+ * Thrown to indicate that the request size is not specified.
+ */
+ public class UnknownSizeException
+ extends FileUploadException
+ {
+ /**
+ * Constructs a <code>UnknownSizeException</code> with no
+ * detail message.
+ */
+ public UnknownSizeException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs an <code>UnknownSizeException</code> with
+ * the specified detail message.
+ *
+ * @param message The detail message.
+ */
+ public UnknownSizeException(String message)
+ {
+ super(message);
+ }
+ }
+
+
+ /**
+ * Thrown to indicate that the request size exceeds the configured maximum.
+ */
+ public class SizeLimitExceededException
+ extends FileUploadException
+ {
+ /**
+ * Constructs a <code>SizeExceededException</code> with no
+ * detail message.
+ */
+ public SizeLimitExceededException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs an <code>SizeExceededException</code> with
+ * the specified detail message.
+ *
+ * @param message The detail message.
+ */
+ public SizeLimitExceededException(String message)
+ {
+ super(message);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org