You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by na...@apache.org on 2011/04/13 12:32:15 UTC

svn commit: r1091732 - in /tuscany/sca-java-1.x/trunk: itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/ itest/wsdlgen-verify/src/test/java/wsdlgen/verify/ modules/binding-ws-wsdlgen/src/main/jav...

Author: nash
Date: Wed Apr 13 10:32:15 2011
New Revision: 1091732

URL: http://svn.apache.org/viewvc?rev=1091732&view=rev
Log:
TUSCANY-3859: Update "no namespace" type references in xs:extension schema elements

Added:
    tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/BaseClass.java
    tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ExtClass.java
Modified:
    tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java
    tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java
    tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java
    tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java
    tuscany/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java

Added: tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/BaseClass.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/BaseClass.java?rev=1091732&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/BaseClass.java (added)
+++ tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/BaseClass.java Wed Apr 13 10:32:15 2011
@@ -0,0 +1,46 @@
+/*
+ * 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 wsdlgen.verify;
+
+import java.io.Serializable;
+
+public class BaseClass implements Serializable {
+    private static final long serialVersionUID = -4086312879555658070L;
+
+    private long id;
+
+    private String commentair;
+    
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getCommentair() {
+        return commentair;
+    }
+
+    public void setCommentair(String commentair) {
+        this.commentair = commentair;
+    }
+}

Modified: tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java?rev=1091732&r1=1091731&r2=1091732&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java (original)
+++ tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java Wed Apr 13 10:32:15 2011
@@ -50,6 +50,8 @@ public interface DataTypes {
 
     void testByteArray(byte[] byteArray);
 
+    void testBaseExtension(ExtClass ext);
+
     void testException() throws Exception;
 
     DataObject testDynamicSDO();

Added: tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ExtClass.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ExtClass.java?rev=1091732&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ExtClass.java (added)
+++ tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ExtClass.java Wed Apr 13 10:32:15 2011
@@ -0,0 +1,34 @@
+/*
+ * 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 wsdlgen.verify;
+
+public class ExtClass extends BaseClass {
+    private static final long serialVersionUID = 7076974968473202208L;
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Modified: tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java?rev=1091732&r1=1091731&r2=1091732&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java (original)
+++ tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java Wed Apr 13 10:32:15 2011
@@ -23,8 +23,10 @@ import java.util.List;
 import javax.jws.WebParam;
 import javax.jws.soap.SOAPBinding;
 import commonj.sdo.DataObject;
+import wsdlgen.verify.BaseClass;
 import wsdlgen.verify.ComplexNumber;
 import wsdlgen.verify.DataTypes;
+import wsdlgen.verify.ExtClass;
 
 public class DataTypesImpl implements DataTypes {
 
@@ -62,6 +64,9 @@ public class DataTypesImpl implements Da
     public void testByteArray(byte[] byteArray) {
     }
 
+    public void testBaseExtension(ExtClass ext) {
+    }
+
     public void testException() throws Exception {
     }
 

Modified: tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java?rev=1091732&r1=1091731&r2=1091732&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java (original)
+++ tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java Wed Apr 13 10:32:15 2011
@@ -199,6 +199,16 @@ public class BaseFramework {
         return (Element)childNodes.item(0);
     }
 
+    protected Element extensionElement(Element complexType) {
+        // find xs:complexContent child element
+        NodeList childNodes = complexType.getElementsByTagNameNS(SCHEMA_NS, "complexContent");
+        Element complexContent = (Element)childNodes.item(0);
+
+        // find first xs:extension child element
+        childNodes = complexContent.getElementsByTagNameNS(SCHEMA_NS, "extension");
+        return (Element)childNodes.item(0);
+    }
+
     private static void readWSDL(String serviceName) throws Exception {
         WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
         wsdlReader.setFeature("javax.wsdl.verbose",false);

Modified: tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java?rev=1091732&r1=1091731&r2=1091732&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java (original)
+++ tuscany/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java Wed Apr 13 10:32:15 2011
@@ -107,6 +107,13 @@ public class DataTypesTestCase extends B
     }
 
     @Test
+    public void testBaseExtension() throws Exception {
+        String paramType = parameterType("testBaseExtension");
+        assertEquals("tns:extClass", paramType);
+        assertEquals("tns:baseClass", extensionElement(typeDefinition(paramType)).getAttribute("base"));
+    }
+
+    @Test
     public void testException() throws Exception {
         assertEquals("xs:string", faultType("testException", "Exception"));
     }

Modified: tuscany/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java?rev=1091732&r1=1091731&r2=1091732&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java (original)
+++ tuscany/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java Wed Apr 13 10:32:15 2011
@@ -728,41 +728,56 @@ public class Interface2WSDLGenerator {
 	                _import.getParentNode().removeChild(_import);
 	            }
 	
-	            // look for any type attributes that refer to the 
-	            // node being merged
-	            NodeList elements = refSchema.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema","element");
-	            for (int k = 0; k < elements.getLength(); k++){
-	                Element element = (Element) elements.item(k);
-	                if (element != null && element.getAttributes() != null) {
-	                    Node type = element.getAttributes().getNamedItem("type");
-	                    
-	                    if (type != null &&
-	                        type.getNodeValue().equals(typeName)){
-	                        if (xsDef.getNamespace().equals(defaultNamespace)){
-	                            // double check that there is a "tns" namespace shortname specified
-	                            String tnsNamespace = refSchema.getDocumentElement().getAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
-	                            
-	                            if (tnsNamespace == null || tnsNamespace.length() == 0) {
-	                                refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns", defaultNamespace);
-	                            }
-	                            
-	                            // just add "tns" in front of the type name as
-	                            // we have merged the type into this schema
-	                            type.setNodeValue("tns:" + type.getNodeValue());
-	                        } else {
-	                            // add a namespace 
-	                            refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:__nnns", defaultNamespace);
-	
-	                            // prefix the type name with the namespace
-	                            type.setNodeValue("__nnns:" + type.getNodeValue());
-	                        }
-	                    }
-	                }
-	            }
+	            // TUSCANY-3859: Look for any attributes that refer to the node being merged
+                fixUpNoNamespaceAttributes("element", "type", xsDef, typeName, defaultNamespace);
+                fixUpNoNamespaceAttributes("extension", "base", xsDef, typeName, defaultNamespace);
         	}
         }
     }
 
+    /**
+     * TUSCANY-3859 
+     * Correct any schema attributes that used to point to types in the no namespace schema
+     * 
+     * @param elementName
+     * @param attributeName
+     * @param xsDef
+     * @param defaultNamespace
+     */  
+    private void fixUpNoNamespaceAttributes(String elementName, String attributeName,
+                                            XSDefinition xsDef, String typeName, String defaultNamespace) {
+        Document refSchema = xsDef.getDocument();
+        NodeList elements = refSchema.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", elementName);
+        for (int k = 0; k < elements.getLength(); k++){
+            Element element = (Element) elements.item(k);
+            if (element != null && element.getAttributes() != null) {
+                Node type = element.getAttributes().getNamedItem(attributeName);
+                
+                if (type != null &&
+                    type.getNodeValue().equals(typeName)){
+                    if (xsDef.getNamespace().equals(defaultNamespace)){
+                        // double check that there is a "tns" namespace shortname specified
+                        String tnsNamespace = refSchema.getDocumentElement().getAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
+                        
+                        if (tnsNamespace == null || tnsNamespace.length() == 0) {
+                            refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns", defaultNamespace);
+                        }
+                        
+                        // just add "tns" in front of the type name as
+                        // we have merged the type into this schema
+                        type.setNodeValue("tns:" + type.getNodeValue());
+                    } else {
+                        // add a namespace 
+                        refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:__nnns", defaultNamespace);
+    
+                        // prefix the type name with the namespace
+                        type.setNodeValue("__nnns:" + type.getNodeValue());
+                    }
+                }
+            }
+        }
+    }
+
     /*
      * Just used when debugging DOM problems
      */