[gatein-commits] gatein SVN: r2087 - in portal/trunk/component/portal/src: main/java/org/exoplatform/portal/pom/data and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Mar 10 05:28:11 EST 2010


Author: julien_viet
Date: 2010-03-10 05:28:10 -0500 (Wed, 10 Mar 2010)
New Revision: 2087

Added:
   portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSerialization.java
Modified:
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/ApplicationType.java
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java
Log:
GTNPORTAL-770 : make pom cache data sieralizable


Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/ApplicationType.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/ApplicationType.java	2010-03-10 09:48:29 UTC (rev 2086)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/ApplicationType.java	2010-03-10 10:28:10 UTC (rev 2087)
@@ -24,6 +24,9 @@
 import org.exoplatform.portal.pom.spi.wsrp.WSRP;
 import org.gatein.mop.api.content.ContentType;
 
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
 /**
  * The type of an application.
  *
@@ -31,7 +34,7 @@
  * @version $Revision$
  * @param <S> the content state type of the application
  */
-public class ApplicationType<S>
+public class ApplicationType<S> implements Serializable
 {
 
    public static ApplicationType<?> getType(String name)
@@ -84,7 +87,7 @@
    public static final ApplicationType<WSRP> WSRP_PORTLET = new ApplicationType<WSRP>(WSRP.CONTENT_TYPE, "wsrp");
 
    /** . */
-   private final ContentType<S> contentType;
+   private transient final ContentType<S> contentType;
 
    /** . */
    private final String name;
@@ -104,4 +107,15 @@
    {
       return name;
    }
+
+   /**
+    * This is needed to preserve the enumation aspect of this class.
+    *
+    * @return the correct instance
+    * @throws ObjectStreamException never thrown
+    */
+   private Object readResolve() throws ObjectStreamException
+   {
+      return getType(name);
+   }
 }

Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java	2010-03-10 09:48:29 UTC (rev 2086)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ComponentData.java	2010-03-10 10:28:10 UTC (rev 2087)
@@ -22,7 +22,7 @@
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
-public class ComponentData extends ModelData
+public abstract class ComponentData extends ModelData
 {
 
    public ComponentData(String storageId, String storageName)

Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java	2010-03-10 09:48:29 UTC (rev 2086)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/ModelData.java	2010-03-10 10:28:10 UTC (rev 2087)
@@ -19,11 +19,13 @@
 
 package org.exoplatform.portal.pom.data;
 
+import java.io.Serializable;
+
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
-public abstract class ModelData
+public abstract class ModelData implements Serializable
 {
 
    /** Storage id. */

Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java	2010-03-10 09:48:29 UTC (rev 2086)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeContainerData.java	2010-03-10 10:28:10 UTC (rev 2087)
@@ -18,15 +18,13 @@
  */
 package org.exoplatform.portal.pom.data;
 
-import org.exoplatform.portal.pom.data.ModelData;
-
 import java.util.List;
 
 /**
  * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
  * @version $Revision$
  */
-public class NavigationNodeContainerData extends ModelData
+public abstract class NavigationNodeContainerData extends ModelData
 {
 
    /** . */

Added: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSerialization.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSerialization.java	                        (rev 0)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSerialization.java	2010-03-10 10:28:10 UTC (rev 2087)
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config;
+
+import org.exoplatform.component.test.AbstractGateInTest;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.config.model.PersistentApplicationState;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.mop.Visibility;
+import org.exoplatform.portal.pom.data.*;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.gatein.common.io.IOTools;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestSerialization extends AbstractGateInTest
+{
+   /** . */
+   private final BodyData body = new BodyData("foo", BodyType.PAGE);
+
+   /** . */
+   private final ContainerData container = new ContainerData(
+      "foo01",
+      "foo02",
+      "foo03",
+      "foo04",
+      "foo05",
+      "foo06",
+      "foo07",
+      "foo08",
+      "foo09",
+      "foo10",
+      Arrays.asList("foo11"),
+      Arrays.<ComponentData>asList(body)
+   );
+
+
+   public void testNavigationKey() throws Exception
+   {
+      NavigationKey key = new NavigationKey("foo", "bar");
+      assertEquals(key.hashCode(), IOTools.clone(key).hashCode());
+      assertEquals(key, IOTools.clone(key));
+   }
+   
+   public void testPortalKey() throws Exception
+   {
+      PortalKey key = new PortalKey("foo", "bar");
+      assertEquals(key.hashCode(), IOTools.clone(key).hashCode());
+      assertEquals(key, IOTools.clone(key));
+   }
+
+   public void testPageKey() throws Exception
+   {
+      PageKey key = new PageKey("foo", "bar", "juu");
+      assertEquals(key.hashCode(), IOTools.clone(key).hashCode());
+      assertEquals(key, IOTools.clone(key));
+   }
+
+   public void testBody() throws Exception
+   {
+      BodyData clone = IOTools.clone(body);
+      assertEquals(body.getStorageId(), clone.getStorageId());
+      assertEquals(body.getStorageName(), clone.getStorageName());
+      assertEquals(body.getType(), clone.getType());
+   }
+
+   public void testContainer() throws Exception
+   {
+      ContainerData clone = IOTools.clone(container);
+      assertEquals(container.getStorageId(), clone.getStorageId());
+      assertEquals(container.getStorageName(), clone.getStorageName());
+      assertEquals(container.getId(), clone.getId());
+      assertEquals(container.getName(), clone.getName());
+      assertEquals(container.getIcon(), clone.getIcon());
+      assertEquals(container.getTemplate(), clone.getTemplate());
+      assertEquals(container.getFactoryId(), clone.getFactoryId());
+      assertEquals(container.getTitle(), clone.getTitle());
+      assertEquals(container.getDescription(), clone.getDescription());
+      assertEquals(container.getWidth(), clone.getWidth());
+      assertEquals(container.getHeight(), clone.getHeight());
+      assertEquals(container.getAccessPermissions(), clone.getAccessPermissions());
+      List<ComponentData> clonedChildren = container.getChildren();
+      assertEquals(1, clonedChildren.size());
+      assertEquals("foo", clonedChildren.get(0).getStorageId());
+      assertEquals(BodyType.PAGE, ((BodyData)clonedChildren.get(0)).getType());
+   }
+
+   public void testPage() throws Exception
+   {
+      PageData obj = new PageData(
+         "foo01",
+         "foo02",
+         "foo03",
+         "foo04",
+         "foo05",
+         "foo06",
+         "foo07",
+         "foo08",
+         "foo09",
+         "foo10",
+         Arrays.asList("foo11"),
+         Arrays.<ComponentData>asList(body),
+         "foo12",
+         "foo13",
+         "foo14",
+         true
+      );
+      PageData clone = IOTools.clone(obj);
+      assertEquals(obj.getStorageId(), clone.getStorageId());
+      assertEquals(obj.getStorageName(), clone.getStorageName());
+      assertEquals(obj.getId(), clone.getId());
+      assertEquals(obj.getName(), clone.getName());
+      assertEquals(obj.getIcon(), clone.getIcon());
+      assertEquals(obj.getTemplate(), clone.getTemplate());
+      assertEquals(obj.getFactoryId(), clone.getFactoryId());
+      assertEquals(obj.getTitle(), clone.getTitle());
+      assertEquals(obj.getDescription(), clone.getDescription());
+      assertEquals(obj.getWidth(), clone.getWidth());
+      assertEquals(obj.getHeight(), clone.getHeight());
+      assertEquals(obj.getAccessPermissions(), clone.getAccessPermissions());
+      List<ComponentData> clonedChildren = obj.getChildren();
+      assertEquals(1, clonedChildren.size());
+      assertEquals("foo", clonedChildren.get(0).getStorageId());
+      assertEquals(BodyType.PAGE, ((BodyData)clonedChildren.get(0)).getType());
+      assertEquals(obj.getOwnerType(), clone.getOwnerType());
+      assertEquals(obj.getOwnerId(), clone.getOwnerId());
+      assertEquals(obj.getEditPermission(), clone.getEditPermission());
+      assertEquals(obj.isShowMaxWindow(), clone.isShowMaxWindow());
+   }
+
+   public void testPortal() throws Exception
+   {
+      PortalData obj = new PortalData(
+         "foo01",
+         "foo02",
+         "foo03",
+         "foo04",
+         Arrays.asList("foo05"),
+         "foo06",
+         Collections.singletonMap("foo07", "foo08"),
+         "foo09",
+         container
+      );
+      PortalData clone = IOTools.clone(obj);
+      assertEquals(obj.getStorageId(), clone.getStorageId());
+      assertEquals(obj.getStorageName(), clone.getStorageName());
+      assertEquals(obj.getName(), clone.getName());
+      assertEquals(obj.getType(), clone.getType());
+      assertEquals(obj.getLocale(), clone.getLocale());
+      assertEquals(obj.getAccessPermissions(), clone.getAccessPermissions());
+      assertEquals(obj.getEditPermission(), clone.getEditPermission());
+      assertEquals(obj.getProperties(), clone.getProperties());
+      assertEquals(obj.getSkin(), clone.getSkin());
+   }
+
+   public void testNavigationNode() throws Exception
+   {
+      Date a = new Date();
+      Date b = new Date();
+      NavigationNodeData obj = new NavigationNodeData(
+         "foo01",
+         "foo02",
+         "foo03",
+         "foo04",
+         "foo05",
+         a,
+         b,
+         Visibility.SYSTEM,
+         "foo06",
+         Collections.<NavigationNodeData>emptyList()
+      );
+      NavigationNodeData clone = IOTools.clone(obj);
+      assertEquals(obj.getStorageId(), clone.getStorageId());
+      assertEquals(obj.getStorageName(), clone.getStorageName());
+      assertEquals(obj.getURI(), clone.getURI());
+      assertEquals(obj.getLabel(), clone.getLabel());
+      assertEquals(obj.getIcon(), clone.getIcon());
+      assertEquals(obj.getName(), clone.getName());
+      assertEquals(obj.getStartPublicationDate(), clone.getStartPublicationDate());
+      assertEquals(obj.getEndPublicationDate(), clone.getEndPublicationDate());
+      assertEquals(obj.getVisibility(), clone.getVisibility());
+      assertEquals(obj.getPageReference(), clone.getPageReference());
+   }
+
+   public void testNavigationData() throws Exception
+   {
+      NavigationData obj = new NavigationData(
+         "foo01",
+         "foo02",
+         "foo03",
+         3,
+         Collections.<NavigationNodeData>emptyList()
+      );
+      NavigationData clone = IOTools.clone(obj);
+      assertEquals(obj.getStorageId(), clone.getStorageId());
+      assertEquals(obj.getStorageName(), clone.getStorageName());
+      assertEquals(obj.getOwnerType(), clone.getOwnerType());
+      assertEquals(obj.getOwnerId(), clone.getOwnerId());
+      assertEquals(obj.getPriority(), clone.getPriority());
+   }
+
+   public void testApplicationData() throws Exception
+   {
+      ApplicationData<?> obj = new ApplicationData<Gadget>(
+         "foo01",
+         "foo02",
+         ApplicationType.GADGET,
+         new PersistentApplicationState<Gadget>("bar"),
+         "foo03",
+         "foo04",
+         "foo05",
+         "foo06",
+         true,
+         true,
+         true,
+         "foo07",
+         "foo08",
+         "foo09",
+         Collections.singletonMap("foo10", "foo11"),
+         Arrays.asList("foo12")
+      );
+      ApplicationData clone = IOTools.clone(obj);
+      assertEquals(obj.getStorageId(), clone.getStorageId());
+      assertEquals(obj.getType(), clone.getType());
+      assertEquals(((PersistentApplicationState)obj.getState()).getStorageId(), ((PersistentApplicationState)clone.getState()).getStorageId());
+      assertEquals(obj.getId(), clone.getId());
+      assertEquals(obj.getTitle(), clone.getTitle());
+      assertEquals(obj.getIcon(), clone.getIcon());
+      assertEquals(obj.getDescription(), clone.getDescription());
+      assertEquals(obj.isShowInfoBar(), clone.isShowInfoBar());
+      assertEquals(obj.isShowApplicationState(), clone.isShowApplicationState());
+      assertEquals(obj.isShowApplicationMode(), clone.isShowApplicationMode());
+      assertEquals(obj.getTheme(), clone.getTheme());
+      assertEquals(obj.getWidth(), clone.getWidth());
+      assertEquals(obj.getHeight(), clone.getHeight());
+      assertEquals(obj.getProperties(), clone.getProperties());
+      assertEquals(obj.getAccessPermissions(), clone.getAccessPermissions());
+   }
+}



More information about the gatein-commits mailing list