Author: woonsan
Date: Mon Oct 29 18:51:50 2007
New Revision: 589933

URL: http://svn.apache.org/viewvc?rev=589933&view=rev
Log:
Fixed the bug that portlet action did not work when the portlet was instantly 
rendered in header templates by using JPT.renderPortletEntity().
Very grateful to Ate Douma for his kind reviews.

Modified:
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentFragmentImpl.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/test/org/apache/jetspeed/components/portletentity/ContentFragmentTestImpl.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentFragment.java

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentFragmentImpl.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentFragmentImpl.java?rev=589933&r1=589932&r2=589933&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentFragmentImpl.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentFragmentImpl.java
 Mon Oct 29 18:51:50 2007
@@ -42,12 +42,19 @@
     private static final Log log = 
LogFactory.getLog(ContentFragmentImpl.class);
     private final Map cachedFragments;
     private Decoration decoration;
+    private boolean instantlyRendered;
     
 
     public ContentFragmentImpl(Fragment fragment, Map cachedFagments)
     {
+        this(fragment, cachedFagments, false);
+    }
+
+    public ContentFragmentImpl(Fragment fragment, Map cachedFagments, boolean 
instantlyRendered)
+    {
         this.fragment = fragment;
         this.cachedFragments = cachedFagments;
+        this.instantlyRendered = instantlyRendered;
     }
 
     /* (non-Javadoc)
@@ -854,6 +861,14 @@
     {
         this.decoration = decoration;
         
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#isInstantlyRendered()
+     */
+    public boolean isInstantlyRendered()
+    {
+        return this.instantlyRendered;
     }
     
 }

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java?rev=589933&r1=589932&r2=589933&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
 Mon Oct 29 18:51:50 2007
@@ -49,6 +49,7 @@
 import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
 import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
 import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.om.window.impl.PortletWindowImpl;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.SecurityAccessController;
 import org.apache.jetspeed.services.title.DynamicTitleService;
@@ -438,6 +439,8 @@
 
         PortletEntity portletEntity = portletWindow.getPortletEntity();
         ((MutablePortletEntity)portletEntity).setFragment(fragment);
+        
+        ((PortletWindowImpl) 
portletWindow).setInstantlyRendered(fragment.isInstantlyRendered());
 
         return portletWindow;
     }

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java?rev=589933&r1=589932&r2=589933&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/ContainerValve.java
 Mon Oct 29 18:51:50 2007
@@ -21,6 +21,8 @@
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.container.state.MutableNavigationalState;
 import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
+import org.apache.jetspeed.om.window.impl.PortletWindowImpl;
 import org.apache.jetspeed.pipeline.PipelineException;
 import org.apache.jetspeed.pipeline.valve.AbstractValve;
 import org.apache.jetspeed.pipeline.valve.ValveContext;
@@ -60,11 +62,14 @@
                 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;
+                    if (!((PortletWindowImpl) window).isInstantlyRendered())
+                    {
+                        // 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)

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java?rev=589933&r1=589932&r2=589933&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java
 Mon Oct 29 18:51:50 2007
@@ -31,6 +31,7 @@
 import org.apache.jetspeed.cache.ContentCacheKey;
 import org.apache.jetspeed.cache.JetspeedContentCache;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.container.state.MutableNavigationalState;
 import org.apache.jetspeed.exception.JetspeedException;
 import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
 import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
@@ -105,14 +106,36 @@
                     try 
                     {
                         Fragment fragment = 
request.getPage().getFragmentById(actionWindow.getId().toString());
-                        ContentFragment contentFragment = new 
ContentFragmentImpl(fragment, new HashMap());
-                        actionWindow = 
this.windowAccessor.getPortletWindow(contentFragment);
+                        
+                        if (fragment != null)
+                        {
+                            ContentFragment contentFragment = new 
ContentFragmentImpl(fragment, new HashMap());
+                            actionWindow = 
this.windowAccessor.getPortletWindow(contentFragment);
+                        }
                     } 
                     catch (Exception e)
                     {
                         log.error("Failed to refresh action window.", e);
                     }
                 }
+                
+                if (actionWindow.getPortletEntity() == null)
+                {
+                    // a session is expired and the target actionWindow 
doesn't have portlet entity.
+                    // Redirect the user back to the target page (with 
possibly retaining the other windows navigational state).
+                    log.warn("Portlet action was canceled because the session 
was expired. The actionWindow's id is " + actionWindow.getId());
+                    
+                    request.setActionWindow(null);
+                    MutableNavigationalState state = 
(MutableNavigationalState) request.getPortalURL().getNavigationalState();
+                    
+                    if (state != null)
+                    {
+                        state.removeState(actionWindow);
+                        state.sync(request);
+                        
request.getResponse().sendRedirect(request.getPortalURL().getPortalURL());
+                        return;
+                    }
+                }
 
                 initWindow(actionWindow, request);
                 HttpServletResponse response = 
request.getResponseForWindow(actionWindow);
@@ -203,11 +226,27 @@
         if (!isNonStandardAction(actionWindow))
         {
             notifyFragments(root, request, page);
+            
+            // if the fragment is rendered from a decorator template, the 
target cache would not be cleared by the above notification.
+            // so, let's clear target cache of action window directly again.
+            String fragmentId = actionWindow.getId().toString();
+            if (page.getFragmentById(fragmentId) == null)
+            {
+                clearTargetCache(fragmentId, request);
+            }
         }
         else
         {
             ContentFragment fragment = 
page.getContentFragmentById(actionWindow.getId().toString());
-            clearTargetCache(fragment, request);
+            
+            if (fragment != null)
+            {
+                clearTargetCache(fragment, request);
+            }
+            else
+            {
+                clearTargetCache(actionWindow.getId().toString(), request);
+            }
         }
     }
     
@@ -268,11 +307,17 @@
 
     protected void clearTargetCache(ContentFragment f, RequestContext context)
     {
-        ContentCacheKey cacheKey = portletContentCache.createCacheKey(context, 
f.getId());        
+        clearTargetCache(f.getId(), context);
+    }
+    
+    protected void clearTargetCache(String fragmentId, RequestContext context)
+    {
+        ContentCacheKey cacheKey = portletContentCache.createCacheKey(context, 
fragmentId);
+        
         if (portletContentCache.isKeyInCache(cacheKey))
         {
             portletContentCache.remove(cacheKey);
-            portletContentCache.invalidate(context);            
+            portletContentCache.invalidate(context);
         }
     }
     
@@ -295,7 +340,11 @@
     {
         Page page = request.getPage();
         Fragment fragment = page.getFragmentById(window.getId().toString());
-        
((MutablePortletEntity)window.getPortletEntity()).setFragment(fragment);
+        
+        if (fragment != null)
+        {
+            
((MutablePortletEntity)window.getPortletEntity()).setFragment(fragment);
+        }
     }
 
 }

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java?rev=589933&r1=589932&r2=589933&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
 Mon Oct 29 18:51:50 2007
@@ -866,8 +866,7 @@
                 entityId);
         fragment.setType(Fragment.PORTLET);
         fragment.setName(portletId);
-        ContentFragment contentFragment = new ContentFragmentImpl(fragment,
-                new HashMap());
+        ContentFragment contentFragment = new ContentFragmentImpl(fragment, 
new HashMap(), true);
         renderer.renderNow(contentFragment, context);
         return contentFragment.getRenderedContent();
     }

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java?rev=589933&r1=589932&r2=589933&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
 Mon Oct 29 18:51:50 2007
@@ -39,6 +39,7 @@
 {
     private ObjectID objectId = null;
     private transient PortletEntity portletEntity = null;
+    private boolean instantlyRendered;
 
     public PortletWindowImpl(String id)
     {
@@ -94,6 +95,22 @@
     {
         this.portletEntity = portletEntity;
         
((PortletWindowListCtrl)portletEntity.getPortletWindowList()).add(this);
+    }
+    
+    /**
+     * Sets flag that the content is instantly rendered from JPT.
+     */
+    public void setInstantlyRendered(boolean instantlyRendered)
+    {
+        this.instantlyRendered = instantlyRendered;
+    }
+    
+    /**
+     * Checks if the content is instantly rendered from JPT.
+     */
+    public boolean isInstantlyRendered()
+    {
+        return this.instantlyRendered;
     }
 
 }

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/test/org/apache/jetspeed/components/portletentity/ContentFragmentTestImpl.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/test/org/apache/jetspeed/components/portletentity/ContentFragmentTestImpl.java?rev=589933&r1=589932&r2=589933&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/test/org/apache/jetspeed/components/portletentity/ContentFragmentTestImpl.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/test/org/apache/jetspeed/components/portletentity/ContentFragmentTestImpl.java
 Mon Oct 29 18:51:50 2007
@@ -1,9 +1,9 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
  * 
  *      http://www.apache.org/licenses/LICENSE-2.0
@@ -42,6 +42,7 @@
 class ContentFragmentTestImpl implements Fragment, ContentFragment
 {
     private Fragment f;
+    private boolean instantlyRendered;
 
     /**
      * @param f
@@ -49,8 +50,13 @@
      */
     public ContentFragmentTestImpl(Fragment f, HashMap list)
     {
-        super();
+        this(f, list, false);
+    }
+    
+    public ContentFragmentTestImpl(Fragment f, HashMap list, boolean 
instantlyRendered)
+    {
         this.f = f;
+        this.instantlyRendered = instantlyRendered;
     }
 
     /**
@@ -515,4 +521,12 @@
         // TODO Auto-generated method stub
             
     }        
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#isInstantlyRendered()
+     */
+    public boolean isInstantlyRendered()
+    {
+        return this.instantlyRendered;
+    }
 }

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentFragment.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentFragment.java?rev=589933&r1=589932&r2=589933&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentFragment.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentFragment.java
 Mon Oct 29 18:51:50 2007
@@ -110,4 +110,10 @@
      * @param decoration
      */
     void setDecoration(Decoration decoration);
+    
+    /**
+     * Checks if the content is instantly rendered from JPT.
+     */
+    public boolean isInstantlyRendered();
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to