Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdamus2013-04-10 13:26:02 +0000
committercdamus2013-04-10 13:26:02 +0000
commit1379c8bf3fbeb787d37555fd86f241bba32c2327 (patch)
tree56abcd73ca312232b29a0cf41b4ab076a0b15385 /plugins/xwt
parentdfde4ec089c41a8bbaa5d8f5e957afc2ce272749 (diff)
downloadorg.eclipse.papyrus-1379c8bf3fbeb787d37555fd86f241bba32c2327.tar.gz
org.eclipse.papyrus-1379c8bf3fbeb787d37555fd86f241bba32c2327.tar.xz
org.eclipse.papyrus-1379c8bf3fbeb787d37555fd86f241bba32c2327.zip
Refinement of URL handling fix in XWT to align with XWT project contribution.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=404440 (Papyrus) https://bugs.eclipse.org/bugs/show_bug.cgi?id=404413 (XWT)
Diffstat (limited to 'plugins/xwt')
-rw-r--r--plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/DocumentRoot.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/DocumentRoot.java b/plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/DocumentRoot.java
index a907169f871..5cedea62717 100644
--- a/plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/DocumentRoot.java
+++ b/plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/DocumentRoot.java
@@ -138,7 +138,10 @@ public class DocumentRoot {
case FORMAT_GZIP:
return new GZIPInputStream(new URL(basePath + "/" + baseFile).openStream());
default:
- return new URL(baseURL, basePath + "/" + baseFile).openStream(); // preserve the stream handler
+ if ((basePath != null) && (basePath.length() > 0)) {
+ return new URL(baseURL, basePath + "/" + baseFile).openStream(); // preserve the stream handler
+ }
+ return new URL(baseURL, baseFile).openStream(); // preserve the stream handler
}
}
@@ -265,7 +268,7 @@ public class DocumentRoot {
}
if(basePath == null) {
- String path = url.toString();
+ String path = url.getPath();
while(path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
@@ -275,10 +278,14 @@ public class DocumentRoot {
basePath = path.substring(0, lastIndex);
baseFile = path.substring(lastIndex + 1);
baseURL = new URL(url, basePath); // be sure to preserve the stream handler
- } else {
+ } else if ("file".equals(url.getProtocol())) {
basePath = System.getProperty("user.dir");
baseURL = new File(basePath).toURI().toURL();
baseFile = path;
+ } else {
+ basePath = "";
+ baseFile = path;
+ baseURL = new URL(url, basePath); // be sure to preserve the stream handler
}
}

Back to the top