Author: dkulp Date: Wed Jul 8 01:26:22 2009 New Revision: 792011 URL: http://svn.apache.org/viewvc?rev=792011&view=rev Log: Merged revisions 791948 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes
................ r791948 | dkulp | 2009-07-07 15:30:14 -0400 (Tue, 07 Jul 2009) | 9 lines Merged revisions 791354 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r791354 | bimargulies | 2009-07-05 20:59:50 -0400 (Sun, 05 Jul 2009) | 1 line CXF-2331: try harder to avoid modifying read-only trees. ........ ................ Modified: cxf/branches/2.1.x-fixes/ (props changed) cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java Propchange: cxf/branches/2.1.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Jul 8 01:26:22 2009 @@ -1,2 +1,2 @@ -/cxf/branches/2.2.x-fixes:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218,776429,776459,777189,777224,777243,777481,777505,777572,777580,780033,780184,780213,780421,780664,780800,780902,780911,781497,781841,782733,782735-782736,783099,783407,784064,784197,785293,785296,785298-785299,785301,785656,786158,786587,786589,786591-786592,786640,787272,787276,787282-787283,787285,787295,787307,787324,7873 67,788824-788825,788827-788828,788830,789423,789429,789707,789709-789710,789712,789721,789905,789908,789910,789912,790295,790646-790647,790651,790654-790655,790659 -/cxf/trunk:782181,782728-782730,783097,783396,784059,784181,784895,785279-785282,785468,786142,786271,786395,786582-786583,786638,786647,787269,787277-787279,787290,787305,787323,787366,788060,788187,788703,788774,788820,789371,789420,789527-789529,789704-789705,789896,789898-789900,790294,790637-790644 +/cxf/branches/2.2.x-fixes:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218,776429,776459,777189,777224,777243,777481,777505,777572,777580,780033,780184,780213,780421,780664,780800,780902,780911,781497,781841,782733,782735-782736,783099,783407,784064,784197,785293,785296,785298-785299,785301,785656,786158,786587,786589,786591-786592,786640,787272,787276,787282-787283,787285,787295,787307,787324,7873 67,788824-788825,788827-788828,788830,789423,789429,789707,789709-789710,789712,789721,789905,789908,789910,789912,790295,790646-790647,790651,790654-790655,790659,791948 +/cxf/trunk:782181,782728-782730,783097,783396,784059,784181,784895,785279-785282,785468,786142,786271,786395,786582-786583,786638,786647,787269,787277-787279,787290,787305,787323,787366,788060,788187,788703,788774,788820,789371,789420,789527-789529,789704-789705,789896,789898-789900,790294,790637-790644,791354 Propchange: cxf/branches/2.1.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java?rev=792011&r1=792010&r2=792011&view=diff ============================================================================== --- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java (original) +++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java Wed Jul 8 01:26:22 2009 @@ -42,16 +42,15 @@ import org.apache.ws.commons.schema.XmlSchema; /** - * Supply default implementations, as appropriate, for DataBinding. + * Supply default implementations, as appropriate, for DataBinding. */ public abstract class AbstractDataBinding implements DataBinding { private static final Map<String, String> BUILTIN_SCHEMA_LOCS = new HashMap<String, String>(); { BUILTIN_SCHEMA_LOCS.put("http://www.w3.org/2005/08/addressing", - "http://www.w3.org/2006/03/addressing/ws-addr.xsd"); + "http://www.w3.org/2006/03/addressing/ws-addr.xsd"); } - - + protected int mtomThreshold; private Collection<DOMSource> schemas; @@ -67,44 +66,69 @@ } public XmlSchema addSchemaDocument(ServiceInfo serviceInfo, SchemaCollection col, Document d, - String systemId) { + String systemId) { String ns = d.getDocumentElement().getAttribute("targetNamespace"); + boolean copied = false; if (StringUtils.isEmpty(ns)) { if (DOMUtils.getFirstElement(d.getDocumentElement()) == null) { hackAroundEmptyNamespaceIssue = true; return null; } - //create a copy of the dom so we - //can modify it. + // create a copy of the dom so we + // can modify it. d = copy(d); + copied = true; ns = serviceInfo.getInterface().getName().getNamespaceURI(); d.getDocumentElement().setAttribute("targetNamespace", ns); } SchemaInfo schemaInfo = serviceInfo.getSchema(ns); - if (schemaInfo != null && (systemId == null && schemaInfo.getSystemId() == null - || systemId != null && systemId.equalsIgnoreCase(schemaInfo.getSystemId()))) { + if (schemaInfo != null + && (systemId == null && schemaInfo.getSystemId() == null || systemId != null + && systemId + .equalsIgnoreCase(schemaInfo + .getSystemId()))) { return schemaInfo.getSchema(); } if (hackAroundEmptyNamespaceIssue) { - d = doEmptyNamespaceHack(d); + d = doEmptyNamespaceHack(d, copied); } Node n = d.getDocumentElement().getFirstChild(); - while (n != null) { + boolean patchRequired = false; + while (n != null) { if (n instanceof Element) { Element e = (Element)n; if (e.getLocalName().equals("import")) { - e.removeAttribute("schemaLocation"); - updateSchemaLocation(e); - if (StringUtils.isEmpty(e.getAttribute("namespace"))) { - e.setAttribute("namespace", serviceInfo.getInterface().getName().getNamespaceURI()); - } + patchRequired = true; + break; } } n = n.getNextSibling(); } + if (patchRequired) { + if (!copied) { + d = copy(d); + } + n = d.getDocumentElement().getFirstChild(); + while (n != null) { + if (n instanceof Element) { + Element e = (Element)n; + if (e.getLocalName().equals("import")) { + e = (Element)n; + e.removeAttribute("schemaLocation"); + updateSchemaLocation(e); + if (StringUtils.isEmpty(e.getAttribute("namespace"))) { + e.setAttribute("namespace", serviceInfo.getInterface().getName() + .getNamespaceURI()); + } + } + } + n = n.getNextSibling(); + } + } + SchemaInfo schema = new SchemaInfo(ns); schema.setSystemId(systemId); XmlSchema xmlSchema; @@ -116,11 +140,12 @@ serviceInfo.addSchema(schema); return xmlSchema; } - private Document doEmptyNamespaceHack(Document d) { + + private Document doEmptyNamespaceHack(Document d, boolean alreadyWritable) { 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; @@ -128,9 +153,11 @@ el = DOMUtils.getNextElement(el); } if (hasStuffToRemove) { - //create a copy of the dom so we - //can modify it. - d = copy(d); + // create a copy of the dom so we + // can modify it. + if (!alreadyWritable) { + d = copy(d); + } el = DOMUtils.getFirstElement(d.getDocumentElement()); while (el != null) { if ("import".equals(el.getLocalName()) @@ -142,7 +169,7 @@ } } } - + return d; } @@ -150,9 +177,9 @@ try { return StaxUtils.copy(doc); } catch (XMLStreamException e) { - //ignore + // ignore } catch (ParserConfigurationException e) { - //ignore + // ignore } return doc; } @@ -166,7 +193,7 @@ } /** - * @return Returns the namespaceMap. + * @return Returns the namespaceMap. */ public Map<String, String> getNamespaceMap() { return namespaceMap; @@ -188,10 +215,9 @@ this.namespaceMap = namespaceMap; } - /** - * Provide explicit mappings to ReflectionServiceFactory. - * {...@inheritdoc} - * */ + /** + * Provide explicit mappings to ReflectionServiceFactory. {...@inheritdoc} + */ public Map<String, String> getDeclaredNamespaceMappings() { return this.namespaceMap; }
