geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r449536 - in /geronimo/server/trunk/modules: geronimo-clustering-wadi/ geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/ geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/ geronimo-j2ee-schema/src/test/resources/j2e...
Date Mon, 25 Sep 2006 00:52:26 GMT
Author: djencks
Date: Sun Sep 24 17:52:25 2006
New Revision: 449536

URL: http://svn.apache.org/viewvc?view=rev&rev=449536
Log:
GERONIMO-2414 move the web conversions to AbstractWebModuleBuilder

Added:
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/java/org/apache/geronimo/web/deployment/SchemaConversionTest.java
  (with props)
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-22.xml
  (contents, props changed)
      - copied, changed from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/web-1-22.xml
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-24.xml
  (contents, props changed)
      - copied, changed from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/web-1-24.xml
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-23.xml
  (contents, props changed)
      - copied, changed from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-1-23.xml
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-24.xml
  (contents, props changed)
      - copied, changed from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-1-24.xml
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-23.xml
  (contents, props changed)
      - copied, changed from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-23.xml
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-24.xml
  (contents, props changed)
      - copied, changed from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-24.xml
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-1-24.xml
  (contents, props changed)
      - copied, changed from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/web-1-24.xml
    geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-2-24.xml
  (contents, props changed)
      - copied, changed from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/web-2-24.xml
Removed:
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/web-1-22.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/web-1-24.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-1-23.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-1-24.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-23.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-24.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/web-1-24.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/web-2-24.xml
Modified:
    geronimo/server/trunk/modules/geronimo-clustering-wadi/pom.xml
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
    geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
    geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-tomcat-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-web-builder/src/main/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java

Modified: geronimo/server/trunk/modules/geronimo-clustering-wadi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-clustering-wadi/pom.xml?view=diff&rev=449536&r1=449535&r2=449536
==============================================================================
--- geronimo/server/trunk/modules/geronimo-clustering-wadi/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-clustering-wadi/pom.xml Sun Sep 24 17:52:25 2006
@@ -67,11 +67,11 @@
             <version>${pom.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>${pom.groupId}</groupId>
-            <artifactId>geronimo-jetty</artifactId>
-            <version>${pom.version}</version>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>${pom.groupId}</groupId>-->
+            <!--<artifactId>geronimo-jetty</artifactId>-->
+            <!--<version>${pom.version}</version>-->
+        <!--</dependency>-->
         
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
@@ -99,10 +99,6 @@
             <artifactId>wadi-tribes</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.codehaus.wadi</groupId>
-            <artifactId>wadi-tribes</artifactId>
-        </dependency>
     </dependencies>
     
 </project>

Modified: geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java?view=diff&rev=449536&r1=449535&r2=449536
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Sun Sep 24 17:52:25 2006
@@ -46,7 +46,6 @@
     private static final String GERONIMO_SERVICE_NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.2";
 
     private static final QName RESOURCE_ADAPTER_VERSION = new QName(J2EE_NAMESPACE, "resourceadapter-version");
-    private static final QName TAGLIB = new QName(J2EE_NAMESPACE, "taglib");
     private static final QName CMP_VERSION = new QName(J2EE_NAMESPACE, "cmp-version");
 
     private static final Map GERONIMO_SCHEMA_CONVERSIONS = new HashMap();
@@ -253,78 +252,6 @@
         }
         XmlBeansUtil.validateDD(xmlObject);
         return (EjbJarDocument) xmlObject;
-    }
-
-    public static WebAppDocument convertToServletSchema(XmlObject xmlObject) throws XmlException
{
-        if (WebAppDocument.type.equals(xmlObject.schemaType())) {
-            XmlBeansUtil.validateDD(xmlObject);
-            return (WebAppDocument) xmlObject;
-        }
-        XmlCursor cursor = xmlObject.newCursor();
-        try {
-            cursor.toStartDoc();
-            cursor.toFirstChild();
-            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
-                XmlObject result = xmlObject.changeType(WebAppDocument.type);
-                XmlBeansUtil.validateDD(result);
-                return (WebAppDocument) result;
-            }
-
-            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(J2EE_NAMESPACE, cursor, moveable);
-                    convertToJNDIEnvironmentRefsGroup(J2EE_NAMESPACE, 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) || "context-param".equals(name))
{
-                            cursor.push();
-                            cursor.toFirstChild();
-                            convertToDescriptionGroup(J2EE_NAMESPACE, cursor, moveable);
-                            while (cursor.toNextSibling(J2EE_NAMESPACE, "init-param")) {
-                                cursor.push();
-                                cursor.toFirstChild();
-                                convertToDescriptionGroup(J2EE_NAMESPACE, cursor, moveable);
-                                cursor.pop();
-                            }
-                            cursor.pop();
-                        }
-                    } while (cursor.toNextSibling());
-                } finally {
-                    moveable.dispose();
-                }
-            }
-        } finally {
-            cursor.dispose();
-        }
-        XmlObject result = xmlObject.changeType(WebAppDocument.type);
-        if (result != null) {
-            XmlBeansUtil.validateDD(result);
-            return (WebAppDocument) result;
-        }
-        XmlBeansUtil.validateDD(xmlObject);
-        return (WebAppDocument) xmlObject;
     }
 
     public static void convertToGeronimoSubSchemas(XmlCursor cursor) {

Modified: geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java?view=diff&rev=449536&r1=449535&r2=449536
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/java/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
Sun Sep 24 17:52:25 2006
@@ -23,12 +23,12 @@
 
 import javax.xml.namespace.QName;
 
-import junit.framework.TestCase;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlException;
 import org.apache.geronimo.xbeans.j2ee.EjbJarType;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.testsupport.XmlBeansTestSupport;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -39,7 +39,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class SchemaConversionUtilsTest extends TestCase {
+public class SchemaConversionUtilsTest extends XmlBeansTestSupport {
     private static final Log log = LogFactory.getLog(SchemaConversionUtilsTest.class);
     
     private ClassLoader classLoader = this.getClass().getClassLoader();
@@ -323,70 +323,6 @@
         assertTrue("Differences: " + problems, ok);
     }
 
-    public void testWeb23To24Transform() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/web-23.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/web-24.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-//        log.debug(xmlObject.toString());
-//        log.debug(expected.toString());
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences: " + problems, ok);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences: " + problems, ok2);
-    }
-
-    public void testWeb23To24OtherTransform() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/web-1-23.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/web-1-24.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
-//        log.debug(xmlObject.toString());
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences: " + problems, ok);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences: " + problems, ok2);
-    }
-
-    public void testWeb22To24Transform1() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_2dtd/web-1-22.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_2dtd/web-1-24.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-//        log.debug(xmlObject.toString());
-//        log.debug(expected.toString());
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences: " + problems, ok);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        assertTrue("Differences: " + problems, ok2);
-    }
-
-    public void testWebRejectBad24() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_4schema/web-1-24.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        try {
-            xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
-            fail("doc src/test-data/j2ee_1_4schema/web-1-24.xml is invalid, should not have
validated");
-        } catch (XmlException e) {
-            //expected
-        }
-    }
-
-    public void testParseWeb24() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_4schema/web-2-24.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
-    }
-
     public void testEJB21To21DoesNothing() throws Exception {
         URL srcXml = classLoader.getResource("j2ee_1_4schema/ejb-jar.xml");
         URL expectedOutputXml = classLoader.getResource("j2ee_1_4schema/ejb-jar.xml");
@@ -546,43 +482,6 @@
             cursor.dispose();
         }
 
-    }
-
-    private boolean compareXmlObjects(XmlObject xmlObject, XmlObject expectedObject, List
problems) {
-        XmlCursor test = xmlObject.newCursor();
-        XmlCursor expected = expectedObject.newCursor();
-        boolean similar = true;
-        int elementCount = 0;
-        while (toNextStartToken(test)) {
-            elementCount++;
-            if (!toNextStartToken(expected)) {
-                problems.add("test longer than expected at element: " + elementCount);
-                return false;
-            }
-            QName actualQName = test.getName();
-            QName expectedQName = expected.getName();
-            if (!actualQName.equals(expectedQName)) {
-                problems.add("Different elements at elementCount: " + elementCount + ", test:
" + actualQName + ", expected: " + expectedQName);
-                similar = false;
-            }
-            test.toNextToken();
-            expected.toNextToken();
-        }
-        if (toNextStartToken(expected)) {
-            problems.add("test shorter that expected at element: " + elementCount);
-            similar = false;
-        }
-        return similar;
-    }
-
-    private boolean toNextStartToken(XmlCursor cursor) {
-        while (!cursor.isStart()) {
-            if (!cursor.hasNextToken()) {
-                return false;
-            }
-            cursor.toNextToken();
-        }
-        return true;
     }
 
 }

Modified: geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?view=diff&rev=449536&r1=449535&r2=449536
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Sun Sep 24 17:52:25 2006
@@ -82,7 +82,6 @@
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
-import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 import org.apache.geronimo.security.deployment.SecurityConfiguration;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
@@ -204,7 +203,7 @@
         try {
             // parse it
             XmlObject parsed = XmlBeansUtil.parse(specDD);
-            WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(parsed);
+            WebAppDocument webAppDoc = convertToServletSchema(parsed);
             webApp = webAppDoc.getWebApp();
         } catch (XmlException xmle) {
             // Output the target path in the error to make it clearer to the user which webapp

Modified: geronimo/server/trunk/modules/geronimo-tomcat-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?view=diff&rev=449536&r1=449535&r2=449536
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Sun Sep 24 17:52:25 2006
@@ -62,7 +62,6 @@
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
-import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 import org.apache.geronimo.security.deployment.SecurityConfiguration;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
@@ -142,7 +141,7 @@
         try {
             // parse it
             XmlObject parsed = XmlBeansUtil.parse(specDD);
-            WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(parsed);
+            WebAppDocument webAppDoc = convertToServletSchema(parsed);
             webApp = webAppDoc.getWebApp();
         } catch (XmlException xmle) {
             // Output the target path in the error to make it clearer to the user which webapp

Modified: geronimo/server/trunk/modules/geronimo-web-builder/src/main/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/main/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java?view=diff&rev=449536&r1=449535&r2=449536
==============================================================================
--- geronimo/server/trunk/modules/geronimo-web-builder/src/main/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-web-builder/src/main/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java
Sun Sep 24 17:52:25 2006
@@ -76,15 +76,21 @@
 import org.apache.geronimo.xbeans.j2ee.UrlPatternType;
 import org.apache.geronimo.xbeans.j2ee.WebAppType;
 import org.apache.geronimo.xbeans.j2ee.WebResourceCollectionType;
+import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.j2ee.GerSecurityDocument;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
+import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlDocumentProperties;
 
 /**
  * @version $Rev$ $Date$
  */
 public abstract class AbstractWebModuleBuilder implements ModuleBuilder {
     private static final Log log = LogFactory.getLog(AbstractWebModuleBuilder.class);
+    private static final QName TAGLIB = new QName(SchemaConversionUtils.J2EE_NAMESPACE, "taglib");
     private static final String LINE_SEP = System.getProperty("line.separator");
 
     protected static final AbstractNameQuery MANAGED_CONNECTION_FACTORY_PATTERN;
@@ -591,6 +597,78 @@
         }
         securityBuilders.build(gerWebApp, earContext, module.getEarContext());
         serviceBuilders.build(gerWebApp, earContext, module.getEarContext());
+    }
+
+    protected static WebAppDocument convertToServletSchema(XmlObject xmlObject) throws XmlException
{
+        if (WebAppDocument.type.equals(xmlObject.schemaType())) {
+            XmlBeansUtil.validateDD(xmlObject);
+            return (WebAppDocument) xmlObject;
+        }
+        XmlCursor cursor = xmlObject.newCursor();
+        try {
+            cursor.toStartDoc();
+            cursor.toFirstChild();
+            if (SchemaConversionUtils.J2EE_NAMESPACE.equals(cursor.getName().getNamespaceURI()))
{
+                XmlObject result = xmlObject.changeType(WebAppDocument.type);
+                XmlBeansUtil.validateDD(result);
+                return (WebAppDocument) result;
+            }
+
+            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";
+                    SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.J2EE_NAMESPACE,
schemaLocationURL, version);
+                    cursor.toStartDoc();
+                    cursor.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "web-app");
+                    cursor.toFirstChild();
+                    SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.J2EE_NAMESPACE,
cursor, moveable);
+                    SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(SchemaConversionUtils.J2EE_NAMESPACE,
cursor, moveable);
+                    cursor.push();
+                    if (cursor.toNextSibling(TAGLIB)) {
+                        cursor.toPrevSibling();
+                        moveable.toCursor(cursor);
+                        cursor.beginElement("jsp-config", SchemaConversionUtils.J2EE_NAMESPACE);
+                        while (moveable.toNextSibling(TAGLIB)) {
+                            moveable.moveXml(cursor);
+                        }
+                    }
+                    cursor.pop();
+                    do {
+                        String name = cursor.getName().getLocalPart();
+                        if ("filter".equals(name) || "servlet".equals(name) || "context-param".equals(name))
{
+                            cursor.push();
+                            cursor.toFirstChild();
+                            SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.J2EE_NAMESPACE,
cursor, moveable);
+                            while (cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE,
"init-param")) {
+                                cursor.push();
+                                cursor.toFirstChild();
+                                SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.J2EE_NAMESPACE,
cursor, moveable);
+                                cursor.pop();
+                            }
+                            cursor.pop();
+                        }
+                    } while (cursor.toNextSibling());
+                } finally {
+                    moveable.dispose();
+                }
+            }
+        } finally {
+            cursor.dispose();
+        }
+        XmlObject result = xmlObject.changeType(WebAppDocument.type);
+        if (result != null) {
+            XmlBeansUtil.validateDD(result);
+            return (WebAppDocument) result;
+        }
+        XmlBeansUtil.validateDD(xmlObject);
+        return (WebAppDocument) xmlObject;
     }
 
     class UncheckedItem {

Added: geronimo/server/trunk/modules/geronimo-web-builder/src/test/java/org/apache/geronimo/web/deployment/SchemaConversionTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/java/org/apache/geronimo/web/deployment/SchemaConversionTest.java?view=auto&rev=449536
==============================================================================
--- geronimo/server/trunk/modules/geronimo-web-builder/src/test/java/org/apache/geronimo/web/deployment/SchemaConversionTest.java
(added)
+++ geronimo/server/trunk/modules/geronimo-web-builder/src/test/java/org/apache/geronimo/web/deployment/SchemaConversionTest.java
Sun Sep 24 17:52:25 2006
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.web.deployment;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.testsupport.XmlBeansTestSupport;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * ejb 1.1 dtd appears to be a subset of ejb 2.0 dtd so the same xsl should
+ * work for both.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SchemaConversionTest extends XmlBeansTestSupport {
+    private static final Log log = LogFactory.getLog(SchemaConversionTest.class);
+
+    private ClassLoader classLoader = this.getClass().getClassLoader();
+
+    public void testWeb23To24Transform() throws Exception {
+        URL srcXml = classLoader.getResource("j2ee_1_3dtd/web-23.xml");
+        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/web-24.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+        xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject);
+        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+//        log.debug(xmlObject.toString());
+//        log.debug(expected.toString());
+        List problems = new ArrayList();
+        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences: " + problems, ok);
+        xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject);
+        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences: " + problems, ok2);
+    }
+
+    public void testWeb23To24OtherTransform() throws Exception {
+        URL srcXml = classLoader.getResource("j2ee_1_3dtd/web-1-23.xml");
+        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/web-1-24.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+        xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject);
+//        log.debug(xmlObject.toString());
+        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+        List problems = new ArrayList();
+        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences: " + problems, ok);
+        xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject);
+        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences: " + problems, ok2);
+    }
+
+    public void testWeb22To24Transform1() throws Exception {
+        URL srcXml = classLoader.getResource("j2ee_1_2dtd/web-1-22.xml");
+        URL expectedOutputXml = classLoader.getResource("j2ee_1_2dtd/web-1-24.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+        xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject);
+        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+//        log.debug(xmlObject.toString());
+//        log.debug(expected.toString());
+        List problems = new ArrayList();
+        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences: " + problems, ok);
+        xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject);
+        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+        assertTrue("Differences: " + problems, ok2);
+    }
+
+    public void testWebRejectBad24() throws Exception {
+        URL srcXml = classLoader.getResource("j2ee_1_4schema/web-1-24.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+        try {
+            AbstractWebModuleBuilder.convertToServletSchema(xmlObject);
+            fail("doc src/test-data/j2ee_1_4schema/web-1-24.xml is invalid, should not have
validated");
+        } catch (XmlException e) {
+            //expected
+        }
+    }
+
+    public void testParseWeb24() throws Exception {
+        URL srcXml = classLoader.getResource("j2ee_1_4schema/web-2-24.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+        xmlObject = AbstractWebModuleBuilder.convertToServletSchema(xmlObject);
+        assertNotNull(xmlObject);
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/java/org/apache/geronimo/web/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/java/org/apache/geronimo/web/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/java/org/apache/geronimo/web/deployment/SchemaConversionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-22.xml
(from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/web-1-22.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-22.xml?view=diff&rev=449536&p1=geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/web-1-22.xml&r1=449524&p2=geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-22.xml&r2=449536
==============================================================================
    (empty)

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-22.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-22.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-22.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-24.xml
(from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/web-1-24.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-24.xml?view=diff&rev=449536&p1=geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_2dtd/web-1-24.xml&r1=449524&p2=geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-24.xml&r2=449536
==============================================================================
    (empty)

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-24.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-24.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_2dtd/web-1-24.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-23.xml
(from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-1-23.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-23.xml?view=diff&rev=449536&p1=geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-1-23.xml&r1=449524&p2=geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-23.xml&r2=449536
==============================================================================
    (empty)

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-23.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-23.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-23.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-24.xml
(from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-1-24.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-24.xml?view=diff&rev=449536&p1=geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-1-24.xml&r1=449524&p2=geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-24.xml&r2=449536
==============================================================================
    (empty)

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-24.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-24.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-1-24.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-23.xml
(from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-23.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-23.xml?view=diff&rev=449536&p1=geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-23.xml&r1=449524&p2=geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-23.xml&r2=449536
==============================================================================
    (empty)

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-23.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-23.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-23.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-24.xml
(from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-24.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-24.xml?view=diff&rev=449536&p1=geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_3dtd/web-24.xml&r1=449524&p2=geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-24.xml&r2=449536
==============================================================================
    (empty)

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-24.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-24.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_3dtd/web-24.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-1-24.xml
(from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/web-1-24.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-1-24.xml?view=diff&rev=449536&p1=geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/web-1-24.xml&r1=449524&p2=geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-1-24.xml&r2=449536
==============================================================================
    (empty)

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-1-24.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-1-24.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-1-24.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-2-24.xml
(from r449524, geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/web-2-24.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-2-24.xml?view=diff&rev=449536&p1=geronimo/server/trunk/modules/geronimo-j2ee-schema/src/test/resources/j2ee_1_4schema/web-2-24.xml&r1=449524&p2=geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-2-24.xml&r2=449536
==============================================================================
    (empty)

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-2-24.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-2-24.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-web-builder/src/test/resources/j2ee_1_4schema/web-2-24.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message