Author: nfilotto
Date: 2010-09-23 05:28:45 -0400 (Thu, 23 Sep 2010)
New Revision: 3181
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/container-configuration.xml
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
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml
Log:
EXOJCR-974: ignore.unregistered.webapp has been added at PortalContainerConfig definition
to be able to remain compatible with the requirements of EXOJCR 795 needed for PLF
(implementation and doc about this parameter)
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/container-configuration.xml
===================================================================
---
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/container-configuration.xml 2010-09-23
07:59:35 UTC (rev 3180)
+++
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/container-configuration.xml 2010-09-23
09:28:45 UTC (rev 3181)
@@ -385,6 +385,11 @@
<name>default.realm.name</name>
<value>my-exo-domain</value>
</value-param>
+ <!-- Indicates whether the unregistered webapps have to be ignored
-->
+ <value-param>
+ <name>ignore.unregistered.webapp</name>
+ <value>true</value>
+ </value-param>
<!-- The default portal container definition -->
<!-- It cans be used to avoid duplicating configuration -->
<object-param>
@@ -470,6 +475,28 @@
</row>
<row>
+ <entry>ignore.unregistered.webapp</entry>
+
+ <entry>Indicates whether the unregistered webapps have to be
+ ignored. If a webapp has not been registered as a dependency
+ of any portal container, the application will use the value of
+ this parameter to know what to do:<itemizedlist>
+ <listitem>
+ <para>If it is set to <emphasis>false</emphasis>,
this
+ webapp will be considered by default as a dependency of
+ all the portal containers.</para>
+ </listitem>
+
+ <listitem>
+ <para>If it is set to <emphasis>true</emphasis>,
this
+ webapp won't be considered by default as a dependency of
+ any portal container, it will be simply ignored.</para>
+ </listitem>
+ </itemizedlist>This field is optional and by default this
+ parameter is set to
<emphasis>false</emphasis>.</entry>
+ </row>
+
+ <row>
<entry>default.portal.definition</entry>
<entry>The definition of the default portal container. This
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-09-23
07:59:35 UTC (rev 3180)
+++
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-09-23
09:28:45 UTC (rev 3181)
@@ -147,6 +147,15 @@
* Indicates if new system properties have been added
*/
private final PropertyConfigurator pc;
+
+ /**
+ * Indicates whether the unregistered webapps have to be ignored. If a webapp has not
been registered as a dependency
+ * of any portal containers, we will use the value of this parameter to know what to
do.
+ * If it is set to false, this webapp will be considered by default as a dependency of
all the portal containers.
+ * If it is set to true, this webapp won't be considered by default as a
dependency of any portal container, it will
+ * be simply ignored.
+ */
+ private final boolean ignoreUnregisteredWebapp;
public PortalContainerConfig(ConfigurationManager cm)
{
@@ -195,6 +204,9 @@
this.cm = cm;
this.serverInfo = serverInfo;
this.defaultDefinition = create(params);
+ this.ignoreUnregisteredWebapp =
+ params != null &&
params.getValueParam("ignore.unregistered.webapp") != null
+ &&
Boolean.valueOf(params.getValueParam("ignore.unregistered.webapp").getValue());
}
/**
@@ -489,11 +501,12 @@
// The given context is a portal container
return Collections.singletonList(contextName);
}
- else if (portalContainerNamesDisabled.contains(contextName))
+ else if (portalContainerNamesDisabled.contains(contextName) ||
ignoreUnregisteredWebapp)
{
- // The given context name is a context name of a disabled portal container
+ // The given context name is a context name of a disabled portal container
or
+ // the webapp is ignored since it has not been registered in any portal
container dependency list
return Collections.emptyList();
- }
+ }
// By default we scope it to all the portal containers
return portalContainerNames;
}
@@ -526,9 +539,15 @@
if (result == null || result.isEmpty())
{
// This context has not been added as dependency of any portal containers
- if (portalContainerNamesDisabled.contains(contextName))
+ if (portalContainerNamesDisabled.contains(contextName) ||
ignoreUnregisteredWebapp)
{
- // The given context name is a context name of a disabled portal container
+ // The given context name is a context name of a disabled portal container
or
+ // the webapp is ignored since it has not been registered in any portal
container dependency list
+ if (PropertyManager.isDevelopping())
+ {
+ log.warn("The context '" + contextName + "' has not
been added as " +
+ "dependency of any portal containers");
+ }
return null;
}
if (PropertyManager.isDevelopping())
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-09-23
07:59:35 UTC (rev 3180)
+++
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-09-23
09:28:45 UTC (rev 3181)
@@ -289,41 +289,66 @@
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME,
names.get(0));
}
// 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(2, names.size());
- assertTrue(names.contains("myPortal"));
- assertTrue(names.contains("myPortal-pcdef"));
- names = config.getPortalContainerNames("myPortal");
- 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",
config.getPortalContainerName("foo"));
- assertEquals("myPortal",
config.getPortalContainerName("myPortal"));
- assertEquals("myPortal-pcdef",
config.getPortalContainerName("myPortal-pcdef"));
- assertEquals("myRest", config.getRestContextName("foo"));
- assertEquals("myRest", config.getRestContextName("myPortal"));
- assertEquals("myRest-pcdef",
config.getRestContextName("myPortal-pcdef"));
- assertEquals("my-exo-domain", config.getRealmName("foo"));
- assertEquals("my-exo-domain",
config.getRealmName("myPortal"));
- assertEquals("my-exo-domain-pcdef",
config.getRealmName("myPortal-pcdef"));
- assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
- assertTrue(config.isPortalContainerName("myPortal-pcdef"));
- // Needed for backward compatibility
- assertFalse(config.isScopeValid("foo", "foo"));
- assertTrue(config.isScopeValid("myPortal", "foo"));
- assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
- assertTrue(config.isScopeValid("myPortal", "myPortal"));
- assertTrue(config.isScopeValid("myPortal-pcdef",
"myPortal-pcdef"));
- assertTrue(config.hasDefinition());
+ String[] ignoreWebappProfiles = {"ignore.unregistered.webapp-default",
"ignore.unregistered.webapp-false",
"ignore.unregistered.webapp-true"};
+ for (int i = 0; i < ignoreWebappProfiles.length; i++)
+ {
+ rootContainer =
createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml",
ignoreWebappProfiles[i]);
+ config =
(PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getDependencies("foo"));
+ assertNull(config.getDependencies("myPortal"));
+ assertNull(config.getDependencies("myPortal-pcdef"));
+ names = config.getPortalContainerNames("foo");
+ if (i < ignoreWebappProfiles.length - 1)
+ {
+ // Default behavior
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(2, names.size());
+ assertTrue(names.contains("myPortal"));
+ assertTrue(names.contains("myPortal-pcdef"));
+ assertEquals("myPortal",
config.getPortalContainerName("foo"));
+ }
+ else
+ {
+ // Ignore webapp needed for EXOJCR-795
+ assertTrue(names != null && names.isEmpty());
+ assertNull(config.getPortalContainerName("foo"));
+ }
+ names = config.getPortalContainerNames("myPortal");
+ 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",
config.getPortalContainerName("myPortal"));
+ assertEquals("myPortal-pcdef",
config.getPortalContainerName("myPortal-pcdef"));
+ assertEquals("myRest", config.getRestContextName("foo"));
+ assertEquals("myRest",
config.getRestContextName("myPortal"));
+ assertEquals("myRest-pcdef",
config.getRestContextName("myPortal-pcdef"));
+ assertEquals("my-exo-domain", config.getRealmName("foo"));
+ assertEquals("my-exo-domain",
config.getRealmName("myPortal"));
+ assertEquals("my-exo-domain-pcdef",
config.getRealmName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal-pcdef"));
+ // Needed for backward compatibility
+ assertFalse(config.isScopeValid("foo", "foo"));
+ if (i < ignoreWebappProfiles.length - 1)
+ {
+ // Default behavior
+ assertTrue(config.isScopeValid("myPortal", "foo"));
+ assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ }
+ else
+ {
+ // Ignore webapp needed for EXOJCR-795
+ assertFalse(config.isScopeValid("myPortal", "foo"));
+ assertFalse(config.isScopeValid("myPortal-pcdef",
"foo"));
+ }
+ assertTrue(config.isScopeValid("myPortal", "myPortal"));
+ assertTrue(config.isScopeValid("myPortal-pcdef",
"myPortal-pcdef"));
+ assertTrue(config.hasDefinition());
+ }
+
// Unregister the portal container
rootContainer =
createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml",
"disable-pc");
config =
(PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
Modified:
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml
===================================================================
---
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml 2010-09-23
07:59:35 UTC (rev 3180)
+++
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml 2010-09-23
09:28:45 UTC (rev 3181)
@@ -28,6 +28,15 @@
<name>default.realm.name</name>
<value>my-exo-domain</value>
</value-param>
+ <!-- Indicates whether the unregistered webapps have to be ignored -->
+ <value-param profiles="ignore.unregistered.webapp-false">
+ <name>ignore.unregistered.webapp</name>
+ <value>false</value>
+ </value-param>
+ <value-param profiles="ignore.unregistered.webapp-true">
+ <name>ignore.unregistered.webapp</name>
+ <value>true</value>
+ </value-param>
</init-params>
</component>
<external-component-plugins>