]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/src/org/simantics/district/maps/server/Activator.java
Enhancements to district functionalities and code
[simantics/district.git] / org.simantics.maps.server / src / org / simantics / district / maps / server / Activator.java
index eaeda86acb88b6acf71432b556a3aa81d5d42aed..a09545fbf6034587aa74e90f17e7c382e886df9d 100644 (file)
@@ -1,6 +1,7 @@
 package org.simantics.district.maps.server;
 
 import java.io.IOException;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.nio.file.Path;
@@ -40,15 +41,18 @@ public class Activator implements BundleActivator {
     }
 
     public static Path getNodeJSRoot() throws IOException, URISyntaxException {
-        URL nodeURL = getContext().getBundle().getEntry("/node");
-        URL nodeFileURL = FileLocator.toFileURL(nodeURL);
-        return Paths.get(nodeFileURL.toURI());
+        return resolvePath("/node");
     }
     
     public static Path getTileserverMapnikRoot() throws IOException, URISyntaxException {
-        URL serverURL = getContext().getBundle().getEntry("/server");
-        URL serverFileURL = FileLocator.toFileURL(serverURL);
-        return Paths.get(serverFileURL.toURI());
+        return resolvePath("/server");
+    }
+    
+    private static Path resolvePath(String entry) throws IOException, URISyntaxException {
+        URL entryURL = getContext().getBundle().getEntry(entry);
+        URL entryFileURL = FileLocator.toFileURL(entryURL);
+        URI encodedUri = new URI(entryFileURL.getProtocol(), entryFileURL.getPath(), null).normalize();
+        return Paths.get(encodedUri);
     }
 
 }