geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r419193 - in /geronimo/sandbox/servlet-2.5/modules: client-builder/src/java/org/apache/geronimo/client/builder/ j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/ j2ee-schema/src/java/org/apache/geronimo/schema/ j2ee-schema/src/test...
Date Wed, 05 Jul 2006 09:32:02 GMT
Author: janb
Date: Wed Jul  5 02:31:58 2006
New Revision: 419193

URL: http://svn.apache.org/viewvc?rev=419193&view=rev
Log:
Still trying to make the schema to schema conversion work. Seems like a bug in xmlbeans that
removeAttribute() doesn't work on version attribute.

Modified:
    geronimo/sandbox/servlet-2.5/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/sandbox/servlet-2.5/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
    geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
    geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtilsJavaEE.java
    geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
    geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
    geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
    geronimo/sandbox/servlet-2.5/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java

Modified: geronimo/sandbox/servlet-2.5/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/servlet-2.5/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?rev=419193&r1=419192&r2=419193&view=diff
==============================================================================
--- geronimo/sandbox/servlet-2.5/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(original)
+++ geronimo/sandbox/servlet-2.5/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Wed Jul  5 02:31:58 2006
@@ -55,7 +55,7 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
-import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.schema.SchemaConversionUtilsJavaEE;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 import org.apache.geronimo.security.deployment.SecurityBuilder;
 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientDocument;
@@ -215,7 +215,7 @@
         try {
             // parse it
             XmlObject xmlObject = XmlBeansUtil.parse(specDD);
-            ApplicationClientDocument appClientDoc = SchemaConversionUtils.convertToApplicationClientSchema(xmlObject);
+            ApplicationClientDocument appClientDoc = SchemaConversionUtilsJavaEE.convertToApplicationClientSchema(xmlObject);
             appClient = appClientDoc.getApplicationClient();
         } catch (XmlException e) {
             throw new DeploymentException("Unable to parse application-client.xml", e);
@@ -280,7 +280,7 @@
 
             // if we got one extract the validate it otherwise create a default one
             if (rawPlan != null) {
-                gerAppClient = (GerApplicationClientType) SchemaConversionUtils.fixGeronimoSchema(rawPlan,
GerApplicationClientDocument.type.getDocumentElementName(), GerApplicationClientType.type);
+                gerAppClient = (GerApplicationClientType) SchemaConversionUtilsJavaEE.fixGeronimoSchema(rawPlan,
GerApplicationClientDocument.type.getDocumentElementName(), GerApplicationClientType.type);
             } else {
                 String path;
                 if (standAlone) {

Modified: geronimo/sandbox/servlet-2.5/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/servlet-2.5/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=419193&r1=419192&r2=419193&view=diff
==============================================================================
--- geronimo/sandbox/servlet-2.5/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
(original)
+++ geronimo/sandbox/servlet-2.5/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Wed Jul  5 02:31:58 2006
@@ -80,7 +80,7 @@
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.management.J2EEServer;
 import org.apache.geronimo.management.J2EEResource;
-import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.schema.SchemaConversionUtilsJavaEE;
 import org.apache.geronimo.security.deployment.SecurityBuilder;
 import org.apache.geronimo.security.deployment.SecurityConfiguration;
 import org.apache.geronimo.xbeans.geronimo.j2ee.GerApplicationDocument;
@@ -311,7 +311,7 @@
             //we found something called application.xml in the right place, if we can't parse
it it's an error
             try {
                 XmlObject xmlObject = XmlBeansUtil.parse(specDD);
-                application = SchemaConversionUtils.convertToApplicationSchema(xmlObject).getApplication();
+                application = SchemaConversionUtilsJavaEE.convertToApplicationSchema(xmlObject).getApplication();
             } catch (XmlException e) {
                 throw new DeploymentException("Could not parse application.xml", e);
             }
@@ -324,14 +324,14 @@
             try {
                 if (planFile != null) {
                     rawPlan = XmlBeansUtil.parse(planFile.toURL());
-                    gerApplication = (GerApplicationType) SchemaConversionUtils.fixGeronimoSchema(rawPlan,
APPLICATION_QNAME, GerApplicationType.type);
+                    gerApplication = (GerApplicationType) SchemaConversionUtilsJavaEE.fixGeronimoSchema(rawPlan,
APPLICATION_QNAME, GerApplicationType.type);
                     if (gerApplication == null) {
                         return null;
                     }
                 } else {
                     URL path = DeploymentUtil.createJarURL(earFile, "META-INF/geronimo-application.xml");
                     rawPlan = XmlBeansUtil.parse(path);
-                    gerApplication = (GerApplicationType) SchemaConversionUtils.fixGeronimoSchema(rawPlan,
APPLICATION_QNAME, GerApplicationType.type);
+                    gerApplication = (GerApplicationType) SchemaConversionUtilsJavaEE.fixGeronimoSchema(rawPlan,
APPLICATION_QNAME, GerApplicationType.type);
                 }
             } catch (IOException e) {
                 //TODO isn't this an error?

Modified: geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java?rev=419193&r1=419192&r2=419193&view=diff
==============================================================================
--- geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Wed Jul  5 02:31:58 2006
@@ -23,11 +23,11 @@
 import java.util.Map;
 import javax.xml.namespace.QName;
 
-import org.apache.geronimo.xbeans.javaee.ApplicationClientDocument;
-import org.apache.geronimo.xbeans.javaee.ApplicationDocument;
+import org.apache.geronimo.xbeans.j2ee.ApplicationClientDocument;
+import org.apache.geronimo.xbeans.j2ee.ApplicationDocument;
 import org.apache.geronimo.xbeans.j2ee.ConnectorDocument;
-import org.apache.geronimo.xbeans.javaee.EjbJarDocument;
-import org.apache.geronimo.xbeans.javaee.WebAppDocument;
+import org.apache.geronimo.xbeans.j2ee.EjbJarDocument;
+import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlDocumentProperties;
@@ -40,15 +40,14 @@
  */
 public class SchemaConversionUtils {
     static final String J2EE_NAMESPACE = "http://java.sun.com/xml/ns/j2ee";
-    static final String JAVAEE_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
 
     static final String GERONIMO_NAMING_NAMESPACE = "http://geronimo.apache.org/xml/ns/naming-1.1";
     private static final String GERONIMO_SECURITY_NAMESPACE = "http://geronimo.apache.org/xml/ns/security-1.1";
     private static final String GERONIMO_SERVICE_NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.1";
 
     private static final QName RESOURCE_ADAPTER_VERSION = new QName(J2EE_NAMESPACE, "resourceadapter-version");
-    private static final QName TAGLIB = new QName(JAVAEE_NAMESPACE, "taglib");
-    private static final QName CMP_VERSION = new QName(JAVAEE_NAMESPACE, "cmp-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();
 
@@ -89,12 +88,12 @@
         }
         XmlCursor cursor = xmlObject.newCursor();
         XmlCursor moveable = xmlObject.newCursor();
-        String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/application_5.xsd";
-        String version = "5";
+        String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application_1_4.xsd";
+        String version = "1.4";
         try {
-            convertToSchema(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
+            convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
             cursor.toStartDoc();
-            cursor.toChild(JAVAEE_NAMESPACE, "application");
+            cursor.toChild(J2EE_NAMESPACE, "application");
             cursor.toFirstChild();
             convertToDescriptionGroup(cursor, moveable);
         } finally {
@@ -118,12 +117,12 @@
         }
         XmlCursor cursor = xmlObject.newCursor();
         XmlCursor moveable = xmlObject.newCursor();
-        String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/application-client_5.xsd
";
-        String version = "5";
+        String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd";
+        String version = "1.4";
         try {
-            convertToSchema(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
+            convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
             cursor.toStartDoc();
-            cursor.toChild(JAVAEE_NAMESPACE, "application-client");
+            cursor.toChild(J2EE_NAMESPACE, "application-client");
             cursor.toFirstChild();
             convertToDescriptionGroup(cursor, moveable);
         } finally {
@@ -221,7 +220,7 @@
         //cursor is intially located before the logical STARTDOC token
         try {
             cursor.toFirstChild();
-            if ("http://java.sun.com/xml/ns/javaee".equals(cursor.getName().getNamespaceURI()))
{
+            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
                 XmlObject result = xmlObject.changeType(EjbJarDocument.type);
                 validateDD(result);
                 return (EjbJarDocument) result;
@@ -237,9 +236,9 @@
             } else {
                 throw new XmlException("Unrecognized document type: " + publicId);
             }
-            String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd";
-            String version = "3.0";
-            convertToSchema(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
+            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
+            String version = "2.1";
+            convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
             //play with message-driven
             cursor.toStartDoc();
             convertBeans(cursor, moveable, cmpVersion);
@@ -258,7 +257,6 @@
 
     public static WebAppDocument convertToServletSchema(XmlObject xmlObject) throws XmlException
{
         if (WebAppDocument.type.equals(xmlObject.schemaType())) {
-            System.err.println("DOC Is correct type:"+WebAppDocument.type+" validating");
             validateDD(xmlObject);
             return (WebAppDocument) xmlObject;
         }
@@ -267,14 +265,6 @@
             cursor.toStartDoc();
             cursor.toFirstChild();
             if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
-                System.err.println("DOC Is j2ee type, converting type and validating");
-                XmlObject result = xmlObject.changeType(WebAppDocument.type);
-                validateDD(result);
-                return (WebAppDocument) result;
-            }
-            
-            if ("http://java.sun.com/xml/ns/javaee".equals(cursor.getName().getNamespaceURI()))
{
-                System.err.println("Doc is javaee namespace, converting to type:"+WebAppDocument.type);
                 XmlObject result = xmlObject.changeType(WebAppDocument.type);
                 validateDD(result);
                 return (WebAppDocument) result;
@@ -286,14 +276,13 @@
                     "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId))
{
                 XmlCursor moveable = xmlObject.newCursor();
                 try {
-                    System.err.println("Coverting 2.3 or 2.2 to schema 5");
                     moveable.toStartDoc();
                     moveable.toFirstChild();
-                    String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
-                    String version = "2.5";
-                    convertToSchema(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
+                    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(JAVAEE_NAMESPACE, "web-app");
+                    cursor.toChild(J2EE_NAMESPACE, "web-app");
                     cursor.toFirstChild();
                     convertToDescriptionGroup(cursor, moveable);
                     convertToJNDIEnvironmentRefsGroup(cursor, moveable);
@@ -301,7 +290,7 @@
                     if (cursor.toNextSibling(TAGLIB)) {
                         cursor.toPrevSibling();
                         moveable.toCursor(cursor);
-                        cursor.beginElement("jsp-config", JAVAEE_NAMESPACE);
+                        cursor.beginElement("jsp-config", J2EE_NAMESPACE);
                         while (moveable.toNextSibling(TAGLIB)) {
                             moveable.moveXml(cursor);
                         }
@@ -313,7 +302,7 @@
                             cursor.push();
                             cursor.toFirstChild();
                             convertToDescriptionGroup(cursor, moveable);
-                            while (cursor.toNextSibling(JAVAEE_NAMESPACE, "init-param"))
{
+                            while (cursor.toNextSibling(J2EE_NAMESPACE, "init-param")) {
                                 cursor.push();
                                 cursor.toFirstChild();
                                 convertToDescriptionGroup(cursor, moveable);
@@ -475,22 +464,22 @@
     }
 
     public static void convertBeans(XmlCursor cursor, XmlCursor moveable, String cmpVersion)
{
-        cursor.toChild(JAVAEE_NAMESPACE, "ejb-jar");
-        cursor.toChild(JAVAEE_NAMESPACE, "enterprise-beans");
+        cursor.toChild(J2EE_NAMESPACE, "ejb-jar");
+        cursor.toChild(J2EE_NAMESPACE, "enterprise-beans");
         if (cursor.toFirstChild()) {
             //there's at least one ejb...
             do {
                 cursor.push();
                 String type = cursor.getName().getLocalPart();
                 if ("session".equals(type)) {
-                    cursor.toChild(JAVAEE_NAMESPACE, "transaction-type");
+                    cursor.toChild(J2EE_NAMESPACE, "transaction-type");
                     cursor.toNextSibling();
                     convertToJNDIEnvironmentRefsGroup(cursor, moveable);
                 } else if ("entity".equals(type)) {
-                    cursor.toChild(JAVAEE_NAMESPACE, "persistence-type");
+                    cursor.toChild(J2EE_NAMESPACE, "persistence-type");
                     String persistenceType = cursor.getTextValue();
                     //reentrant is the last required tag before jndiEnvironmentRefsGroup
-                    cursor.toNextSibling(JAVAEE_NAMESPACE, "reentrant");
+                    cursor.toNextSibling(J2EE_NAMESPACE, "reentrant");
                     //Convert 2.0 True/False to true/false for 2.1
                     cursor.setTextValue(cursor.getTextValue().toLowerCase());
                     if (cmpVersion != null && !cursor.toNextSibling(CMP_VERSION)
&& "Container".equals(persistenceType)) {
@@ -498,35 +487,35 @@
                         cursor.insertElementWithText(CMP_VERSION, cmpVersion);
                     }
 
-                    cursor.toNextSibling(JAVAEE_NAMESPACE, "abstract-schema-name");
-                    while (cursor.toNextSibling(JAVAEE_NAMESPACE, "cmp-field")) {
+                    cursor.toNextSibling(J2EE_NAMESPACE, "abstract-schema-name");
+                    while (cursor.toNextSibling(J2EE_NAMESPACE, "cmp-field")) {
                         ;
                     }
-                    cursor.toNextSibling(JAVAEE_NAMESPACE, "primkey-field");
+                    cursor.toNextSibling(J2EE_NAMESPACE, "primkey-field");
                     cursor.toNextSibling();
                     convertToJNDIEnvironmentRefsGroup(cursor, moveable);
                 } else if ("message-driven".equals(type)) {
                     cursor.toFirstChild();
-                    if (cursor.toNextSibling(JAVAEE_NAMESPACE, "messaging-type")) {
-                        cursor.toNextSibling(JAVAEE_NAMESPACE, "transaction-type");
+                    if (cursor.toNextSibling(J2EE_NAMESPACE, "messaging-type")) {
+                        cursor.toNextSibling(J2EE_NAMESPACE, "transaction-type");
                     } else {
-                        cursor.toNextSibling(JAVAEE_NAMESPACE, "transaction-type");
+                        cursor.toNextSibling(J2EE_NAMESPACE, "transaction-type");
                         //insert messaging-type (introduced in EJB 2.1 spec) before transaction-type
-                        cursor.insertElementWithText("messaging-type", JAVAEE_NAMESPACE,
"javax.jms.MessageListener");
+                        cursor.insertElementWithText("messaging-type", J2EE_NAMESPACE, "javax.jms.MessageListener");
                         //cursor still on transaction-type
                     }
-                    if (!cursor.toNextSibling(JAVAEE_NAMESPACE, "activation-config")) {
+                    if (!cursor.toNextSibling(J2EE_NAMESPACE, "activation-config")) {
                         boolean hasProperties = false;
                         //skip transaction-type
                         cursor.toNextSibling();
                         //convert EJB 2.0 elements to activation-config-properties.
                         moveable.toCursor(cursor);
                         cursor.push();
-                        cursor.beginElement("activation-config", JAVAEE_NAMESPACE);
+                        cursor.beginElement("activation-config", J2EE_NAMESPACE);
                         hasProperties |= addActivationConfigProperty(moveable, cursor, "message-selector",
"messageSelector");
                         hasProperties |= addActivationConfigProperty(moveable, cursor, "acknowledge-mode",
"acknowledgeMode");
-                        if (new QName(JAVAEE_NAMESPACE, "message-driven-destination").equals(moveable.getName())
||
-                                moveable.toNextSibling(JAVAEE_NAMESPACE, "message-driven-destination"))
{
+                        if (new QName(J2EE_NAMESPACE, "message-driven-destination").equals(moveable.getName())
||
+                                moveable.toNextSibling(J2EE_NAMESPACE, "message-driven-destination"))
{
                             moveable.push();
                             moveable.toFirstChild();
                             hasProperties |= addActivationConfigProperty(moveable, cursor,
"destination-type", "destinationType");
@@ -554,12 +543,12 @@
     }
 
     private static boolean addActivationConfigProperty(XmlCursor moveable, XmlCursor cursor,
String elementName, String propertyName) {
-        QName name = new QName(JAVAEE_NAMESPACE, elementName);
+        QName name = new QName(J2EE_NAMESPACE, elementName);
         if (name.equals(moveable.getName()) || moveable.toNextSibling(name)) {
             cursor.push();
-            cursor.beginElement("activation-config-property", JAVAEE_NAMESPACE);
-            cursor.insertElementWithText("activation-config-property-name", JAVAEE_NAMESPACE,
propertyName);
-            cursor.insertElementWithText("activation-config-property-value", JAVAEE_NAMESPACE,
moveable.getTextValue());
+            cursor.beginElement("activation-config-property", J2EE_NAMESPACE);
+            cursor.insertElementWithText("activation-config-property-name", J2EE_NAMESPACE,
propertyName);
+            cursor.insertElementWithText("activation-config-property-value", J2EE_NAMESPACE,
moveable.getTextValue());
             moveable.removeXml();
             cursor.pop();
             cursor.toNextSibling();
@@ -619,7 +608,7 @@
     }
 
     private static void moveElements(String localName, XmlCursor moveable, XmlCursor toHere)
{
-        QName name = new QName(JAVAEE_NAMESPACE, localName);
+        QName name = new QName(J2EE_NAMESPACE, localName);
         //skip elements already in the correct order.
         while (name.equals(toHere.getName()) && toHere.toNextSibling()) {
         }

Modified: geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtilsJavaEE.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtilsJavaEE.java?rev=419193&r1=419192&r2=419193&view=diff
==============================================================================
--- geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtilsJavaEE.java
(original)
+++ geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtilsJavaEE.java
Wed Jul  5 02:31:58 2006
@@ -82,11 +82,9 @@
         GERONIMO_SCHEMA_CONVERSIONS.putAll(conversions);
     }
 
+    
     public static ApplicationDocument convertToApplicationSchema(XmlObject xmlObject) throws
XmlException {
-        if (ApplicationDocument.type.equals(xmlObject.schemaType())) {
-            validateDD(xmlObject);
-            return (ApplicationDocument) xmlObject;
-        }
+       
         XmlCursor cursor = xmlObject.newCursor();
         XmlCursor moveable = xmlObject.newCursor();
         String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/application_5.xsd";
@@ -96,20 +94,37 @@
             cursor.toFirstChild();
             if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
                 System.err.println("DOC Is j2ee type, converting type and validating");
+                System.err.println("PRIOR TO CONVERSION: "+xmlObject.toString());
+                System.err.println("____________________________________");
+                convertSchemaVersion(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
+                
+                System.err.println("____________________________________");
+                System.err.println("CONVERSION: "+xmlObject.toString());
+                System.err.println("____________________________________");
                 XmlObject result = xmlObject.changeType(ApplicationDocument.type);
+                System.err.println("AFTER CONVERSION TO APPLICATIONDOCUMENT");
+                System.err.println(result.toString());
                 validateDD(result);
                 return (ApplicationDocument) result;
             }
             
             if ("http://java.sun.com/xml/ns/javaee".equals(cursor.getName().getNamespaceURI()))
{
-                System.err.println("Doc is javaee namespace, converting to type:"+ApplicationDocument.type);
+                System.err.println("Doc is javaee namespace, ensuring full conversion");
+                
+                System.err.println("PRIOR TO CONVERSION: "+xmlObject.toString());
+                System.err.println("____________________________________");
+                convertSchemaVersion(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
+                
+                System.err.println("____________________________________");
+                System.err.println("CONVERSION: "+xmlObject.toString());
+                System.err.println("____________________________________");
                 XmlObject result = xmlObject.changeType(ApplicationDocument.type);
+                System.err.println("AFTER CONVERSION TO APPLICATIONDOCUMENT");
+                System.err.println(result.toString());
                 validateDD(result);
                 return (ApplicationDocument) result;
             }
             
-            XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
-
             convertToSchema(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
             cursor.toStartDoc();
             cursor.toChild(JAVAEE_NAMESPACE, "application");
@@ -138,7 +153,17 @@
         XmlCursor moveable = xmlObject.newCursor();
         String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/application-client_5.xsd
";
         String version = "5";
-        try {
+        try {           
+            cursor.toStartDoc();
+            cursor.toFirstChild();
+            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
+                System.err.println("DOC Is j2ee type, converting type and validating");
+                convertSchemaVersion(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
+                XmlObject result = xmlObject.changeType(ApplicationDocument.type);
+                validateDD(result);
+                return (ApplicationClientDocument) result;
+            }
+            
             convertToSchema(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
             cursor.toStartDoc();
             cursor.toChild(JAVAEE_NAMESPACE, "application-client");
@@ -234,12 +259,16 @@
             validateDD(xmlObject);
             return (EjbJarDocument) xmlObject;
         }
+        String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd";
+        String version = "3.0";
+        
         XmlCursor cursor = xmlObject.newCursor();
         XmlCursor moveable = xmlObject.newCursor();
         //cursor is intially located before the logical STARTDOC token
         try {
             cursor.toFirstChild();
-            if ("http://java.sun.com/xml/ns/javaee".equals(cursor.getName().getNamespaceURI()))
{
+            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
+                convertSchemaVersion(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
                 XmlObject result = xmlObject.changeType(EjbJarDocument.type);
                 validateDD(result);
                 return (EjbJarDocument) result;
@@ -255,8 +284,7 @@
             } else {
                 throw new XmlException("Unrecognized document type: " + publicId);
             }
-            String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd";
-            String version = "3.0";
+
             convertToSchema(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
             //play with message-driven
             cursor.toStartDoc();
@@ -280,12 +308,15 @@
             validateDD(xmlObject);
             return (WebAppDocument) xmlObject;
         }
+        String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
+        String version = "2.5";
         XmlCursor cursor = xmlObject.newCursor();
         try {
             cursor.toStartDoc();
             cursor.toFirstChild();
             if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI()))
{
                 System.err.println("DOC Is j2ee type, converting type and validating");
+                convertSchemaVersion(cursor,JAVAEE_NAMESPACE, schemaLocationURL, version);
                 XmlObject result = xmlObject.changeType(WebAppDocument.type);
                 validateDD(result);
                 return (WebAppDocument) result;
@@ -307,8 +338,7 @@
                     System.err.println("Coverting 2.3 or 2.2 to schema 5");
                     moveable.toStartDoc();
                     moveable.toFirstChild();
-                    String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
-                    String version = "2.5";
+
                     convertToSchema(cursor, JAVAEE_NAMESPACE, schemaLocationURL, version);
                     cursor.toStartDoc();
                     cursor.toChild(JAVAEE_NAMESPACE, "web-app");
@@ -489,6 +519,31 @@
                 cursor.toNextToken();
             }
         }
+        return true;
+    }
+    
+    public static boolean convertSchemaVersion (XmlCursor cursor, String namespace, String
schemaLocationURL, String version) {
+        
+        //convert namespace
+        boolean isFirstStart = true;
+        while (cursor.hasNextToken()) {
+            if (cursor.isStart()) {
+                System.err.println("CURSOR="+cursor.getName().getLocalPart()+" "+cursor.getName().getNamespaceURI());
+                cursor.setName(new QName(namespace, cursor.getName().getLocalPart()));
+                System.err.println("CURSOR="+cursor.getName().getLocalPart()+" "+cursor.getName().getNamespaceURI()+"
"+cursor.getName().getPrefix());               
+                cursor.toNextToken();                
+                if (isFirstStart) {
+                    cursor.removeAttribute(new QName("version"));
+                    //cursor.insertAttributeWithValue(new QName("version"), version);
+                    cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance",
"schemaLocation", "xsi"), namespace + "  "+schemaLocationURL);   
+                    isFirstStart = false;
+                }
+ 
+            } else {
+                cursor.toNextToken();
+            }
+        }
+        
         return true;
     }
 

Modified: geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java?rev=419193&r1=419192&r2=419193&view=diff
==============================================================================
--- geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
(original)
+++ geronimo/sandbox/servlet-2.5/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
Wed Jul  5 02:31:58 2006
@@ -321,14 +321,14 @@
         URL srcXml = classLoader.getResource("j2ee_1_3dtd/web-23.xml");
         URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/web-25.xml");
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
+        xmlObject = SchemaConversionUtilsJavaEE.convertToServletSchema(xmlObject);
         XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
 //        System.out.println(xmlObject.toString());
 //        System.out.println(expected.toString());
         List problems = new ArrayList();
         boolean ok = compareXmlObjects(xmlObject, expected, problems);
         assertTrue("Differences: " + problems, ok);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
+        xmlObject = SchemaConversionUtilsJavaEE.convertToServletSchema(xmlObject);
         boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
         assertTrue("Differences: " + problems, ok2);
     }
@@ -337,13 +337,13 @@
         URL srcXml = classLoader.getResource("j2ee_1_3dtd/web-1-23.xml");
         URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/web-1-25.xml");
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
+        xmlObject = SchemaConversionUtilsJavaEE.convertToServletSchema(xmlObject);
 //        System.out.println(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);
+        xmlObject = SchemaConversionUtilsJavaEE.convertToServletSchema(xmlObject);
         boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
         assertTrue("Differences: " + problems, ok2);
     }
@@ -352,14 +352,14 @@
         URL srcXml = classLoader.getResource("j2ee_1_2dtd/web-1-22.xml");
         URL expectedOutputXml = classLoader.getResource("j2ee_1_2dtd/web-1-25.xml");
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
+        xmlObject = SchemaConversionUtilsJavaEE.convertToServletSchema(xmlObject);
         XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
 //        System.out.println(xmlObject.toString());
 //        System.out.println(expected.toString());
         List problems = new ArrayList();
         boolean ok = compareXmlObjects(xmlObject, expected, problems);
         assertTrue("Differences: " + problems, ok);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
+        xmlObject = SchemaConversionUtilsJavaEE.convertToServletSchema(xmlObject);
         boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
         assertTrue("Differences: " + problems, ok2);
     }
@@ -368,7 +368,7 @@
         URL srcXml = classLoader.getResource("javaee_5schema/web-1-25.xml");
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
         try {
-            xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
+            xmlObject = SchemaConversionUtilsJavaEE.convertToServletSchema(xmlObject);
             fail("doc src/test-data/javaee_5schema/web-1-25.xml is invalid, should not have
validated");
         } catch (XmlException e) {
             //expected
@@ -378,14 +378,14 @@
     public void testParseWeb25() throws Exception {
         URL srcXml = classLoader.getResource("javaee_5schema/web-2-25.xml");
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
+        xmlObject = SchemaConversionUtilsJavaEE.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");
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = SchemaConversionUtils.convertToEJBSchema(xmlObject);
+        xmlObject = SchemaConversionUtilsJavaEE.convertToEJBSchema(xmlObject);
         XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
         List problems = new ArrayList();
         boolean ok = compareXmlObjects(xmlObject, expected, problems);
@@ -399,14 +399,14 @@
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
         XmlCursor cursor = xmlObject.newCursor();
         try {
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+            SchemaConversionUtilsJavaEE.convertToGeronimoSubSchemas(cursor);
                     System.out.println(xmlObject.toString());
             XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
             System.out.println(expected.toString());
             List problems = new ArrayList();
             boolean ok = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok);
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+            SchemaConversionUtilsJavaEE.convertToGeronimoSubSchemas(cursor);
             boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok2);
         } finally {
@@ -419,7 +419,7 @@
 //        URL expectedOutputXml = classLoader.getResource("geronimo/ejb-naming-post.xml");
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
         //this is not a usable type, we'll see what happens though
-        xmlObject = SchemaConversionUtils.getNestedObjectAsType(xmlObject, new QName("http://www.openejb.org/xml/ns/openejb-jar-2.1",
"openejb-jar"), EjbJarType.type);
+        xmlObject = SchemaConversionUtilsJavaEE.getNestedObjectAsType(xmlObject, new QName("http://www.openejb.org/xml/ns/openejb-jar-2.1",
"openejb-jar"), EjbJarType.type);
 //	        System.out.println(xmlObject.toString());
     }
 
@@ -437,7 +437,7 @@
             List problems = new ArrayList();
             boolean ok = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok);
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+            SchemaConversionUtilsJavaEE.convertToGeronimoSubSchemas(cursor);
             boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok2);
         } finally {
@@ -461,7 +461,7 @@
             List problems = new ArrayList();
             boolean ok = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok);
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+            SchemaConversionUtilsJavaEE.convertToGeronimoSubSchemas(cursor);
             boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok2);
         } finally {
@@ -485,7 +485,7 @@
             List problems = new ArrayList();
             boolean ok = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok);
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+            SchemaConversionUtilsJavaEE.convertToGeronimoSubSchemas(cursor);
             boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok2);
         } finally {
@@ -508,7 +508,7 @@
             List problems = new ArrayList();
             boolean ok = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok);
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+            SchemaConversionUtilsJavaEE.convertToGeronimoSubSchemas(cursor);
             boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok2);
         } finally {
@@ -523,14 +523,14 @@
         XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
         XmlCursor cursor = xmlObject.newCursor();
         try {
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+            SchemaConversionUtilsJavaEE.convertToGeronimoSubSchemas(cursor);
                     System.out.println(xmlObject.toString());
             XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
             System.out.println(expected.toString());
             List problems = new ArrayList();
             boolean ok = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok);
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+            SchemaConversionUtilsJavaEE.convertToGeronimoSubSchemas(cursor);
             boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
             assertTrue("Differences: " + problems, ok2);
         } finally {

Modified: geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=419193&r1=419192&r2=419193&view=diff
==============================================================================
--- geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Wed Jul  5 02:31:58 2006
@@ -80,7 +80,7 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
-import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.schema.SchemaConversionUtilsJavaEE;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 import org.apache.geronimo.security.deployment.SecurityBuilder;
 import org.apache.geronimo.security.deployment.SecurityConfiguration;
@@ -201,7 +201,7 @@
         try {
             // parse it
             XmlObject parsed = XmlBeansUtil.parse(specDD);
-            WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(parsed);
+            WebAppDocument webAppDoc = SchemaConversionUtilsJavaEE.convertToServletSchema(parsed);
             webApp = webAppDoc.getWebApp();
         } catch (XmlException xmle) {
             // Output the target path in the error to make it clearer to the user which webapp
@@ -286,7 +286,7 @@
                 XmlObject webPlan = new GenericToSpecificPlanConverter(GerJettyDocument.type.getDocumentElementName().getNamespaceURI(),
                         JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI(),
"jetty").convertToSpecificPlan(rawPlan);
                 jettyWebApp = (JettyWebAppType) webPlan.changeType(JettyWebAppType.type);
-                SchemaConversionUtils.validateDD(jettyWebApp);
+                SchemaConversionUtilsJavaEE.validateDD(jettyWebApp);
             } else {
                 String defaultContextRoot = determineDefaultContextRoot(webApp, standAlone,
moduleFile, targetPath);
                 jettyWebApp = createDefaultPlan(defaultContextRoot);

Modified: geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java?rev=419193&r1=419192&r2=419193&view=diff
==============================================================================
--- geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
(original)
+++ geronimo/sandbox/servlet-2.5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
Wed Jul  5 02:31:58 2006
@@ -13,14 +13,14 @@
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.schema.SchemaConversionUtilsJavaEE;
 import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.config.GerJettyDocument;
-import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
-import org.apache.geronimo.xbeans.j2ee.WebAppType;
+import org.apache.geronimo.xbeans.javaee.WebAppDocument;
+import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 
@@ -117,7 +117,7 @@
         ref.setRefName("ref");
         ref.setResourceLink("target");
 
-        SchemaConversionUtils.validateDD(webApp);
+        SchemaConversionUtilsJavaEE.validateDD(webApp);
         System.out.println(webApp.toString());
     }
 
@@ -204,7 +204,7 @@
         assertTrue(ConvertedPlan != null);
         XmlObject converted = XmlBeansUtil.parse(ConvertedPlan);
         XmlCursor c = converted.newCursor();
-        SchemaConversionUtils.findNestedElement(c, JettyWebAppDocument.type.getDocumentElementName());
+        SchemaConversionUtilsJavaEE.findNestedElement(c, JettyWebAppDocument.type.getDocumentElementName());
         c.toFirstChild();
         ArrayList problems = new ArrayList();
         compareXmlObjects(webPlan, c, problems);

Modified: geronimo/sandbox/servlet-2.5/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/servlet-2.5/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java?rev=419193&r1=419192&r2=419193&view=diff
==============================================================================
--- geronimo/sandbox/servlet-2.5/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java
(original)
+++ geronimo/sandbox/servlet-2.5/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java
Wed Jul  5 02:31:58 2006
@@ -54,6 +54,7 @@
         NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/pkgen", "http://www.openejb.org/xml/ns/pkgen-2.0");
         NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/corba-css-config_1_0", "http://www.openejb.org/xml/ns/corba-css-config-2.0");
         NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/corba-tss-config_1_0", "http://www.openejb.org/xml/ns/corba-tss-config-2.0");
+        NAMESPACE_UPDATES.put("http://java.sun.com/xml/ns/j2ee", "http://java.sun.com/xml/ns/javaee");
     }
 
     private XmlBeansUtil() {



Mime
View raw message