portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r377043 - /portals/jetspeed-2/trunk/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
Date Sat, 11 Feb 2006 20:19:26 GMT
Author: ate
Date: Sat Feb 11 12:19:23 2006
New Revision: 377043

URL: http://svn.apache.org/viewcvs?rev=377043&view=rev
Log:
Added more generic methods to add a Portlet to a layout or remove a fragment to be able to
support nested layouts.
Also refactored the existing onces to make use of these new methods.
See http://issues.apache.org/jira/browse/JS2-468.

Modified:
    portals/jetspeed-2/trunk/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java

Modified: portals/jetspeed-2/trunk/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java?rev=377043&r1=377042&r2=377043&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
(original)
+++ portals/jetspeed-2/trunk/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
Sat Feb 11 12:19:23 2006
@@ -263,41 +263,67 @@
 
     protected void removeFragment(String pageId, String fragmentId)
     {
+        Page page = null;
+        try
+        {
+            page = pageManager.getPage(pageId);
+            
+        }
+        catch (Exception e)
+        {
+            log.error("failed to remove portlet " + fragmentId + " from page: " + pageId,
e);
+        }
+        removeFragment(page,page.getRootFragment(), fragmentId);            
+    }
+    
+    protected void removeFragment(Page page, Fragment root, String fragmentId)
+    {
         try
         {
-            Page page = pageManager.getPage(pageId);
             Fragment f = page.getFragmentById(fragmentId);
-            Fragment root = page.getRootFragment();
+            if ( f == null )
+            {
+                // ignore no longer existing fragment error
+                return;
+            }
             root.getFragments().remove(f);
             pageManager.updatePage(page);
         }
         catch (Exception e)
         {
-            log.error("failed to remove portlet " + fragmentId + " from page: " + pageId);
+            log.error("failed to remove portlet " + fragmentId + " from page: " + page, e);
         }
-            
     }
     
     protected void addPortletToPage(String pageId, String portletId)
     {
+        Page page = null;
+        try
+        {
+            page = pageManager.getContentPage(pageId);
+        }
+        catch (Exception e)
+        {
+            log.error("failed to add portlet " + portletId + " to page: " + pageId, e);
+        }
+        addPortletToPage(page, page.getRootFragment(), portletId);
+    }
+    
+    protected void addPortletToPage(Page page, Fragment root, String portletId)
+    {
         try
         {
             Fragment fragment = pageManager.newFragment();
             fragment.setType(Fragment.PORTLET);
             fragment.setName(portletId);
             
-            Page page = pageManager.getContentPage(pageId);
-            // WARNING: under construction
-            // this is prototype and very dependent on a single depth fragment structure
           
-            Fragment root = page.getRootFragment();
             root.getFragments().add(fragment);
             pageManager.updatePage(page);            
         }
         catch (Exception e)
         {
-            log.error("failed to add portlet " + portletId + " to page: " + pageId);
+            log.error("failed to add portlet " + portletId + " to page: " + page, e);
         }
-        
     }
     
     /**



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