Author: dkulp
Date: Thu Sep 29 15:33:09 2011
New Revision: 1177334
URL: http://svn.apache.org/viewvc?rev=1177334&view=rev
Log:
Merged revisions 1177331 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1177331 | dkulp | 2011-09-29 11:21:32 -0400 (Thu, 29 Sep 2011) | 1 line
[CXF-3828] Fix some issues with URI handling in the tooling
........
Modified:
cxf/branches/2.4.x-fixes/ (props changed)
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
cxf/branches/2.4.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Propchange: cxf/branches/2.4.x-fixes/
('svn:mergeinfo' removed)
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java?rev=1177334&r1=1177333&r2=1177334&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
(original)
+++
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
Thu Sep 29 15:33:09 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;
@@ -126,16 +127,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/branches/2.4.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java?rev=1177334&r1=1177333&r2=1177334&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
(original)
+++
cxf/branches/2.4.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
Thu Sep 29 15:33:09 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/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=1177334&r1=1177333&r2=1177334&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++
cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Thu Sep 29 15:33:09 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...
}
}