Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Dreier2018-10-31 13:07:01 +0000
committerFabian Dreier2018-11-01 06:39:11 +0000
commit8b7fcff7ae7f4a340847a6544331e4c8538b489a (patch)
treecec1f34ece3bada3cd7b58d923e8365cca3bcca7
parent2f7e44af63db3e9402ea8636e0dc7c9f6d1a5e68 (diff)
downloadorg.eclipse.mdm.api.base-8b7fcff7ae7f4a340847a6544331e4c8538b489a.tar.gz
org.eclipse.mdm.api.base-8b7fcff7ae7f4a340847a6544331e4c8538b489a.tar.xz
org.eclipse.mdm.api.base-8b7fcff7ae7f4a340847a6544331e4c8538b489a.zip
Fix problem with remote file paths on windows
Signed-off-by: Fabian Dreier <fabian.dreier@karakun.com>
-rw-r--r--src/main/java/org/eclipse/mdm/api/base/model/FileLink.java30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/main/java/org/eclipse/mdm/api/base/model/FileLink.java b/src/main/java/org/eclipse/mdm/api/base/model/FileLink.java
index 74333b9..e942d48 100644
--- a/src/main/java/org/eclipse/mdm/api/base/model/FileLink.java
+++ b/src/main/java/org/eclipse/mdm/api/base/model/FileLink.java
@@ -1,16 +1,16 @@
-/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/********************************************************************************
+ * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ ********************************************************************************/
package org.eclipse.mdm.api.base.model;
@@ -156,7 +156,9 @@ public final class FileLink {
fileNamePath = getLocalPath().getFileName();
} else if (isRemote()) {
try {
- fileNamePath = Paths.get(URLDecoder.decode(remotePath, StandardCharsets.UTF_8.name())).getFileName();
+ //on Windows, Paths.get() cannot handle file urls in the form file://REMOTE_HOST/path/filename
+ String fixedPath = remotePath.replaceFirst("file:", "");
+ fileNamePath = Paths.get(URLDecoder.decode(fixedPath, StandardCharsets.UTF_8.name())).getFileName();
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Unable to decode remote path due to: " + e.getMessage(), e);
}

Back to the top