[exo-jcr-commits] exo-jcr SVN: r2594 - in kernel/trunk/exo.kernel.container/src: test/java/org/exoplatform/container/definition and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jun 15 05:10:32 EDT 2010


Author: nfilotto
Date: 2010-06-15 05:10:32 -0400 (Tue, 15 Jun 2010)
New Revision: 2594

Added:
   kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-defs.xml
   kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs.xml
   kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs2.xml
Modified:
   kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
   kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
Log:
EXOJCR-788: Inconsistency issue fixed

Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java	2010-06-15 08:44:56 UTC (rev 2593)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java	2010-06-15 09:10:32 UTC (rev 2594)
@@ -442,7 +442,7 @@
       {
          result = definition.getDependencies();
       }
-      return result == null ? defaultDefinition.getDependencies() : result;
+      return result == null || result.isEmpty() ? defaultDefinition.getDependencies() : result;
    }
 
    /**
@@ -462,7 +462,7 @@
       if (definition != null)
       {
          final Map<String, Object> settings = definition.getSettings();
-         if (settings != null)
+         if (settings != null && !settings.isEmpty())
          {
             return settings.get(settingName);
          }
@@ -547,7 +547,7 @@
                throw new IllegalStateException("The PortalContainerConfig has already been initialized");
             }
             final Map<String, PortalContainerDefinition> tempDefinitions =
-               new HashMap<String, PortalContainerDefinition>(definitions);
+               new LinkedHashMap<String, PortalContainerDefinition>(definitions);
             for (PortalContainerDefinition def : lDefs)
             {
                String name = def.getName();
@@ -944,6 +944,7 @@
       // Add the default portal container name
       lPortalContainerNames.add(defaultDefinition.getName());
       final Map<String, List<String>> mScopes = new HashMap<String, List<String>>();
+      boolean first = true;
       for (Map.Entry<String, PortalContainerDefinition> entry : mDefinitions.entrySet())
       {
          PortalContainerDefinition definition = entry.getValue();
@@ -951,25 +952,30 @@
          boolean hasChanged = false;
          if (!name.equals(defaultDefinition.getName()))
          {
+            lPortalContainerNames.add(name);
+         }
+         if (first)
+         {
+            first = false;
+            // Initialize the main fields thanks to the data found in the first portal container
             if (defaultDefinition.getName() == DEFAULT_PORTAL_CONTAINER_NAME)
             {
                defaultDefinition.setName(name);
                hasChanged = true;
             }
-            lPortalContainerNames.add(name);
+            if (defaultDefinition.getRestContextName() == DEFAULT_REST_CONTEXT_NAME
+               && definition.getRestContextName() != null && definition.getRestContextName().trim().length() > 0)
+            {
+               defaultDefinition.setRestContextName(definition.getRestContextName().trim());
+               hasChanged = true;
+            }
+            if (defaultDefinition.getRealmName() == DEFAULT_REALM_NAME && definition.getRealmName() != null
+               && definition.getRealmName().trim().length() > 0)
+            {
+               defaultDefinition.setRealmName(definition.getRealmName().trim());
+               hasChanged = true;
+            }
          }
-         if (defaultDefinition.getRestContextName() == DEFAULT_REST_CONTEXT_NAME
-            && definition.getRestContextName() != null && definition.getRestContextName().trim().length() > 0)
-         {
-            defaultDefinition.setRestContextName(definition.getRestContextName().trim());
-            hasChanged = true;
-         }
-         if (defaultDefinition.getRealmName() == DEFAULT_REALM_NAME && definition.getRealmName() != null
-            && definition.getRealmName().trim().length() > 0)
-         {
-            defaultDefinition.setRealmName(definition.getRealmName().trim());
-            hasChanged = true;
-         }
          registerDependencies(definition, mScopes);
          if (hasChanged)
          {

Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java	2010-06-15 08:44:56 UTC (rev 2593)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java	2010-06-15 09:10:32 UTC (rev 2594)
@@ -71,6 +71,14 @@
       assertEquals("my-exo-domain", config.getDefaultRealmName());
       assertTrue(config.hasDefinition());
 
+      rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-defs.xml");
+      config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+
+      assertEquals("myPortal", config.getDefaultPortalContainer());
+      assertEquals("myRest", config.getDefaultRestContext());
+      assertEquals("my-exo-domain", config.getDefaultRealmName());
+      assertTrue(config.hasDefinition());
+
       rootContainer =
          createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml");
       config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -87,20 +95,73 @@
       assertEquals("myRest-pcdef", config.getDefaultRestContext());
       assertEquals("my-exo-domain-pcdef", config.getDefaultRealmName());
       assertTrue(config.hasDefinition());
+      
+      rootContainer = createRootContainer("portal-container-config-with-no-default-values-but-with-portal-defs.xml");
+      config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+
+      assertEquals("portal", config.getDefaultPortalContainer());
+      assertEquals("myRest", config.getDefaultRestContext());
+      assertEquals("my-exo-domain", config.getDefaultRealmName());
+      assertTrue(config.hasDefinition());
+      
+      rootContainer = createRootContainer("portal-container-config-with-no-default-values-but-with-portal-defs2.xml");
+      config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+
+      assertEquals("myPortal-pcdef", config.getDefaultPortalContainer());
+      assertEquals("myRest-pcdef", config.getDefaultRestContext());
+      assertEquals("my-exo-domain-pcdef", config.getDefaultRealmName());
+      assertTrue(config.hasDefinition());     
    }
 
    public void testDependencies()
    {
-      // Without dependencies
-      RootContainer rootContainer =
-         createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
+      
+      // Empty
+      RootContainer rootContainer = createRootContainer("portal-container-config-with-no-default-values.xml");
       PortalContainerConfig config =
          (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+      assertNull(config.getDependencies(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
       assertNull(config.getDependencies("foo"));
       assertNull(config.getDependencies("myPortal"));
       assertNull(config.getDependencies("myPortal-pcdef"));
       List<String> names = config.getPortalContainerNames("foo");
       assertTrue(names != null && !names.isEmpty());
+      assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+      names = config.getPortalContainerNames("myPortal");
+      assertTrue(names != null && !names.isEmpty());
+      assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+      names = config.getPortalContainerNames("myPortal-pcdef");
+      assertTrue(names != null && !names.isEmpty());
+      assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+      assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
+      assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal"));
+      assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal-pcdef"));
+      assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("foo"));
+      assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal"));
+      assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal-pcdef"));
+      assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("foo"));
+      assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("myPortal"));
+      assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("myPortal-pcdef"));
+      assertFalse(config.isPortalContainerName("foo"));
+      assertFalse(config.isPortalContainerName("myPortal"));
+      assertFalse(config.isPortalContainerName("myPortal-pcdef"));   
+      assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
+      // Needed for backward compatibility
+      assertTrue(config.isScopeValid("foo", "foo"));
+      assertTrue(config.isScopeValid("myPortal", "foo"));
+      assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+      assertFalse(config.hasDefinition());
+      
+      // Without dependencies
+      rootContainer =
+         createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
+      config =
+         (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+      assertNull(config.getDependencies("foo"));
+      assertNull(config.getDependencies("myPortal"));
+      assertNull(config.getDependencies("myPortal-pcdef"));
+      names = config.getPortalContainerNames("foo");
+      assertTrue(names != null && !names.isEmpty());
       assertEquals("myPortal", names.get(0));
       names = config.getPortalContainerNames("myPortal");
       assertTrue(names != null && !names.isEmpty());

Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-defs.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-defs.xml	                        (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-defs.xml	2010-06-15 09:10:32 UTC (rev 2594)
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+	<!--
+
+		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.
+	-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+	xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+	<component>
+		<!-- The full qualified name of the PortalContainerConfig -->
+		<type>org.exoplatform.container.definition.PortalContainerConfig</type>
+		<init-params>
+			<!-- The name of the default portal container -->
+			<value-param>
+				<name>default.portal.container</name>
+				<value>myPortal</value>
+			</value-param>
+			<!-- The name of the default rest ServletContext -->
+			<value-param>
+				<name>default.rest.context</name>
+				<value>myRest</value>
+			</value-param>
+			<!-- The name of the default realm -->
+			<value-param>
+				<name>default.realm.name</name>
+				<value>my-exo-domain</value>
+			</value-param>
+		</init-params>
+	</component>
+	<external-component-plugins>
+		<!-- The full qualified name of the PortalContainerConfig -->
+		<target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+		<component-plugin>
+			<!-- The name of the plugin -->
+			<name>Add PortalContainer Definitions</name>
+			<!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+			<set-method>registerPlugin</set-method>
+			<!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+			<type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+			<init-params>
+				<object-param>
+					<name>portal</name>
+					<object type="org.exoplatform.container.definition.PortalContainerDefinition">
+						<!-- The name of the portal container -->
+						<field name="name">
+							<string>myPortal-pcdef</string>
+						</field>
+						<!-- The name of the context name of the rest web application -->
+						<field name="restContextName">
+							<string>myRest-pcdef</string>
+						</field>
+						<!-- The name of the realm -->
+						<field name="realmName">
+							<string>my-exo-domain-pcdef</string>
+						</field>
+					</object>
+				</object-param>
+				<object-param>
+					<name>portal</name>
+					<object type="org.exoplatform.container.definition.PortalContainerDefinition">
+						<!-- The name of the portal container -->
+						<field name="name">
+							<string>myPortal</string>
+						</field>
+						<!-- The name of the context name of the rest web application -->
+						<field name="restContextName">
+							<string>myRest2</string>
+						</field>
+						<!-- The name of the realm -->
+						<field name="realmName">
+							<string>my-exo-domain2</string>
+						</field>
+					</object>
+				</object-param>	
+			</init-params>
+		</component-plugin>
+	</external-component-plugins>
+</configuration>
\ No newline at end of file

Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs.xml	                        (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs.xml	2010-06-15 09:10:32 UTC (rev 2594)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+	<!--
+
+		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.
+	-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+	xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+	<component>
+		<type>org.exoplatform.container.definition.PortalContainerConfig</type>
+	</component>
+	<external-component-plugins>
+		<!-- The full qualified name of the PortalContainerConfig -->
+		<target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+		<component-plugin>
+			<!-- The name of the plugin -->
+			<name>Add PortalContainer Definitions</name>
+			<!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+			<set-method>registerPlugin</set-method>
+			<!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+			<type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+			<init-params>
+				<object-param>
+					<name>portal1</name>
+					<object type="org.exoplatform.container.definition.PortalContainerDefinition">
+						<!-- The name of the portal container -->
+						<field name="name">
+							<string>portal</string>
+						</field>
+						<!-- The name of the context name of the rest web application -->
+						<field name="restContextName">
+							<string>myRest</string>
+						</field>
+						<!-- The name of the realm -->
+						<field name="realmName">
+							<string>my-exo-domain</string>
+						</field>
+					</object>
+				</object-param>
+				<object-param>
+					<name>portal2</name>
+					<object type="org.exoplatform.container.definition.PortalContainerDefinition">
+						<!-- The name of the portal container -->
+						<field name="name">
+							<string>myPortal-pcdef</string>
+						</field>
+						<!-- The name of the context name of the rest web application -->
+						<field name="restContextName">
+							<string>myRest-pcdef</string>
+						</field>
+						<!-- The name of the realm -->
+						<field name="realmName">
+							<string>my-exo-domain-pcdef</string>
+						</field>
+					</object>
+				</object-param>
+			</init-params>
+		</component-plugin>				
+	</external-component-plugins>
+</configuration>
\ No newline at end of file

Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs2.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs2.xml	                        (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs2.xml	2010-06-15 09:10:32 UTC (rev 2594)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+	<!--
+
+		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.
+	-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+	xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+	<component>
+		<type>org.exoplatform.container.definition.PortalContainerConfig</type>
+	</component>
+	<external-component-plugins>
+		<!-- The full qualified name of the PortalContainerConfig -->
+		<target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+		<component-plugin>
+			<!-- The name of the plugin -->
+			<name>Add PortalContainer Definitions</name>
+			<!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+			<set-method>registerPlugin</set-method>
+			<!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+			<type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+			<init-params>
+				<object-param>
+					<name>portal1</name>
+					<object type="org.exoplatform.container.definition.PortalContainerDefinition">
+						<!-- The name of the portal container -->
+						<field name="name">
+							<string>myPortal-pcdef</string>
+						</field>
+						<!-- The name of the context name of the rest web application -->
+						<field name="restContextName">
+							<string>myRest-pcdef</string>
+						</field>
+						<!-- The name of the realm -->
+						<field name="realmName">
+							<string>my-exo-domain-pcdef</string>
+						</field>
+					</object>
+				</object-param>			
+				<object-param>
+					<name>portal2</name>
+					<object type="org.exoplatform.container.definition.PortalContainerDefinition">
+						<!-- The name of the portal container -->
+						<field name="name">
+							<string>portal</string>
+						</field>
+						<!-- The name of the context name of the rest web application -->
+						<field name="restContextName">
+							<string>myRest</string>
+						</field>
+						<!-- The name of the realm -->
+						<field name="realmName">
+							<string>my-exo-domain</string>
+						</field>
+					</object>
+				</object-param>
+			</init-params>
+		</component-plugin>
+	</external-component-plugins>
+</configuration>
\ No newline at end of file



More information about the exo-jcr-commits mailing list