cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r538479 - /incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Date Wed, 16 May 2007 08:36:40 GMT
Author: ema
Date: Wed May 16 01:36:39 2007
New Revision: 538479

URL: http://svn.apache.org/viewvc?view=rev&rev=538479
Log:
Check if the schema import is exist before add to schema 

Modified:
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=538479&r1=538478&r2=538479
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Wed May 16 01:36:39 2007
@@ -76,6 +76,7 @@
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaForm;
 import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaObject;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaSerializer;
 import org.apache.ws.commons.schema.XmlSchemaSerializer.XmlSchemaSerializerException;
@@ -552,7 +553,7 @@
 
             if (mpi.isElement()) {
                 el.setRefName(mpi.getElementQName());
-                String ns = message.getMessageParts().get(0).getElementQName().getNamespaceURI();
+                String ns = mpi.getElementQName().getNamespaceURI();
                 if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NU_SCHEMA_XSD))
{
                     XmlSchemaImport is = new XmlSchemaImport();
                     is.setNamespace(ns);
@@ -560,11 +561,13 @@
                 }
             } else {
                 el.setSchemaTypeName(mpi.getTypeQName());
-                String ns = message.getMessageParts().get(0).getTypeQName().getNamespaceURI();
+                String ns = mpi.getTypeQName().getNamespaceURI();
                 if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NU_SCHEMA_XSD))
{
                     XmlSchemaImport is = new XmlSchemaImport();
-                    is.setNamespace(ns);
-                    schema.getItems().add(is);
+                    is.setNamespace(ns);                   
+                    if (!isExistImport(schema, ns)) {
+                        schema.getItems().add(is);
+                    }
                 }
             }
 
@@ -583,6 +586,23 @@
         }
     }
 
+    private boolean isExistImport(XmlSchema schema, String ns) {
+        boolean isExist = false;
+
+        for (Iterator ite = schema.getItems().getIterator(); ite.hasNext();) {
+            XmlSchemaObject obj = (XmlSchemaObject)ite.next();
+            if (obj instanceof XmlSchemaImport) {
+                XmlSchemaImport xsImport = (XmlSchemaImport)obj;
+                if (xsImport.getNamespace().equals(ns)) {
+                    isExist = true;
+                    break;
+                }
+            }
+        }
+        return isExist;
+
+    }
+    
     private void createWrappedMessageSchema(AbstractMessageContainer wrappedMessage,
                                             AbstractMessageContainer unwrappedMessage, XmlSchema
schema,
                                             QName wrapperName) {



Mime
View raw message