Author: rich
Date: Fri Oct 29 13:43:16 2004
New Revision: 55993

Added:
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/welcomeFile/
      - copied from rev 55944, 
incubator/beehive/branches/v1/alpha/netui/test/webapps/drt/coreWeb/miniTests/welcomeFile/
   
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/welcomeFile/WelcomeFileController.jpf
   (props changed)
      - copied unchanged from rev 55944, 
incubator/beehive/branches/v1/alpha/netui/test/webapps/drt/coreWeb/miniTests/welcomeFile/WelcomeFileController.jpf
   
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/welcomeFile/index.jsp
   (props changed)
      - copied unchanged from rev 55944, 
incubator/beehive/branches/v1/alpha/netui/test/webapps/drt/coreWeb/miniTests/welcomeFile/index.jsp
   
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/WelcomeFile.xml
   (props changed)
      - copied unchanged from rev 55944, 
incubator/beehive/branches/v1/alpha/netui/test/webapps/drt/testRecorder/tests/WelcomeFile.xml
Modified:
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java
   
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java
   
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
   incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/web.xml
   
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
   
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NonNormalizedPath.xml
Log:
Integ of revision 55944 (alpha branch):
Fix for http://nagoya.apache.org/jira/browse/BEEHIVE-34 : Cannot make a page 
flow a welcome file

DRT: netui server (WinXP)
BB: self (linux)



Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/AutoRegisterActionServlet.java
 Fri Oct 29 13:43:16 2004
@@ -534,7 +534,7 @@
         ServletContext servletContext = getServletContext();
         ContextCache.get( servletContext ).getReloadableClassHandler().reinit( 
request );
         
-        String modulePath = PageFlowUtils.getModulePath( request, 
InternalUtils.decodeURI( request ) );
+        String modulePath = PageFlowUtils.getModulePathForRelativeURI( 
InternalUtils.getDecodedServletPath( request ) );
         ModuleConfig registeredApp;
         
         //
@@ -586,14 +586,14 @@
                 //
                 SharedFlowController sf =
                         FlowControllerFactory.getSharedFlowForRequest( 
request, response, servletContext );
-                String uri = InternalUtils.decodeURI( request );
+                String relativeURI = InternalUtils.getDecodedServletPath( 
request );
                 
                 if ( sf != null )
                 {
                     StringBuilder sfActionURI = new StringBuilder( 
sf.getModulePath() );
                     sfActionURI.append( '/' );
-                    sfActionURI.append( ServletUtils.getBaseName( uri ) );
-                    RequestValues.setOriginalRequestURI( request, uri );
+                    sfActionURI.append( ServletUtils.getBaseName( relativeURI 
) );
+                    RequestValues.setOriginalServletPath( request, relativeURI 
);
                     ForwardRedirectHandler frh = ContextCache.get( 
servletContext ).getForwardRedirectHandler();
                     frh.forward( sfActionURI.toString(), request, response );
                     return;
@@ -603,7 +603,7 @@
                 if ( _log.isErrorEnabled() )
                 {
                     StringBuilder msg = new StringBuilder( "No module 
configuration registered for " );
-                    msg.append( uri ).append( " (module path " ).append( 
modulePath ).append( ")." );
+                    msg.append( relativeURI ).append( " (module path " 
).append( modulePath ).append( ")." );
                     _log.error( msg.toString() );
                 }
 
@@ -611,7 +611,7 @@
                 // If we're not in production mode, send a diagnostic on the 
response; otherwise, simply send a 404.
                 //
                 InternalUtils.sendDevTimeError( "PageFlow_NoModuleConf", null, 
HttpServletResponse.SC_NOT_FOUND, 
-                                                request, response, 
servletContext, uri, modulePath );
+                                                request, response, 
servletContext, relativeURI, modulePath );
             }
         }
     }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java
   (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java
   Fri Oct 29 13:43:16 2004
@@ -42,7 +42,7 @@
                                                                   
HttpServletResponse response, 
                                                                   
ServletContext servletContext )
     {
-        String uri = PageFlowUtils.getRelativeURI( request, 
InternalUtils.decodeURI( request ), null );
+        String uri = InternalUtils.getDecodedServletPath( request );
         assert uri.startsWith( "/" ) : uri;
         String backingClassName = FileUtils.stripFileExtension( uri.substring( 
1 ).replace( '/', '.' ) );
         FacesBackingBean currentBean = InternalUtils.getFacesBackingBean( 
request );

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
     (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
     Fri Oct 29 13:43:16 2004
@@ -56,9 +56,16 @@
     public static PageFlowController getPageFlowForRequest( HttpServletRequest 
request,  HttpServletResponse response,
                                                             ServletContext 
servletContext )
     {
-        return getPageFlowForURI( request, response, InternalUtils.decodeURI( 
request ), servletContext );
+        return getPageFlowForRelativeURI( request, response, 
InternalUtils.getDecodedServletPath( request ), servletContext );
     }    
     
+    public static PageFlowController getPageFlowForURI( HttpServletRequest 
request, HttpServletResponse response,
+                                                        String uri, 
ServletContext servletContext )
+    {
+        return getPageFlowForRelativeURI( request, response, 
PageFlowUtils.getRelativeURI( request, uri, null ),
+                                          servletContext );
+    }
+    
     /**
      * Get the [EMAIL PROTECTED] PageFlowController} instance that should be 
associated with the given URI.
      * If it doesn't exist, create it.  The PageFlowController stack (for
@@ -67,17 +74,17 @@
      * 
      * @param request the current HttpServletRequest.
      * @param response the current HttpServletResponse.
-     * @param uri the webapp-relative URI for the page flow.
+     * @param relativeURI the webapp-relative URI for the page flow.
      * @param servletContext the current ServletContext.
      * @return the PageFlowController for the request, or <code>null</code> if 
none was found
      *             and none could be created.
      */
-    public static PageFlowController getPageFlowForURI( HttpServletRequest 
request, HttpServletResponse response,
-                                                        String uri, 
ServletContext servletContext )
+    public static PageFlowController getPageFlowForRelativeURI( 
HttpServletRequest request,
+                                                                
HttpServletResponse response, String relativeURI,
+                                                                ServletContext 
servletContext )
     {
         PageFlowController cur = InternalUtils.getCurrentPageFlow( request, 
false );
-        String parentDir =
-                PageFlowUtils.getModulePathForRelativeURI( 
PageFlowUtils.getRelativeURI( request, uri, null ) );
+        String parentDir = PageFlowUtils.getModulePathForRelativeURI( 
relativeURI );
         
         //
         // If there's no current PageFlow, or if the current 
PageFlowController has a module path that
@@ -100,13 +107,13 @@
                                                                 
HttpServletResponse response,
                                                                 ServletContext 
servletContext )
     {
-        return getSharedFlowForURI( request, response, 
InternalUtils.decodeURI( request ), servletContext );
+        return getSharedFlowForRelativeURI( request, response, 
InternalUtils.getDecodedServletPath( request ), servletContext );
     }
     
-    public static SharedFlowController getSharedFlowForURI( HttpServletRequest 
request, HttpServletResponse response,
-                                                            String uri, 
ServletContext servletContext )
+    public static SharedFlowController getSharedFlowForRelativeURI( 
HttpServletRequest request, HttpServletResponse response,
+                                                                    String 
relativeURI, ServletContext servletContext )
     {
-        String className = InternalUtils.getSharedFlowClassNameForURI( uri, 
request, servletContext );
+        String className = InternalUtils.getSharedFlowClassNameForRelativeURI( 
relativeURI, request, servletContext );
         if ( className == null ) return null;
         SharedFlowController cur = PageFlowUtils.getSharedFlow( className, 
request );
         

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
  (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
  Fri Oct 29 13:43:16 2004
@@ -465,7 +465,7 @@
     private void processInternal( HttpServletRequest request, 
HttpServletResponse response )
             throws IOException, ServletException
     {
-        String uri = PageFlowUtils.getRelativeURI( request, 
InternalUtils.decodeURI( request ), null );
+        String uri = InternalUtils.getDecodedServletPath( request );
         ServletContext servletContext = getServletContext();
         ServerAdapter serverAdapter = ContextCache.get( servletContext 
).getServerAdapter();
 
@@ -608,7 +608,7 @@
             {
                 String desiredType = beginMapping.getParameter();
                 desiredType = desiredType.substring( desiredType.lastIndexOf( 
'.' ) + 1 ) + JPF_EXTENSION;
-                String requestedType = InternalUtils.decodeURI( request );
+                String requestedType = InternalUtils.getDecodedServletPath( 
request );
                 requestedType = requestedType.substring( 
requestedType.lastIndexOf( '/' ) + 1 );
 
                 if ( ! requestedType.equals( desiredType ) )
@@ -964,17 +964,17 @@
         //
         
         // originalRequestURI is the request URI we had before trying to 
forward to an action in Global.app.
-        String originalRequestURI = RequestValues.getOriginalRequestURI( 
request );
+        String originalServletPath = RequestValues.getOriginalServletPath( 
request );
         
-        if ( originalRequestURI != null )
+        if ( originalServletPath != null )
         {
-            return processUnresolvedAction( path, originalRequestURI, request, 
response, forwardedForm );
+            return processUnresolvedAction( path, originalServletPath, 
request, response, forwardedForm );
         }
         else
         {
             if ( !trySharedFlowAction( path, request, response ) )
             {
-                return processUnresolvedAction( path, InternalUtils.decodeURI( 
request ),
+                return processUnresolvedAction( path, 
InternalUtils.getDecodedServletPath( request ),
                                                 request, response, 
forwardedForm );
             }
         }
@@ -1000,7 +1000,7 @@
             // Save the original request URI, so if the action fails on the 
shared flow, too, then we can
             // give an error message that includes *this* URI, not the shared 
flow URI.
             //
-            RequestValues.setOriginalRequestURI( request, 
InternalUtils.decodeURI( request ) );
+            RequestValues.setOriginalServletPath( request, 
InternalUtils.getDecodedServletPath( request ) );
             
             //
             // Construct a URI that is [shared flow module path] + [base 
action path] + [action-extension (.do)]
@@ -1026,7 +1026,7 @@
         return false;
     }
     
-    protected ActionMapping processUnresolvedAction( String actionPath, String 
originalRequestURI,
+    protected ActionMapping processUnresolvedAction( String actionPath, String 
originalServletPath,
                                                      HttpServletRequest 
request, HttpServletResponse response,
                                                      Object returningForm )
         throws IOException
@@ -1047,7 +1047,7 @@
         try
         {
             ServletContext servletContext = getServletContext();
-            fc = FlowControllerFactory.getPageFlowForURI( request, response, 
originalRequestURI, servletContext );
+            fc = FlowControllerFactory.getPageFlowForRelativeURI( request, 
response, originalServletPath, servletContext );
             if ( fc == null ) fc = PageFlowUtils.getSharedFlow( request, 
servletContext );
             
             if ( fc != null )

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
     (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
     Fri Oct 29 13:43:16 2004
@@ -92,8 +92,7 @@
      */
     public static String getModulePath( HttpServletRequest request )
     {
-        String requestURI = InternalUtils.decodeURI( request );
-        return getModulePathForRelativeURI( getRelativeURI( request, 
requestURI, null ) );
+        return getModulePathForRelativeURI( 
InternalUtils.getDecodedServletPath( request ) );
     }
 
     /**
@@ -122,7 +121,7 @@
      */
     public static final String getRelativeURI( HttpServletRequest request, 
PageFlowController relativeTo )
     {
-        return getRelativeURI( request, InternalUtils.decodeURI( request ), 
relativeTo );
+        return getRelativeURI( request, InternalUtils.getDecodedURI( request 
), relativeTo );
     }
 
     /**
@@ -640,7 +639,7 @@
      */ 
     static void setActionURI( HttpServletRequest request )
     {
-        request.setAttribute( ACTION_URI_ATTR, InternalUtils.decodeURI( 
request ) );
+        request.setAttribute( ACTION_URI_ATTR, InternalUtils.getDecodedURI( 
request ) );
     }
     
     /**

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
    (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
    Fri Oct 29 13:43:16 2004
@@ -414,9 +414,14 @@
         ScopedServletUtils.removeScopedSessionAttr( CURRENT_SINGLETON_ATTR, 
unwrappedRequest );
     }
     
-    public static String decodeURI( HttpServletRequest request )
+    public static String getDecodedURI( HttpServletRequest request )
     {
-        return ScopedServletUtils.decodeURI( request );
+        return request.getContextPath() + request.getServletPath();     // 
TODO: is this always decoded?
+    }
+    
+    public static String getDecodedServletPath( HttpServletRequest request )
+    {
+        return request.getServletPath();    // TODO: is this always decoded 
under all containers?
     }
         
     public static void addActionOutputs( Map toAdd, ServletRequest request, 
boolean overwrite )
@@ -814,18 +819,16 @@
     
     public static String getSharedFlowClassName( HttpServletRequest request, 
ServletContext servletContext )
     {
-        return getSharedFlowClassNameForURI( InternalUtils.decodeURI( request 
), request, servletContext );
+        return getSharedFlowClassNameForRelativeURI( getDecodedServletPath( 
request ), request, servletContext );
     }    
     
-    public static String getSharedFlowClassNameForURI( String uri, 
HttpServletRequest request,
-                                                       ServletContext 
servletContext )
+    public static String getSharedFlowClassNameForRelativeURI( String 
relativeURI, HttpServletRequest request,
+                                                               ServletContext 
servletContext )
     {
         String cachedInRequest = ( String ) request.getAttribute( 
SHARED_FLOW_CLASSNAME_ATTR );
         if ( cachedInRequest != null ) return cachedInRequest.length() > 0 ? 
cachedInRequest : null;
         
-        // TODO: must cache this
-        String relativeUrl = PageFlowUtils.getRelativeURI( request, uri, null 
);
-        String parentDir = PageFlowUtils.getModulePathForRelativeURI( 
relativeUrl );
+        String parentDir = PageFlowUtils.getModulePathForRelativeURI( 
relativeURI );
         String className = null;
         
         if ( parentDir.length() > 0 )

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java
    (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/RequestValues.java
    Fri Oct 29 13:43:16 2004
@@ -31,7 +31,7 @@
 {
     private static final String FORWARDED_REQUEST_COUNT_ATTR = ATTR_PREFIX + 
"forwardedRequestCount";
     private static final String AVOID_DIRECT_RESPONSE_OUTPUT_ATTR = 
ATTR_PREFIX + "_avoidDirectResponseOutput";
-    private static final String ORIGINAL_REQUEST_URI_ATTR = ATTR_PREFIX + 
"origRequestURI";
+    private static final String ORIGINAL_SERVLET_PATH_ATTR = ATTR_PREFIX + 
"origServletPath";
     private static final String FORWARDED_FORMBEAN_ATTR = ATTR_PREFIX + 
"forwardedForm";
     private static final String DEFERRED_EXCEPTION_ATTR = ATTR_PREFIX + 
"deferredException";
     
@@ -71,14 +71,14 @@
         request.setAttribute( AVOID_DIRECT_RESPONSE_OUTPUT_ATTR, Boolean.TRUE 
);
     }
     
-    public static void setOriginalRequestURI( ServletRequest request, String 
uri )
+    public static void setOriginalServletPath( ServletRequest request, String 
servletPath )
     {
-        request.setAttribute( ORIGINAL_REQUEST_URI_ATTR, uri );
+        request.setAttribute( ORIGINAL_SERVLET_PATH_ATTR, servletPath );
     }
     
-    public static String getOriginalRequestURI( ServletRequest request )
+    public static String getOriginalServletPath( ServletRequest request )
     {
-        return ( String ) request.getAttribute( ORIGINAL_REQUEST_URI_ATTR );
+        return ( String ) request.getAttribute( ORIGINAL_SERVLET_PATH_ATTR );
     }
     
     /**

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java
     (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/PageflowTagUtils.java
     Fri Oct 29 13:43:16 2004
@@ -121,7 +121,7 @@
     {
         StringBuilder value = new StringBuilder(qualifiedAction.length() + 16);
 
-        String pageURI = InternalUtils.decodeURI( servletRequest );
+        String pageURI = InternalUtils.getDecodedURI( servletRequest );
         int lastSlash = pageURI.lastIndexOf( '/' );
         if ( lastSlash != -1 )
         {

Modified: 
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedServletUtils.java
 Fri Oct 29 13:43:16 2004
@@ -31,10 +31,8 @@
 
 import org.apache.log4j.Logger;
 
-import java.net.URLDecoder;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.io.UnsupportedEncodingException;
 
 
 /**
@@ -49,8 +47,6 @@
     static final String ATTR_PREFIX = "_netui:";
     private static final String OVERRIDE_REQUEST_ATTR = ATTR_PREFIX + 
"overrideRequest";
     private static final String OVERRIDE_RESPONSE_ATTR = ATTR_PREFIX + 
"overrideResponse";
-    private static final String ORIGINAL_URI_ATTR = ATTR_PREFIX + 
"originalURI";
-    private static final String DECODED_URI_ATTR = ATTR_PREFIX + "decodedURI";
     
     private static final Logger logger = Logger.getLogger( 
ScopedServletUtils.class );
     
@@ -339,7 +335,7 @@
      */
     public static final String getRelativeURI( HttpServletRequest request )
     {
-        return getRelativeURI( request, decodeURI( request ) );
+        return request.getServletPath();    // TODO: is this always decoded 
under all containers?
     }
 
     /**
@@ -398,44 +394,6 @@
      */ 
     public static String decodeURI( HttpServletRequest request )
     {
-        //
-        // First see if we've cached it.  But make sure it hasn't changed 
(e.g. on a forwarded request).
-        //
-        String requestURI = request.getRequestURI();
-        String originalURI = ( String ) request.getAttribute( 
ORIGINAL_URI_ATTR );
-        String decodedURI;
-        
-        if ( originalURI != null && originalURI.equals( requestURI ) )
-        {
-            decodedURI = ( String ) request.getAttribute( DECODED_URI_ATTR );
-            
-            if ( decodedURI != null )
-            {
-                return decodedURI;
-            }
-        }
-        
-        
-        String encoding = request.getCharacterEncoding();
-
-        try
-        {            
-            if ( encoding == null )
-            {
-                encoding = "utf-8"; // @TODO is this a safe assumption?
-            }
-            
-            decodedURI = URLDecoder.decode( requestURI, encoding );
-        }
-        catch ( UnsupportedEncodingException e )
-        {
-            logger.error( "unsupported encoding " + encoding + " in request " 
+ requestURI, e );
-            decodedURI = request.getRequestURI();
-        }
-        
-        decodedURI = normalizeURI( decodedURI );
-        request.setAttribute( ORIGINAL_URI_ATTR, requestURI );
-        request.setAttribute( DECODED_URI_ATTR, decodedURI );
-        return decodedURI;
+        return request.getContextPath() + request.getServletPath();     // 
TODO: always decoded?
     }
 }

Modified: 
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
==============================================================================
--- 
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
 Fri Oct 29 13:43:16 2004
@@ -35,6 +35,8 @@
 import java.util.List;
 import java.util.Set;
 import java.util.HashSet;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 
 import org.apache.log4j.Logger;
 
@@ -51,6 +53,7 @@
         implements ScopedRequest
 {
     private String _requestURI;
+    private String _servletPath;
     private String _forwardedURI;
     private ScopedAttributeContainer _scopedContainer;
     private List _listenScopes;
@@ -76,7 +79,7 @@
         super( req );
         
         _scopedContainer = new ScopedAttributeContainer( scopeKey );
-        _requestURI = overrideRequestURI != null ? overrideRequestURI : "";
+        setRequestURI( overrideRequestURI );
         _seeOuterRequestAttributes = seeOuterRequestAttributes;
         
         if ( seeOuterRequestAttributes )
@@ -111,8 +114,43 @@
     public void setRequestURI( String uri )
     {
         _requestURI = uri;
+        
+        if ( uri == null )
+        {
+            _servletPath = null;
+            return;
+        }
+        
+        //
+        // Set the servlet path (decoded)
+        //
+        assert uri.startsWith( getOuterRequest().getContextPath() ) : uri;
+        setServletPath( uri.substring( 
getOuterRequest().getContextPath().length() ) );
     }
-
+        
+    public void setRequestURI( String contextPath, String servletPath )
+    {
+        _requestURI = contextPath + servletPath;
+        setServletPath( servletPath );
+    }
+    
+    private void setServletPath( String servletPath )
+    {
+        String encoding = getCharacterEncoding();
+        
+        try
+        {            
+            if ( encoding == null ) encoding = "utf-8"; // TODO: is this a 
safe assumption?
+            servletPath = URLDecoder.decode( servletPath, encoding );
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            logger.error( "unsupported encoding " + encoding + " in request " 
+ _requestURI, e );
+        }
+        
+        _servletPath = ScopedServletUtils.normalizeURI( servletPath );
+    }
+    
     public StringBuffer getRequestURL()
     {
         HttpServletRequest outerRequest = getOuterRequest();
@@ -125,7 +163,7 @@
 
     public String getServletPath()
     {
-        return ScopedServletUtils.getRelativeURI( this );
+        return _servletPath;
     }
 
     public String getParameter( String paramName )
@@ -325,23 +363,27 @@
 
     public void doForward()
     {
-        String forwardURI = _forwardedURI;
-
-        if ( forwardURI != null )
+        String forwardedURI = _forwardedURI;
+        
+        if ( forwardedURI != null )
         {
-            if ( ! forwardURI.startsWith( "/" ) )
+            if ( ! forwardedURI.startsWith( "/" ) )
             {
-                logger.error( "Invalid forward URI " + forwardURI );
-                _requestURI = forwardURI;
+                int lastSlash = _requestURI.lastIndexOf( '/' );
+                assert lastSlash != -1 : _requestURI;
+                setRequestURI( _requestURI.substring( 0, lastSlash + 1 ) + 
forwardedURI );
             }
-    
-            _requestURI = getOuterRequest().getContextPath() + 
getForwardedURI();
+            else
+            {
+                setRequestURI( getOuterRequest().getContextPath(), 
forwardedURI );
+            }
+            
             // CR174862 -- parse the query string and add parameters to the 
internal map
             parseQueryParameters();
         }
         else
         {
-            _requestURI = null;
+            setRequestURI( null );
         }
     }
 

Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/web.xml
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/web.xml      
(original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/WEB-INF/web.xml      
Fri Oct 29 13:43:16 2004
@@ -203,6 +203,7 @@
   -->
 
   <welcome-file-list>
+    <welcome-file>WelcomeFileController.jpf</welcome-file>
     <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
 

Modified: 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
==============================================================================
--- 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
   (original)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
   Fri Oct 29 13:43:16 2004
@@ -5268,6 +5268,18 @@
          </features>
       </test>
       <test>
+         <name>WelcomeFile</name>
+         <description>Test of hitting a page flow directory, when the page 
flow is registered in web.xml as a welcome-file.</description>
+         <webapp>coreWeb</webapp>
+         <categories>
+            <category>bvt</category>
+            <category>corePageFlow</category>
+         </categories>
+         <features>
+            <feature>PageFlow</feature>
+         </features>
+      </test>
+      <test>
          <name>XhtmlAnchor</name>
          <description>Validation of the XHTML for Anchors</description>
          <webapp>coreWeb</webapp>

Modified: 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NonNormalizedPath.xml
==============================================================================
--- 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NonNormalizedPath.xml
     (original)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NonNormalizedPath.xml
     Fri Oct 29 13:43:16 2004
@@ -327,13 +327,13 @@
         </title>
     </head>
     <body>
-        <a href="/coreWeb/miniTests/nonNormalizedPath/begin.do">index.jsp</a>
+        <a href="/coreWeb/miniTests/nonNormalizedPath/./begin.do">index.jsp</a>
         <br>
-        <a href="/coreWeb/miniTests/nonNormalizedPath/ok1.do">./index.jsp</a>
+        <a href="/coreWeb/miniTests/nonNormalizedPath/./ok1.do">./index.jsp</a>
         <br>
-        <a 
href="/coreWeb/miniTests/nonNormalizedPath/ok2.do">../nonNormalizedPath/index.jsp</a>
+        <a 
href="/coreWeb/miniTests/nonNormalizedPath/./ok2.do">../nonNormalizedPath/index.jsp</a>
         <br>
-        <a href="/coreWeb/miniTests/nonNormalizedPath/bad1.do">../../index.jsp 
(bad)</a>
+        <a 
href="/coreWeb/miniTests/nonNormalizedPath/./bad1.do">../../index.jsp (bad)</a>
     </body>
 </html>]]></responseBody>
 
@@ -559,4 +559,4 @@
   <testCount>5</testCount>
   <passedCount>1</passedCount>
   <failedCount>4</failedCount>
-</recorderSession>
\ No newline at end of file
+</recorderSession>

Reply via email to