exo-jcr SVN: r1928 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-19 08:56:18 -0500 (Fri, 19 Feb 2010)
New Revision: 1928
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
Log:
EXOJCR-528: Javadoc about how the external settings are loaded, has been added
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-02-19 11:42:10 UTC (rev 1927)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-02-19 13:56:18 UTC (rev 1928)
@@ -481,36 +481,11 @@
String path = def.getExternalSettingsPath();
if (path != null && (path = path.trim()).length() > 0)
{
- try
+ final Map<String, String> props = loadExternalSettings(path, def.getName());
+ if (props != null && !props.isEmpty())
{
- URL url = null;
- if (path.indexOf(':') == -1)
- {
- // We first check if the file is not in eXo configuration directory
- String fullPath = serverInfo.getExoConfigurationDirectory() + "/portal/" + def.getName() + "/" + path;
- File file = new File(fullPath);
- if (file.exists())
- {
- // The file exists so we will use it
- url = file.toURI().toURL();
- }
- }
- if (url == null)
- {
- // We assume that the path is an eXo standard path
- url = cm.getURL(path);
- }
- // We load the properties from the url found
- final Map<String, String> props = ContainerUtil.loadProperties(url);
- if (props != null && !props.isEmpty())
- {
- mergeSettings(settings, props);
- }
+ mergeSettings(settings, props);
}
- catch (Exception e)
- {
- log.error("Cannot load property file " + path, e);
- }
}
// We then add the portal container name
settings.put(PORTAL_CONTAINER_SETTING_NAME, def.getName());
@@ -524,6 +499,57 @@
}
/**
+ * Loads the external settings corresponding to the given path. The target file cans be either
+ * a file of type "properties" or "xml". The given path will be interpreted as follows:
+ * <ol>
+ * <li>The path doesn't contain any prefix of type "classpath:", "jar:" or "file:", we
+ * assume then apply the following rules
+ * <ol>
+ * <li>A file exists at ${exo-conf-dir}/portal/${portalContainerName}/${path}, we
+ * will load this file</li>
+ * <li>No file exists at the previous path, we then assume that the path can be
+ * interpreted by the {@link ConfigurationManager}</li>
+ * </ol>
+ * </li>
+ * <li>The path contains a prefix, we then assume that the path can be interpreted
+ * by the {@link ConfigurationManager}</li>
+ * </ol>
+ * @param path the path of the external settings to load
+ * @param portalContainerName the name of the related portal container
+ * @return A {@link Map} of settings if the file could be loaded, <code>null</code> otherwise
+ */
+ private Map<String, String> loadExternalSettings(String path, String portalContainerName)
+ {
+ try
+ {
+ URL url = null;
+ if (path.indexOf(':') == -1)
+ {
+ // We first check if the file is not in eXo configuration directory
+ String fullPath = serverInfo.getExoConfigurationDirectory() + "/portal/" + portalContainerName + "/" + path;
+ File file = new File(fullPath);
+ if (file.exists())
+ {
+ // The file exists so we will use it
+ url = file.toURI().toURL();
+ }
+ }
+ if (url == null)
+ {
+ // We assume that the path is an eXo standard path
+ url = cm.getURL(path);
+ }
+ // We load the properties from the url found
+ return ContainerUtil.loadProperties(url);
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot load property file " + path, e);
+ }
+ return null;
+ }
+
+ /**
* Merge the internal settings with the external settings. If the same setting name exists
* in both settings, we apply the following rules:
* <ol>
16 years, 2 months
exo-jcr SVN: r1927 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-19 06:42:10 -0500 (Fri, 19 Feb 2010)
New Revision: 1927
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
Log:
EXOJCR-528: Javadoc about how the settings are merged has been improved
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-02-19 11:17:26 UTC (rev 1926)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-02-19 11:42:10 UTC (rev 1927)
@@ -457,14 +457,16 @@
}
/**
- * Initialize all the settings tied to the corresponding portal container. It will first initialize
- * a new {@link Map} of settings from the settings retrieved from PortalContainerDefinition.getSettings(),
- * then it will add the external settings corresponding the properties file found at the path
- * PortalContainerDefinition.getExternalSettingsPath(), if such file exists. If the same key has been
- * defined in both, the value defined in the external settings will be kept. Then we will add the main
- * settings such as the portal container name, the realm name and the rest context name.
- * @param def the {@link PortalContainerDefinition} from which we have the extract the settings and in
- * which we have to re-inject the final settings
+ * Initialize all the settings tied to the corresponding portal container. It will
+ * first initialize a new {@link Map} of settings from the settings retrieved from
+ * <code>PortalContainerDefinition.getSettings()</code>, then it will add the
+ * external settings corresponding the properties file found at the path
+ * <code>PortalContainerDefinition.getExternalSettingsPath()</code>, if such file
+ * exists. If the same key has been defined in both, the value defined in the
+ * external settings will be kept. Then we will add the main settings such as the
+ * portal container name, the realm name and the rest context name.
+ * @param def the {@link PortalContainerDefinition} from which we have the extract the
+ * settings and in which we have to re-inject the final settings
*/
private void initializeSettings(PortalContainerDefinition def)
{
@@ -513,7 +515,8 @@
// We then add the portal container name
settings.put(PORTAL_CONTAINER_SETTING_NAME, def.getName());
// We add the rest context name
- settings.put(REST_CONTEXT_SETTING_NAME, def.getRestContextName() == null ? defaultRestContextName : def.getRestContextName());
+ settings.put(REST_CONTEXT_SETTING_NAME, def.getRestContextName() == null ? defaultRestContextName : def
+ .getRestContextName());
// We add the realm name
settings.put(REALM_SETTING_NAME, def.getRealmName() == null ? defaultRealmName : def.getRealmName());
// We re-inject the settings and we make sure it is thread safe
@@ -521,7 +524,30 @@
}
/**
- * Merge the internal settings with the external settings
+ * Merge the internal settings with the external settings. If the same setting name exists
+ * in both settings, we apply the following rules:
+ * <ol>
+ * <li>The value of the external setting is <code>null</code>, we ignore the value</li>
+ * <li>The value of the external setting is not <code>null</code> and the value of the
+ * internal setting is <code>null</code>, the final value will be the external setting
+ * value that is of type {@link String}</li>
+ * <li>Both values are not <code>null</code>, we will have to convert the external
+ * setting value into the target type which is the type of the internal setting value,
+ * thanks to the static method <code>valueOf(String)</code>, the following sub-rules are
+ * then applied:
+ * <ol>
+ * <li>The method cannot be found, the final value will be the external setting value
+ * that is of type {@link String}</li>
+ * <li>The method can be found and the external setting value is an empty
+ * {@link String}, we ignore the external setting value</li>
+ * <li>The method can be found and the external setting value is not an empty String
+ * but the method call fails, we ignore the external setting value</li>
+ * <li>The method can be found and the external setting value is not an empty String
+ * and the method call succeeds, the final value will be the external setting value
+ * that is of type of the internal setting value</li>
+ * </ol>
+ * </li>
+ * </ol>
* @param settings the internal settings
* @param props the external settings
*/
@@ -562,8 +588,8 @@
{
if (log.isDebugEnabled())
{
- log.debug("The static method valueOf(String) cannot be found for the class "
- + oldValue.getClass(), e);
+ log.debug(
+ "The static method valueOf(String) cannot be found for the class " + oldValue.getClass(), e);
}
}
if (m != null)
16 years, 2 months
exo-jcr SVN: r1926 - jcr/trunk.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-02-19 06:17:26 -0500 (Fri, 19 Feb 2010)
New Revision: 1926
Modified:
jcr/trunk/pom.xml
Log:
EXOJCR-521 exo.jcr.component.cluster.test.client renamed to exo.jcr.cluster.testclient
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2010-02-19 11:13:51 UTC (rev 1925)
+++ jcr/trunk/pom.xml 2010-02-19 11:17:26 UTC (rev 1926)
@@ -152,7 +152,7 @@
</dependency>
<dependency>
<groupId>org.exoplatform.jcr</groupId>
- <artifactId>exo.jcr.component.cluster.test.client</artifactId>
+ <artifactId>exo.jcr.cluster.testclient</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
16 years, 2 months
exo-jcr SVN: r1925 - jcr/trunk/applications/exo.jcr.cluster.testclient.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-02-19 06:13:51 -0500 (Fri, 19 Feb 2010)
New Revision: 1925
Modified:
jcr/trunk/applications/exo.jcr.cluster.testclient/pom.xml
Log:
EXOJCR-521 exo.jcr.component.cluster.test.client renamed to exo.jcr.cluster.testclient
Modified: jcr/trunk/applications/exo.jcr.cluster.testclient/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.cluster.testclient/pom.xml 2010-02-19 11:07:35 UTC (rev 1924)
+++ jcr/trunk/applications/exo.jcr.cluster.testclient/pom.xml 2010-02-19 11:13:51 UTC (rev 1925)
@@ -26,7 +26,7 @@
<artifactId>jcr-applications-parent</artifactId>
<version>1.12.0-GA-SNAPSHOT</version>
</parent>
- <artifactId>exo.jcr.component.cluster.test.client</artifactId>
+ <artifactId>exo.jcr.cluster.testclient</artifactId>
<name>eXo JCR :: Cluster :: Test Client</name>
<description>Cluster test client</description>
<dependencies>
16 years, 2 months
exo-jcr SVN: r1924 - jcr/trunk/exo.jcr.component.core.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-02-19 06:07:35 -0500 (Fri, 19 Feb 2010)
New Revision: 1924
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
Log:
EXOJCR-521 exo.jcr.component.cluster.test.client renamed to exo.jcr.cluster.testclient
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-02-19 11:05:35 UTC (rev 1923)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-02-19 11:07:35 UTC (rev 1924)
@@ -71,6 +71,11 @@
<artifactId>exo.core.component.security.core</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>exo.jcr.cluster.testclient</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
</dependency>
@@ -165,12 +170,7 @@
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.jcr</groupId>
- <artifactId>exo.jcr.component.cluster.test.client</artifactId>
- <scope>test</scope>
- </dependency>
+ </dependency>
<!-- TCK binaries and deps for repo stub, some eXo API test -->
<dependency>
<groupId>org.jboss.cache</groupId>
16 years, 2 months
exo-jcr SVN: r1923 - jcr/trunk/applications.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-02-19 06:05:35 -0500 (Fri, 19 Feb 2010)
New Revision: 1923
Modified:
jcr/trunk/applications/pom.xml
Log:
EXOJCR-521 exo.jcr.component.cluster.test.client renamed to exo.jcr.cluster.testclient
Modified: jcr/trunk/applications/pom.xml
===================================================================
--- jcr/trunk/applications/pom.xml 2010-02-19 10:59:25 UTC (rev 1922)
+++ jcr/trunk/applications/pom.xml 2010-02-19 11:05:35 UTC (rev 1923)
@@ -35,7 +35,7 @@
<description>eXo JCR Applications Reactor</description>
<modules>
- <module>exo.jcr.component.cluster.test.client</module>
+ <module>exo.jcr.cluster.testclient</module>
<module>exo.jcr.applications.backupconsole</module>
<module>exo.jcr.applications.browser</module>
<module>exo.jcr.applications.config</module>
16 years, 2 months
exo-jcr SVN: r1922 - jcr/trunk/applications.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-02-19 05:59:25 -0500 (Fri, 19 Feb 2010)
New Revision: 1922
Added:
jcr/trunk/applications/exo.jcr.cluster.testclient/
Removed:
jcr/trunk/applications/exo.jcr.component.cluster.test.client/
Log:
EXOJCR-521 exo.jcr.component.cluster.test.client renamed to exo.jcr.cluster.testclient according to Maven best practice : module name = artifactId
Copied: jcr/trunk/applications/exo.jcr.cluster.testclient (from rev 1921, jcr/trunk/applications/exo.jcr.component.cluster.test.client)
16 years, 2 months
exo-jcr SVN: r1921 - kernel/trunk.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-02-19 05:55:23 -0500 (Fri, 19 Feb 2010)
New Revision: 1921
Modified:
kernel/trunk/pom.xml
Log:
EXOJCR-483 deps on junit.framework GA-SNAPSHOT
Modified: kernel/trunk/pom.xml
===================================================================
--- kernel/trunk/pom.xml 2010-02-19 10:52:00 UTC (rev 1920)
+++ kernel/trunk/pom.xml 2010-02-19 10:55:23 UTC (rev 1921)
@@ -64,7 +64,7 @@
<dependency>
<groupId>org.exoplatform.tool</groupId>
<artifactId>exo.tool.framework.junit</artifactId>
- <version>1.2.1-CR2</version>
+ <version>1.2.1-GA-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
16 years, 2 months
exo-jcr SVN: r1920 - jcr/trunk/applications/exo.jcr.component.cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-02-19 05:52:00 -0500 (Fri, 19 Feb 2010)
New Revision: 1920
Modified:
jcr/trunk/applications/exo.jcr.component.cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
Log:
EXOJCR-393 method addNode(String name, HttpOutputStream stream, String mimeType) added to be able to specify node's mime type.
Modified: jcr/trunk/applications/exo.jcr.component.cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
===================================================================
--- jcr/trunk/applications/exo.jcr.component.cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java 2010-02-19 10:21:51 UTC (rev 1919)
+++ jcr/trunk/applications/exo.jcr.component.cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java 2010-02-19 10:52:00 UTC (rev 1920)
@@ -124,6 +124,13 @@
{
return Put(workspacePath + name, stream);
}
+
+ public HTTPResponse addNode(String name, HttpOutputStream stream, String mimeType) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, mimeType);
+ return Put(workspacePath + name, stream, headers);
+ }
public HTTPResponse removeNode(String name) throws IOException, ModuleException
{
16 years, 2 months
exo-jcr SVN: r1919 - in kernel/trunk/exo.kernel.container/src: test/java/org/exoplatform/container/definition and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-19 05:21:51 -0500 (Fri, 19 Feb 2010)
New Revision: 1919
Added:
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-invalid-values.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings-with-invalid-values.properties
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-528: Invalid values where not properly managed
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-02-19 08:53:30 UTC (rev 1918)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-02-19 10:21:51 UTC (rev 1919)
@@ -406,6 +406,7 @@
String name = def.getName();
if (name == null || (name = name.trim()).length() == 0)
{
+ log.warn("A PortalContainerDefinition cannot have empty name");
continue;
}
else
@@ -501,58 +502,7 @@
final Map<String, String> props = ContainerUtil.loadProperties(url);
if (props != null && !props.isEmpty())
{
- if (settings.isEmpty())
- {
- // No settings exist so we can add everything
- settings.putAll(props);
- }
- else
- {
- // Some settings exists so we need to be careful if we override properties
- // We need to try to keep the same type if possible
- for (Map.Entry<String, String> entry : props.entrySet())
- {
- String propertyName = entry.getKey();
- Object propertyValue = entry.getValue();
- propertyValue = Deserializer.resolveString((String)propertyValue);
- Object oldValue = settings.get(propertyName);
- if (oldValue != null)
- {
- // The value is not null so we need to convert the String into
- // the target type, we will convert thanks to the static method
- // valueOf(String value) if it exist for the target type
- Method m = null;
- try
- {
- // First we check if the method exists
- m = oldValue.getClass().getMethod("valueOf", String.class);
- }
- catch (Exception e)
- {
- if (log.isDebugEnabled())
- {
- log.debug("The static method valueOf(String) cannot be found for the class "
- + oldValue.getClass(), e);
- }
- }
- if (m != null)
- {
- // The method could be found, thus we will try to convert the value
- try
- {
- propertyValue = m.invoke(null, propertyValue);
- }
- catch (Exception e)
- {
- log.error("Cannot convert the value '" + propertyValue + "' to an Object of type "
- + oldValue.getClass(), e);
- }
- }
- }
- // We set the new value
- settings.put(propertyName, propertyValue);
- }
- }
+ mergeSettings(settings, props);
}
}
catch (Exception e)
@@ -563,14 +513,88 @@
// We then add the portal container name
settings.put(PORTAL_CONTAINER_SETTING_NAME, def.getName());
// We add the rest context name
- settings.put(REST_CONTEXT_SETTING_NAME, def.getRestContextName());
+ settings.put(REST_CONTEXT_SETTING_NAME, def.getRestContextName() == null ? defaultRestContextName : def.getRestContextName());
// We add the realm name
- settings.put(REALM_SETTING_NAME, def.getRealmName());
+ settings.put(REALM_SETTING_NAME, def.getRealmName() == null ? defaultRealmName : def.getRealmName());
// We re-inject the settings and we make sure it is thread safe
def.setSettings(Collections.unmodifiableMap(settings));
}
/**
+ * Merge the internal settings with the external settings
+ * @param settings the internal settings
+ * @param props the external settings
+ */
+ private void mergeSettings(final Map<String, Object> settings, final Map<String, String> props)
+ {
+ if (settings.isEmpty())
+ {
+ // No settings exist so we can add everything
+ settings.putAll(props);
+ }
+ else
+ {
+ // Some settings exists so we need to be careful if we override properties
+ // We need to try to keep the same type if possible
+ for (Map.Entry<String, String> entry : props.entrySet())
+ {
+ String propertyName = entry.getKey();
+ Object propertyValue = entry.getValue();
+ propertyValue = Deserializer.resolveString((String)propertyValue);
+ if (propertyValue == null)
+ {
+ // We skip null value
+ continue;
+ }
+ Object oldValue = settings.get(propertyName);
+ if (oldValue != null)
+ {
+ // The value is not null so we need to convert the String into
+ // the target type, we will convert thanks to the static method
+ // valueOf(String value) if it exist for the target type
+ Method m = null;
+ try
+ {
+ // First we check if the method exists
+ m = oldValue.getClass().getMethod("valueOf", String.class);
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("The static method valueOf(String) cannot be found for the class "
+ + oldValue.getClass(), e);
+ }
+ }
+ if (m != null)
+ {
+ // The method could be found, thus we will try to convert the value
+ String sPropertyValue = ((String)propertyValue).trim();
+ if (sPropertyValue.length() == 0)
+ {
+ // We ignore empty value since it cannot be converted
+ continue;
+ }
+ try
+ {
+ propertyValue = m.invoke(null, propertyValue);
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot convert the value '" + propertyValue + "' to an Object of type "
+ + oldValue.getClass(), e);
+ // we ignore invalid value
+ continue;
+ }
+ }
+ }
+ // We set the new value
+ settings.put(propertyName, propertyValue);
+ }
+ }
+ }
+
+ /**
* Initialize the current component
* @param mDefinitions the list of all the portal container definition to treat
*/
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-02-19 08:53:30 UTC (rev 1918)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-02-19 10:21:51 UTC (rev 1919)
@@ -106,7 +106,69 @@
assertTrue(config.isScopeValid("foo", "foo"));
assertTrue(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
-
+ assertTrue(config.hasDefinition());
+
+ // Without dependencies and with no portal container name
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-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());
+ assertEquals("myPortal", names.get(0));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal", names.get(0));
+ assertEquals("myPortal", config.getPortalContainerName("foo"));
+ assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertEquals("myPortal", config.getPortalContainerName("myPortal-pcdef"));
+ assertEquals("myRest", config.getRestContextName("foo"));
+ assertEquals("myRest", config.getRestContextName("myPortal"));
+ assertEquals("myRest", config.getRestContextName("myPortal-pcdef"));
+ assertEquals("my-exo-domain", config.getRealmName("foo"));
+ assertEquals("my-exo-domain", config.getRealmName("myPortal"));
+ assertEquals("my-exo-domain", config.getRealmName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+
+ // Without dependencies and with no rest context name an realm name
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def2.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());
+ 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", config.getRestContextName("myPortal-pcdef"));
+ assertEquals("my-exo-domain", config.getRealmName("foo"));
+ assertEquals("my-exo-domain", config.getRealmName("myPortal"));
+ assertEquals("my-exo-domain", config.getRealmName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal-pcdef"));
+ // Needed for backward compatibility
+ assertTrue(config.isScopeValid("foo", "foo"));
+ assertTrue(config.isScopeValid("myPortal", "foo"));
+ assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertTrue(config.hasDefinition());
+
// With dependencies
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -138,6 +200,7 @@
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertTrue(config.hasDefinition());
}
public void testSettings()
@@ -294,5 +357,24 @@
assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+
+ // With both settings internal and external, and with invalid values
+ rootContainer = createRootContainer("portal-container-config-with-invalid-values.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals("value", config.getSetting("myPortal-pcdef", "internal-empty-value"));
+ assertEquals("", config.getSetting("myPortal-pcdef", "external-empty-value"));
+ assertEquals("", config.getSetting("myPortal-pcdef", "fake-value-4-string"));
+ assertEquals(new Integer(10), config.getSetting("myPortal-pcdef", "fake-value-4-int"));
+ assertEquals(new Integer(10), config.getSetting("myPortal-pcdef", "invalid-value-4-int"));
+ assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertNull(config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertNull(config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
}
}
Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml 2010-02-19 10:21:51 UTC (rev 1919)
@@ -0,0 +1,60 @@
+<?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 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-default-values-and-with-empty-portal-def2.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml 2010-02-19 10:21:51 UTC (rev 1919)
@@ -0,0 +1,56 @@
+<?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>
+ </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-invalid-values.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-invalid-values.xml (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-invalid-values.xml 2010-02-19 10:21:51 UTC (rev 1919)
@@ -0,0 +1,105 @@
+<?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>
+ <!-- A map of settings tied to the portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>internal-empty-value</string>
+ </key>
+ <value>
+ <string></string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>external-empty-value</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>fake-value-4-string</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>fake-value-4-int</string>
+ </key>
+ <value>
+ <int>10</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>invalid-value-4-int</string>
+ </key>
+ <value>
+ <int>10</int>
+ </value>
+ </entry>
+ </map>
+ </field>
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>classpath:/org/exoplatform/container/definition/settings-with-invalid-values.properties</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/settings-with-invalid-values.properties
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings-with-invalid-values.properties (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings-with-invalid-values.properties 2010-02-19 10:21:51 UTC (rev 1919)
@@ -0,0 +1,5 @@
+external-empty-value=
+internal-empty-value=value
+fake-value-4-string=
+fake-value-4-int=
+invalid-value-4-int=foo
\ No newline at end of file
16 years, 2 months