You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2009/05/27 13:51:22 UTC

svn commit: r779119 - in /myfaces/trinidad/trunk: src/site/xdoc/devguide/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ trinidad-api/src/main/resources/ trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/ trinidad-impl/src...

Author: matzew
Date: Wed May 27 11:51:22 2009
New Revision: 779119

URL: http://svn.apache.org/viewvc?rev=779119&view=rev
Log:
TRINIDAD-1464 - max upload size cannot be reconfigured after app is deployed

applied patch;

Thanks to Mark Yvanovich for his patch!

Modified:
    myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml
    myfaces/trinidad/trunk/src/site/xdoc/devguide/fileUpload.xml
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
    myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd
    myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java
    myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java

Modified: myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml (original)
+++ myfaces/trinidad/trunk/src/site/xdoc/devguide/configuration.xml Wed May 27 11:51:22 2009
@@ -301,6 +301,38 @@
 Apache Trinidad to handle temporary storage during the request.
 </p>
         </subsection>
+        <subsection name="uploaded-file-max-memory">
+<p>
+
+The <code>&lt;uploaded-file-max-memory&gt;</code> element is used to
+set the maximum amount of memory used during the file upload process
+before the data will start writing out to disk.  This setting directly
+overrides the web.xml setting org.apache.myfaces.trinidad.UPLOAD_MAX_MEMORY. 
+This value can be hardcoded or can be explicitly configured with an EL 
+expression that returns a Long object.
+</p>
+        </subsection>
+        <subsection name="uploaded-file-max-disk-space">
+<p>
+
+The <code>&lt;uploaded-file-max-disk-space&gt;</code> element is used to
+set the maximum amount of disk space allowed for an uploaded file before 
+an EOFException is thrown.  This setting directly overrides the web.xml 
+setting org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE. This value can 
+be hardcoded or can be explicitly configured with an EL expression that 
+returns a Long object.
+</p>
+        </subsection>
+        <subsection name="uploaded-file-temp-dir">
+<p>
+
+The <code>&lt;uploaded-file-max-disk-space&gt;</code> element is used to
+change the default location uploaded files are stored.  This setting directly 
+overrides the web.xml setting org.apache.myfaces.trinidad.UPLOAD_TEMP_DIR. 
+This value can be hardcoded or can be explicitly configured with an EL 
+expression that returns a String object.
+</p>
+        </subsection>
         <subsection name="formatting-locale">
 <p>
 The <code>&lt;formatting-locale&gt;</code> element is used by converters without
@@ -465,14 +497,14 @@
 memory, so memory-limited servers may in some cases benefit from using
 "all" client-side state saving.</p>
 
-<subsection name="The Application View Cache">
-<p>
-  <font color="#FF0000">
-    <strong>
-This feature is NOT supported.
-    </strong>
-See <a href="https://issues.apache.org/jira/browse/TRINIDAD-1487" style="color:red">TRINIDAD-1487</a> for more.
-  </font>
+<subsection name="The Application View Cache">
+<p>
+  <font color="#FF0000">
+    <strong>
+This feature is NOT supported.
+    </strong>
+See <a href="https://issues.apache.org/jira/browse/TRINIDAD-1487" style="color:red">TRINIDAD-1487</a> for more.
+  </font>
 </p>
 <p>
 Apache Trinidad supports a special Application View Cache feature

Modified: myfaces/trinidad/trunk/src/site/xdoc/devguide/fileUpload.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/src/site/xdoc/devguide/fileUpload.xml?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/src/site/xdoc/devguide/fileUpload.xml (original)
+++ myfaces/trinidad/trunk/src/site/xdoc/devguide/fileUpload.xml Wed May 27 11:51:22 2009
@@ -258,16 +258,33 @@
 </source>
       </p>
       <p>
-Developers can also customize file upload more comprehensively
-by replacing the entire
+Developers can also customize file upload more comprehensively in <code>trinidad-config.xml</code>
+with the following elements:
+<source>&lt;uploaded-file-processor&gt;</source>
+The
 <code>org.apache.myfaces.trinidad.webapp.UploadedFileProcessor</code>
-with the <code>&lt;uploaded-file-processor&gt;</code> element
-in <code>trinidad-config.xml</code>.  Please see the
+can be replaced by specifying a new class with the <code>&lt;uploaded-file-processor&gt;</code> element.  
+<source>&lt;uploaded-file-max-memory&gt;</source>
+The servlet context param <code>org.apache.myfaces.trinidad.UPLOAD_MAX_MEMORY</code>
+can be overridden by <code>&lt;uploaded-file-max-memory&gt;</code> if this param
+needs to be bound to an EL expression.
+<source>&lt;uploaded-file-max-disk-space&gt;</source>
+The servlet context param <code>org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE</code>
+can be overridden by <code>&lt;uploaded-file-max-disk-space&gt;</code> if this param
+needs to be bound to an EL expression.
+<source>&lt;uploaded-file-temp-dir&gt;</source>
+The servlet context param <code>org.apache.myfaces.trinidad.UPLOAD_TEMP_DIR</code>
+can be overridden by <code>&lt;uploaded-file-temp-dir&gt;</code> if this param
+needs to be bound to an EL expression.
+      </p>
+      <p>
+Please see the
 <a href="configuration.html">Configuration</a> chapter for
-more information on that element.  Replacing the
+more information on these <code>trinidad-config.xml</code> elements.  <b>NOTE:</b> Replacing the
 <code>UploadedFileProcessor</code> makes the init-params listed
 above irrelevant;  they are only processed by the default
-<code>UploadedFileProcessor</code>.
+<code>UploadedFileProcessor</code>, <b>unless</b> they are specifically taken
+into consideration by the class that replaces the deault file processor class.
       </p>
     </section>
   </body>

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/RequestContext.java Wed May 27 11:51:22 2009
@@ -514,6 +514,12 @@
 
   public abstract UploadedFileProcessor getUploadedFileProcessor();
 
+  public abstract Long getUploadedFileMaxMemory();
+
+  public abstract Long getUploadedFileMaxDiskSpace();
+
+  public abstract String getUploadedFileTempDir();
+
   /**
    * Returns a Map that takes color palette names as keys, and returns
    * the color palette as a result.

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/resources/trinidad-config.xsd Wed May 27 11:51:22 2009
@@ -173,6 +173,38 @@
           </annotation>
         </element>
 
+        <element name="uploaded-file-max-memory" minOccurs="0" maxOccurs="1"
+                 type="config:longExpressionType">
+          <annotation>
+            <documentation>The &lt;uploaded-file-max-memory&gt; element
+should be a string expression for the maximum amount, in bytes, of the incoming
+file that will be stored in memory. Once these limits have been exceeded, disk 
+space will be used.
+            </documentation>
+          </annotation>
+        </element>
+
+        <element name="uploaded-file-max-disk-space" minOccurs="0" maxOccurs="1"
+                 type="config:longExpressionType">
+          <annotation>
+            <documentation>The &lt;uploaded-file-max-disk-space&gt; element
+should be a string expression for the maximum amount of disk space, in bytes,
+allowed for a single file.  If this is exceeded, an EOFException will be thrown.
+            </documentation>
+          </annotation>
+        </element>
+
+        <element name="uploaded-file-temp-dir" minOccurs="0" maxOccurs="1"
+                 type="config:stringExpressionType">
+          <annotation>
+            <documentation>The &lt;uploaded-file-temp-dir&gt; element
+should be a string expression for the path to the temporary directory 
+to use.  If not specified, files will be stored in the temporary 
+directory used by java.io.File.createTempFile()
+            </documentation>
+          </annotation>
+        </element>
+
         <element name="formatting-locale" minOccurs="0" maxOccurs="1"
                  type="config:stringExpressionType">
           <annotation>
@@ -208,6 +240,7 @@
     </restriction>
   </simpleType>
 
+  <!-- The Global type definition for positive integers ( and zero )-->
   <simpleType name="outputModeType">
     <restriction base="string">
       <enumeration value="default"/>
@@ -247,6 +280,10 @@
     <union memberTypes="string config:expressionType" />
   </simpleType>
 
+  <simpleType name="longExpressionType">
+    <union memberTypes="long config:expressionType" />
+  </simpleType>
+
   <simpleType name="booleanExpressionType">
     <union memberTypes="boolean config:expressionType" />
   </simpleType>

Modified: myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/context/MockRequestContext.java Wed May 27 11:51:22 2009
@@ -278,6 +278,39 @@
     _timeZone = timeZone;
   }
 
+  public void setUploadedFileMaxMemory(Long maxMemory)
+  {
+    _maxMemory = maxMemory;
+  }
+
+  @Override
+  public Long getUploadedFileMaxMemory()
+  {
+    return _maxMemory;
+  }
+
+  public void setUploadedFileMaxDiskSpace(Long maxDiskSpace)
+  {
+    _maxDiskSpace = maxDiskSpace;
+  }
+
+  @Override
+  public Long getUploadedFileMaxDiskSpace()
+  {
+    return _maxDiskSpace;
+  }
+
+  public void setUploadedFileTempDir(String tempDir)
+  {
+    _tempDir= tempDir;
+  }
+
+  @Override
+  public String getUploadedFileTempDir()
+  {
+    return _tempDir;
+  }
+
   @Override
   public void addPartialTarget(UIComponent newTarget)
   {
@@ -387,4 +420,7 @@
   private boolean _rtl = false;
   private boolean _animationEnabled = true;
   private Locale _formattingLocale;
+  private Long _maxMemory;
+  private Long _maxDiskSpace;
+  private String _tempDir;
 }

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java Wed May 27 11:51:22 2009
@@ -41,6 +41,7 @@
 import org.apache.myfaces.trinidad.util.ExternalContextUtils;
 import org.apache.myfaces.trinidad.util.RequestStateMap;
 import org.apache.myfaces.trinidad.util.RequestType;
+import org.apache.myfaces.trinidad.webapp.UploadedFileProcessor;
 import org.apache.myfaces.trinidadinternal.share.util.MultipartFormHandler;
 import org.apache.myfaces.trinidadinternal.share.util.MultipartFormItem;
 
@@ -210,7 +211,11 @@
       final MultipartFormItem item) throws IOException
   {
     final UploadedFile temp = new TempUploadedFile(item);
-
+    Map<String, Object> sessionMap = externalContext.getSessionMap();
+    Map<String, Object> requestMap = externalContext.getRequestMap();
+    _copyFromSessionToRequestMap(sessionMap, requestMap, UploadedFileProcessor.MAX_MEMORY_PARAM_NAME);
+    _copyFromSessionToRequestMap(sessionMap, requestMap, UploadedFileProcessor.MAX_DISK_SPACE_PARAM_NAME);
+    _copyFromSessionToRequestMap(sessionMap, requestMap, UploadedFileProcessor.TEMP_DIR_PARAM_NAME);    
     final UploadedFile file =
       context.getUploadedFileProcessor().processFile(externalContext.getRequest(), temp);
 
@@ -227,6 +232,11 @@
     }
   }
 
+  private void _copyFromSessionToRequestMap(Map<String, Object> sessionMap, Map<String, Object> requestMap, String param)
+  {
+   requestMap.put(param,  sessionMap.get(param));
+  }
+
   static private ExternalContext _getExternalContextWrapper(ExternalContext externalContext, Map<String, String[]> addedParams)
   {
     if(!isApplied(externalContext))

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java Wed May 27 11:51:22 2009
@@ -30,9 +30,9 @@
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 
-import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.model.UploadedFile;
+import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
 import org.apache.myfaces.trinidad.webapp.UploadedFileProcessor;
 import org.apache.myfaces.trinidadinternal.context.external.PortletApplicationMap;
 import org.apache.myfaces.trinidadinternal.context.external.PortletInitParameterMap;
@@ -41,6 +41,7 @@
 import org.apache.myfaces.trinidadinternal.context.external.ServletInitParameterMap;
 import org.apache.myfaces.trinidadinternal.context.external.ServletRequestMap;
 
+
 public class UploadedFileProcessorImpl implements UploadedFileProcessor
 {
   public UploadedFileProcessorImpl()
@@ -93,7 +94,7 @@
         }
         catch (NumberFormatException nfe)
         {
-          _maxMemory = _DEFAULT_MAX_DISK_SPACE;
+          _maxDiskSpace = _DEFAULT_MAX_DISK_SPACE;
         }
       }
       else
@@ -122,6 +123,30 @@
   {
     RequestInfo info = _getRequestInfo(request);
     int contentLength = getContentLength(request);
+    Map<String, Object> requestMap;
+    
+    if (_isPortletRequestClass(request))
+      requestMap = _getPortletRequestMap(request);
+    else
+      requestMap = _getServletRequestMap(request);
+
+    Long maxMemory = (Long)requestMap.get(MAX_MEMORY_PARAM_NAME);
+    Long maxDiskSpace = (Long)requestMap.get(MAX_DISK_SPACE_PARAM_NAME);
+    String tempDir = (String)requestMap.get(TEMP_DIR_PARAM_NAME);
+    
+    if (maxMemory != null)
+    {
+      _maxMemory = maxMemory;
+    }
+      
+    if (maxDiskSpace != null)
+    {
+      _maxDiskSpace = maxDiskSpace;
+    }
+ 
+    if (tempDir != null)
+      _tempDir = tempDir;
+    
     if(contentLength>_maxDiskSpace)
     {
       return new ErrorFile();
@@ -159,7 +184,7 @@
   private int getContentLength(Object request)
   {
     int length = -1;
-    if (_PORTLET_REQUEST_CLASS != null && _PORTLET_REQUEST_CLASS.isInstance(request))
+    if (_isPortletRequestClass(request))
     {
       length = _getPortletRequestLength(request);
     }
@@ -174,7 +199,7 @@
   private RequestInfo _getRequestInfo(Object request)
   {
     Map<String, Object> attributes;
-    if (_PORTLET_REQUEST_CLASS != null && _PORTLET_REQUEST_CLASS.isInstance(request))
+    if (_isPortletRequestClass(request))
     {
       attributes = _getPortletRequestMap(request);
     }
@@ -194,6 +219,11 @@
 
     return info;
   }
+  
+  private boolean _isPortletRequestClass(Object request)
+  {
+    return (_PORTLET_REQUEST_CLASS != null && _PORTLET_REQUEST_CLASS.isInstance(request));
+  }
 
   private static final ContextInfo _getServletContextInfo(final Object context)
   {

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextBean.java Wed May 27 11:51:22 2009
@@ -72,7 +72,13 @@
   static public final PropertyKey UPLOADED_FILE_PROCESSOR_KEY = 
     TYPE.registerKey("uploaded-file-processor",
                      PropertyKey.CAP_NOT_BOUND);
-    static public final PropertyKey REMOTE_DEVICE_REPOSITORY_URI =
+  static public final PropertyKey UPLOADED_FILE_MAX_MEMORY_KEY = 
+    TYPE.registerKey("uploaded-file-max-memory", Long.class);
+  static public final PropertyKey UPLOADED_FILE_MAX_DISK_SPACE_KEY = 
+    TYPE.registerKey("uploaded-file-max-disk-space", Long.class);
+  static public final PropertyKey UPLOADED_FILE_TEMP_DIR_KEY = 
+    TYPE.registerKey("uploaded-file-temp-dir");
+  static public final PropertyKey REMOTE_DEVICE_REPOSITORY_URI =
       TYPE.registerKey("remote-device-repository-uri");                       
   static public final PropertyKey ANIMATION_ENABLED_KEY =
     TYPE.registerKey("animation-enabled", Boolean.class, true);

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Wed May 27 11:51:22 2009
@@ -167,6 +167,24 @@
       _bean.getProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY);
   }
 
+  @Override
+  public Long getUploadedFileMaxMemory()
+  {
+    return (Long) _bean.getProperty(RequestContextBean.UPLOADED_FILE_MAX_MEMORY_KEY);
+  }
+
+  @Override
+  public Long getUploadedFileMaxDiskSpace()
+  {
+    return (Long) _bean.getProperty(RequestContextBean.UPLOADED_FILE_MAX_DISK_SPACE_KEY);
+  }
+
+  @Override
+  public String getUploadedFileTempDir()
+  {
+    return (String) _bean.getProperty(RequestContextBean.UPLOADED_FILE_TEMP_DIR_KEY);
+  }
+
 
   @Override
   public boolean isPostback()

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java Wed May 27 11:51:22 2009
@@ -19,8 +19,13 @@
 
 package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
 
+import java.io.IOException;
+
+import java.util.Map;
+
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
@@ -31,9 +36,12 @@
 import org.apache.myfaces.trinidad.component.core.input.CoreInputText;
 
 import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.model.UploadedFile;
 import org.apache.myfaces.trinidad.util.MessageFactory;
+import org.apache.myfaces.trinidad.webapp.UploadedFileProcessor;
 import org.apache.myfaces.trinidadinternal.config.upload.UploadedFiles;
+import org.apache.myfaces.trinidadinternal.context.RequestContextBean;
 
 /**
  */
@@ -131,6 +139,30 @@
   // ENCODE BEHAVIOR
   // 
 
+  @Override
+  protected void encodeAllAsElement(
+    FacesContext        context,
+    RenderingContext arc,
+    UIComponent         component,
+    FacesBean           bean) throws IOException
+  {
+     // call super...
+    super.encodeAllAsElement(context, arc, component, bean);
+
+    // now evaluate the EL
+    // We need to evaluate it here and store it on the sessionMap because
+    // during UploadedFileProcessor.processFile() there is no FacesContext
+    RequestContext rc = RequestContext.getCurrentInstance();
+    Object maxMemory = rc.getUploadedFileMaxMemory();
+    Object maxDiskSpace = rc.getUploadedFileMaxDiskSpace();
+    Object tempDir = rc.getUploadedFileTempDir();
+    ExternalContext external = context.getExternalContext();
+    Map<String, Object> sessionMap = external.getSessionMap();
+    sessionMap.put(UploadedFileProcessor.MAX_MEMORY_PARAM_NAME, maxMemory);
+    sessionMap.put(UploadedFileProcessor.MAX_DISK_SPACE_PARAM_NAME, maxDiskSpace);
+    sessionMap.put(UploadedFileProcessor.TEMP_DIR_PARAM_NAME, tempDir);
+  }
+
   /**
    * <inputFile> cannot show a value.
    */

Modified: myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java?rev=779119&r1=779118&r2=779119&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MRequestContext.java Wed May 27 11:51:22 2009
@@ -265,6 +265,39 @@
     return _FIXED_TIME_ZONE;
   }
 
+  public void setUploadedFileMaxMemory(Long maxMemory)
+  {
+    _maxMemory = maxMemory;
+  }
+
+  @Override
+  public Long getUploadedFileMaxMemory()
+  {
+    return _maxMemory;
+  }
+
+  public void setUploadedFileMaxDiskSpace(Long maxDiskSpace)
+  {
+    _maxDiskSpace = maxDiskSpace;
+  }
+
+  @Override
+  public Long getUploadedFileMaxDiskSpace()
+  {
+    return _maxDiskSpace;
+  }
+
+  public void setUploadedFileTempDir(String tempDir)
+  {
+    _tempDir= tempDir;
+  }
+
+  @Override
+  public String getUploadedFileTempDir()
+  {
+    return _tempDir;
+  }
+
   @Override
   public void addPartialTarget(UIComponent newTarget)
   {
@@ -359,6 +392,9 @@
 
 
   private String _skin;
+  private Long _maxMemory;
+  private Long _maxDiskSpace;
+  private String _tempDir;
   private Accessibility _accMode;
   private AccessibilityProfile _accProfile;
   private ClientValidation _clientValidation = ClientValidation.ALERT;