cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1177331 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/resource/ tools/common/src/main/java/org/apache/cxf/tools/util/ tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/
Date Thu, 29 Sep 2011 15:21:33 GMT
Author: dkulp
Date: Thu Sep 29 15:21:32 2011
New Revision: 1177331

URL: http://svn.apache.org/viewvc?rev=1177331&view=rev
Log:
[CXF-3828] Fix some issues with URI handling in the tooling

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
    cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java?rev=1177331&r1=1177330&r2=1177331&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java Thu Sep
29 15:21:32 2011
@@ -29,6 +29,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.net.URLDecoder;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.Level;
@@ -127,16 +128,32 @@ public class URIResolver {
         try {
             URI relative;
 
+            String orig = uriStr;
+            
             // It is possible that spaces have been encoded.  We should decode them first.
             uriStr = uriStr.replaceAll("%20", " ");
 
             File uriFile = new File(uriStr);
+            
+            
             uriFile = new File(uriFile.getAbsolutePath());
-
-            if (uriFile.exists()) {
-                relative = uriFile.toURI();
+            if (!uriFile.exists()) {
+                try {
+                    URI urif = new URI(URLDecoder.decode(orig, "ASCII"));
+                    if ("file".equals(urif.getScheme()) && urif.isAbsolute()) {
+                        File f2 = new File(urif);
+                        if (f2.exists()) {
+                            uriFile = f2;
+                        }
+                    }
+                } catch (URISyntaxException ex) {
+                    //ignore
+                }
+            }
+            if (!uriFile.exists()) {
+                relative =  new URI(uriStr.replaceAll(" ", "%20"));
             } else {
-                relative = new URI(uriStr.replaceAll(" ", "%20"));
+                relative = uriFile.getAbsoluteFile().toURI();
             }
             
             if (relative.isAbsolute()) {

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java?rev=1177331&r1=1177330&r2=1177331&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java Thu
Sep 29 15:21:32 2011
@@ -22,6 +22,7 @@ package org.apache.cxf.tools.util;
 import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -287,16 +288,16 @@ public final class URIParserUtil {
         }
 
         try {
-            URL url = new URL(normalize(arg));
-            if (url.toURI().isOpaque()
-                && "file".equalsIgnoreCase(url.getProtocol())) {
-                return new File("").toURI().resolve(url.getPath()).toString();
+            URI uri = new URI(arg);
+            if ("file".equalsIgnoreCase(uri.getScheme())) {
+                if (!uri.isOpaque()) {
+                    return uri.toString();
+                }
+                return new File("").toURI().resolve(uri.getPath()).toString();
             } else {
                 return normalize(arg);
             }
-        } catch (MalformedURLException e1) {
-            return normalize(arg);
-        } catch (URISyntaxException e2) {
+        } catch (Exception e2) {
             return normalize(arg);
         }
     }

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=1177331&r1=1177330&r2=1177331&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Thu Sep 29 15:21:32 2011
@@ -24,7 +24,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -426,14 +426,14 @@ public class WSDLToJavaContainer extends
             throw new ToolException(msg);
         }
 
-        env.put(ToolConstants.CFG_WSDLURL, URIParserUtil.normalize(wsdl));
+        env.put(ToolConstants.CFG_WSDLURL, URIParserUtil.getAbsoluteURI(wsdl));
         if (!env.containsKey(ToolConstants.CFG_WSDLLOCATION)) {
             //make sure the "raw" form is used for the wsdlLocation
             //instead of the absolute URI that normalize may return
             try {
-                URL url = new URL(wsdl);
-                wsdl = url.toString();
-            } catch (MalformedURLException e) {
+                URI uri = new URI(wsdl);
+                wsdl = uri.toString();
+            } catch (Exception e) {
                 //not a URL, assume file
                 if (wsdl.indexOf(":") != -1 && !wsdl.startsWith("/")) {
                     wsdl = "file:/" + wsdl;
@@ -441,9 +441,9 @@ public class WSDLToJavaContainer extends
                     wsdl = "file:" + wsdl;
                 }
                 try {
-                    URL url = new URL(wsdl);
-                    wsdl = url.toString();
-                } catch (MalformedURLException e1) {
+                    URI uri = new URI(wsdl);
+                    wsdl = uri.toString();
+                } catch (Exception e1) {
                     //ignore... 
                 }
             }



Mime
View raw message