Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-03-26 17:40:07 +0000
committercletavernie2013-03-26 17:40:07 +0000
commit2828f55bb525073b05eebc590fcb7fbc1e59a655 (patch)
tree71b82d4d1dc6b8ca5a8c2ea616acb0a8db2f3055 /plugins/xwt
parent49176742f87905c2d4dcdb3a493a99074bffbf66 (diff)
downloadorg.eclipse.papyrus-2828f55bb525073b05eebc590fcb7fbc1e59a655.tar.gz
org.eclipse.papyrus-2828f55bb525073b05eebc590fcb7fbc1e59a655.tar.xz
org.eclipse.papyrus-2828f55bb525073b05eebc590fcb7fbc1e59a655.zip
290952: [CDO] Support for CDO model repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=290952 Merge plug-ins modifications from the cdo_kepler branch to the trunk.
Diffstat (limited to 'plugins/xwt')
-rw-r--r--plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/DocumentRoot.java25
-rw-r--r--plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/ElementManager.java11
2 files changed, 23 insertions, 13 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 f8ac63bb79d..a907169f871 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
+ * Copyright (c) 2006, 2013 Soyatec (http://www.soyatec.com), CEA, and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Soyatec - initial API and implementation
+ * Christian W. Damus (CEA) - Fix failure to propagate stream handlers of URLs (CDO)
*******************************************************************************/
package org.eclipse.papyrus.xwt.internal.xml;
@@ -18,6 +19,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipEntry;
@@ -136,7 +138,7 @@ public class DocumentRoot {
case FORMAT_GZIP:
return new GZIPInputStream(new URL(basePath + "/" + baseFile).openStream());
default:
- return new URL(basePath + "/" + baseFile).openStream();
+ return new URL(baseURL, basePath + "/" + baseFile).openStream(); // preserve the stream handler
}
}
@@ -222,16 +224,22 @@ public class DocumentRoot {
* @param file
* the xaml file path.
*/
- protected void init(InputStream inputStream, String path) throws IOException {
- path = path.replace('\\', '/');
- File file = new File(path);
- if(inputStream == null && file.exists()) {
+ protected void init(InputStream inputStream, URL url) throws IOException {
+ File file = null;
+
+ try {
+ file = "file".equals(url.getProtocol()) ? new File(url.toURI()) : null;
+ } catch (URISyntaxException e) {
+ // not a valid file URL. Fine
+ }
+
+ if((inputStream == null) && (file != null) && file.exists()) {
// Is file
init(file);
} else {
// Is URL
basePath = null;
- baseURL = new URL(path);
+ baseURL = url;
PushbackInputStream pis = null;
boolean shouldClose_pis = false;
if(inputStream instanceof PushbackInputStream) {
@@ -257,6 +265,7 @@ public class DocumentRoot {
}
if(basePath == null) {
+ String path = url.toString();
while(path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
@@ -265,7 +274,7 @@ public class DocumentRoot {
if(lastIndex > 0) {
basePath = path.substring(0, lastIndex);
baseFile = path.substring(lastIndex + 1);
- baseURL = new URL(basePath);
+ baseURL = new URL(url, basePath); // be sure to preserve the stream handler
} else {
basePath = System.getProperty("user.dir");
baseURL = new File(basePath).toURI().toURL();
diff --git a/plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/ElementManager.java b/plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/ElementManager.java
index 814ea2555cc..51d0d06cf8a 100644
--- a/plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/ElementManager.java
+++ b/plugins/xwt/org.eclipse.papyrus.xwt/src/org/eclipse/papyrus/xwt/internal/xml/ElementManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
+ * Copyright (c) 2006, 2013 Soyatec (http://www.soyatec.com), CEA, and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Soyatec - initial API and implementation
+ * Christian W. Damus (CEA) - Fix failure to propagate stream handlers of URLs (CDO)
*******************************************************************************/
package org.eclipse.papyrus.xwt.internal.xml;
@@ -76,7 +77,7 @@ public class ElementManager {
this.parserFactory.setValidating(true);
if(url != null) {
try {
- documentRoot.init(null, url.toString());
+ documentRoot.init(null, url);
} catch (IOException e) {
}
}
@@ -229,7 +230,7 @@ public class ElementManager {
if(callback == null) {
// Initialize document root
- documentRoot.init(null, url.toString());
+ documentRoot.init(null, url);
InputStream input = url.openStream();
try {
@@ -247,7 +248,7 @@ public class ElementManager {
} else {
String content = callback.onParsing(url.toString());
- documentRoot.init(null, content);
+ documentRoot.init(null, new URL(url, content)); // preserve the stream handler
InputStream input = new ByteArrayInputStream(content.getBytes());
try {
@@ -283,7 +284,7 @@ public class ElementManager {
}
}
- documentRoot.init(pis, url.toString());
+ documentRoot.init(pis, url);
InputStream input = pis;
if(pis == null) {

Back to the top