myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1406858 - /myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
Date Wed, 07 Nov 2012 23:03:10 GMT
Author: lu4242
Date: Wed Nov  7 23:03:10 2012
New Revision: 1406858

URL: http://svn.apache.org/viewvc?rev=1406858&view=rev
Log:
TOMAHAWK-1635 Allow 'long' values for maxSize and maxFileSize configuration

Modified:
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java?rev=1406858&r1=1406857&r2=1406858&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
(original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
Wed Nov  7 23:03:10 2012
@@ -144,9 +144,9 @@ public class ExtensionsFilter implements
 
     private Log log = LogFactory.getLog(ExtensionsFilter.class);
     
-    private int _uploadMaxSize = 100 * 1024 * 1024; // 100 MB
+    private long _uploadMaxSize = 100 * 1024 * 1024; // 100 MB
 
-    private int _uploadMaxFileSize = 100 * 1024 * 1024; // 100 MB
+    private long _uploadMaxFileSize = 100 * 1024 * 1024; // 100 MB
 
     private int _uploadThresholdSize = 1 * 1024 * 1024; // 1 MB
 
@@ -255,6 +255,30 @@ public class ExtensionsFilter implements
         filterConfig.getServletContext().setAttribute(EXTENSIONS_FILTER_INITIALIZED, true);
     }
 
+    private long resolveSize(String param, long defaultValue) {
+        long numberParam = defaultValue;
+
+        if (param != null) {
+            param = param.toLowerCase();
+            long factor = 1;
+            String number = param;
+
+            if (param.endsWith("g")) {
+                factor = 1024 * 1024 * 1024;
+                number = param.substring(0, param.length() - 1);
+            } else if (param.endsWith("m")) {
+                factor = 1024 * 1024;
+                number = param.substring(0, param.length() - 1);
+            } else if (param.endsWith("k")) {
+                factor = 1024;
+                number = param.substring(0, param.length() - 1);
+            }
+
+            numberParam = Long.parseLong(number) * factor;
+        }
+        return numberParam;
+    }
+    
     private int resolveSize(String param, int defaultValue) {
         int numberParam = defaultValue;
 
@@ -278,6 +302,7 @@ public class ExtensionsFilter implements
         }
         return numberParam;
     }
+
     
     private static boolean getBooleanValue(String initParameter, boolean defaultVal)
     {



Mime
View raw message