Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 5968 invoked from network); 14 Nov 2007 22:18:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Nov 2007 22:18:25 -0000 Received: (qmail 79123 invoked by uid 500); 14 Nov 2007 22:18:13 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 79022 invoked by uid 500); 14 Nov 2007 22:18:12 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 79013 invoked by uid 99); 14 Nov 2007 22:18:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Nov 2007 14:18:12 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Nov 2007 22:18:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 487CB1A9832; Wed, 14 Nov 2007 14:18:04 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r595094 - in /incubator/cxf/branches/2.0.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/xmlschema/ rt/core/src/main/java/org/apache/cxf/service/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ Date: Wed, 14 Nov 2007 22:18:03 -0000 To: cxf-commits@incubator.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071114221804.487CB1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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()); }