1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.fileupload;
18
19 import static java.lang.String.format;
20
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.io.UnsupportedEncodingException;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.Iterator;
27 import java.util.List;
28 import java.util.Locale;
29 import java.util.Map;
30 import java.util.NoSuchElementException;
31
32 import javax.servlet.http.HttpServletRequest;
33
34 import org.apache.commons.fileupload.MultipartStream.ItemInputStream;
35 import org.apache.commons.fileupload.servlet.ServletFileUpload;
36 import org.apache.commons.fileupload.servlet.ServletRequestContext;
37 import org.apache.commons.fileupload.util.Closeable;
38 import org.apache.commons.fileupload.util.FileItemHeadersImpl;
39 import org.apache.commons.fileupload.util.LimitedInputStream;
40 import org.apache.commons.fileupload.util.Streams;
41 import org.apache.commons.io.IOUtils;
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 public abstract class FileUploadBase {
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 public static final boolean isMultipartContent(RequestContext ctx) {
76 String contentType = ctx.getContentType();
77 if (contentType == null) {
78 return false;
79 }
80 if (contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART)) {
81 return true;
82 }
83 return false;
84 }
85
86
87
88
89
90
91
92
93
94
95
96
97 @Deprecated
98 public static boolean isMultipartContent(HttpServletRequest req) {
99 return ServletFileUpload.isMultipartContent(req);
100 }
101
102
103
104
105
106
107 public static final String CONTENT_TYPE = "Content-type";
108
109
110
111
112 public static final String CONTENT_DISPOSITION = "Content-disposition";
113
114
115
116
117 public static final String CONTENT_LENGTH = "Content-length";
118
119
120
121
122 public static final String FORM_DATA = "form-data";
123
124
125
126
127 public static final String ATTACHMENT = "attachment";
128
129
130
131
132 public static final String MULTIPART = "multipart/";
133
134
135
136
137 public static final String MULTIPART_FORM_DATA = "multipart/form-data";
138
139
140
141
142 public static final String MULTIPART_MIXED = "multipart/mixed";
143
144
145
146
147
148
149
150
151 @Deprecated
152 public static final int MAX_HEADER_SIZE = 1024;
153
154
155
156
157
158
159
160 private long sizeMax = -1;
161
162
163
164
165
166 private long fileSizeMax = -1;
167
168
169
170
171 private String headerEncoding;
172
173
174
175
176 private ProgressListener listener;
177
178
179
180
181
182
183
184
185 public abstract FileItemFactory getFileItemFactory();
186
187
188
189
190
191
192 public abstract void setFileItemFactory(FileItemFactory factory);
193
194
195
196
197
198
199
200
201
202
203
204 public long getSizeMax() {
205 return sizeMax;
206 }
207
208
209
210
211
212
213
214
215
216
217
218 public void setSizeMax(long sizeMax) {
219 this.sizeMax = sizeMax;
220 }
221
222
223
224
225
226
227
228
229 public long getFileSizeMax() {
230 return fileSizeMax;
231 }
232
233
234
235
236
237
238
239
240 public void setFileSizeMax(long fileSizeMax) {
241 this.fileSizeMax = fileSizeMax;
242 }
243
244
245
246
247
248
249
250
251
252 public String getHeaderEncoding() {
253 return headerEncoding;
254 }
255
256
257
258
259
260
261
262
263
264 public void setHeaderEncoding(String encoding) {
265 headerEncoding = encoding;
266 }
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284 @Deprecated
285 public List<FileItem> parseRequest(HttpServletRequest req)
286 throws FileUploadException {
287 return parseRequest(new ServletRequestContext(req));
288 }
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306 public FileItemIterator getItemIterator(RequestContext ctx)
307 throws FileUploadException, IOException {
308 try {
309 return new FileItemIteratorImpl(ctx);
310 } catch (FileUploadIOException e) {
311
312 throw (FileUploadException) e.getCause();
313 }
314 }
315
316
317
318
319
320
321
322
323
324
325
326
327
328 public List<FileItem> parseRequest(RequestContext ctx)
329 throws FileUploadException {
330 List<FileItem> items = new ArrayList<FileItem>();
331 boolean successful = false;
332 try {
333 FileItemIterator iter = getItemIterator(ctx);
334 FileItemFactory fac = getFileItemFactory();
335 if (fac == null) {
336 throw new NullPointerException("No FileItemFactory has been set.");
337 }
338 while (iter.hasNext()) {
339 final FileItemStream item = iter.next();
340
341 final String fileName = ((FileItemIteratorImpl.FileItemStreamImpl) item).name;
342 FileItem fileItem = fac.createItem(item.getFieldName(), item.getContentType(),
343 item.isFormField(), fileName);
344 items.add(fileItem);
345 try {
346 Streams.copy(item.openStream(), fileItem.getOutputStream(), true);
347 } catch (FileUploadIOException e) {
348 throw (FileUploadException) e.getCause();
349 } catch (IOException e) {
350 throw new IOFileUploadException(format("Processing of %s request failed. %s",
351 MULTIPART_FORM_DATA, e.getMessage()), e);
352 }
353 final FileItemHeaders fih = item.getHeaders();
354 fileItem.setHeaders(fih);
355 }
356 successful = true;
357 return items;
358 } catch (FileUploadIOException e) {
359 throw (FileUploadException) e.getCause();
360 } catch (IOException e) {
361 throw new FileUploadException(e.getMessage(), e);
362 } finally {
363 if (!successful) {
364 for (FileItem fileItem : items) {
365 try {
366 fileItem.delete();
367 } catch (Exception ignored) {
368
369 }
370 }
371 }
372 }
373 }
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388 public Map<String, List<FileItem>> parseParameterMap(RequestContext ctx)
389 throws FileUploadException {
390 final List<FileItem> items = parseRequest(ctx);
391 final Map<String, List<FileItem>> itemsMap = new HashMap<String, List<FileItem>>(items.size());
392
393 for (FileItem fileItem : items) {
394 String fieldName = fileItem.getFieldName();
395 List<FileItem> mappedItems = itemsMap.get(fieldName);
396
397 if (mappedItems == null) {
398 mappedItems = new ArrayList<FileItem>();
399 itemsMap.put(fieldName, mappedItems);
400 }
401
402 mappedItems.add(fileItem);
403 }
404
405 return itemsMap;
406 }
407
408
409
410
411
412
413
414
415
416
417
418 protected byte[] getBoundary(String contentType) {
419 ParameterParser parser = new ParameterParser();
420 parser.setLowerCaseNames(true);
421
422 Map<String, String> params = parser.parse(contentType, new char[] {';', ','});
423 String boundaryStr = params.get("boundary");
424
425 if (boundaryStr == null) {
426 return null;
427 }
428 byte[] boundary;
429 try {
430 boundary = boundaryStr.getBytes("ISO-8859-1");
431 } catch (UnsupportedEncodingException e) {
432 boundary = boundaryStr.getBytes();
433 }
434 return boundary;
435 }
436
437
438
439
440
441
442
443
444
445
446 @Deprecated
447 protected String getFileName(Map<String, String> headers) {
448 return getFileName(getHeader(headers, CONTENT_DISPOSITION));
449 }
450
451
452
453
454
455
456
457
458
459 protected String getFileName(FileItemHeaders headers) {
460 return getFileName(headers.getHeader(CONTENT_DISPOSITION));
461 }
462
463
464
465
466
467
468 private String getFileName(String pContentDisposition) {
469 String fileName = null;
470 if (pContentDisposition != null) {
471 String cdl = pContentDisposition.toLowerCase(Locale.ENGLISH);
472 if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT)) {
473 ParameterParser parser = new ParameterParser();
474 parser.setLowerCaseNames(true);
475
476 Map<String, String> params = parser.parse(pContentDisposition, ';');
477 if (params.containsKey("filename")) {
478 fileName = params.get("filename");
479 if (fileName != null) {
480 fileName = fileName.trim();
481 } else {
482
483
484
485 fileName = "";
486 }
487 }
488 }
489 }
490 return fileName;
491 }
492
493
494
495
496
497
498
499
500
501 protected String getFieldName(FileItemHeaders headers) {
502 return getFieldName(headers.getHeader(CONTENT_DISPOSITION));
503 }
504
505
506
507
508
509
510
511 private String getFieldName(String pContentDisposition) {
512 String fieldName = null;
513 if (pContentDisposition != null
514 && pContentDisposition.toLowerCase(Locale.ENGLISH).startsWith(FORM_DATA)) {
515 ParameterParser parser = new ParameterParser();
516 parser.setLowerCaseNames(true);
517
518 Map<String, String> params = parser.parse(pContentDisposition, ';');
519 fieldName = params.get("name");
520 if (fieldName != null) {
521 fieldName = fieldName.trim();
522 }
523 }
524 return fieldName;
525 }
526
527
528
529
530
531
532
533
534
535
536 @Deprecated
537 protected String getFieldName(Map<String, String> headers) {
538 return getFieldName(getHeader(headers, CONTENT_DISPOSITION));
539 }
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555 @Deprecated
556 protected FileItem createItem(Map<String, String> headers,
557 boolean isFormField)
558 throws FileUploadException {
559 return getFileItemFactory().createItem(getFieldName(headers),
560 getHeader(headers, CONTENT_TYPE),
561 isFormField,
562 getFileName(headers));
563 }
564
565
566
567
568
569
570
571
572
573
574
575
576
577 protected FileItemHeaders getParsedHeaders(String headerPart) {
578 final int len = headerPart.length();
579 FileItemHeadersImpl headers = newFileItemHeaders();
580 int start = 0;
581 for (;;) {
582 int end = parseEndOfLine(headerPart, start);
583 if (start == end) {
584 break;
585 }
586 StringBuilder header = new StringBuilder(headerPart.substring(start, end));
587 start = end + 2;
588 while (start < len) {
589 int nonWs = start;
590 while (nonWs < len) {
591 char c = headerPart.charAt(nonWs);
592 if (c != ' ' && c != '\t') {
593 break;
594 }
595 ++nonWs;
596 }
597 if (nonWs == start) {
598 break;
599 }
600
601 end = parseEndOfLine(headerPart, nonWs);
602 header.append(" ").append(headerPart.substring(nonWs, end));
603 start = end + 2;
604 }
605 parseHeaderLine(headers, header.toString());
606 }
607 return headers;
608 }
609
610
611
612
613
614 protected FileItemHeadersImpl newFileItemHeaders() {
615 return new FileItemHeadersImpl();
616 }
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631 @Deprecated
632 protected Map<String, String> parseHeaders(String headerPart) {
633 FileItemHeaders headers = getParsedHeaders(headerPart);
634 Map<String, String> result = new HashMap<String, String>();
635 for (Iterator<String> iter = headers.getHeaderNames(); iter.hasNext();) {
636 String headerName = iter.next();
637 Iterator<String> iter2 = headers.getHeaders(headerName);
638 StringBuilder headerValue = new StringBuilder(iter2.next());
639 while (iter2.hasNext()) {
640 headerValue.append(",").append(iter2.next());
641 }
642 result.put(headerName, headerValue.toString());
643 }
644 return result;
645 }
646
647
648
649
650
651
652
653
654
655 private int parseEndOfLine(String headerPart, int end) {
656 int index = end;
657 for (;;) {
658 int offset = headerPart.indexOf('\r', index);
659 if (offset == -1 || offset + 1 >= headerPart.length()) {
660 throw new IllegalStateException(
661 "Expected headers to be terminated by an empty line.");
662 }
663 if (headerPart.charAt(offset + 1) == '\n') {
664 return offset;
665 }
666 index = offset + 1;
667 }
668 }
669
670
671
672
673
674
675 private void parseHeaderLine(FileItemHeadersImpl headers, String header) {
676 final int colonOffset = header.indexOf(':');
677 if (colonOffset == -1) {
678
679 return;
680 }
681 String headerName = header.substring(0, colonOffset).trim();
682 String headerValue =
683 header.substring(header.indexOf(':') + 1).trim();
684 headers.addHeader(headerName, headerValue);
685 }
686
687
688
689
690
691
692
693
694
695
696
697
698 @Deprecated
699 protected final String getHeader(Map<String, String> headers,
700 String name) {
701 return headers.get(name.toLowerCase(Locale.ENGLISH));
702 }
703
704
705
706
707
708 private class FileItemIteratorImpl implements FileItemIterator {
709
710
711
712
713 class FileItemStreamImpl implements FileItemStream {
714
715
716
717
718 private final String contentType;
719
720
721
722
723 private final String fieldName;
724
725
726
727
728 private final String name;
729
730
731
732
733 private final boolean formField;
734
735
736
737
738 private final InputStream stream;
739
740
741
742
743 private boolean opened;
744
745
746
747
748 private FileItemHeaders headers;
749
750
751
752
753
754
755
756
757
758
759
760 FileItemStreamImpl(String pName, String pFieldName,
761 String pContentType, boolean pFormField,
762 long pContentLength) throws IOException {
763 name = pName;
764 fieldName = pFieldName;
765 contentType = pContentType;
766 formField = pFormField;
767 final ItemInputStream itemStream = multi.newInputStream();
768 InputStream istream = itemStream;
769 if (fileSizeMax != -1) {
770 if (pContentLength != -1
771 && pContentLength > fileSizeMax) {
772 FileSizeLimitExceededException e =
773 new FileSizeLimitExceededException(
774 format("The field %s exceeds its maximum permitted size of %s bytes.",
775 fieldName, Long.valueOf(fileSizeMax)),
776 pContentLength, fileSizeMax);
777 e.setFileName(pName);
778 e.setFieldName(pFieldName);
779 throw new FileUploadIOException(e);
780 }
781 istream = new LimitedInputStream(istream, fileSizeMax) {
782 @Override
783 protected void raiseError(long pSizeMax, long pCount)
784 throws IOException {
785 itemStream.close(true);
786 FileSizeLimitExceededException e =
787 new FileSizeLimitExceededException(
788 format("The field %s exceeds its maximum permitted size of %s bytes.",
789 fieldName, Long.valueOf(pSizeMax)),
790 pCount, pSizeMax);
791 e.setFieldName(fieldName);
792 e.setFileName(name);
793 throw new FileUploadIOException(e);
794 }
795 };
796 }
797 stream = istream;
798 }
799
800
801
802
803
804
805 public String getContentType() {
806 return contentType;
807 }
808
809
810
811
812
813
814 public String getFieldName() {
815 return fieldName;
816 }
817
818
819
820
821
822
823
824
825
826
827 public String getName() {
828 return Streams.checkFileName(name);
829 }
830
831
832
833
834
835
836
837 public boolean isFormField() {
838 return formField;
839 }
840
841
842
843
844
845
846
847
848 public InputStream openStream() throws IOException {
849 if (opened) {
850 throw new IllegalStateException(
851 "The stream was already opened.");
852 }
853 if (((Closeable) stream).isClosed()) {
854 throw new FileItemStream.ItemSkippedException();
855 }
856 return stream;
857 }
858
859
860
861
862
863
864 void close() throws IOException {
865 stream.close();
866 }
867
868
869
870
871
872
873 public FileItemHeaders getHeaders() {
874 return headers;
875 }
876
877
878
879
880
881
882 public void setHeaders(FileItemHeaders pHeaders) {
883 headers = pHeaders;
884 }
885
886 }
887
888
889
890
891 private final MultipartStream multi;
892
893
894
895
896
897 private final MultipartStream.ProgressNotifier notifier;
898
899
900
901
902 private final byte[] boundary;
903
904
905
906
907 private FileItemStreamImpl currentItem;
908
909
910
911
912 private String currentFieldName;
913
914
915
916
917 private boolean skipPreamble;
918
919
920
921
922 private boolean itemValid;
923
924
925
926
927 private boolean eof;
928
929
930
931
932
933
934
935
936
937 FileItemIteratorImpl(RequestContext ctx)
938 throws FileUploadException, IOException {
939 if (ctx == null) {
940 throw new NullPointerException("ctx parameter");
941 }
942
943 String contentType = ctx.getContentType();
944 if ((null == contentType)
945 || (!contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART))) {
946 throw new InvalidContentTypeException(
947 format("the request doesn't contain a %s or %s stream, content type header is %s",
948 MULTIPART_FORM_DATA, MULTIPART_MIXED, contentType));
949 }
950
951
952 @SuppressWarnings("deprecation")
953 final int contentLengthInt = ctx.getContentLength();
954
955 final long requestSize = UploadContext.class.isAssignableFrom(ctx.getClass())
956
957 ? ((UploadContext) ctx).contentLength()
958 : contentLengthInt;
959
960
961 InputStream input;
962 if (sizeMax >= 0) {
963 if (requestSize != -1 && requestSize > sizeMax) {
964 throw new SizeLimitExceededException(
965 format("the request was rejected because its size (%s) exceeds the configured maximum (%s)",
966 Long.valueOf(requestSize), Long.valueOf(sizeMax)),
967 requestSize, sizeMax);
968 }
969
970 input = new LimitedInputStream(ctx.getInputStream(), sizeMax) {
971 @Override
972 protected void raiseError(long pSizeMax, long pCount)
973 throws IOException {
974 FileUploadException ex = new SizeLimitExceededException(
975 format("the request was rejected because its size (%s) exceeds the configured maximum (%s)",
976 Long.valueOf(pCount), Long.valueOf(pSizeMax)),
977 pCount, pSizeMax);
978 throw new FileUploadIOException(ex);
979 }
980 };
981 } else {
982 input = ctx.getInputStream();
983 }
984
985 String charEncoding = headerEncoding;
986 if (charEncoding == null) {
987 charEncoding = ctx.getCharacterEncoding();
988 }
989
990 boundary = getBoundary(contentType);
991 if (boundary == null) {
992 IOUtils.closeQuietly(input);
993 throw new FileUploadException("the request was rejected because no multipart boundary was found");
994 }
995
996 notifier = new MultipartStream.ProgressNotifier(listener, requestSize);
997 try {
998 multi = new MultipartStream(input, boundary, notifier);
999 } catch (IllegalArgumentException iae) {
1000 IOUtils.closeQuietly(input);
1001 throw new InvalidContentTypeException(
1002 format("The boundary specified in the %s header is too long", CONTENT_TYPE), iae);
1003 }
1004 multi.setHeaderEncoding(charEncoding);
1005
1006 skipPreamble = true;
1007 findNextItem();
1008 }
1009
1010
1011
1012
1013
1014
1015
1016 private boolean findNextItem() throws IOException {
1017 if (eof) {
1018 return false;
1019 }
1020 if (currentItem != null) {
1021 currentItem.close();
1022 currentItem = null;
1023 }
1024 for (;;) {
1025 boolean nextPart;
1026 if (skipPreamble) {
1027 nextPart = multi.skipPreamble();
1028 } else {
1029 nextPart = multi.readBoundary();
1030 }
1031 if (!nextPart) {
1032 if (currentFieldName == null) {
1033
1034 eof = true;
1035 return false;
1036 }
1037
1038 multi.setBoundary(boundary);
1039 currentFieldName = null;
1040 continue;
1041 }
1042 FileItemHeaders headers = getParsedHeaders(multi.readHeaders());
1043 if (currentFieldName == null) {
1044
1045 String fieldName = getFieldName(headers);
1046 if (fieldName != null) {
1047 String subContentType = headers.getHeader(CONTENT_TYPE);
1048 if (subContentType != null
1049 && subContentType.toLowerCase(Locale.ENGLISH)
1050 .startsWith(MULTIPART_MIXED)) {
1051 currentFieldName = fieldName;
1052
1053 byte[] subBoundary = getBoundary(subContentType);
1054 multi.setBoundary(subBoundary);
1055 skipPreamble = true;
1056 continue;
1057 }
1058 String fileName = getFileName(headers);
1059 currentItem = new FileItemStreamImpl(fileName,
1060 fieldName, headers.getHeader(CONTENT_TYPE),
1061 fileName == null, getContentLength(headers));
1062 currentItem.setHeaders(headers);
1063 notifier.noteItem();
1064 itemValid = true;
1065 return true;
1066 }
1067 } else {
1068 String fileName = getFileName(headers);
1069 if (fileName != null) {
1070 currentItem = new FileItemStreamImpl(fileName,
1071 currentFieldName,
1072 headers.getHeader(CONTENT_TYPE),
1073 false, getContentLength(headers));
1074 currentItem.setHeaders(headers);
1075 notifier.noteItem();
1076 itemValid = true;
1077 return true;
1078 }
1079 }
1080 multi.discardBodyData();
1081 }
1082 }
1083
1084 private long getContentLength(FileItemHeaders pHeaders) {
1085 try {
1086 return Long.parseLong(pHeaders.getHeader(CONTENT_LENGTH));
1087 } catch (Exception e) {
1088 return -1;
1089 }
1090 }
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102 public boolean hasNext() throws FileUploadException, IOException {
1103 if (eof) {
1104 return false;
1105 }
1106 if (itemValid) {
1107 return true;
1108 }
1109 try {
1110 return findNextItem();
1111 } catch (FileUploadIOException e) {
1112
1113 throw (FileUploadException) e.getCause();
1114 }
1115 }
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128 public FileItemStream next() throws FileUploadException, IOException {
1129 if (eof || (!itemValid && !hasNext())) {
1130 throw new NoSuchElementException();
1131 }
1132 itemValid = false;
1133 return currentItem;
1134 }
1135
1136 }
1137
1138
1139
1140
1141
1142 public static class FileUploadIOException extends IOException {
1143
1144
1145
1146
1147 private static final long serialVersionUID = -7047616958165584154L;
1148
1149
1150
1151
1152
1153
1154 private final FileUploadException cause;
1155
1156
1157
1158
1159
1160
1161
1162 public FileUploadIOException(FileUploadException pCause) {
1163
1164 cause = pCause;
1165 }
1166
1167
1168
1169
1170
1171
1172 @Override
1173 public Throwable getCause() {
1174 return cause;
1175 }
1176
1177 }
1178
1179
1180
1181
1182 public static class InvalidContentTypeException
1183 extends FileUploadException {
1184
1185
1186
1187
1188 private static final long serialVersionUID = -9073026332015646668L;
1189
1190
1191
1192
1193
1194 public InvalidContentTypeException() {
1195 super();
1196 }
1197
1198
1199
1200
1201
1202
1203
1204 public InvalidContentTypeException(String message) {
1205 super(message);
1206 }
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217 public InvalidContentTypeException(String msg, Throwable cause) {
1218 super(msg, cause);
1219 }
1220 }
1221
1222
1223
1224
1225 public static class IOFileUploadException extends FileUploadException {
1226
1227
1228
1229
1230 private static final long serialVersionUID = 1749796615868477269L;
1231
1232
1233
1234
1235
1236
1237 private final IOException cause;
1238
1239
1240
1241
1242
1243
1244
1245 public IOFileUploadException(String pMsg, IOException pException) {
1246 super(pMsg);
1247 cause = pException;
1248 }
1249
1250
1251
1252
1253
1254
1255 @Override
1256 public Throwable getCause() {
1257 return cause;
1258 }
1259
1260 }
1261
1262
1263
1264
1265
1266 protected abstract static class SizeException extends FileUploadException {
1267
1268
1269
1270
1271 private static final long serialVersionUID = -8776225574705254126L;
1272
1273
1274
1275
1276 private final long actual;
1277
1278
1279
1280
1281 private final long permitted;
1282
1283
1284
1285
1286
1287
1288
1289
1290 protected SizeException(String message, long actual, long permitted) {
1291 super(message);
1292 this.actual = actual;
1293 this.permitted = permitted;
1294 }
1295
1296
1297
1298
1299
1300
1301
1302 public long getActualSize() {
1303 return actual;
1304 }
1305
1306
1307
1308
1309
1310
1311
1312 public long getPermittedSize() {
1313 return permitted;
1314 }
1315
1316 }
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326 @Deprecated
1327 public static class UnknownSizeException
1328 extends FileUploadException {
1329
1330
1331
1332
1333 private static final long serialVersionUID = 7062279004812015273L;
1334
1335
1336
1337
1338
1339 public UnknownSizeException() {
1340 super();
1341 }
1342
1343
1344
1345
1346
1347
1348
1349 public UnknownSizeException(String message) {
1350 super(message);
1351 }
1352
1353 }
1354
1355
1356
1357
1358 public static class SizeLimitExceededException
1359 extends SizeException {
1360
1361
1362
1363
1364 private static final long serialVersionUID = -2474893167098052828L;
1365
1366
1367
1368
1369
1370 @Deprecated
1371 public SizeLimitExceededException() {
1372 this(null, 0, 0);
1373 }
1374
1375
1376
1377
1378
1379
1380 @Deprecated
1381 public SizeLimitExceededException(String message) {
1382 this(message, 0, 0);
1383 }
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393 public SizeLimitExceededException(String message, long actual,
1394 long permitted) {
1395 super(message, actual, permitted);
1396 }
1397
1398 }
1399
1400
1401
1402
1403 public static class FileSizeLimitExceededException
1404 extends SizeException {
1405
1406
1407
1408
1409 private static final long serialVersionUID = 8150776562029630058L;
1410
1411
1412
1413
1414 private String fileName;
1415
1416
1417
1418
1419 private String fieldName;
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429 public FileSizeLimitExceededException(String message, long actual,
1430 long permitted) {
1431 super(message, actual, permitted);
1432 }
1433
1434
1435
1436
1437
1438
1439
1440 public String getFileName() {
1441 return fileName;
1442 }
1443
1444
1445
1446
1447
1448
1449
1450 public void setFileName(String pFileName) {
1451 fileName = pFileName;
1452 }
1453
1454
1455
1456
1457
1458
1459
1460 public String getFieldName() {
1461 return fieldName;
1462 }
1463
1464
1465
1466
1467
1468
1469
1470
1471 public void setFieldName(String pFieldName) {
1472 fieldName = pFieldName;
1473 }
1474
1475 }
1476
1477
1478
1479
1480
1481
1482 public ProgressListener getProgressListener() {
1483 return listener;
1484 }
1485
1486
1487
1488
1489
1490
1491 public void setProgressListener(ProgressListener pListener) {
1492 listener = pListener;
1493 }
1494
1495 }