portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r656692 - in /portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE: layout-portlets/src/java/org/apache/jetspeed/portlets/layout/ layout-portlets/src/webapp/WEB-INF/ src/webapp/WEB-INF/conf/
Date Thu, 15 May 2008 15:01:27 GMT
Author: ddam
Date: Thu May 15 08:01:26 2008
New Revision: 656692

URL: http://svn.apache.org/viewvc?rev=656692&view=rev
Log:
JS2-867 : Optional portlet session caching of layout view templates
turn on/off viewpage portlet session caching by setting jetspeed property "layout.page.storeViewPageInSession"
to true / false

Modified:
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/conf/jetspeed.properties

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java?rev=656692&r1=656691&r2=656692&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
(original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
Thu May 15 08:01:26 2008
@@ -38,6 +38,7 @@
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.administration.PortalConfiguration;
 import org.apache.jetspeed.capabilities.CapabilityMap;
 import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
@@ -85,6 +86,7 @@
     protected PortletEntityAccessComponent entityAccess;
     protected PortletWindowAccessor windowAccess;
     protected TemplateLocator decorationLocator;
+    protected boolean storeViewPageInSession;
     
     private Map layoutTemplatesCache = new HashMap();
     public static final String DEFAULT_TEMPLATE_EXT = ".vm";
@@ -123,6 +125,13 @@
         {
             throw new PortletException("Failed to find the Window Access on portlet initialization");
         }        
+
+        PortalConfiguration portalConfiguration = (PortalConfiguration) getPortletContext().getAttribute(CommonPortletServices.CPS_PORTAL_CONFIGURATION);
+        if (null == portalConfiguration)
+        {
+            throw new PortletException("Failed to find the Portal Configuration on portlet
initialization");
+        }        
+        storeViewPageInSession = portalConfiguration.getBoolean("layout.page.storeViewPageInSession",
true);
         
         templateLocator = (TemplateLocator) getPortletContext().getAttribute("TemplateLocator");
         decorationLocator = (TemplateLocator) getPortletContext().getAttribute("DecorationLocator");
@@ -141,7 +150,7 @@
 
         try
         {
-            String helpPage = (String)request.getPortletSession().getAttribute(PortalReservedParameters.PAGE_LAYOUT_HELP);
                      
+            String helpPage = getCachedLayoutViewPage(request, PortalReservedParameters.PAGE_LAYOUT_HELP);
                      
             if (helpPage == null)
             {
                 PortletPreferences prefs = request.getPreferences();
@@ -152,7 +161,7 @@
                     if (helpPage == null)
                         helpPage = "columns";
                 }
-                request.getPortletSession().setAttribute(PortalReservedParameters.PAGE_LAYOUT_HELP,
helpPage);
+                cacheLayoutViewPage(request, PortalReservedParameters.PAGE_LAYOUT_HELP, helpPage);
             }
 
             String templateKey = helpPage + "/" + JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE
 + "-help";
@@ -222,7 +231,7 @@
             JetspeedPowerTool jpt = getJetspeedPowerTool(request);
             if (maximized)
             {
-                viewPage = (String)request.getPortletSession().getAttribute(PortalReservedParameters.PAGE_LAYOUT_MAX);
                      
+                viewPage = getCachedLayoutViewPage(request, PortalReservedParameters.PAGE_LAYOUT_MAX);
                      
                 if (viewPage == null)
                 {
                     PortletPreferences prefs = request.getPreferences();
@@ -233,12 +242,12 @@
                         if (viewPage == null)
                             viewPage = "maximized";
                     }
-                    request.getPortletSession().setAttribute(PortalReservedParameters.PAGE_LAYOUT_MAX,
viewPage);
+                    cacheLayoutViewPage(request, PortalReservedParameters.PAGE_LAYOUT_MAX,
viewPage);
                 }
             }
             else if (solo)
             {
-                viewPage = (String)request.getPortletSession().getAttribute(PortalReservedParameters.PAGE_LAYOUT_SOLO);
                      
+                viewPage = getCachedLayoutViewPage(request, PortalReservedParameters.PAGE_LAYOUT_SOLO);
                      
                 if (viewPage == null)
                 {
                     PortletPreferences prefs = request.getPreferences();                
@@ -251,12 +260,12 @@
                             viewPage = "solo";
                         }
                     }
-                    request.getPortletSession().setAttribute(PortalReservedParameters.PAGE_LAYOUT_SOLO,
viewPage);                    
+                    cacheLayoutViewPage(request, PortalReservedParameters.PAGE_LAYOUT_SOLO,
viewPage);                    
                 }
             }
             else
             {
-                viewPage = (String)request.getPortletSession().getAttribute(PortalReservedParameters.PAGE_LAYOUT_VIEW);
                      
+                viewPage = getCachedLayoutViewPage(request, PortalReservedParameters.PAGE_LAYOUT_VIEW);
                      
                 if (viewPage == null)
                 {
                     PortletPreferences prefs = request.getPreferences();                
               
@@ -267,7 +276,7 @@
                         if (viewPage == null)
                             viewPage = "columns";
                     }
-                    request.getPortletSession().setAttribute(PortalReservedParameters.PAGE_LAYOUT_VIEW,
viewPage);                                        
+                    cacheLayoutViewPage(request, PortalReservedParameters.PAGE_LAYOUT_VIEW,
viewPage);                    
                 }
             }
             
@@ -739,6 +748,32 @@
         return props;
     }
 
+    
+    /**
+     * Retrieve the cached layout view page location. This method provides an easy way to
turn on/off caching of 
+     * layout view page locations. By default, view page locations are stored in the portlet
session. Set the Jetspeed property 
+     * <code>layout.page.storeViewPageInSession</code> to <code>true</code>
/ <code>false</code> to turn on / off caching.
+     * @param request portlet request
+     * @param viewPageType the view page type, see the PortalReservedParameters.PAGE_LAYOUT_*
parameters.
+     * @return the cached view page location
+     */
+    protected String getCachedLayoutViewPage(RenderRequest request, String viewPageType){
+    	return storeViewPageInSession ? (String)request.getPortletSession().getAttribute(viewPageType)
: null;  
+    }
+    
+    /**
+     * Cache a layout view page location. By default, the value is stored in the portlet
session. 
+     * @param request portlet request
+     * @param viewPageType the type of the view page (e.g. help, maximized view, solo, etc.).
See the 
+     * PortalReservedParameters.PAGE_LAYOUT_* parameters.
+     * @param page the view page to cache
+     */
+    protected void cacheLayoutViewPage(RenderRequest request, String viewPageType, String
page){
+    	if (storeViewPageInSession){
+        	request.getPortletSession().setAttribute(viewPageType, page);
+    	}
+    }
+    
     class CachedTemplate
     {
         private String key;

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml?rev=656692&r1=656691&r2=656692&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml
(original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml
Thu May 15 08:01:26 2008
@@ -42,6 +42,7 @@
         <js:service name='Desktop'/>
         <js:service name='decorationContentCache'/>
         <js:service name='portletContentCache'/>        
+	    <js:service name='PortalConfiguration'/>        
 	</js:services>
 	
 </portlet-app>

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/conf/jetspeed.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/conf/jetspeed.properties?rev=656692&r1=656691&r2=656692&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/conf/jetspeed.properties
(original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/conf/jetspeed.properties
Thu May 15 08:01:26 2008
@@ -193,6 +193,8 @@
 #-------------------------------------------------------------------------
 # the default page layout if none is specified
 layout.page.default = jetspeed-layouts::VelocityTwoColumns
+# optimization for looking up LayoutPortlet Page template, default == true
+layout.page.storeViewPageInSession = true
 
 #-------------------------------------------------------------------------
 # D E C O R A T O R S



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