portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r883664 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/ components/jetspeed-portal/src/main/java/org/apache...
Date Tue, 24 Nov 2009 11:41:51 GMT
Author: woonsan
Date: Tue Nov 24 11:41:32 2009
New Revision: 883664

URL: http://svn.apache.org/viewvc?rev=883664&view=rev
Log:
JS2-1086: Allowing portlet mode parameter in the portlet pipeline. 
With this, client-side page aggregation engines such as desktop mode are able to render help,
edit, about, edit_defaults, config and preview modes through portlet pipeline.
By the way, the portlet aggregator in portlet pipeline cannot depend on the navigational state
generated from the portal url to decide which portlet mode is in concern. So, the portlet
aggregator set a portlet mode in the navigational state based on the requested portlet mode
parameter.
Also, the portlet renderer retrieves portlet content cache but it hasn't checked if the portlet
mode was the same because the content cache has been already invalidated during resetting
navigation states in the pre-executing valves. However, the portlet pipeline cannot depend
on navigational state and encoded portal urls, so I added one more checking if the portlet
content has the same portlet mode as the current portlet window.
TO-DO: Modify decorator to not show preview action in the portlet window ui. Add preview custom
mode implementation in PickANumberPortlet as an example. Add default preview mode handling
in the portlet proxy with thumbnail metadata in jetspeed-portlet.xml. Add configuration properties
in jetspeed.properties for default handlings.

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletAggregatorImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/JetspeedActions.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/aggregator/PortletContent.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java
Tue Nov 24 11:41:32 2009
@@ -21,6 +21,8 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import javax.portlet.PortletMode;
+
 import junit.framework.TestCase;
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
@@ -404,6 +406,12 @@
             // TODO Auto-generated method stub
             return null;
         }
+
+
+        public PortletMode getPortletMode()
+        {
+            return PortletMode.VIEW;
+        }
     }
         
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletAggregatorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletAggregatorImpl.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletAggregatorImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletAggregatorImpl.java
Tue Nov 24 11:41:32 2009
@@ -18,14 +18,21 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
 
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.aggregator.PortletAggregator;
 import org.apache.jetspeed.aggregator.PortletContent;
 import org.apache.jetspeed.aggregator.PortletRenderer;
 import org.apache.jetspeed.container.PortletWindow;
+import org.apache.jetspeed.container.state.MutableNavigationalState;
+import org.apache.jetspeed.container.state.NavigationalState;
 import org.apache.jetspeed.exception.JetspeedException;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.portlet.HeadElement;
@@ -43,6 +50,7 @@
 {
     private PortletRenderer renderer;
     private boolean titleInHeader;
+    private Map<String, PortletMode> availablePortletModesMap;
 
     public PortletAggregatorImpl(PortletRenderer renderer) 
     {
@@ -93,6 +101,18 @@
             window = context.getInstantlyCreatedPortletWindow(entity, name);
         }
         
+        PortletMode requetedPortletMode = getRequestedPortletMode(context);
+        NavigationalState navState = context.getPortalURL().getNavigationalState();
+        
+        if (!requetedPortletMode.equals(navState.getMode(window)))
+        {
+            if (navState instanceof MutableNavigationalState)
+            {
+                MutableNavigationalState mutableNavState = (MutableNavigationalState) navState;
+                mutableNavState.setMode(window, requetedPortletMode);
+            }
+        }
+        
         ContentFragment contentFragment = window.getFragment();
         renderer.renderNow(contentFragment, context);
         
@@ -132,4 +152,33 @@
         }
     }
     
+    private PortletMode getRequestedPortletMode(final RequestContext context)
+    {
+        String portletModeName = context.getRequestParameter(PortalReservedParameters.PORTLET_MODE);
+        
+        if (portletModeName == null || "".equals(portletModeName))
+        {
+            return PortletMode.VIEW;
+        }
+        
+        if (availablePortletModesMap == null)
+        {
+            Map<String, PortletMode> portletModesMap = new HashMap<String, PortletMode>();
+            
+            for (PortletMode portletMode : JetspeedActions.getStandardPortletModes())
+            {
+                portletModesMap.put(portletMode.toString(), portletMode);
+            }
+            
+            for (PortletMode portletMode : JetspeedActions.getExtendedPortletModes())
+            {
+                portletModesMap.put(portletMode.toString(), portletMode);
+            }
+            
+            availablePortletModesMap = portletModesMap;
+        }
+        
+        PortletMode portletMode = availablePortletModesMap.get(portletModeName);
+        return (portletMode != null ? portletMode : PortletMode.VIEW);
+    }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java
Tue Nov 24 11:41:32 2009
@@ -21,6 +21,8 @@
 import java.util.Collections;
 import java.util.List;
 
+import javax.portlet.PortletMode;
+
 import org.apache.commons.collections.list.TreeList;
 import org.apache.jetspeed.aggregator.PortletContent;
 import org.apache.jetspeed.cache.ContentCacheKey;
@@ -30,6 +32,11 @@
 import org.apache.jetspeed.util.KeyValue;
 
 
+/**
+ * PortletContentImpl
+ * 
+ * @version $Id$
+ */
 public class PortletContentImpl implements PortletContent
 {
     private CharArrayWriter cw;
@@ -39,6 +46,7 @@
     private int expiration;
     private String title;
     private String contentType;
+    private PortletMode portletMode;
     
     /**
      * The list container for all contributed head elements from this portlet content.
@@ -52,12 +60,13 @@
         writer = new PrintWriter(cw);
     }
     
-    PortletContentImpl(ContentCacheKey cacheKey, int expiration, String title)
+    PortletContentImpl(ContentCacheKey cacheKey, int expiration, String title, PortletMode
portletMode)
     {
         this();
         this.cacheKey = cacheKey;
         this.expiration = expiration;
         this.title = title;
+        this.portletMode = portletMode;
     }
 
     public PrintWriter getWriter()
@@ -151,7 +160,12 @@
     {
         this.contentType = contentType;
     }
-     
+    
+    public PortletMode getPortletMode()
+    {
+        return (portletMode != null ? portletMode : PortletMode.VIEW);
+    }
+    
     public void reset()
     {
         if (!complete)

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
Tue Nov 24 11:41:32 2009
@@ -299,12 +299,18 @@
         ContentFragment fragment = portletWindow.getFragment();
         ContentCacheKey cacheKey = portletContentCache.createCacheKey(requestContext, fragment.getId());
       
         CacheElement cachedElement = portletContentCache.get(cacheKey);
+        
         if (cachedElement != null)
         {
-            PortletContent portletContent = (PortletContent)cachedElement.getContent(); 
          
-            fragment.setPortletContent(portletContent);
-            return true;
-        }        
+            PortletContent portletContent = (PortletContent) cachedElement.getContent();
+            
+            if (portletWindow.getPortletMode().equals(portletContent.getPortletMode()))
+            {
+                fragment.setPortletContent(portletContent);
+                return true;
+            }
+        }
+        
         return false;
     }
     
@@ -320,7 +326,7 @@
         {
             title = portletWindow.getPortletDefinition().getPortletName();
         }
-        return new PortletContentImpl(cacheKey, expirationCache, title);
+        return new PortletContentImpl(cacheKey, expirationCache, title, portletWindow.getPortletMode());
     }
     
     protected RenderingJob buildRenderingJob( PortletWindow portletWindow, 

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
Tue Nov 24 11:41:32 2009
@@ -34,10 +34,8 @@
 
 public class CustomDecoratorActionsFactory extends AbstractDecoratorActionsFactory
 {
-    private static final DecoratorActionTemplate ABOUT_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.ABOUT_MODE);
     private static final DecoratorActionTemplate CONFIG_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.CONFIG_MODE);
     private static final DecoratorActionTemplate EDIT_DEFAULTS_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.EDIT_DEFAULTS_MODE);
-    //private static final DecoratorActionTemplate PREVIEW_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.PREVIEW_MODE);
     private static final DecoratorActionTemplate PRINT_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.PRINT_MODE);
     private static final DecoratorActionTemplate SOLO_ACTION_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.SOLO_STATE);
     
@@ -50,7 +48,7 @@
         list.add(JetspeedActions.ABOUT_MODE);
         list.add(JetspeedActions.CONFIG_MODE);
         list.add(JetspeedActions.EDIT_DEFAULTS_MODE);
-        //list.add(JetspeedActions.PREVIEW_MODE);
+        list.add(JetspeedActions.PREVIEW_MODE);
         list.add(JetspeedActions.PRINT_MODE);
         list.addAll(JetspeedActions.getStandardWindowStates());
         list.add(JetspeedActions.SOLO_STATE);

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
Tue Nov 24 11:41:32 2009
@@ -75,6 +75,8 @@
     private PortletRequestContext portletRequestContext;
     private PortletResponse portletResponse;
     private PortletInstance portletInstance;
+    private PortletMode portletMode;
+    private WindowState windowState;
     private List<KeyValue<String, HeadElement>> headElements;
 
     private boolean valid;
@@ -158,12 +160,22 @@
 
     public PortletMode getPortletMode()
     {
-        return valid ? requestContext.getPortalURL().getNavigationalState().getMode(this)
: PortletMode.VIEW;
+        if (portletMode == null && valid)
+        {
+            portletMode = requestContext.getPortalURL().getNavigationalState().getMode(this);
+        }
+        
+        return (portletMode != null ? portletMode : PortletMode.VIEW);
     }
 
     public WindowState getWindowState()
     {
-        return valid ? requestContext.getPortalURL().getNavigationalState().getState(this)
: WindowState.NORMAL;
+        if (windowState == null && valid)
+        {
+            windowState = requestContext.getPortalURL().getNavigationalState().getState(this);
+        }
+        
+        return (windowState != null ? windowState : WindowState.NORMAL);
     }
 
     public Map<String,Object> getAttributes()

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/JetspeedActions.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/JetspeedActions.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/JetspeedActions.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/JetspeedActions.java
Tue Nov 24 11:41:32 2009
@@ -39,7 +39,7 @@
     public static final PortletMode ABOUT_MODE = new PortletMode("about");
     public static final PortletMode CONFIG_MODE = new PortletMode("config");
     public static final PortletMode EDIT_DEFAULTS_MODE = new PortletMode("edit_defaults");
-    //public static final PortletMode PREVIEW_MODE = new PortletMode("preview");
+    public static final PortletMode PREVIEW_MODE = new PortletMode("preview");
     public static final PortletMode PRINT_MODE = new PortletMode("print");
     public static final WindowState SOLO_STATE = new WindowState("solo");
   
@@ -56,7 +56,7 @@
     public static final String ABOUT = ABOUT_MODE.toString();
     public static final String CONFIG = CONFIG_MODE.toString();
     public static final String EDIT_DEFAULTS = EDIT_DEFAULTS_MODE.toString();
-    //public static final String PREVIEW = PREVIEW_MODE.toString();
+    public static final String PREVIEW = PREVIEW_MODE.toString();
     public static final String PRINT = PRINT_MODE.toString();
     public static final String NORMAL = WindowState.NORMAL.toString();
     public static final String MINIMIZE = WindowState.MINIMIZED.toString();

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
Tue Nov 24 11:41:32 2009
@@ -27,6 +27,7 @@
 {
     public final static String PORTLET = "portlet";
     public final static String PORTLET_ENTITY = "entity";        
+    public final static String PORTLET_MODE = "mode";
     public final static String PAGE = "page";
     public final static String PIPELINE = "pipeline";
     public final static String DEFAULT_PIPELINE = "jetspeed-pipeline";

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/aggregator/PortletContent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/aggregator/PortletContent.java?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/aggregator/PortletContent.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/aggregator/PortletContent.java
Tue Nov 24 11:41:32 2009
@@ -19,6 +19,8 @@
 import java.io.PrintWriter;
 import java.util.List;
 
+import javax.portlet.PortletMode;
+
 import org.apache.jetspeed.cache.ContentCacheKey;
 import org.apache.jetspeed.portlet.HeadElement;
 import org.apache.jetspeed.util.KeyValue;
@@ -106,7 +108,14 @@
      * @param contentType
      */
     void setContentType(String contentType);
-
+    
+    /**
+     * Gets the portlet mode of this portlet content.
+     * 
+     * @return
+     */
+    PortletMode getPortletMode();
+    
     /**
      * Adds an header element to be contributed to the page.
      * If keyHint argument is provided and if a header element 

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties?rev=883664&r1=883663&r2=883664&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/conf/jetspeed/jetspeed.properties
Tue Nov 24 11:41:32 2009
@@ -72,6 +72,7 @@
 supported.portletmode = about
 supported.portletmode = config
 supported.portletmode = edit_defaults
+supported.portletmode = preview
 supported.portletmode = print
 supported.portletmode = secure  # currently only used for testing purposes
 # auto-switching



---------------------------------------------------------------------
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