Author: dkulp
Date: Wed Nov 14 14:18:00 2007
New Revision: 595094

URL: http://svn.apache.org/viewvc?rev=595094&view=rev
Log:
Merged revisions 594504 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r594504 | bimargulies | 2007-11-13 07:12:06 -0500 (Tue, 13 Nov 2007) | 11 
lines
  
  
  Fix some cases in RSFB where it added global XmlSchema items to the
  schema collection's 'table of all items' but not to the specific lists
  of elements or types. Add utility functions to make this harder to
  mess up. PMD comes when I can think it through. Add a visitor to
  validate all the cross-references in the service model and the end of
  the construction process. This overlapa a dkulp thing that I noticed
  belatedly, we'll have to sort out whose to keep. This one logs all its
  complaints, of which it sadly has a number.
........

Added:
    
incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/InvalidXmlSchemaReferenceException.java
      - copied unchanged from r594504, 
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/InvalidXmlSchemaReferenceException.java
    
incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/service/ServiceModelSchemaValidator.java
      - copied unchanged from r594504, 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceModelSchemaValidator.java
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    
incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
    
incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java?rev=595094&r1=595093&r2=595094&view=diff
==============================================================================
--- 
incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
 (original)
+++ 
incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
 Wed Nov 14 14:18:00 2007
@@ -157,4 +157,47 @@
         StringReader reader = new 
StringReader(tinyXmlSchemaDocument.toString());
         return schemaCollection.read(reader, new ValidationEventHandler() { });
     }
+
+    /**
+     * Validate that a qualified name points to some namespace in the schema.
+     * @param qname
+     */
+    public void validateQNameNamespace(QName qname) {
+        // astonishingly, xmlSchemaCollection has no accessor by target URL.
+        for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
+            if (schema.getTargetNamespace().equals(qname.getNamespaceURI())) {
+                return;
+            }
+        }
+        throw new InvalidXmlSchemaReferenceException(qname + " refers to 
unknown namespace.");
+    }
+
+    public void validateElementName(QName referrer, QName elementQName) {
+        XmlSchemaElement element = 
schemaCollection.getElementByQName(elementQName);
+        if (element == null) {
+            throw new InvalidXmlSchemaReferenceException(referrer 
+                                                         + " references "
+                                                         + elementQName);
+        }
+    }
+
+    public void validateTypeName(QName referrer, QName typeQName) {
+        XmlSchemaType type = schemaCollection.getTypeByQName(typeQName);
+        if (type == null) {
+            throw new InvalidXmlSchemaReferenceException(referrer 
+                                                         + " references "
+                                                         + typeQName);
+        }
+    }
+    
+    public static void addGlobalElementToSchema(XmlSchema schema, 
XmlSchemaElement element) {
+        schema.getItems().add(element);
+        // believe it or not, it is up to us to do both of these adds!
+        schema.getElements().add(element.getQName(), element);
+    }
+    
+    public static void addGlobalTypeToSchema(XmlSchema schema, XmlSchemaType 
type) {
+        schema.getItems().add(type);
+        schema.addType(type);
+    }
 }

Modified: 
incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=595094&r1=595093&r2=595094&view=diff
==============================================================================
--- 
incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
 (original)
+++ 
incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
 Wed Nov 14 14:18:00 2007
@@ -59,6 +59,7 @@
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.ServiceImpl;
+import org.apache.cxf.service.ServiceModelSchemaValidator;
 import org.apache.cxf.service.invoker.ApplicationScopePolicy;
 import org.apache.cxf.service.invoker.FactoryInvoker;
 import org.apache.cxf.service.invoker.Invoker;
@@ -320,6 +321,12 @@
                 }
             }
         }
+        ServiceModelSchemaValidator validator = new 
ServiceModelSchemaValidator(serviceInfo);
+        validator.walk();
+        String validationComplaints = validator.getComplaints();
+        if (!"".equals(validationComplaints)) {
+            LOG.info(validationComplaints);
+        }
     }
 
 
@@ -632,7 +639,7 @@
         el.setQName(mpi.getElementQName());
         el.setName(mpi.getElementQName().getLocalPart());
         if (!isExistSchemaElement(schema, mpi.getElementQName())) {
-            schema.getItems().add(el);
+            SchemaCollection.addGlobalElementToSchema(schema, el);
         }
         el.setMinOccurs(1);
         el.setMaxOccurs(0);
@@ -741,8 +748,7 @@
             el.setNillable(true);
             
             if (!isExistSchemaElement(schema, qname)) {
-                schema.getItems().add(el);
-                schema.getElements().add(qname, el);
+                SchemaCollection.addGlobalElementToSchema(schema, el);
             } else {
                 el = getExistingSchemaElement(schema, qname);    
             }
@@ -828,7 +834,7 @@
         XmlSchemaElement el = new XmlSchemaElement();
         el.setQName(wrapperName);
         el.setName(wrapperName.getLocalPart());
-        schema.getItems().add(el);
+        SchemaCollection.addGlobalElementToSchema(schema, el);
 
         wrappedMessage.getMessageParts().get(0).setXmlSchema(el);
 
@@ -836,9 +842,8 @@
         
         if (!isAnonymousWrapperTypes()) {
             ct.setName(wrapperName.getLocalPart());
-            el.setSchemaTypeName(wrapperName);            
-            schema.addType(ct);
-            schema.getItems().add(ct);
+            el.setSchemaTypeName(wrapperName);
+            SchemaCollection.addGlobalTypeToSchema(schema, ct);
         }
         el.setSchemaType(ct);
 
@@ -1079,6 +1084,7 @@
         }
         if (part.getElementQName() == null) {
             part.setElementQName(inMsg.getName());
+//Benson            checkForElement(op.getInterface().getService(), part);
         } else if (!part.getElementQName().equals(op.getInput().getName())) {
             op.getInput().setName(part.getElementQName());
         }


Reply via email to