[exo-jcr-commits] exo-jcr SVN: r2756 - in kernel/trunk/exo.kernel.container/src: main/java/org/exoplatform/container/definition and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jul 8 06:48:02 EDT 2010
Author: nfilotto
Date: 2010-07-08 06:48:01 -0400 (Thu, 08 Jul 2010)
New Revision: 2756
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
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/TestPortalContainer.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
Log:
EXOJCR-842: Changes reverted, a patch will be proposed instead
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-07-08 10:28:40 UTC (rev 2755)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-07-08 10:48:01 UTC (rev 2756)
@@ -189,20 +189,12 @@
public void registerPortalContainer(ServletContext context)
{
PortalContainerConfig config = getPortalContainerConfig();
+ // Ensure that the portal container has been registered
+ config.registerPortalContainerName(context.getServletContextName());
if (config.hasDefinition())
{
// The new behavior has been detected thus, the creation will be done at the end asynchronously
- if (config.isPortalContainerName(context.getServletContextName()))
- {
- // The portal context has been registered has a portal container
- portalContexts.add(new WebAppInitContext(context));
- }
- else
- {
- log.info("We assume that the ServletContext '" + context.getServletContextName()
- + "' is not a portal since no portal container with the same name has been"
- + " registered to the component PortalContainerConfig.");
- }
+ portalContexts.add(new WebAppInitContext(context));
// We assume that a ServletContext of a portal container owns configuration files
final PortalContainerPreInitTask task = new PortalContainerPreInitTask()
{
@@ -216,8 +208,6 @@
}
else
{
- // Ensure that the portal container has been registered
- config.registerPortalContainerName(context.getServletContextName());
// The old behavior has been detected thus, the creation will be done synchronously
createPortalContainer(context);
}
@@ -254,14 +244,11 @@
PortalContainerConfig config = getPortalContainerConfig();
for (String portalContainerName : initTasks.keySet())
{
- if (config.isPortalContainerName(portalContainerName))
- {
- // Unregister name of portal container that doesn't exist
- log.warn("The portal container '" + portalContainerName + "' doesn't not exist or"
- + " it has not yet been registered, please check your PortalContainerDefinitions and "
- + "the loading order.");
- config.unregisterPortalContainerName(portalContainerName);
- }
+ // Unregister name of portal container that doesn't exist
+ log.warn("The portal container '" + portalContainerName + "' doesn't not exist or"
+ + " it has not yet been registered, please check your PortalContainerDefinitions and "
+ + "the loading order.");
+ config.unregisterPortalContainerName(portalContainerName);
}
// remove all the unneeded tasks
initTasks.clear();
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-07-08 10:28:40 UTC (rev 2755)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-07-08 10:48:01 UTC (rev 2756)
@@ -39,10 +39,8 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import javax.servlet.ServletContext;
@@ -107,9 +105,9 @@
private volatile boolean initialized;
/**
- * The set of all the portal containers
+ * The list of all the portal containers
*/
- private Set<String> portalContainerNames;
+ private List<String> portalContainerNames;
/**
* The list of all the web application scopes
@@ -356,10 +354,10 @@
{
if (!portalContainerNames.contains(name))
{
- final Set<String> lPortalContainerNames = new LinkedHashSet<String>(portalContainerNames.size() + 1);
+ final List<String> lPortalContainerNames = new ArrayList<String>(portalContainerNames.size() + 1);
lPortalContainerNames.add(name);
lPortalContainerNames.addAll(portalContainerNames);
- this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
}
}
@@ -371,9 +369,9 @@
{
if (portalContainerNames.contains(name))
{
- final Set<String> lPortalContainerNames = new LinkedHashSet<String>(portalContainerNames);
+ final List<String> lPortalContainerNames = new ArrayList<String>(portalContainerNames);
lPortalContainerNames.remove(name);
- this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
}
}
@@ -440,7 +438,7 @@
else if (scopes.isEmpty())
{
// we assume that the old behavior is expected
- return defaultDefinition.getName();
+ return defaultDefinition.getName();
}
final List<String> result = scopes.get(contextName);
if (result == null || result.isEmpty())
@@ -544,7 +542,7 @@
if (portalContainerName == null)
{
throw new IllegalArgumentException("The portal container name cannot be null");
- }
+ }
return getPortalContainerNames(contextName).contains(portalContainerName);
}
@@ -977,12 +975,9 @@
*/
private void initialize(Map<String, PortalContainerDefinition> mDefinitions)
{
- final Set<String> lPortalContainerNames = new LinkedHashSet<String>(mDefinitions.size() + 1);
- if (mDefinitions.isEmpty())
- {
- // Add the default portal container name
- lPortalContainerNames.add(defaultDefinition.getName());
- }
+ final List<String> lPortalContainerNames = new ArrayList<String>(mDefinitions.size() + 1);
+ // 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())
@@ -990,7 +985,10 @@
PortalContainerDefinition definition = entry.getValue();
String name = definition.getName();
boolean hasChanged = false;
- lPortalContainerNames.add(name);
+ if (!name.equals(defaultDefinition.getName()))
+ {
+ lPortalContainerNames.add(name);
+ }
if (first)
{
first = false;
@@ -1034,7 +1032,7 @@
registerDependencies(defaultDefinition, mScopes);
}
}
- this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
this.scopes = Collections.unmodifiableMap(mScopes);
// clear the changes
changes.clear();
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2010-07-08 10:28:40 UTC (rev 2755)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2010-07-08 10:48:01 UTC (rev 2756)
@@ -43,7 +43,7 @@
assertEquals("myRest", portal.getRestContextName());
assertEquals("my-exo-domain", portal.getRealmName());
- assertFalse(PortalContainer.isPortalContainerName("myPortal"));
+ assertTrue(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
@@ -73,7 +73,7 @@
assertEquals("myRest", PortalContainer.getRestContextName("foo"));
assertEquals("my-exo-domain", PortalContainer.getRealmName("foo"));
- assertFalse(PortalContainer.isPortalContainerName("myPortal"));
+ assertTrue(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
@@ -84,7 +84,7 @@
assertEquals("myRest", PortalContainer.getCurrentRestContextName());
assertEquals("my-exo-domain", PortalContainer.getCurrentRealmName());
- assertFalse(PortalContainer.isPortalContainerName("myPortal"));
+ assertTrue(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
}
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-07-08 10:28:40 UTC (rev 2755)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-07-08 10:48:01 UTC (rev 2756)
@@ -48,9 +48,6 @@
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getDefaultPortalContainer());
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getDefaultRestContext());
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getDefaultRealmName());
- assertTrue(config.isPortalContainerName("portal"));
- assertFalse(config.isPortalContainerName("myPortal"));
- assertFalse(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer = createRootContainer("portal-container-config-with-default-values.xml");
@@ -59,9 +56,6 @@
assertEquals("myPortal", config.getDefaultPortalContainer());
assertEquals("myRest", config.getDefaultRestContext());
assertEquals("my-exo-domain", config.getDefaultRealmName());
- assertFalse(config.isPortalContainerName("portal"));
- assertTrue(config.isPortalContainerName("myPortal"));
- assertFalse(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer =
@@ -71,9 +65,6 @@
assertEquals("myPortal-dpcdef", config.getDefaultPortalContainer());
assertEquals("myRest-dpcdef", config.getDefaultRestContext());
assertEquals("my-exo-domain-dpcdef", config.getDefaultRealmName());
- assertFalse(config.isPortalContainerName("portal"));
- assertFalse(config.isPortalContainerName("myPortal"));
- assertTrue(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
@@ -291,7 +282,7 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertFalse(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
@@ -354,7 +345,7 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertFalse(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
@@ -475,12 +466,13 @@
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && names.isEmpty());
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertNull(config.getPortalContainerName("myPortal"));
+ assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -489,7 +481,7 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertFalse(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
@@ -531,12 +523,13 @@
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && names.isEmpty());
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertNull(config.getPortalContainerName("myPortal"));
+ assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -545,7 +538,7 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertFalse(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
@@ -572,12 +565,13 @@
assertEquals(1, names.size());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && names.isEmpty());
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertNull(config.getPortalContainerName("myPortal"));
+ assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -586,7 +580,7 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertFalse(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
More information about the exo-jcr-commits
mailing list