[KARAF-3737] This closes #3
diff --git a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
index 1be4e0a..572d4dc 100644
--- a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
+++ b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
@@ -38,7 +38,9 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
+import java.net.URI;
import java.net.URL;
+import java.nio.file.Paths;
/**
* Default implementation of a Cave repository.
@@ -430,15 +432,21 @@
* @throws Exception in cave of URI conversion failure.
*/
private void useResourceRelativeUri(ResourceImpl resource) throws Exception {
- String resourceURI = resource.getURI();
+ URI resourceURI = new URI(resource.getURI());
String locationURI = "file:" + this.getLocation();
- LOGGER.debug("Converting resource URI {} relatively to repository URI {}", resourceURI, locationURI);
- if (resourceURI.startsWith(locationURI)) {
- resourceURI = resourceURI.substring(locationURI.length() + 1);
- LOGGER.debug("Resource URI converted to " + resourceURI);
- resource.put(Resource.URI, resourceURI);
+
+ if(locationURI.contains("\\")){
+ locationURI = "file:/" + this.getLocation();
+ locationURI = locationURI.replace("\\","/");
}
+ LOGGER.debug("Converting resource URI {} relatively to repository URI {}", resourceURI, locationURI);
+ String fullResourceURI = resourceURI.getScheme() + ":" + resourceURI.getPath();
+ if (fullResourceURI.startsWith(locationURI)) {
+ String ResourceURIString = fullResourceURI.substring(locationURI.length() + 1);
+ LOGGER.debug("Resource URI converted to " + ResourceURIString);
+ resource.put(Resource.URI, ResourceURIString);
+ }
}
/**