portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r587730 - in /portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout: LayoutPortlet.java MultiColumnPortlet.java
Date Wed, 24 Oct 2007 01:13:09 GMT
Author: taylor
Date: Tue Oct 23 18:13:09 2007
New Revision: 587730

URL: http://svn.apache.org/viewvc?rev=587730&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-785

Modified:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java?rev=587730&r1=587729&r2=587730&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
Tue Oct 23 18:13:09 2007
@@ -86,14 +86,12 @@
     protected PortletWindowAccessor windowAccess;
     protected TemplateLocator decorationLocator;
     
-    //B: mk
-    private Map layoutTemplateProperties = new HashMap();
+    private Map layoutTemplatesCache = new HashMap();
     public static final String DEFAULT_TEMPLATE_EXT = ".vm";
     public static final String TEMPLATE_EXTENSION_KEY = "template.extension";
     public static final String DEFAULT_TEMPLATE_TYPE = "velocity";
     public static final String TEMPLATE_TYPE_KEY = "template.type";
     
-    //E: mk
     public void init( PortletConfig config ) throws PortletException
     {
         super.init(config);
@@ -157,11 +155,31 @@
                 request.getPortletSession().setAttribute(PortalReservedParameters.PAGE_LAYOUT_HELP,
helpPage);
             }
 
-            //Mohan: closed task
-            Configuration props = getConfiguration(request, helpPage);
-            String ext = (String) props.getString(TEMPLATE_EXTENSION_KEY);
-            absHelpPage = jpt.getTemplate(helpPage + "/" + JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE
+ "-help" + ext,
-                    JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE).getAppRelativePath();
+            String templateKey = helpPage + "/" + JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE
 + "-help";
+            CachedTemplate ct = (CachedTemplate)layoutTemplatesCache.get(templateKey);
+            if (ct == null)
+            {
+                TemplateDescriptor template = null;
+                Configuration props = getConfiguration(request, helpPage);
+                String ext = (String) props.getString(TEMPLATE_EXTENSION_KEY);
+                String path = helpPage + "/" + JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE + ext;
                              
+                template = jpt.getTemplate(path, JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE);
+                if (template == null)
+                {
+                    String msg = "*** FAILED getTemplate:" + path;
+                    throw new TemplateLocatorException(msg);
+                }
+                else
+                {
+                    synchronized(layoutTemplatesCache)
+                    {
+                        ct = new CachedTemplate(templateKey, template, props);
+                        layoutTemplatesCache.put(templateKey, ct);
+                    }                
+                }
+            }
+                
+            absHelpPage = ct.getTemplate().getAppRelativePath();            
             log.debug("Path to help page for LayoutPortlet " + absHelpPage);
             request.setAttribute(PARAM_VIEW_PAGE, absHelpPage);
         }
@@ -253,13 +271,32 @@
                 }
             }
             
-            //Mohan: closed task
-            Configuration props = getConfiguration(request, viewPage);
-            String ext = (String) props.getString(TEMPLATE_EXTENSION_KEY);
-
-            
-            absViewPage = jpt.getTemplate(viewPage + "/" + JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE
+ ext,
-                    JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE).getAppRelativePath();
+            String templateKey = viewPage + "/" + JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE;
+            CachedTemplate ct = (CachedTemplate)layoutTemplatesCache.get(templateKey);
+            if (ct == null)
+            {
+                TemplateDescriptor template = null;
+                Configuration props = getConfiguration(request, viewPage);
+                String ext = (String) props.getString(TEMPLATE_EXTENSION_KEY);
+                String path = viewPage + "/" + JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE + ext;
+                
+                template = jpt.getTemplate(path, JetspeedPowerTool.LAYOUT_TEMPLATE_TYPE);
+                if (template == null)
+                {
+                    String msg = "*** FAILED getTemplate:" + path;
+                    throw new TemplateLocatorException(msg);
+                }
+                else
+                {
+                    synchronized(layoutTemplatesCache)
+                    {
+                        ct = new CachedTemplate(templateKey, template, props);
+                        layoutTemplatesCache.put(templateKey, ct);
+                    }
+                
+                }
+            }
+            absViewPage = ct.getTemplate().getAppRelativePath();
             log.debug("Path to view page for LayoutPortlet " + absViewPage);
             request.setAttribute(PARAM_VIEW_PAGE, absViewPage);
         }
@@ -608,7 +645,6 @@
         catch (TemplateLocatorException e)
         {
             log.error("Unable to locate template: " + path, e);
-//            System.out.println("Unable to locate template: " + path);
             throw e;
         }
     }
@@ -652,13 +688,8 @@
         {
             key = templatePropertiesPath;
         }
-        props = (Configuration)this.layoutTemplateProperties.get(key);
-        
-        if ( props != null )
+        if (log.isDebugEnabled())
         {
-            return props;
-        }
-        if (log.isDebugEnabled()){
             log.debug(
                     "Template descriptor path:<" + templatePropertiesPath + ">"
             );
@@ -701,7 +732,6 @@
             }
         }
 
-        this.layoutTemplateProperties.put(key, props);
         if (log.isDebugEnabled())
         {
             log.debug("Template layout.properties extension is:<" + props.getString(TEMPLATE_EXTENSION_KEY));
@@ -709,4 +739,35 @@
         return props;
     }
 
+    class CachedTemplate
+    {
+        private String key;
+        private TemplateDescriptor template;
+        private Configuration config;
+        
+        public CachedTemplate(String key, TemplateDescriptor template, Configuration config)
+        {
+            this.key = key;
+            this.template = template;
+            this.config = config;
+        }
+
+        
+        public Configuration getConfig()
+        {
+            return config;
+        }
+
+        
+        public String getKey()
+        {
+            return key;
+        }
+
+        
+        public TemplateDescriptor getTemplate()
+        {
+            return template;
+        }
+    }
 }

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java?rev=587730&r1=587729&r2=587730&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
Tue Oct 23 18:13:09 2007
@@ -121,10 +121,15 @@
 
         ContentPage requestPage = context.getPage();       
         PageEditAccess pageEditAccess = (PageEditAccess)context.getAttribute(PortalReservedParameters.PAGE_EDIT_ACCESS_ATTRIBUTE);
-        if ( requestPage == null || pageEditAccess == null )
+        if ( requestPage == null)
         {
             // Targetting this portlet REQUIRES that the ProfilerValve has been invoked!
-            throw new PortletException("Current request page or PageEditAccess not available.");
+            throw new PortletException("Current request page not available.");
+        }
+        if (pageEditAccess == null)
+        {
+            // Targetting this portlet REQUIRES that the ProfilerValve has been invoked!
+            throw new PortletException("Current PageEditAccess not available.");        
   
         }
         
         Boolean editing = ( pageEditAccess.isEditing() && 
@@ -244,10 +249,10 @@
                         {
                             Fragment fragment = pageManager.newFragment();
                             fragment.setType(Fragment.LAYOUT);
-                            fragment.setName(layout);
-                            
+                            fragment.setName(layout);                            
                             targetFragment.getFragments().add(fragment);
-                            pageManager.updatePage(requestPage);            
+                            pageManager.updatePage(requestPage);
+                            clearLayoutAttributes(request);                            
                         }
                         catch (Exception e)
                         {
@@ -263,8 +268,8 @@
                             pageManager.updatePage(requestPage);
                             entityAccess.updatePortletEntity(window.getPortletEntity(), targetFragment);
                             entityAccess.storePortletEntity(window.getPortletEntity());
-
                             windowAccess.createPortletWindow(window.getPortletEntity(), targetFragment.getId());
+                            clearLayoutAttributes(request);
                             return;
                         }
                         catch (Exception e)
@@ -311,7 +316,7 @@
                                             && !jsPageShortTitle.equals("") ? jsPageShortTitle
                                             : jsPageName);
                             pageManager.updatePage(page);
-
+                            clearLayoutAttributes(request);                            
                             List orderList = parent.getDocumentOrder();
                             if (orderList != null)
                             {
@@ -1011,6 +1016,14 @@
         }
     }
         
+    protected void clearLayoutAttributes(ActionRequest request)
+    {
+        request.getPortletSession().removeAttribute(PortalReservedParameters.PAGE_LAYOUT_VIEW);
+        request.getPortletSession().removeAttribute(PortalReservedParameters.PAGE_LAYOUT_SOLO);
+        request.getPortletSession().removeAttribute(PortalReservedParameters.PAGE_LAYOUT_MAX);
       
+        request.getPortletSession().removeAttribute(PortalReservedParameters.PAGE_LAYOUT_HELP);
+    }
+
     protected int getFragmentNestingLevel(Page page, String fragmentId)
     {
         Fragment root = page.getRootFragment();



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