myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1379874 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces: component/html/util/ webapp/filter/
Date Sat, 01 Sep 2012 22:13:08 GMT
Author: lu4242
Date: Sat Sep  1 22:13:08 2012
New Revision: 1379874

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

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/MultipartFilter.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapperConfig.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletMultipartRequestWrapper.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/MultipartFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/MultipartFilter.java?rev=1379874&r1=1379873&r2=1379874&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/MultipartFilter.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/MultipartFilter.java
Sat Sep  1 22:13:08 2012
@@ -45,9 +45,9 @@ import org.apache.myfaces.webapp.filter.
 public class MultipartFilter implements Filter
 {
 
-    private int uploadMaxSize = 100 * 1024 * 1024; // 100 MB
+    private long uploadMaxSize = 100 * 1024 * 1024; // 100 MB
     
-    private int uploadMaxFileSize = 100 * 1024 * 1024; // 10 MB
+    private long uploadMaxFileSize = 100 * 1024 * 1024; // 10 MB
 
     private int uploadThresholdSize = 1 * 1024 * 1024; // 1 MB
 
@@ -103,6 +103,35 @@ public class MultipartFilter implements 
         return numberParam;
     }
     
+    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 static boolean getBooleanValue(String initParameter, boolean defaultVal)
     {
         if(initParameter == null || initParameter.trim().length()==0)

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java?rev=1379874&r1=1379873&r2=1379874&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
Sat Sep  1 22:13:08 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
 
@@ -247,6 +247,30 @@ public class ExtensionsFilter implements
         _servletContext = filterConfig.getServletContext();
     }
 
+    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;
 
@@ -270,6 +294,7 @@ public class ExtensionsFilter implements
         }
         return numberParam;
     }
+
     
     private static boolean getBooleanValue(String initParameter, boolean defaultVal)
     {

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java?rev=1379874&r1=1379873&r2=1379874&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapper.java
Sat Sep  1 22:13:08 2012
@@ -56,8 +56,8 @@ public class MultipartRequestWrapper
     HashMap parametersMap = null;
     ServletFileUpload fileUpload = null;
     HashMap fileItems = null;
-    int maxFileSize;
-    int maxSize;
+    long maxFileSize;
+    long maxSize;
     int thresholdSize;
     String repositoryPath;
     boolean cacheFileSizeErrors;
@@ -86,6 +86,31 @@ public class MultipartRequestWrapper
         this.repositoryPath = repositoryPath;
         this.cacheFileSizeErrors = cacheFileSizeErrors;
     }
+    
+    public MultipartRequestWrapper(HttpServletRequest request,
+                                   long maxFileSize, int thresholdSize,
+                                   String repositoryPath){
+        super( request );
+        this.request = request;
+        this.maxFileSize = maxFileSize;
+        this.thresholdSize = thresholdSize;
+        this.repositoryPath = repositoryPath;
+        //Default values
+        this.maxSize = maxFileSize;
+        this.cacheFileSizeErrors = false;
+    }
+    
+    public MultipartRequestWrapper(HttpServletRequest request,
+            long maxFileSize, int thresholdSize,
+            String repositoryPath, long maxRequestSize, boolean cacheFileSizeErrors){
+        super( request );
+        this.request = request;
+        this.maxFileSize = maxFileSize;
+        this.maxSize = maxRequestSize;
+        this.thresholdSize = thresholdSize;
+        this.repositoryPath = repositoryPath;
+        this.cacheFileSizeErrors = cacheFileSizeErrors;
+    }
 
     private void parseRequest() {
         if (cacheFileSizeErrors)

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapperConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapperConfig.java?rev=1379874&r1=1379873&r2=1379874&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapperConfig.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapperConfig.java
Sat Sep  1 22:13:08 2012
@@ -33,8 +33,8 @@ import org.apache.myfaces.tomahawk.util.
 class MultipartRequestWrapperConfig
 {
     
-    private int _uploadMaxSize = 100 * 1024 * 1024; // 10 MB
-    private int _uploadMaxFileSize = 100 * 1024 * 1024; // 10 MB
+    private long _uploadMaxSize = 100 * 1024 * 1024; // 10 MB
+    private long _uploadMaxFileSize = 100 * 1024 * 1024; // 10 MB
     private int _uploadThresholdSize = 1 * 1024 * 1024; // 1 MB
     private String _uploadRepositoryPath = null; //standard temp directory 
     private boolean _cacheFileSizeErrors = false;
@@ -79,6 +79,37 @@ class MultipartRequestWrapperConfig
         return numberParam;
     }
     
+    private static 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 static boolean getBooleanValue(String initParameter, boolean defaultVal)
     {
         if(initParameter == null || initParameter.trim().length()==0)
@@ -87,22 +118,22 @@ class MultipartRequestWrapperConfig
         return (initParameter.equalsIgnoreCase("on") || initParameter.equals("1") || initParameter.equalsIgnoreCase("true"));
     }
     
-    public int getUploadMaxSize()
+    public long getUploadMaxSize()
     {
         return _uploadMaxSize;
     }
 
-    public void setUploadMaxSize(int uploadMaxSize)
+    public void setUploadMaxSize(long uploadMaxSize)
     {
         this._uploadMaxSize = uploadMaxSize;
     }
 
-    public int getUploadMaxFileSize()
+    public long getUploadMaxFileSize()
     {
         return _uploadMaxFileSize;
     }
 
-    public void setUploadMaxFileSize(int uploadMaxFileSize)
+    public void setUploadMaxFileSize(long uploadMaxFileSize)
     {
         this._uploadMaxFileSize = uploadMaxFileSize;
     }

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletMultipartRequestWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletMultipartRequestWrapper.java?rev=1379874&r1=1379873&r2=1379874&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletMultipartRequestWrapper.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/PortletMultipartRequestWrapper.java
Sat Sep  1 22:13:08 2012
@@ -55,8 +55,8 @@ public class PortletMultipartRequestWrap
     HashMap parametersMap = null;
     PortletFileUpload fileUpload = null;
     HashMap fileItems = null;
-    int maxFileSize;
-    int maxSize;
+    long maxFileSize;
+    long maxSize;
     int thresholdSize;
     String repositoryPath;
     boolean cacheFileSizeErrors;
@@ -86,6 +86,30 @@ public class PortletMultipartRequestWrap
         this.cacheFileSizeErrors = cacheFileSizeErrors;
     }
 
+        public PortletMultipartRequestWrapper(Object request,
+                                   long maxFileSize, int thresholdSize,
+                                   String repositoryPath){
+        super((ActionRequest) request );
+        this.request = (ActionRequest) request;
+        this.maxFileSize = maxFileSize;
+        this.thresholdSize = thresholdSize;
+        this.repositoryPath = repositoryPath;
+        //Default values
+        this.maxSize = maxFileSize;
+        this.cacheFileSizeErrors = false;
+    }
+    
+    public PortletMultipartRequestWrapper(Object request,
+            long maxFileSize, int thresholdSize,
+            String repositoryPath, long maxRequestSize, boolean cacheFileSizeErrors){
+        super((ActionRequest) request );
+        this.request = (ActionRequest) request;
+        this.maxFileSize = maxFileSize;
+        this.maxSize = maxRequestSize;
+        this.thresholdSize = thresholdSize;
+        this.repositoryPath = repositoryPath;
+        this.cacheFileSizeErrors = cacheFileSizeErrors;
+    }
 
     private void parseRequest() {
         if (cacheFileSizeErrors)



Mime
View raw message