You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/06/16 01:16:11 UTC

svn commit: r190830 - in /incubator/beehive/trunk/netui/src: compiler-core/org/apache/beehive/netui/compiler/ compiler-core/org/apache/beehive/netui/compiler/genmodel/ compiler-core/org/apache/beehive/netui/compiler/model/ pageflow/org/apache/beehive/netui/pageflow/ pageflow/org/apache/beehive/netui/pageflow/config/ pageflow/org/apache/beehive/netui/pageflow/internal/

Author: rich
Date: Wed Jun 15 16:16:10 2005
New Revision: 190830

URL: http://svn.apache.org/viewcvs?rev=190830&view=rev
Log:
Fix for http://issues.apache.org/jira/browse/BEEHIVE-802 : Need to remove the "disk" multipart handler option

tests: bvt in netui (WinXP)
BB: self (linux)


Modified:
    incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
    incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java
    incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java
    incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java
    incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java
    incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java

Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/JpfLanguageConstants.java?rev=190830&r1=190829&r2=190830&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/JpfLanguageConstants.java (original)
+++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/JpfLanguageConstants.java Wed Jun 15 16:16:10 2005
@@ -209,8 +209,7 @@
     public static final String MULTIPART_HANDLER_MEMORY_STR = "memory";
     public static final String MULTIPART_HANDLER_DISK_STR = "disk";
     
-    public static final String MULTIPART_HANDLER_MEMORY_CLASSNAME = STRUTS_PACKAGE + ".upload.CommonsMultipartRequestHandler";
-    public static final String MULTIPART_HANDLER_DISK_CLASSNAME = STRUTS_PACKAGE + ".upload.DiskMultipartRequestHandler";
+    public static final String COMMONS_MULTIPART_HANDLER_CLASSNAME = STRUTS_PACKAGE + ".upload.CommonsMultipartRequestHandler";
     
     public static final String VALIDATOR_VERSION_ONE_ZERO_STR = "oneZero";
     public static final String VALIDATOR_VERSION_ONE_ONE_STR = "oneOne";

Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java?rev=190830&r1=190829&r2=190830&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java (original)
+++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java Wed Jun 15 16:16:10 2005
@@ -221,18 +221,22 @@
     {
         if ( mpHandler != null )
         {
-            if ( mpHandler.equals( MULTIPART_HANDLER_MEMORY_STR ) )
+            if ( mpHandler.equals( MULTIPART_HANDLER_DISABLED_STR ) )
             {
-                setMultipartHandlerClassName( MULTIPART_HANDLER_MEMORY_CLASSNAME );
-            }
-            else if ( mpHandler.equals( MULTIPART_HANDLER_DISK_STR ) )
-            {
-                setMultipartHandlerClassName( MULTIPART_HANDLER_DISK_CLASSNAME );
+                setMultipartHandlerClassName( "none" );
             }
             else
             {
-                assert mpHandler.equals( MULTIPART_HANDLER_DISABLED_STR );
-                setMultipartHandlerClassName( "none" );
+                setMultipartHandlerClassName( COMMONS_MULTIPART_HANDLER_CLASSNAME );
+                
+                if ( mpHandler.equals( MULTIPART_HANDLER_DISK_STR ) )
+                {
+                    setMemFileSize( "0K" );
+                }
+                else
+                {
+                    assert mpHandler.equals( MULTIPART_HANDLER_MEMORY_STR ) : mpHandler;
+                }
             }
         }
     }

Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java?rev=190830&r1=190829&r2=190830&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java (original)
+++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java Wed Jun 15 16:16:10 2005
@@ -60,6 +60,7 @@
     private Map _sharedFlows = null;
     private String _controllerClassName = null;
     private String _multipartHandlerClassName = null;
+    private String _memFileSize = null;
     private List _tilesDefinitionsConfigs = null;
 
 
@@ -699,6 +700,11 @@
             controller.setMultipartClass( _multipartHandlerClassName );
         }
         
+        if ( _memFileSize != null && controller.getMemFileSize() == null )
+        {
+            controller.setMemFileSize( _memFileSize );
+        }
+        
         if ( _isNestedPageFlow ) addSetProperty( controller, "isNestedPageFlow", "true" );
         if ( _isLongLivedPageFlow ) addSetProperty( controller, "isLongLivedPageFlow", "true" );
         if ( _isSharedFlow ) addSetProperty( controller, "isSharedFlow", "true" );
@@ -944,5 +950,23 @@
     protected boolean isSharedFlow()
     {
         return _isSharedFlow;
+    }
+
+    /**
+     * Get the threshold for keeping a file in memory when processing a multipart request.  An example is
+     * <code>256K</code>
+     */ 
+    protected String getMemFileSize()
+    {
+        return _memFileSize;
+    }
+
+    /**
+     * Set the threshold for keeping a file in memory when processing a multipart request.  An example is
+     * <code>256K</code>
+     */ 
+    protected void setMemFileSize( String memFileSize )
+    {
+        _memFileSize = memFileSize;
     }
 }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java?rev=190830&r1=190829&r2=190830&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java Wed Jun 15 16:16:10 2005
@@ -257,8 +257,13 @@
         // Tell the page flow that it is on the nesting stack.
         pageFlow.setIsOnNestingStack( true );
         
-        // To ensure that this attribute is replicated for session failover...
-        ensureFailover( request, pageFlow.getServletContext() );
+        // To ensure that this attribute is replicated for session failover.
+        // First, we can only use the page flow's transient ServletContext reference if it hasn't lost it.
+        // The user never has to deal with this possibility because we always reinitialize it before user
+        // code, but here we don't have that guarantee.
+        ServletContext servletContext = pageFlow.getServletContext();
+        if ( servletContext == null ) servletContext = InternalUtils.getServletContext( request );
+        ensureFailover( request, servletContext );
     }
     
     /**

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java?rev=190830&r1=190829&r2=190830&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java Wed Jun 15 16:16:10 2005
@@ -19,7 +19,6 @@
 
 import org.apache.struts.config.ControllerConfig;
 import org.apache.struts.upload.CommonsMultipartRequestHandler;
-import org.apache.struts.upload.DiskMultipartRequestHandler;
 import org.apache.beehive.netui.util.config.bean.PageflowConfig;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 
@@ -31,8 +30,7 @@
  */
 public class PageFlowControllerConfig extends ControllerConfig
 {
-    private static final String MEMORY_MULTIPART_HANDLER_CLASS = CommonsMultipartRequestHandler.class.getName();
-    private static final String DISK_MULTIPART_HANDLER_CLASS = DiskMultipartRequestHandler.class.getName();
+    private static final String COMMONS_MULTIPART_HANDLER_CLASS = CommonsMultipartRequestHandler.class.getName();
     
     private boolean _isNestedPageFlow;
     private boolean _isLongLivedPageFlow;
@@ -43,6 +41,7 @@
     private String _controllerClass;
     private boolean _isSharedFlow;
     private String _overrideMultipartClass = null;
+    private String _overrideMemFileSize = null;
     private boolean _forceMultipartDisabled = false;
 
     
@@ -147,6 +146,10 @@
         _isSharedFlow = sharedFlow;
     }
 
+    /**
+     * This gets the multipart class.  If it was explicitly set on the associated <controller> element, just use that;
+     * otherwise, get the value from WEB-INF/beehive-netui-config.xml.
+     */ 
     public String getMultipartClass()
     {
         if ( _forceMultipartDisabled ) return null;
@@ -159,24 +162,33 @@
             switch ( mpHandler.intValue() )
             {
                 case PageflowConfig.MultipartHandler.INT_DISABLED: return null;
-                case PageflowConfig.MultipartHandler.INT_MEMORY: return MEMORY_MULTIPART_HANDLER_CLASS;
-                case PageflowConfig.MultipartHandler.INT_DISK: return DISK_MULTIPART_HANDLER_CLASS;
+                case PageflowConfig.MultipartHandler.INT_MEMORY: return COMMONS_MULTIPART_HANDLER_CLASS;
+                case PageflowConfig.MultipartHandler.INT_DISK: return COMMONS_MULTIPART_HANDLER_CLASS;
                 default: assert false : "unknown value for multipart handler: " + mpHandler.toString();
             }
         }
         
         return null;
     }
-
-    /**
-     * Get the directory for DiskMultipartRequestHandler temporary files.
-     * @return directory string
-     */ 
-    public String getTempDir()
+    
+    public String getMemFileSize()
     {
-        // TODO: In the Struts 1.1 version of DiskMultipartRequestHandler, there is an NPE on line 295
-        // (in retrieveTempDir).  When this is fixed, we can remove our override of getTempDir().
-        return tempDir != null ? tempDir : System.getProperty( "java.io.tmpdir" );
+        if ( _overrideMemFileSize != null ) return _overrideMemFileSize;
+        
+        PageflowConfig.MultipartHandler.Enum mpHandler = InternalUtils.getMultipartHandlerType();
+        
+        if ( mpHandler != null )
+        {
+            switch ( mpHandler.intValue() )
+            {
+                case PageflowConfig.MultipartHandler.INT_DISABLED: return super.getMemFileSize();
+                case PageflowConfig.MultipartHandler.INT_MEMORY: return super.getMemFileSize();
+                case PageflowConfig.MultipartHandler.INT_DISK: return "0K"; // memory filesize threshold of zero.
+                default: assert false : "unknown value for multipart handler: " + mpHandler.toString();
+            }
+        }
+        
+        return super.getMemFileSize();
     }
 
     public void setMultipartClass( String overrideMultipartClass )
@@ -189,5 +201,10 @@
         {
             _overrideMultipartClass = overrideMultipartClass;
         }
+    }
+    
+    public void setMemFileSize( String fileSize )
+    {
+        _overrideMemFileSize = fileSize;
     }
 }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java?rev=190830&r1=190829&r2=190830&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java Wed Jun 15 16:16:10 2005
@@ -219,8 +219,6 @@
         throws ControlFieldInitializationException
     {
         Class controlClientClass = controlClient.getClass();
-        Map controlFields = getAccessibleControlFieldAnnotations( controlClientClass, servletContext );
-        if ( controlFields.isEmpty() ) return;
 
         request = PageFlowUtils.unwrapMultipart( request );
         ControlBeanContext beanContext = getControlBeanContext( request, response, servletContext, false );