geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r109829 - /geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java /geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/test-data/j2ee_1_3dtd/web-23.xml
Date Sat, 04 Dec 2004 23:20:14 GMT
Author: djencks
Date: Sat Dec  4 15:20:12 2004
New Revision: 109829

URL: http://svn.apache.org/viewcvs?view=rev&rev=109829
Log:
somewhat better validation checking for web.xml descriptors
Modified:
   geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
   geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/test-data/j2ee_1_3dtd/web-23.xml

Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java?view=diff&rev=109829&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java&r1=109828&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java&r2=109829
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Sat Dec  4 15:20:12 2004
@@ -46,7 +46,6 @@
     private static final String GERONIMO_SECURITY_NAMESPACE = "http://geronimo.apache.org/xml/ns/security";
 
     private static final QName RESOURCE_ADAPTER_VERSION = new QName(J2EE_NAMESPACE, "resourceadapter-version");
-    private static final QName OUTBOUND_RESOURCEADAPTER = new QName(J2EE_NAMESPACE, "outbound-resourceadapter");
     private static final QName TAGLIB = new QName(J2EE_NAMESPACE, "taglib");
 
     private SchemaConversionUtils() {
@@ -248,50 +247,60 @@
             return (WebAppDocument) xmlObject;
         }
         XmlCursor cursor = xmlObject.newCursor();
-        XmlCursor moveable = xmlObject.newCursor();
-        moveable.toStartDoc();
-        moveable.toFirstChild();
-        if ("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd".equals(moveable.getName().getNamespaceURI()))
{
-            XmlObject result = xmlObject.changeType(WebAppDocument.type);
-            validateDD(result);
-            return (WebAppDocument) result;
-        }
-        String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
-        String version = "2.4";
         try {
-            convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
             cursor.toStartDoc();
-            cursor.toChild(J2EE_NAMESPACE, "web-app");
             cursor.toFirstChild();
-            convertToDescriptionGroup(cursor, moveable);
-            convertToJNDIEnvironmentRefsGroup(cursor, moveable);
-            cursor.push();
-            if (cursor.toNextSibling(TAGLIB)) {
-                cursor.toPrevSibling();
-                moveable.toCursor(cursor);
-                cursor.beginElement("jsp-config", J2EE_NAMESPACE);
-                while (moveable.toNextSibling(TAGLIB)) {
-                    moveable.moveXml(cursor);
-                }
+            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
+                XmlObject result = xmlObject.changeType(WebAppDocument.type);
+                validateDD(result);
+                return (WebAppDocument) result;
             }
-            cursor.pop();
-            do {
-                String name = cursor.getName().getLocalPart();
-                if ("filter".equals(name) || "servlet".equals(name)) {
-                    cursor.push();
+
+            XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
+            String publicId = xmlDocumentProperties.getDoctypePublicId();
+            if ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN".equals(publicId)
||
+                    "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId))
{
+                XmlCursor moveable = xmlObject.newCursor();
+                try {
+                    moveable.toStartDoc();
+                    moveable.toFirstChild();
+                    String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
+                    String version = "2.4";
+                    convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
+                    cursor.toStartDoc();
+                    cursor.toChild(J2EE_NAMESPACE, "web-app");
                     cursor.toFirstChild();
                     convertToDescriptionGroup(cursor, moveable);
-                    if (cursor.toNextSibling(J2EE_NAMESPACE, "init-param")) {
-                        cursor.toFirstChild();
-                        convertToDescriptionGroup(cursor, moveable);
+                    convertToJNDIEnvironmentRefsGroup(cursor, moveable);
+                    cursor.push();
+                    if (cursor.toNextSibling(TAGLIB)) {
+                        cursor.toPrevSibling();
+                        moveable.toCursor(cursor);
+                        cursor.beginElement("jsp-config", J2EE_NAMESPACE);
+                        while (moveable.toNextSibling(TAGLIB)) {
+                            moveable.moveXml(cursor);
+                        }
                     }
                     cursor.pop();
+                    do {
+                        String name = cursor.getName().getLocalPart();
+                        if ("filter".equals(name) || "servlet".equals(name)) {
+                            cursor.push();
+                            cursor.toFirstChild();
+                            convertToDescriptionGroup(cursor, moveable);
+                            if (cursor.toNextSibling(J2EE_NAMESPACE, "init-param")) {
+                                cursor.toFirstChild();
+                                convertToDescriptionGroup(cursor, moveable);
+                            }
+                            cursor.pop();
+                        }
+                    } while (cursor.toNextSibling());
+                } finally {
+                    moveable.dispose();
                 }
-            } while (cursor.toNextSibling());
-
+            }
         } finally {
             cursor.dispose();
-            moveable.dispose();
         }
         XmlObject result = xmlObject.changeType(WebAppDocument.type);
         if (result != null) {
@@ -305,7 +314,6 @@
     public static XmlObject convertToGeronimoNamingSchema(XmlObject xmlObject) {
         XmlCursor cursor = xmlObject.newCursor();
         XmlCursor end = xmlObject.newCursor();
-        String version = "1.0";
         try {
             while (cursor.hasNextToken()) {
                 if (cursor.isStart()) {
@@ -331,7 +339,6 @@
     public static XmlObject convertToGeronimoSecuritySchema(XmlObject xmlObject) {
         XmlCursor cursor = xmlObject.newCursor();
         XmlCursor end = xmlObject.newCursor();
-        String version = "1.0";
         try {
             while (cursor.hasNextToken()) {
                 if (cursor.isStart()) {

Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/test-data/j2ee_1_3dtd/web-23.xml
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/test-data/j2ee_1_3dtd/web-23.xml?view=diff&rev=109829&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/test-data/j2ee_1_3dtd/web-23.xml&r1=109828&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/test-data/j2ee_1_3dtd/web-23.xml&r2=109829
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/test-data/j2ee_1_3dtd/web-23.xml
(original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/j2ee-schema/src/test-data/j2ee_1_3dtd/web-23.xml
Sat Dec  4 15:20:12 2004
@@ -1,4 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+
 <web-app>
     <icon>
         <small-icon>small</small-icon>

Mime
View raw message