You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/03/21 21:33:37 UTC

svn commit: r387615 - in /jakarta/tapestry/branches/4.0: framework/src/documentation/content/xdocs/tapestry/ComponentReference/ framework/src/java/org/apache/tapestry/form/ framework/src/java/org/apache/tapestry/multipart/ portlet/src/java/org/apache/t...

Author: jkuhnert
Date: Tue Mar 21 12:33:35 2006
New Revision: 387615

URL: http://svn.apache.org/viewcvs?rev=387615&view=rev
Log:
Added checking of maxSize on multipart service so that manual setting of the value can be detected and Upload component
parameters ignored if the service has had its value set.

Modified:
    jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
    jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java
    jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java
    jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java
    jakarta/tapestry/branches/4.0/portlet/src/java/org/apache/tapestry/portlet/multipart/PortletMultipartDecoderImpl.java

Modified: jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml?rev=387615&r1=387614&r2=387615&view=diff
==============================================================================
--- jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml (original)
+++ jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml Tue Mar 21 12:33:35 2006
@@ -118,7 +118,9 @@
     <td>no</td>
     <td>10000000</td>
     <td>
-      The default maximum file upload size, in bytes. Default is 10kb.
+      The default maximum file upload size, in bytes. Default is 10kb. 
+      Note: This parameter will be ignored if the maximum size is set manually
+      on the <link href="&apiroot;/multipart/MultipartDecoder.html">MultipartDecoder</link> service.
     </td>
 
   </tr>

Modified: jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java?rev=387615&r1=387614&r2=387615&view=diff
==============================================================================
--- jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java (original)
+++ jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java Tue Mar 21 12:33:35 2006
@@ -79,8 +79,10 @@
      */
     protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
-    	// set the max file upload size first
-    	getDecoder().setSizeMax(getMaxSize());
+    	// set the max file upload size first, but only if
+    	// not already set manually on the decoder service
+    	if (!getDecoder().isMaxSizeSet())
+    		getDecoder().setSizeMax(getMaxSize());
     	
         IUploadFile file = getDecoder().getFileUpload(getName());
         
@@ -102,7 +104,9 @@
     }
     
     /**
-     * Max size parameter, in bytes. 
+     * Max size parameter, in bytes. Parameter is ignored if 
+     * {@link MultipartDecoder#isMaxSizeSet()} returns true.
+     * 
      * @return The maximum file size that may be uploaded.
      */
     public abstract long getMaxSize();

Modified: jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java?rev=387615&r1=387614&r2=387615&view=diff
==============================================================================
--- jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java (original)
+++ jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java Tue Mar 21 12:33:35 2006
@@ -35,13 +35,21 @@
 
     /**
      * Sets the maximum upload file size on the resulting {@link FileUpload} 
-     * object.
+     * object. Also sets the internal state so that {@link #isMaxSizeSet()} will 
+     * return true.
      * 
      * @see <a href="http://jakarta.apache.org/commons/fileupload/apidocs/org/apache/commons/fileupload/FileUploadBase.html#setSizeMax(long)">FileUpload</a>
      * @param sizeMax The maximum file size allowed for uploads, default is 10kb
      */
     
     public void setSizeMax(long sizeMax);
+    
+    /**
+     * Checks if the {@link #setSizeMax(long)} value has been manually set.
+     * @return True, if the {@link #setSizeMax(long)} method has been called.
+     */
+    
+    public boolean isMaxSizeSet();
     
 	/**
 	 * Cleans up any temporary resources created during the request processing.

Modified: jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java?rev=387615&r1=387614&r2=387615&view=diff
==============================================================================
--- jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java (original)
+++ jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java Tue Mar 21 12:33:35 2006
@@ -38,6 +38,11 @@
 {	
 	/* maximum size of file allowed to be uploaded */
 	protected long _sizeMax = 10000000;
+	/* 
+	 * boolean check for whether someone has manually set 
+	 * the maximum upload size directly on this service 
+	 */
+	protected boolean _sizeMaxSet = false;
 	
     public HttpServletRequest decode(HttpServletRequest request)
     {
@@ -65,7 +70,7 @@
     	FileItemFactory factory = new DiskFileItemFactory(_thresholdSize, new File(_repositoryPath));
     	ServletFileUpload upload = new ServletFileUpload(factory);
     	
-    	//set maximum file upload size
+    	// set maximum file upload size
     	upload.setSizeMax(_sizeMax);
     	
         if (_encoding != null)
@@ -79,6 +84,15 @@
 	 */
 	public void setSizeMax(long sizeMax)
 	{
+		_sizeMaxSet = true;
 		_sizeMax = sizeMax;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean isMaxSizeSet()
+	{
+		return _sizeMaxSet;
 	}
 }

Modified: jakarta/tapestry/branches/4.0/portlet/src/java/org/apache/tapestry/portlet/multipart/PortletMultipartDecoderImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/portlet/src/java/org/apache/tapestry/portlet/multipart/PortletMultipartDecoderImpl.java?rev=387615&r1=387614&r2=387615&view=diff
==============================================================================
--- jakarta/tapestry/branches/4.0/portlet/src/java/org/apache/tapestry/portlet/multipart/PortletMultipartDecoderImpl.java (original)
+++ jakarta/tapestry/branches/4.0/portlet/src/java/org/apache/tapestry/portlet/multipart/PortletMultipartDecoderImpl.java Tue Mar 21 12:33:35 2006
@@ -35,6 +35,11 @@
 
 	/* maximum size of file allowed to be uploaded */
 	protected long _sizeMax = 10000000;
+	/* 
+	 * boolean check for whether someone has manually set 
+	 * the maximum upload size directly on this service 
+	 */
+	protected boolean _sizeMaxSet = false;
 	
 	public ActionRequest decode(ActionRequest request) {
         _encoding = request.getCharacterEncoding();
@@ -61,7 +66,7 @@
     	FileItemFactory factory = new DiskFileItemFactory(_thresholdSize, new File(_repositoryPath));
     	PortletFileUpload upload = new PortletFileUpload(factory);
     	
-    	//set maximum file upload size
+    	// set maximum file upload size
     	upload.setSizeMax(_sizeMax);
     	
         if (_encoding != null)
@@ -75,6 +80,15 @@
 	 */
 	public void setSizeMax(long sizeMax)
 	{
+		_sizeMaxSet = true;
 		_sizeMax = sizeMax;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean isMaxSizeSet()
+	{
+		return _sizeMaxSet;
 	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org