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 2017/03/30 18:47:14 UTC
cxf git commit: [CXF-6717] Fix problem with schemaLocation not
getting properly updated to resolvable schema
Repository: cxf
Updated Branches:
refs/heads/master 1cf17867a -> 28a092319
[CXF-6717] Fix problem with schemaLocation not getting properly updated to resolvable schema
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/28a09231
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/28a09231
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/28a09231
Branch: refs/heads/master
Commit: 28a092319a9223d93bcbd94abd3e9c0a8a54ac09
Parents: 1cf1786
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu Mar 30 14:46:38 2017 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu Mar 30 14:46:38 2017 -0400
----------------------------------------------------------------------
.../org/apache/cxf/frontend/WSDLGetUtils.java | 44 +++++++++++++++++---
1 file changed, 39 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/28a09231/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
index bf0ee17..ff1b254 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
@@ -163,7 +163,8 @@ public class WSDLGetUtils {
return doc;
}
- protected String mapUri(Bus bus, String base, Map<String, SchemaReference> smp, String loc, String xsd)
+ protected String mapUri(Bus bus, String base, Map<String, SchemaReference> smp,
+ String loc, String xsd, String resolvedXsd)
throws UnsupportedEncodingException {
String key = loc;
try {
@@ -172,7 +173,8 @@ public class WSDLGetUtils {
// resolve requested location with relative import path
key = new URI(xsd).resolve(loc).toString();
- if (!smp.containsKey(URLDecoder.decode(key, "utf-8"))) {
+ SchemaReference ref = smp.get(URLDecoder.decode(key, "utf-8"));
+ if (ref == null) {
// if the result is not known, check if we can resolve it into something known
String resolved = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus), key, base);
if (resolved != null && smp.containsKey(URLDecoder.decode(resolved, "utf-8"))) {
@@ -187,6 +189,34 @@ public class WSDLGetUtils {
//ignore
}
SchemaReference ref = smp.get(URLDecoder.decode(key, "utf-8"));
+ if (ref == null && resolvedXsd != null) {
+ try {
+ String key2 = new URI(resolvedXsd).resolve(loc).toString();
+ SchemaReference ref2 = smp.get(URLDecoder.decode(key2, "utf-8"));
+ if (ref2 == null) {
+ // if the result is not known, check if we can resolve it into something known
+ String resolved = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus), key2, base);
+ if (resolved != null && smp.containsKey(URLDecoder.decode(resolved, "utf-8"))) {
+ // if it is resolvable, we can use it
+ ref = smp.get(URLDecoder.decode(resolved, "utf-8"));
+ }
+ } else {
+ ref = smp.get(URLDecoder.decode(key2, "utf-8"));
+ }
+ } catch (URISyntaxException e) {
+ //ignore, ref can remain null
+ }
+ if (ref != null) {
+ // we are able to map this, but for some reason the default key passed in cannot
+ // be used for a direct lookup, we need to create a unique import key
+ int count = 1;
+ while (smp.containsKey("_import" + count + ".xsd")) {
+ count++;
+ }
+ key = "_import" + count + ".xsd";
+ smp.put(key, ref);
+ }
+ }
if (ref != null) {
return base + "?xsd=" + key.replace(" ", "%20");
}
@@ -218,7 +248,7 @@ public class WSDLGetUtils {
"http://www.w3.org/2001/XMLSchema", "import");
for (Element el : elementList) {
String sl = el.getAttribute("schemaLocation");
- sl = mapUri(bus, base, smp, sl, xsdWsdlPar);
+ sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI());
if (sl != null) {
el.setAttribute("schemaLocation", sl);
}
@@ -229,7 +259,7 @@ public class WSDLGetUtils {
"include");
for (Element el : elementList) {
String sl = el.getAttribute("schemaLocation");
- sl = mapUri(bus, base, smp, sl, xsdWsdlPar);
+ sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI());
if (sl != null) {
el.setAttribute("schemaLocation", sl);
}
@@ -239,7 +269,7 @@ public class WSDLGetUtils {
"redefine");
for (Element el : elementList) {
String sl = el.getAttribute("schemaLocation");
- sl = mapUri(bus, base, smp, sl, xsdWsdlPar);
+ sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI());
if (sl != null) {
el.setAttribute("schemaLocation", sl);
}
@@ -534,8 +564,12 @@ public class WSDLGetUtils {
//check to see if it's already in a URL format. If so, leave it.
new URL(start);
} catch (MalformedURLException e) {
+
doneSchemas.put(decodedStart, schemaReference);
doneSchemas.put(schemaReference.getReferencedSchema().getDocumentBaseURI(), schemaReference);
+ if (!doneSchemas.containsKey(decodedOrigLocation)) {
+ doneSchemas.put(decodedOrigLocation, schemaReference);
+ }
try {
if (!(new URI(origLocation).isAbsolute()) && parentResolved != null) {
resolvedSchemaLocation = resolveRelativePath(parentResolved, decodedOrigLocation);