Repository: karaf-cave Updated Branches: refs/heads/cave-3.x 154db6aff -> bf4b2323f
[KARAF-3727] Fix repository path on Windows Project: http://git-wip-us.apache.org/repos/asf/karaf-cave/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-cave/commit/2e6f9c22 Tree: http://git-wip-us.apache.org/repos/asf/karaf-cave/tree/2e6f9c22 Diff: http://git-wip-us.apache.org/repos/asf/karaf-cave/diff/2e6f9c22 Branch: refs/heads/cave-3.x Commit: 2e6f9c223947ce8456a95d49afa9aae6aef927c4 Parents: 154db6a Author: mhautman <[email protected]> Authored: Tue May 24 18:02:34 2016 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Mon Jul 18 07:13:47 2016 +0200 ---------------------------------------------------------------------- .../cave/server/storage/CaveRepositoryImpl.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/2e6f9c22/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java ---------------------------------------------------------------------- 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 org.slf4j.LoggerFactory; 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 @@ public class CaveRepositoryImpl extends CaveRepository { * @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); + } } /**
