You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/09/07 20:43:12 UTC

svn commit: r993464 - in /cxf/branches/2.2.x-fixes: ./ api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java

Author: dkulp
Date: Tue Sep  7 18:43:12 2010
New Revision: 993464

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

........
  r992605 | bimargulies | 2010-09-04 10:05:21 -0400 (Sat, 04 Sep 2010) | 2 lines
  
  Add some sanity checks to AbstractDataBinding.addSchemaDocument. Something is rotten, and this will help find out what.
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java

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

Modified: cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java?rev=993464&r1=993463&r2=993464&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java (original)
+++ cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java Tue Sep  7 18:43:12 2010
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Set;
 
 import javax.annotation.Resource;
+import javax.xml.XMLConstants;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMSource;
@@ -69,7 +70,7 @@ public abstract class AbstractDataBindin
 
     /**
      * This call is used to set the bus. It should only be called once.
-     * 
+     *
      * @param bus
      */
     @Resource(name = "cxf")
@@ -88,6 +89,23 @@ public abstract class AbstractDataBindin
 
     public XmlSchema addSchemaDocument(ServiceInfo serviceInfo, SchemaCollection col, Document d,
                                        String systemId) {
+
+
+        /*
+         * Sanity check. The document has to remotely resemble a schema.
+         */
+        if (!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(d.getDocumentElement().getNamespaceURI())) {
+            throw new RuntimeException("Invalid schema document passed to "
+                                       + "AbstractDataBinding.addSchemaDocument, "
+                                       + "not in W3C schema namespace");
+        }
+
+        if (!"schema".equals(d.getDocumentElement().getLocalName())) {
+            throw new RuntimeException("Invalid schema document passed to "
+                                       + "AbstractDataBinding.addSchemaDocument, "
+                                       + "document element isn't 'schema'");
+        }
+
         String ns = d.getDocumentElement().getAttribute("targetNamespace");
         boolean copied = false;
 
@@ -129,7 +147,7 @@ public abstract class AbstractDataBindin
             }
             n = n.getNextSibling();
         }
-        
+
         if (patchRequired) {
             if (!copied) {
                 d = copy(d);
@@ -168,7 +186,7 @@ public abstract class AbstractDataBindin
         boolean hasStuffToRemove = false;
         Element el = DOMUtils.getFirstElement(d.getDocumentElement());
         while (el != null) {
-            if ("import".equals(el.getLocalName()) 
+            if ("import".equals(el.getLocalName())
                 && StringUtils.isEmpty(el.getAttribute("targetNamespace"))) {
                 hasStuffToRemove = true;
                 break;
@@ -216,7 +234,7 @@ public abstract class AbstractDataBindin
     }
 
     /**
-     * @return the namespaceMap (URI to prefix). This will be null 
+     * @return the namespaceMap (URI to prefix). This will be null
      * if no particular namespace map has been set.
      */
     public Map<String, String> getNamespaceMap() {
@@ -224,9 +242,9 @@ public abstract class AbstractDataBindin
     }
 
     /**
-     * Set a map of from URI to prefix. If possible, the data binding will use these 
+     * Set a map of from URI to prefix. If possible, the data binding will use these
      * prefixes on the wire.
-     * 
+     *
      * @param namespaceMap The namespaceMap to set.
      */
     public void setNamespaceMap(Map<String, String> namespaceMap) {