myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From haz...@apache.org
Subject svn commit: r691858 - /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapperConfig.java
Date Thu, 04 Sep 2008 03:04:31 GMT
Author: hazems
Date: Wed Sep  3 20:04:31 2008
New Revision: 691858

URL: http://svn.apache.org/viewvc?rev=691858&view=rev
Log:
Applying Leonardo comments on https://issues.apache.org/jira/browse/TOMAHAWK-1323

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/MultipartRequestWrapperConfig.java

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=691858&r1=691857&r2=691858&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
Wed Sep  3 20:04:31 2008
@@ -35,6 +35,12 @@
     private int _uploadThresholdSize = 1 * 1024 * 1024; // 1 MB
     private String _uploadRepositoryPath = null; //standard temp directory 
     
+    private static final String UPLOAD_MAX_FILE_SIZE = "org.apache.myfaces.UPLOAD_MAX_FILE_SIZE";
+    private static final String UPLOAD_THRESHOLD_SIZE = "org.apache.myfaces.UPLOAD_THRESHOLD_SIZE";

+    private static final String UPLOAD_MAX_REPOSITORY_PATH = "org.apache.myfaces.UPLOAD_MAX_REPOSITORY_PATH";
 
+    
+    private static final String MULTIPART_REQUEST_WRAPPER_CONFIG = MultipartRequestWrapperConfig.class.getName();
+    
     private MultipartRequestWrapperConfig() {}
         
     private static int resolveSize(String param, int defaultValue)
@@ -101,22 +107,34 @@
     public static MultipartRequestWrapperConfig getMultipartRequestWrapperConfig(
             ExternalContext context)
     {
-        MultipartRequestWrapperConfig config = new MultipartRequestWrapperConfig();
 
-        ServletContext servletContext = (ServletContext) context.getContext();
+        MultipartRequestWrapperConfig config = (MultipartRequestWrapperConfig) context
+                .getApplicationMap().get(MULTIPART_REQUEST_WRAPPER_CONFIG);
+
+        if (config == null)
+        {
+            config = new MultipartRequestWrapperConfig();
 
-        String param = servletContext.getInitParameter("uploadMaxFileSize");
+            ServletContext servletContext = (ServletContext) context
+                    .getContext();
 
-        config._uploadMaxFileSize = resolveSize(param,
-                config._uploadMaxFileSize);
+            String param = servletContext
+                    .getInitParameter(UPLOAD_MAX_FILE_SIZE);
 
-        param = servletContext.getInitParameter("uploadThresholdSize");
+            config._uploadMaxFileSize = resolveSize(param,
+                    config._uploadMaxFileSize);
 
-        config._uploadThresholdSize = resolveSize(param,
-                config._uploadThresholdSize);
+            param = servletContext.getInitParameter(UPLOAD_THRESHOLD_SIZE);
 
-        config._uploadRepositoryPath = servletContext
-                .getInitParameter("uploadRepositoryPath");
+            config._uploadThresholdSize = resolveSize(param,
+                    config._uploadThresholdSize);
+
+            config._uploadRepositoryPath = servletContext
+                    .getInitParameter(UPLOAD_MAX_REPOSITORY_PATH);
+
+            context.getApplicationMap().put(MULTIPART_REQUEST_WRAPPER_CONFIG,
+                    config);
+        }
 
         return config;
     }



Mime
View raw message