Author: nfilotto
Date: 2011-09-15 12:56:12 -0400 (Thu, 15 Sep 2011)
New Revision: 4917
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_0/sample-configuration-17.xml
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_1/sample-configuration-17.xml
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_2/sample-configuration-17.xml
Log:
EXOJCR-1540: default property values produce an validation error with <int> and
<long> tag
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java
===================================================================
---
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java 2011-09-15
12:44:37 UTC (rev 4916)
+++
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java 2011-09-15
16:56:12 UTC (rev 4917)
@@ -21,6 +21,7 @@
import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.container.xml.Configuration;
+import org.exoplatform.container.xml.Deserializer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jibx.runtime.BindingDirectory;
@@ -29,6 +30,7 @@
import org.jibx.runtime.JiBXException;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -153,61 +155,60 @@
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
KERNEL_NAMESPACES);
factory.setNamespaceAware(true);
factory.setValidating(true);
-
- try
+ return SecurityHelper.doPrivilegedIOExceptionAction(new
PrivilegedExceptionAction<Boolean>()
{
- DocumentBuilder builder = null;
- try
+ public Boolean run() throws Exception
{
- builder = SecurityHelper.doPrivilegedExceptionAction(new
PrivilegedExceptionAction<DocumentBuilder>()
+ try
{
- public DocumentBuilder run() throws Exception
- {
- return factory.newDocumentBuilder();
- }
- });
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof ParserConfigurationException)
- {
- throw (ParserConfigurationException)cause;
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Reporter reporter = new Reporter(url);
+ builder.setErrorHandler(reporter);
+ builder.setEntityResolver(Namespaces.resolver);
+ String content =
Deserializer.resolveVariables(readStream(url.openStream()));
+ InputSource is = new InputSource(new StringReader(content));
+ builder.parse(is);
+ return reporter.valid;
}
- else if (cause instanceof RuntimeException)
+ catch (ParserConfigurationException e)
{
- throw (RuntimeException)cause;
+ log.error("Got a parser configuration exception when doing XSD
validation");
+ return false;
}
- else
+ catch (SAXException e)
{
- throw new RuntimeException(cause);
+ log.error("Got a sax exception when doing XSD validation");
+ return false;
}
}
-
- Reporter reporter = new Reporter(url);
- builder.setErrorHandler(reporter);
- builder.setEntityResolver(Namespaces.resolver);
- builder.parse(SecurityHelper.doPrivilegedIOExceptionAction(new
PrivilegedExceptionAction<InputStream>()
+ });
+ }
+
+ private String readStream(InputStream inputStream) throws IOException
+ {
+ try
+ {
+ StringBuilder out = new StringBuilder();
+ byte[] b = new byte[4096];
+ for (int n; (n = inputStream.read(b)) != -1;)
{
- public InputStream run() throws Exception
- {
- return url.openStream();
- }
- }));
- return reporter.valid;
+ out.append(new String(b, 0, n));
+ }
+ return out.toString();
}
- catch (ParserConfigurationException e)
+ finally
{
- log.error("Got a parser configuration exception when doing XSD
validation");
- return false;
+ try
+ {
+ inputStream.close();
+ }
+ catch (Exception e)
+ {
+ // ignore me
+ }
}
- catch (SAXException e)
- {
- log.error("Got a sax exception when doing XSD validation");
- return false;
- }
}
-
+
public Configuration unmarshall(final URL url) throws Exception
{
if (PropertyManager.isDevelopping())
Modified:
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_0/sample-configuration-17.xml
===================================================================
---
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_0/sample-configuration-17.xml 2011-09-15
12:44:37 UTC (rev 4916)
+++
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_0/sample-configuration-17.xml 2011-09-15
16:56:12 UTC (rev 4917)
@@ -83,5 +83,18 @@
</object-param>
</init-params>
</component>
+ <component>
+ <type>org.exoplatform.container.TestExoContainer$C3</type>
+ <init-params>
+ <object-param>
+ <name>O1</name>
+ <object
type="org.exoplatform.container.TestExoContainer$O1">
+ <field
name="name"><string>IdentityCache</string></field>
+ <field
name="maxSize"><int>${cache.exo.social.IdentityCache.Capacity:200}</int></field>
+ <field
name="liveTime"><long>${cache.exo.social.IdentityCache.TimeToLive:-1}</long></field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
</configuration>
\ No newline at end of file
Modified:
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_1/sample-configuration-17.xml
===================================================================
---
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_1/sample-configuration-17.xml 2011-09-15
12:44:37 UTC (rev 4916)
+++
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_1/sample-configuration-17.xml 2011-09-15
16:56:12 UTC (rev 4917)
@@ -83,5 +83,17 @@
</object-param>
</init-params>
</component>
-
+ <component profiles="testDefaultValue">
+ <type>org.exoplatform.container.TestExoContainer$C3</type>
+ <init-params>
+ <object-param>
+ <name>O1</name>
+ <object
type="org.exoplatform.container.TestExoContainer$O1">
+ <field
name="name"><string>IdentityCache</string></field>
+ <field
name="maxSize"><int>${cache.exo.social.IdentityCache.Capacity:200}</int></field>
+ <field
name="liveTime"><long>${cache.exo.social.IdentityCache.TimeToLive:-1}</long></field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
</configuration>
\ No newline at end of file
Modified:
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_2/sample-configuration-17.xml
===================================================================
---
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_2/sample-configuration-17.xml 2011-09-15
12:44:37 UTC (rev 4916)
+++
kernel/trunk/exo.kernel.container/src/test/resources/xsd_1_2/sample-configuration-17.xml 2011-09-15
16:56:12 UTC (rev 4917)
@@ -83,5 +83,17 @@
</object-param>
</init-params>
</component>
-
+ <component profiles="testDefaultValue">
+ <type>org.exoplatform.container.TestExoContainer$C3</type>
+ <init-params>
+ <object-param>
+ <name>O1</name>
+ <object
type="org.exoplatform.container.TestExoContainer$O1">
+ <field
name="name"><string>IdentityCache</string></field>
+ <field
name="maxSize"><int>${cache.exo.social.IdentityCache.Capacity:200}</int></field>
+ <field
name="liveTime"><long>${cache.exo.social.IdentityCache.TimeToLive:-1}</long></field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
</configuration>
\ No newline at end of file