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 2015/02/09 19:29:44 UTC

[6/7] cxf git commit: CXF-6234 - Ensure imported schema locations are resolved correctly Fix checkstyle errors This closes #51

CXF-6234 - Ensure imported schema locations are resolved correctly
Fix checkstyle errors
This closes #51


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ab2c01ac
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ab2c01ac
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ab2c01ac

Branch: refs/heads/2.7.x-fixes
Commit: ab2c01ac4a79db84f5293a23888838abe749578b
Parents: bfbce4b
Author: Mustafa Musaji <mm...@redhat.com>
Authored: Mon Feb 2 10:28:32 2015 +0000
Committer: Daniel Kulp <dk...@apache.org>
Committed: Mon Feb 9 13:15:35 2015 -0500

----------------------------------------------------------------------
 .../org/apache/cxf/frontend/WSDLGetUtils.java   | 47 ++++++++++++++++----
 1 file changed, 39 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ab2c01ac/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 5539afa..57f178a 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
@@ -393,7 +393,7 @@ public class WSDLGetUtils {
                 : CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class)) {
                 if (el instanceof Schema) {
                     Schema see = (Schema)el;
-                    updateSchemaImports(bus, see, see.getDocumentBaseURI(), doneSchemas, base);
+                    updateSchemaImports(bus, see, see.getDocumentBaseURI(), doneSchemas, base, null);
                 }
             }
         }
@@ -450,7 +450,8 @@ public class WSDLGetUtils {
                                        Schema schema,
                                        String docBase,
                                        Map<String, SchemaReference> doneSchemas,
-                                       String base) {
+                                       String base,
+                                       String parent) {
         OASISCatalogManager catalogs = OASISCatalogManager.getCatalogManager(bus);
         Collection<List<?>>  imports = CastUtils.cast((Collection<?>)schema.getImports().values());
         for (List<?> lst : imports) {
@@ -482,14 +483,29 @@ public class WSDLGetUtils {
                                 new URL(start);
                             } catch (MalformedURLException e) {
                                 if (doneSchemas.put(decodedStart, imp) == null) {
-                                    updateSchemaImports(bus, imp.getReferencedSchema(), docBase, doneSchemas, base);
+                                    try {
+                                        //CHECKSTYLE:OFF:NestedIfDepth
+                                        if (!(new URI(decodedStart).isAbsolute()) && parent != null) {
+                                            resolvedSchemaLocation = new URI(parent).resolve(decodedStart).toString();
+                                            decodedStart = URLDecoder.decode(resolvedSchemaLocation, "utf-8");
+                                            doneSchemas.put(resolvedSchemaLocation, imp);
+                                        }
+                                        //CHECKSTYLE:ON:NestedIfDepth 
+                                    } catch (URISyntaxException ex) {
+                                        // ignore
+                                    } catch (UnsupportedEncodingException ex) {
+                                        // ignore
+                                    }
+                                    updateSchemaImports(bus, imp.getReferencedSchema(), docBase,
+                                                        doneSchemas, base, decodedStart);
                                 }
                             }
                         } else {
                             if (doneSchemas.put(decodedStart, imp) == null) {
                                 doneSchemas.put(resolvedSchemaLocation, imp);
                                 doneSchemas.put(imp.getSchemaLocationURI(), imp);
-                                updateSchemaImports(bus, imp.getReferencedSchema(), docBase, doneSchemas, base);
+                                updateSchemaImports(bus, imp.getReferencedSchema(), docBase,
+                                                    doneSchemas, base, decodedStart);
                             }
                         }
                     }
@@ -522,7 +538,8 @@ public class WSDLGetUtils {
                             new URL(start);
                         } catch (MalformedURLException e) {
                             if (doneSchemas.put(decodedStart, included) == null) {
-                                updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
+                                updateSchemaImports(bus, included.getReferencedSchema(), 
+                                                    docBase, doneSchemas, base, decodedStart);
                             }
                         }
                     }
@@ -530,7 +547,7 @@ public class WSDLGetUtils {
                     || !doneSchemas.containsKey(resolvedSchemaLocation)) {
                     doneSchemas.put(decodedStart, included);
                     doneSchemas.put(resolvedSchemaLocation, included);
-                    updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
+                    updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base, decodedStart);
                 }
             }
         }
@@ -559,7 +576,21 @@ public class WSDLGetUtils {
                             new URL(start);
                         } catch (MalformedURLException e) {
                             if (doneSchemas.put(decodedStart, included) == null) {
-                                updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
+                                try {
+                                    //CHECKSTYLE:OFF:NestedIfDepth
+                                    if (!(new URI(decodedStart).isAbsolute()) && parent != null) {
+                                        resolvedSchemaLocation = new URI(parent).resolve(decodedStart).toString();
+                                        decodedStart = URLDecoder.decode(resolvedSchemaLocation, "utf-8");
+                                        doneSchemas.put(resolvedSchemaLocation, included);
+                                    }
+                                    //CHECKSTYLE:ON:NestedIfDepth
+                                } catch (URISyntaxException ex) {
+                                    // ignore
+                                } catch (UnsupportedEncodingException ex) {
+                                    // ignore
+                                }
+                                updateSchemaImports(bus, included.getReferencedSchema(),
+                                                    docBase, doneSchemas, base, decodedStart);
                             }
                         }
                     }
@@ -567,7 +598,7 @@ public class WSDLGetUtils {
                     || !doneSchemas.containsKey(resolvedSchemaLocation)) {
                     doneSchemas.put(decodedStart, included);
                     doneSchemas.put(resolvedSchemaLocation, included);
-                    updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
+                    updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base, decodedStart);
                 }
             }
         }