beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eddie O'Neil <ekon...@gmail.com>
Subject netui config file validation -- one last change
Date Mon, 19 Sep 2005 23:07:11 GMT
All--

  I've got one last change to make to the error reporting done when
validating the NetUI config file.  Today on Tomcat 5.0, Java 5
validation doesn't work in the default Tomcat install.  The result is
a big, scary-looking stack trace dumped to the console.

  Often, this stack trace isn't fatal and just indicates a need to
correclty enable Java 5 XSD validation; a NetUI warning message is
displayed for that.

  The change makes the stack trace a *debug* message and passes the
resource paths for both the XML and XSD files.  This improves the
error reporting when validation is mis configured.

  It's a very low risk change; the diff is pasted below.

  I'll check this in tonight and then branch unless anyone has any concerns.

Eddie



<snip>
Index: src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLTemplatesFactory.java
===================================================================
--- src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLTemplatesFactory.java
    (revision 2902
99)
+++ src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLTemplatesFactory.java
    (working copy)

@@ -142,7 +142,8 @@
                 // Validate the XML against the schema
                 xsdInputStream = SCHEMA_RESOLVER.getInputStream();
                 SchemaValidator schemaValidator =
SchemaValidatorFactory.getInstance();
-                schemaValidator.validate(xsdInputStream, xmlInputStream);
+               
schemaValidator.validate(SCHEMA_RESOLVER.getResourcePath(),
xsdInputStream,
+                    _configFilePath, xmlInputStream);
                 try
                 {
                     if ( xmlInputStream != null )
Index: src/util/org/apache/beehive/netui/util/xml/validation/SchemaValidator.java
===================================================================
--- src/util/org/apache/beehive/netui/util/xml/validation/SchemaValidator.java
 (revision 290299)
+++ src/util/org/apache/beehive/netui/util/xml/validation/SchemaValidator.java
 (working copy)
@@ -26,5 +26,6 @@

     /**
      */
-    public abstract void validate(InputStream xsdInputStream,
InputStream xmlInputStrea);
+    public abstract void validate(String xsdResourcePath, InputStream
xsdInputStream,
+                                  String xmlResourcePath, InputStream
xmlInputStrea);
 }
Index: src/util/org/apache/beehive/netui/util/xml/validation/internal/SchemaValidatorJava5.java
===================================================================
--- src/util/org/apache/beehive/netui/util/xml/validation/internal/SchemaValidatorJava5.java
   (revision 2902
99)
+++ src/util/org/apache/beehive/netui/util/xml/validation/internal/SchemaValidatorJava5.java
   (working copy)

@@ -45,8 +45,8 @@

     private static final Logger LOGGER =
Logger.getInstance(SchemaValidatorJava5.class);

-    public void validate(InputStream xsdInputStream, InputStream
xmlInputStream) {
-
+    public void validate(String xsdResourcePath, InputStream xsdInputStream,
+                         String xmlResourcePath, InputStream xmlInputStream) {
         try {
             SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
             StreamSource xsdStreamSource = new StreamSource(xsdInputStream);
@@ -68,9 +68,16 @@
             throw new SchemaValidationException("Exception occurred
validating document.  Cause: " + e, e);
         }
         catch(TransformerFactoryConfigurationError error) {
+            String message =
+                "Beehive NetUI disabled validation on the XML file
\"" + xmlResourcePath + "\" because the XM
L TransformFactory was " +
+                "configured incorrectly.  We suggest configuring the
application runtime to enable Java 5 XML
 Schema validation as additional " +
+                "application configuration errors may occur later.  A
stack trace is available in the NetUI d
ebug log.  Cause: " + error;
+
             if(LOGGER.isWarnEnabled())
-                LOGGER.warn("Beehive NetUI disabled validation on the
given file because the XML TransformFac
tory was configured incorrectly.  " +
-                    "We suggest fixing this error as errors may occur
as a result of having an invalid XML in
stance document.  Cause: " + error, error);
+                LOGGER.warn(message);
+
+            if(LOGGER.isDebugEnabled())
+                LOGGER.debug("XML TransformFactory stack trace:" , error);
         }
     }
 }
Index: src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java
===================================================================
--- src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java
(revision 290299)
+++ src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java
(working copy)
@@ -126,7 +126,8 @@
             xsdInputStream = SCHEMA_RESOLVER.getInputStream();
             try {
                 SchemaValidator schemaValidator =
SchemaValidatorFactory.getInstance();
-                schemaValidator.validate(xsdInputStream, xmlInputStream);
+               
schemaValidator.validate(SCHEMA_RESOLVER.getResourcePath(),
xsdInputStream,
+                    theXmlResolver.getResourcePath(), xmlInputStream);
             }
             catch(SchemaValidationException e) {
                 throw new ConfigInitializationException("Validation
errors occurred parsing the config file \
"" +
</snip>

Mime
View raw message