cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r835911 - in /cxf/trunk: api/src/main/java/org/apache/cxf/wsdl/ common/common/src/main/java/org/apache/cxf/helpers/ common/common/src/main/java/org/apache/cxf/staxutils/ rt/core/src/main/java/org/apache/cxf/transport/http/ rt/core/src/main/...
Date Fri, 13 Nov 2009 16:48:25 GMT
Author: dkulp
Date: Fri Nov 13 16:48:24 2009
New Revision: 835911

URL: http://svn.apache.org/viewvc?rev=835911&view=rev
Log:
Try/catch around some DOM level 3 things that we can safely ignore

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
    cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
    cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java Fri Nov 13
16:48:24 2009
@@ -528,7 +528,11 @@
                     
                     if (null != node) {
                         if (node instanceof Document) {
-                            ((Document)node).setDocumentURI(source.getSystemId());
+                            try {
+                                ((Document)node).setDocumentURI(source.getSystemId());
+                            } catch (Exception ex) {
+                                //ignore - not DOM level 3
+                            }
                             node =  node.getFirstChild();
                         }
                         
@@ -592,7 +596,12 @@
             try {
                 for (SchemaInfo si : serviceInfo.getSchemas()) {
                     Element el = si.getElement();
-                    String baseURI = el.getBaseURI();
+                    String baseURI = null;
+                    try {
+                        baseURI = el.getBaseURI();
+                    } catch (Exception ex) {
+                        //ignore - not DOM level 3
+                    }
                     if (baseURI == null) {
                         baseURI = si.getSystemId();
                     }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java Fri Nov 13
16:48:24 2009
@@ -165,7 +165,11 @@
         String enc = null;
         if (src instanceof DOMSource
             && ((DOMSource)src).getNode() instanceof Document) {
-            enc = ((Document)((DOMSource)src).getNode()).getXmlEncoding();
+            try {
+                enc = ((Document)((DOMSource)src).getNode()).getXmlEncoding();
+            } catch (Exception ex) {
+                //ignore - not DOM level 3
+            }
         }
         writeTo(src, os, indent, enc, "no");
     }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Fri Nov
13 16:48:24 2009
@@ -382,7 +382,11 @@
         W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
         copy(reader, writer);
         Document d = writer.getDocument();
-        d.setDocumentURI(doc.getDocumentURI());
+        try {
+            d.setDocumentURI(doc.getDocumentURI());
+        } catch (Exception ex) {
+            //ignore - probably not DOM level 3
+        }
         return d;
     }
     public static void copy(Document doc, XMLStreamWriter writer) throws XMLStreamException
{
@@ -742,7 +746,11 @@
     public static Document read(XMLStreamReader reader, boolean recordLoc) throws XMLStreamException
{
         Document doc = DOMUtils.createDocument();
         if (reader.getLocation().getSystemId() != null) {
-            doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+            try {
+                doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+            } catch (Exception e) {
+                //ignore - probably not DOM level 3
+            }
         }
         readDocElements(doc, doc, reader, true, recordLoc);
         return doc;
@@ -752,7 +760,11 @@
         throws XMLStreamException {
         Document doc = builder.newDocument();
         if (reader.getLocation().getSystemId() != null) {
-            doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+            try {
+                doc.setDocumentURI(new String(reader.getLocation().getSystemId()));
+            } catch (Exception e) {
+                //ignore - probably not DOM level 3
+            }
         }
         readDocElements(doc, reader, repairing);
         return doc;
@@ -784,7 +796,7 @@
             e.setPrefix(reader.getPrefix());
         }       
         e = (Element)parent.appendChild(e);
-        addLocation(doc, e, reader, recordLocation);
+        recordLocation = addLocation(doc, e, reader, recordLocation);
 
         for (int ns = 0; ns < reader.getNamespaceCount(); ns++) {
             String uri = reader.getNamespaceURI(ns);
@@ -867,8 +879,9 @@
                 break;
             case XMLStreamConstants.CHARACTERS:
                 if (parent != null) {
-                    addLocation(doc, parent.appendChild(doc.createTextNode(reader.getText())),
-                                reader, recordLoc);
+                    recordLoc = addLocation(doc, 
+                                            parent.appendChild(doc.createTextNode(reader.getText())),
+                                            reader, recordLoc);
                 }
                 break;
             case XMLStreamConstants.COMMENT:
@@ -877,8 +890,9 @@
                 }
                 break;
             case XMLStreamConstants.CDATA:
-                addLocation(doc, parent.appendChild(doc.createCDATASection(reader.getText())),
-                            reader, recordLoc);
+                recordLoc = addLocation(doc, 
+                                        parent.appendChild(doc.createCDATASection(reader.getText())),
+                                        reader, recordLoc);
                 break;
             case XMLStreamConstants.PROCESSING_INSTRUCTION:
                 parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(),
reader.getPIData()));
@@ -895,43 +909,49 @@
             }
         }
     }
-    private static void addLocation(Document doc, Node node, 
+    private static boolean addLocation(Document doc, Node node, 
                                     XMLStreamReader reader,
                                     boolean recordLoc) {
         if (recordLoc) {
             Location loc = reader.getLocation();
             if (loc != null && (loc.getColumnNumber() != 0 || loc.getLineNumber()
!= 0)) {
-                final int charOffset = loc.getCharacterOffset();
-                final int colNum = loc.getColumnNumber();
-                final int linNum = loc.getLineNumber();
-                final String pubId = loc.getPublicId() == null ? doc.getDocumentURI() : loc.getPublicId();
-                final String sysId = loc.getSystemId() == null ? doc.getDocumentURI() : loc.getSystemId();
-                Location loc2 = new Location() {
-                    public int getCharacterOffset() {
-                        return charOffset;
-                    }
-                    public int getColumnNumber() {
-                        return colNum;
-                    }
-                    public int getLineNumber() {
-                        return linNum;
-                    }
-                    public String getPublicId() {
-                        return pubId;
-                    }
-                    public String getSystemId() {
-                        return sysId;
-                    }
-                };
-                node.setUserData("location", loc2, new UserDataHandler() {
-                    public void handle(short operation, String key, Object data, Node src,
Node dst) {
-                        if (operation == NODE_CLONED) {
-                            dst.setUserData(key, data, this);
+                try {
+                    final int charOffset = loc.getCharacterOffset();
+                    final int colNum = loc.getColumnNumber();
+                    final int linNum = loc.getLineNumber();
+                    final String pubId = loc.getPublicId() == null ? doc.getDocumentURI()
: loc.getPublicId();
+                    final String sysId = loc.getSystemId() == null ? doc.getDocumentURI()
: loc.getSystemId();
+                    Location loc2 = new Location() {
+                        public int getCharacterOffset() {
+                            return charOffset;
                         }
-                    }
-                });
+                        public int getColumnNumber() {
+                            return colNum;
+                        }
+                        public int getLineNumber() {
+                            return linNum;
+                        }
+                        public String getPublicId() {
+                            return pubId;
+                        }
+                        public String getSystemId() {
+                            return sysId;
+                        }
+                    };
+                    node.setUserData("location", loc2, new UserDataHandler() {
+                        public void handle(short operation, String key, Object data, Node
src, Node dst) {
+                            if (operation == NODE_CLONED) {
+                                dst.setUserData(key, data, this);
+                            }
+                        }
+                    });
+                } catch (Exception ex) {
+                    //possibly not DOM level 3, won't be able to record this then
+                    return false;
+                }
             }
         }
+        return recordLoc;
     }
 
     private static void declare(Element node, String uri, String prefix) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
Fri Nov 13 16:48:24 2009
@@ -393,9 +393,13 @@
         throw new UnsupportedOperationException();
     }   
     public Location getLocation() {
-        Object o = getCurrentNode().getUserData("location");
-        if (o instanceof Location) { 
-            return (Location)o;
+        try {
+            Object o = getCurrentNode().getUserData("location");
+            if (o instanceof Location) { 
+                return (Location)o;
+            }
+        } catch (Exception ex) {
+            //ignore, probably not DOM level 3
         }
         return super.getLocation();
     }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
Fri Nov 13 16:48:24 2009
@@ -251,11 +251,19 @@
     }
 
     public void writeStartDocument(String version) throws XMLStreamException {
-        document.setXmlVersion(version);
+        try {
+            document.setXmlVersion(version);
+        } catch (Exception ex) {
+            //ignore - likely not DOM level 3
+        }
     }
 
     public void writeStartDocument(String encoding, String version) throws XMLStreamException
{
-        document.setXmlVersion(version);
+        try {
+            document.setXmlVersion(version);
+        } catch (Exception ex) {
+            //ignore - likely not DOM level 3
+        }
     }
 
     public void writeCharacters(String text) throws XMLStreamException {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java Fri
Nov 13 16:48:24 2009
@@ -210,7 +210,12 @@
             }
             
             updateDoc(doc, base, mp, smp, endpointInfo);
-            String enc = doc.getXmlEncoding();
+            String enc = null;
+            try {
+                enc = doc.getXmlEncoding();
+            } catch (Exception ex) {
+                //ignore - not dom level 3
+            }
             if (enc == null) {
                 enc = "utf-8";
             }
@@ -287,8 +292,11 @@
                 }
             }
         }
-        
-        doc.setXmlStandalone(true);
+        try {
+            doc.setXmlStandalone(true);
+        } catch (Exception ex) {
+            //likely not DOM level 3
+        }
     }
 
     static String resolveWithCatalogs(OASISCatalogManager catalogs, String start, String
base) {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java Fri Nov 13
16:48:24 2009
@@ -223,7 +223,11 @@
         try {
             doc = StaxUtils.read(StaxUtils.createXMLStreamReader(src), true);
             if (src.getSystemId() != null) {
-                doc.setDocumentURI(new String(src.getSystemId()));
+                try {
+                    doc.setDocumentURI(new String(src.getSystemId()));
+                } catch (Exception e) {
+                    // ignore - probably not DOM level 3
+                }
             }
         } catch (Exception e) {
             throw new WSDLException(WSDLException.PARSER_ERROR, e.getMessage(), e);

Modified: cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
(original)
+++ cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
Fri Nov 13 16:48:24 2009
@@ -220,8 +220,12 @@
         for (Document doc : docs) {
             Node node = (Node) xpather.getValue(fNode.toString(), doc, XPathConstants.NODE);
             if (null != node) {
-                return new FailureLocation((Location)node.getUserData("location"),
-                                           doc.getDocumentURI());
+                try {
+                    return new FailureLocation((Location)node.getUserData("location"),
+                                               doc.getDocumentURI());
+                } catch (Exception ex) {
+                    //ignore, probably not DOM level 3
+                }
             }
         }
         return null;

Modified: cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Fri Nov 13 16:48:24 2009
@@ -390,7 +390,13 @@
                 Element ele = docs[0].getDocumentElement();
                 ele = removeImportElement(ele);
                 if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
-                    validateSchema(ele, docs[0].getDocumentURI());
+                    String uri = null;
+                    try {
+                        uri = docs[0].getDocumentURI();
+                    } catch (Exception ex) {
+                        //ignore - DOM level 3
+                    }
+                    validateSchema(ele, uri);
                 }           
                 InputSource is = new InputSource((InputStream)null);
                 //key = key.replaceFirst("#types[0-9]+$", "");

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=835911&r1=835910&r2=835911&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
Fri Nov 13 16:48:24 2009
@@ -151,12 +151,16 @@
         
         try {
             doc = DOMUtils.readXml(ins);
-            doc.setDocumentURI(uri);
         } catch (Exception e) {
             Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {uri});
             throw new ToolException(msg, e);
         }
-
+        try {
+            doc.setDocumentURI(uri);
+        } catch (Exception ex) {
+            //ignore - probably not DOM level 3
+        }
+        
         if (doc != null) {
             return doc.getDocumentElement();
         }



Mime
View raw message