incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmidd...@apache.org
Subject svn commit: r555933 - /incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java
Date Fri, 13 Jul 2007 11:21:30 GMT
Author: dmiddlem
Date: Fri Jul 13 04:21:29 2007
New Revision: 555933

URL: http://svn.apache.org/viewvc?view=rev&rev=555933
Log:
Commit for YOKO-367:
- fixing a bug with object reference generation in WSDL to IDL when using a WSDL
  which is not wrapped doc-lit.

Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java?view=diff&rev=555933&r1=555932&r2=555933
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java
Fri Jul 13 04:21:29 2007
@@ -37,6 +37,7 @@
 import org.apache.schemas.yoko.bindings.corba.ParamType;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAnnotation;
+import org.apache.ws.commons.schema.XmlSchemaAppInfo;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaImport;
@@ -141,7 +142,8 @@
             while (i.hasNext()) {
                 Part part = (Part) i.next();
                 XmlSchemaType schemaType = null;
-                if (part.getElementName() != null) {
+                boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
+                if (part.getElementName() != null && !isObjectRef) {
                     XmlSchemaElement el = getElement(part, xmlSchemaList);
                     if ((el != null) && (el.getSchemaType() != null)) {
                         schemaType = el.getSchemaType();
@@ -163,9 +165,13 @@
                     }
                 } else if (part.getTypeName() != null) {
                     schemaType = getType(part, xmlSchemaList);
+                    QName typeName = part.getTypeName();
+                    if (isObjectRef) {
+                        typeName = part.getElementName();
+                    }
                     QName idltype = getIdlType(wsdlToCorbaBinding,
                                                schemaType,
-                                               part.getTypeName(),
+                                               typeName,
                                                false);
                     ParamType paramtype = createParam(wsdlToCorbaBinding,
                                                       "in",
@@ -266,10 +272,11 @@
                 // check if in input list
                 String mode = "out";
                 ParamType paramtype = null;
+                boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
                 for (int x = 0; x < inputs.size(); x++) {
                     paramtype = null;
                     ParamType d2 = (ParamType) inputs.get(x);
-                    if (part.getElementName() != null) {
+                    if (part.getElementName() != null && !isObjectRef) {
                         XmlSchemaElement el = getElement(part,
                                                          xmlSchemaList);
                         if (el != null && el.getSchemaType() != null) {
@@ -294,9 +301,13 @@
                         }
                     } else {
                         schemaType = getType(part, xmlSchemaList);
+                        QName typeName = part.getTypeName();
+                        if (isObjectRef) {
+                            typeName = part.getElementName();
+                        }
                         QName idltype = getIdlType(wsdlToCorbaBinding,
                                                    schemaType,
-                                                   part.getTypeName(),
+                                                   typeName,
                                                    false);
                         if ((d2.getName().equals(part.getName()))
                             && (d2.getIdltype().equals(idltype))) {
@@ -310,7 +321,7 @@
                     }
                 }
                 if (paramtype == null) {
-                    if (part.getElementName() != null) {
+                    if (part.getElementName() != null && !isObjectRef) {
                         XmlSchemaElement el = getElement(part, xmlSchemaList);
                         QName typeName = el.getSchemaTypeName();
                         if (typeName == null) {
@@ -325,9 +336,13 @@
                                                 part.getName(),
                                                 idltype);
                     } else {
+                        QName typeName = part.getTypeName();
+                        if (isObjectRef) {
+                            typeName = part.getElementName();
+                        }
                         QName idltype = getIdlType(wsdlToCorbaBinding,
                                                    schemaType,
-                                                   part.getTypeName(),
+                                                   typeName,
                                                    false);
                         paramtype = createParam(wsdlToCorbaBinding,
                                                 mode,
@@ -501,7 +516,7 @@
             // This is used to produce the correct object reference type.
             XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
             XmlSchemaAnnotation annotation = null;
-            if (schemaObj != null && schemaObj instanceof XmlSchemaElement) {
+            if (schemaObj instanceof XmlSchemaElement) {
                 annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
             }
             idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType,
@@ -691,5 +706,28 @@
         return false;
     }
 
+    private boolean isObjectReference(List<XmlSchema> schemaList, QName name) {
+        int length = schemaList.size();
+
+        for (int i = 0; i < length; ++i) {
+            XmlSchema schema = schemaList.get(i);
+            XmlSchemaElement element = schema.getElementByName(name);
+            if (element != null) {
+                XmlSchemaAnnotation annotation = element.getAnnotation();
+                if (annotation != null) {
+                    XmlSchemaObjectCollection annotationColl = annotation.getItems();
+                    Iterator annotationIter = annotationColl.getIterator();
+                    while (annotationIter.hasNext()) {
+                        Object o = annotationIter.next();
+                        if (o instanceof XmlSchemaAppInfo) {
+                            return true;
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
 
 }



Mime
View raw message