portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r367238 - /portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
Date Mon, 09 Jan 2006 07:40:42 GMT
Author: rwatler
Date: Sun Jan  8 23:40:40 2006
New Revision: 367238

URL: http://svn.apache.org/viewcvs?rev=367238&view=rev
Log:
correct updating of root Fragment singleton collection in page: reuse removed/replaced fragments
to preserve oid

Modified:
    portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java

Modified: portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java?rev=367238&r1=367237&r2=367238&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
Sun Jan  8 23:40:40 2006
@@ -47,6 +47,7 @@
     private List menus;
 
     private PageMenuDefinitionList menuDefinitions;
+    private FragmentImpl removedFragment;
 
     public PageImpl()
     {
@@ -187,24 +188,58 @@
      */
     public void setRootFragment(Fragment fragment)
     {
-        // delete existing fragments if required
-        if ((this.fragment != null) && !this.fragment.isEmpty())
-        {
-            this.fragment.clear();
-        }
-
-        // add new singleton fragment
+        // add new or reuse singleton fragment
         if (fragment instanceof FragmentImpl)
         {
-            // add fragment to singleton collection
+            // create singleton collection or remove existing
+            // root fragment and save for reuse
             if (this.fragment == null)
             {
                 this.fragment = new ArrayList(1);
             }
+            else if (!this.fragment.isEmpty())
+            {
+                removedFragment = (FragmentImpl)this.fragment.iterator().next();
+                this.fragment.clear();
+            }
+
+            // add new fragment or copy configuration
+            // from previously removed fragment
+            if (removedFragment != null)
+            {
+                // reuse previously removed fragment
+                FragmentImpl addFragment = (FragmentImpl)fragment;
+                fragment = removedFragment;
+                removedFragment = null;
+                // TODO: move this logic to copy methods on implementations
+                fragment.setName(addFragment.getName());
+                fragment.setTitle(addFragment.getTitle());
+                fragment.setShortTitle(addFragment.getShortTitle());
+                fragment.setType(addFragment.getType());
+                fragment.setSkin(addFragment.getSkin());
+                fragment.setDecorator(addFragment.getDecorator());
+                fragment.setState(addFragment.getState());
+                fragment.setSecurityConstraints(addFragment.getSecurityConstraints());
+                fragment.getProperties().clear();
+                fragment.getProperties().putAll(addFragment.getProperties());
+                fragment.setPreferences(addFragment.getPreferences());
+                fragment.getFragments().clear();
+                fragment.getFragments().addAll(addFragment.getFragments());
+            }
             this.fragment.add(fragment);
 
             // set page implementation in root and children fragments
             ((FragmentImpl)fragment).setPage(this);
+        }
+        else if (fragment == null)
+        {
+            // delete existing fragment if required, saving
+            // removed fragment for later reuse
+            if ((this.fragment != null) && !this.fragment.isEmpty())
+            {
+                removedFragment = (FragmentImpl)this.fragment.iterator().next();
+                this.fragment.clear();
+            }
         }
     }
 



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