portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r554926 - in /portals/jetspeed-2/trunk: components/portal/src/java/org/apache/jetspeed/container/ components/portal/src/java/org/apache/jetspeed/container/state/impl/ components/portal/src/java/org/apache/jetspeed/container/url/impl/ jetspe...
Date Tue, 10 Jul 2007 13:12:34 GMT
Author: ate
Date: Tue Jul 10 06:12:26 2007
New Revision: 554926

URL: http://svn.apache.org/viewvc?view=rev&rev=554926
Log:
Fix for JS2-282: Error when session expires and portlet window is maximized
See: https://issues.apache.org/jira/browse/JS2-282
Now ignoring incoming portlet request parameters if the portlet isn't available (anymore),
and possibly sending a SC_NOT_FOUND (ResourceURL) or doing a direct redirect to render (ActionURL)


Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/MutableNavigationalState.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/NavigationalState.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/url/PortalURL.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java
Tue Jul 10 06:12:26 2007
@@ -16,52 +16,84 @@
  */
 package org.apache.jetspeed.container;
 
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.container.state.NavigationalState;
-import org.apache.jetspeed.container.url.PortalURL;
+import org.apache.jetspeed.container.state.MutableNavigationalState;
+import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.pipeline.PipelineException;
 import org.apache.jetspeed.pipeline.valve.AbstractValve;
 import org.apache.jetspeed.pipeline.valve.ValveContext;
 import org.apache.pluto.om.window.PortletWindow;
 
 /**
- * Determines the action window in the current request
- * If no action was found, sets the request context's action window to null
- * denoting that there is no targeted action for this request otherwise
- * the target action window is set here 
- *
+ * Determines the action window in the current request If no action was found,
+ * sets the request context's action window to null denoting that there is no
+ * targeted action for this request otherwise the target action window is set
+ * here
+ * 
  * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  * @version $Id$
  */
-public class ContainerValve
-       extends AbstractValve
+public class ContainerValve extends AbstractValve
 {
-    public void invoke( RequestContext request, ValveContext context )
-        throws PipelineException
+    public void invoke(RequestContext request, ValveContext context) throws PipelineException
     {
         try
-        {  
+        {
             // create a session if not already created, necessary for Tomcat 5
             request.getRequest().getSession(true);
-            
-            //PortletContainerServices.prepare();
-            NavigationalState state = request.getPortalURL().getNavigationalState();
+
+            // PortletContainerServices.prepare();
+            MutableNavigationalState state = (MutableNavigationalState)request.getPortalURL().getNavigationalState();
             if (state != null)
             {
+                boolean redirect = false;
+                Page page = request.getPage();
+                PortletWindow window = state.getPortletWindowOfResource();
+                if (window != null && page.getFragmentById(window.getId().toString())
== null)
+                {
+                    // target window doesn't exists anymore or the target page is not accessible
(anymore)
+                    request.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
+                    return;
+                }
+                window = state.getPortletWindowOfAction();
+                if (window != null && page.getFragmentById(window.getId().toString())
== null)
+                {
+                    // target window doesn't exists anymore or the target page is not accessible
(anymore)
+                    // remove any navigational state for the window
+                    state.removeState(window);
+                    // as this is an action request which cannot be handled, perform a direct
redirect after sync state (for the other windows)
+                    redirect = true;
+                }
+                window = state.getMaximizedWindow();
+                if (window != null && page.getFragmentById(window.getId().toString())
== null)
+                {
+                    // target window doesn't exists anymore or the target page is not accessible
(anymore)
+                    // remove any navigational state for the window
+                    state.removeState(window);
+                }
                 state.sync(request);
-            }
-            
-            PortalURL url = request.getPortalURL();
-            PortletWindow actionWindow = url.getNavigationalState().getPortletWindowOfAction();
-            if (null == actionWindow)
-            {
-                // set to null to denote that no action was requested
-                request.setActionWindow(null);           
-            }
-            else
-            {
-                // set the requested action window
-                request.setActionWindow(actionWindow);                                
+                if (redirect)
+                {
+                    // target page doesn't contain (anymore) the targeted windowOfAction

+                    // this can also occur when a session is expired and the target page
isn't accessible for the anonymous user
+                    // Redirect the user back to the target page (with possibly retaining
the other windows navigational state).
+                    request.getResponse().sendRedirect(request.getPortalURL().getPortalURL());
+                    return;
+                }
+
+                PortletWindow actionWindow = state.getPortletWindowOfAction();
+                if (null == actionWindow)
+                {
+                    // set to null to denote that no action was requested
+                    request.setActionWindow(null);
+                }
+                else
+                {
+                    // set the requested action window
+                    request.setActionWindow(actionWindow);
+                }
             }
         }
         catch (Exception e)
@@ -69,7 +101,7 @@
             throw new PipelineException(e);
         }
         // Pass control to the next Valve in the Pipeline
-        context.invokeNext( request );
+        context.invokeNext(request);
     }
 
     public String toString()

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
Tue Jul 10 06:12:26 2007
@@ -316,6 +316,11 @@
         }
         return encodedState;
     }
+    
+    public String encode() throws UnsupportedEncodingException
+    {
+        return codec.encode(requestStates, isNavigationalParameterStateFull(), isRenderParameterStateFull());
+    }
 
     public Iterator getWindowIdIterator()
     {
@@ -334,5 +339,10 @@
                 state.setClearParameters(true);
             }
         }
+    }
+    
+    public void removeState(PortletWindow window)
+    {
+        requestStates.removePortletWindowNavigationalState(window.getId().toString());
     }
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java
Tue Jul 10 06:12:26 2007
@@ -261,6 +261,11 @@
         return encode(states, windowId, targetState, action, resource, navParamsStateFull,
renderParamsStateFull);
     }
 
+    public String encode(PortletWindowRequestNavigationalStates states, boolean navParamsStateFull,
boolean renderParamsStateFull)
+    throws UnsupportedEncodingException
+    {
+        return encode(states, null, null, false, false, navParamsStateFull, renderParamsStateFull);
+    }
     protected String encode(PortletWindowRequestNavigationalStates states, String targetWindowId,

             PortletWindowRequestNavigationalState targetState, boolean action, boolean resource,
boolean navParamsStateFull, 
             boolean renderParamsStateFull)
@@ -280,7 +285,7 @@
             {
                 windowId = (String)iter.next();
                 pwfns = states.getPortletWindowNavigationalState(windowId);
-                if ( windowId.equals(targetWindowId))
+                if ( targetWindowId != null && windowId.equals(targetWindowId))
                 {
                     // skip it for now, it will be encoded as the last one below
                 }
@@ -303,20 +308,22 @@
                 }
             }
         }
-        encodedState = encodePortletWindowNavigationalState(targetWindowId, targetState,
action, resource, false, false); 
-        if ( encodedState.length() > 0 )
+        if (targetWindowId != null)
         {
-            if ( !haveState )
+            encodedState = encodePortletWindowNavigationalState(targetWindowId, targetState,
action, resource, false, false); 
+            if ( encodedState.length() > 0 )
             {
-                haveState = true;
-            }
-            else
-            {
-                buffer.append(PARAMETER_SEPARATOR);
+                if ( !haveState )
+                {
+                    haveState = true;
+                }
+                else
+                {
+                    buffer.append(PARAMETER_SEPARATOR);
+                }
+                buffer.append(encodedState);
             }
-            buffer.append(encodedState);
         }
-        
         String encodedNavState = null;
         if ( haveState )
         {

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java
Tue Jul 10 06:12:26 2007
@@ -34,4 +34,7 @@
     String encode(PortletWindowRequestNavigationalStates states, PortletWindow window, Map
parameters,
             PortletMode portletMode, WindowState windowState, boolean action, boolean navParamsStateFull,

             boolean renderParamsStateFull) throws UnsupportedEncodingException;
+
+    String encode(PortletWindowRequestNavigationalStates states, boolean navParamsStateFull,
boolean renderParamsStateFull) 
+            throws UnsupportedEncodingException;
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java
Tue Jul 10 06:12:26 2007
@@ -46,8 +46,23 @@
     }
     
     public void removePortletWindowNavigationalState(String windowId)
-    {
-        pwnStates.remove(windowId);
+    {        
+        boolean removed = pwnStates.remove(windowId) != null;
+        if (removed)
+        {
+            if (maximizedWindow != null && windowId.equals(maximizedWindow.getId().toString()))
+            {
+                maximizedWindow = null;
+            }
+            if (actionWindow != null && windowId.equals(actionWindow.getId().toString()))
+            {
+                actionWindow = null;
+            }
+            if (resourceWindow != null && windowId.equals(actionWindow.getId().toString()))
+            {
+                resourceWindow = null;
+            }
+        }
     }
     
     public PortletWindowRequestNavigationalState getPortletWindowNavigationalState(String
windowId)

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
Tue Jul 10 06:12:26 2007
@@ -299,4 +299,18 @@
         this.characterEncoding = characterEncoding;
     }
     
+    public String getPortalURL()
+    {
+        try
+        {
+            return createPortletURL(navState.encode(), isSecure());
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            // should never happen
+            e.printStackTrace();
+            // to keep the compiler happy
+            return null;
+        }
+    }
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/MutableNavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/MutableNavigationalState.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/MutableNavigationalState.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/MutableNavigationalState.java
Tue Jul 10 06:12:26 2007
@@ -73,4 +73,9 @@
      * @param window
      */
     void clearParameters(PortletWindow window);
+    
+    /**
+     * Remove state for the given (possibly invalid) portlet window
+     */
+    void removeState(PortletWindow window);
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/NavigationalState.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/NavigationalState.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/NavigationalState.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/state/NavigationalState.java
Tue Jul 10 06:12:26 2007
@@ -176,6 +176,13 @@
     String encode(PortletWindow window, PortletMode mode, WindowState state) throws UnsupportedEncodingException;
     
     /**
+     * Encodes the current navigational State into a string to be embedded within a PortalURL.
+     * 
+     * @return encoded new Navigational State 
+     */
+    String encode() throws UnsupportedEncodingException;
+    
+    /**
      * @return true if WindowStates and PortletModes will be saved in the Session
      */
     boolean isNavigationalParameterStateFull();

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/url/PortalURL.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/url/PortalURL.java?view=diff&rev=554926&r1=554925&r2=554926
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/url/PortalURL.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/url/PortalURL.java
Tue Jul 10 06:12:26 2007
@@ -167,4 +167,9 @@
      * @return a new renderURL as String
      */    
     String createNavigationalEncoding(PortletWindow window, PortletMode mode, WindowState
state);
+
+    /**
+     * @return a Portal URL with encoded current navigational state
+     */
+    String getPortalURL();
 }



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


Mime
View raw message