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
32 @Deprecated
33 public class KualiMultipartRequestHandler extends CommonsMultipartRequestHandler {
34 private static final Logger LOG = Logger.getLogger(KualiMultipartRequestHandler.class);
35
36 private String sizeMax;
37
38
39
40
41
42
43
44
45
46 public long getSizeMax(ModuleConfig mc) {
47 return convertSizeToBytes( sizeMax, super.getSizeMax(mc) );
48 }
49
50 public String getSizeMaxString() {
51 return sizeMax;
52 }
53
54 public void setSizeMax( String sizeString ) {
55 this.sizeMax = sizeString;
56 }
57
58
59
60
61
62
63
64
65 public void setMaxUploadSizeToMaxOfList( List<String> sizes ) {
66 long maxSize = 0L;
67 for ( String size : sizes ) {
68 long currSize = convertSizeToBytes(size, 0L);
69 if ( currSize == 0L ) {
70 LOG.warn( "Unable to parse max size (" + size + "). Ignoring." );
71 }
72 if ( currSize > maxSize ) {
73 maxSize = currSize;
74 sizeMax = size;
75 }
76 }
77 }
78
79 public long calculateMaxUploadSizeToMaxOfList( List<String> sizes ) {
80 long maxSize = 0L;
81 for ( String size : sizes ) {
82 long currSize = convertSizeToBytes(size, 0L);
83 if ( currSize == 0L ) {
84 LOG.warn( "Unable to parse max size (" + size + "). Ignoring." );
85 }
86 if ( currSize > maxSize ) {
87 maxSize = currSize;
88 }
89 }
90 return maxSize;
91 }
92
93 }