1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.struts.action;
17
18 import org.apache.log4j.Logger;
19 import org.apache.struts.config.ModuleConfig;
20 import org.apache.struts.upload.CommonsMultipartRequestHandler;
21
22 import java.util.List;
23
24
25
26
27
28
29
30
31 public class KualiMultipartRequestHandler extends CommonsMultipartRequestHandler {
32 private static final Logger LOG = Logger.getLogger(KualiMultipartRequestHandler.class);
33
34 private String sizeMax;
35
36
37
38
39
40
41
42
43
44 public long getSizeMax(ModuleConfig mc) {
45 return convertSizeToBytes( sizeMax, super.getSizeMax(mc) );
46 }
47
48 public String getSizeMaxString() {
49 return sizeMax;
50 }
51
52 public void setSizeMax( String sizeString ) {
53 this.sizeMax = sizeString;
54 }
55
56
57
58
59
60
61
62
63 public void setMaxUploadSizeToMaxOfList( List<String> sizes ) {
64 long maxSize = 0L;
65 for ( String size : sizes ) {
66 long currSize = convertSizeToBytes(size, 0L);
67 if ( currSize == 0L ) {
68 LOG.warn( "Unable to parse max size (" + size + "). Ignoring." );
69 }
70 if ( currSize > maxSize ) {
71 maxSize = currSize;
72 sizeMax = size;
73 }
74 }
75 }
76
77 public long calculateMaxUploadSizeToMaxOfList( List<String> sizes ) {
78 long maxSize = 0L;
79 for ( String size : sizes ) {
80 long currSize = convertSizeToBytes(size, 0L);
81 if ( currSize == 0L ) {
82 LOG.warn( "Unable to parse max size (" + size + "). Ignoring." );
83 }
84 if ( currSize > maxSize ) {
85 maxSize = currSize;
86 }
87 }
88 return maxSize;
89 }
90
91 }