[gatein-commits] gatein SVN: r5069 - in portal/branches/branch-GTNPORTAL-1643/component/portal/src: test/java/org/exoplatform/portal/config and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Nov 12 11:10:59 EST 2010


Author: julien_viet
Date: 2010-11-12 11:10:58 -0500 (Fri, 12 Nov 2010)
New Revision: 5069

Modified:
   portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
   portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
Log:
GTNPORTAL-1631 : Navigation drop down menu is not updated when a page is deleted.


Modified: portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java	2010-11-12 13:47:05 UTC (rev 5068)
+++ portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java	2010-11-12 16:10:58 UTC (rev 5069)
@@ -55,7 +55,7 @@
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
-public class POMSession
+public final class POMSession
 {
 
    /** . */
@@ -361,20 +361,40 @@
       }
       public void afterSynchronization(SynchronizationStatus status)
       {
-         if (status == SynchronizationStatus.SAVED && staleKeys != null)
+         if (status == SynchronizationStatus.SAVED)
          {
-            if (log.isTraceEnabled())
-            {
-               log.trace("Session commit about to evict entries " + staleKeys);
-            }
-            for (Serializable key : staleKeys)
-            {
-               mgr.cacheRemove(key);
-            }
+            reset();
          }
       }
    };
 
+   /**
+    * Reset the session and set its state like it was a newly created session.
+    */
+   private void reset()
+   {
+      // Evict entries from the shared cache if any
+      if (staleKeys != null && staleKeys.size() > 0)
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("About to evict entries " + staleKeys);
+         }
+         for (Serializable key : staleKeys)
+         {
+            mgr.cacheRemove(key);
+         }
+         staleKeys.clear();
+      }
+
+      // Reset modified flag
+      if (log.isTraceEnabled())
+      {
+         log.trace("Setting modified flag to false");
+      }
+      modified = false;
+   }
+
    public <V> V execute(POMTask<V> task) throws Exception
    {
       if (isInTask)
@@ -404,7 +424,11 @@
       {
          if (!markedForRollback)
          {
+            // Trigger persistent save
             model.save();
+
+            // Reset modified state
+            reset();
          }
          else
          {

Modified: portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java	2010-11-12 13:47:05 UTC (rev 5068)
+++ portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java	2010-11-12 16:10:58 UTC (rev 5069)
@@ -21,6 +21,7 @@
 
 import static org.exoplatform.portal.pom.config.Utils.split;
 
+import org.exoplatform.commons.utils.LazyPageList;
 import org.exoplatform.container.PortalContainer;
 import org.exoplatform.portal.application.PortletPreferences;
 import org.exoplatform.portal.application.Preference;
@@ -45,9 +46,12 @@
 {
 
    /** . */
-   private final String testPage = "portal::classic::testPage";
+   private static final String CLASSIC_HOME = "portal::classic::homepage";
 
    /** . */
+   private static final String CLASSIC_TEST = "portal::classic::testPage";
+
+   /** . */
    private final String testPortletPreferences = "portal#classic:/web/BannerPortlet/testPortletPreferences";
 
    /** . */
@@ -297,7 +301,7 @@
       assertEquals(1, events.size());
       
       //
-      page = storage_.getPage(testPage);
+      page = storage_.getPage(CLASSIC_TEST);
       assertNull(page);
    }
 
@@ -868,7 +872,22 @@
       gadgetApp = (Application<Gadget>)row0.getChildren().get(0);
       assertEquals("foo", storage_.getId(gadgetApp.getState()));
    }
+   
+   public void testRemoveAndFindPage() throws Exception
+   {
+      Page page = storage_.getPage(CLASSIC_HOME);
+      assertNotNull(page);
+      storage_.remove(page);
 
+      // This will trigger a save
+      Query<Page> query = new Query<Page>(null, null, null, null, Page.class);
+      LazyPageList<Page> list = storage_.find(query);
+      assertNotNull(list);
+
+      // We check is now seen as removed
+      assertNull(storage_.getPage(CLASSIC_HOME));
+   }
+
    private Application<Portlet> create(String instanceId)
    {
       int i0 = instanceId.indexOf("#");



More information about the gatein-commits mailing list