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

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Nov 9 19:09:39 EST 2009


Author: julien_viet
Date: 2009-11-09 19:09:39 -0500 (Mon, 09 Nov 2009)
New Revision: 534

Added:
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/CloneApplicationState.java
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/Injector.java
   portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestContentRegistry.java
Log:
GTNPORTAL-216 : start to rewrite application registry


Added: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/CloneApplicationState.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/CloneApplicationState.java	                        (rev 0)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/CloneApplicationState.java	2009-11-10 00:09:39 UTC (rev 534)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.portal.config.model;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class CloneApplicationState<S> extends ApplicationState<S>
+{
+
+   /** . */
+   private final String storageId;
+
+   public CloneApplicationState(String storageId)
+   {
+      this.storageId = storageId;
+   }
+
+   public String getStorageId()
+   {
+      return storageId;
+   }
+}

Added: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/Injector.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/Injector.java	                        (rev 0)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/Injector.java	2009-11-10 00:09:39 UTC (rev 534)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.portal.pom.config;
+
+import org.chromattic.api.event.LifeCycleListener;
+import org.exoplatform.portal.pom.registry.CategoryDefinition;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Injector implements LifeCycleListener
+{
+
+   /** . */
+   private final POMSession session;
+
+   public Injector(POMSession session)
+   {
+      this.session = session;
+   }
+
+   public void created(Object o)
+   {
+   }
+
+   public void loaded(String id, String path, String name, Object o)
+   {
+      if (o instanceof CategoryDefinition)
+      {
+         ((CategoryDefinition)o).session = session;
+      }
+   }
+
+   public void added(String id, String path, String name, Object o)
+   {
+      if (o instanceof CategoryDefinition)
+      {
+         ((CategoryDefinition)o).session = session;
+      }
+   }
+
+   public void removed(String id, String path, String name, Object o)
+   {
+      if (o instanceof CategoryDefinition)
+      {
+         ((CategoryDefinition)o).session = null;
+      }
+   }
+}

Added: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestContentRegistry.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestContentRegistry.java	                        (rev 0)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestContentRegistry.java	2009-11-10 00:09:39 UTC (rev 534)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.portal.config;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.registry.CategoryDefinition;
+import org.exoplatform.portal.pom.registry.ContentDefinition;
+import org.exoplatform.portal.pom.registry.ContentRegistry;
+import org.exoplatform.portal.pom.spi.portlet.Preferences;
+import org.exoplatform.test.BasicTestCase;
+import org.gatein.mop.api.workspace.Workspace;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestContentRegistry extends BasicTestCase
+{
+
+   /** . */
+   private DataStorage storage;
+
+   /** . */
+   private POMSessionManager mgr;
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+
+      //
+      PortalContainer container = PortalContainer.getInstance();
+      storage = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+      mgr = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+      mgr.openSession();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      mgr.closeSession(false);
+      storage = null;
+   }
+
+   public void testGetContentRegistry()
+   {
+      POMSession session = POMSessionManager.getSession();
+      ContentRegistry registry = session.getContentRegistry();
+      assertNotNull(registry);
+   }
+
+   public void testCreateCategory()
+   {
+      POMSession session = POMSessionManager.getSession();
+      ContentRegistry registry = session.getContentRegistry();
+      CategoryDefinition category = registry.createCategory("foo");
+      assertNotNull(category);
+      assertSame(category, registry.getCategory("foo"));
+   }
+
+   public void testCreateContent()
+   {
+      POMSession session = POMSessionManager.getSession();
+      ContentRegistry registry = session.getContentRegistry();
+      CategoryDefinition category = registry.createCategory("foo");
+      ContentDefinition content = category.createContent("bar", Preferences.CONTENT_TYPE, "myportlet");
+      assertNotNull(content);
+
+      // Test that we do have a customization shared at the workspace level
+      Workspace workspace = session.getWorkspace();
+      assertNotNull(workspace.getCustomization("bar"));
+   }
+
+}



More information about the gatein-commits mailing list