Repository: karaf-cave Updated Branches: refs/heads/cave-2.x 3a38003f1 -> a8ab37d4b
[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/a8ab37d4 Tree: http://git-wip-us.apache.org/repos/asf/karaf-cave/tree/a8ab37d4 Diff: http://git-wip-us.apache.org/repos/asf/karaf-cave/diff/a8ab37d4 Branch: refs/heads/cave-2.x Commit: a8ab37d4baba92bf6e405efcccadf04d5466606c Parents: 3a38003 Author: mhautman <[email protected]> Authored: Tue May 24 18:02:34 2016 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Mon Jul 18 07:21: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/a8ab37d4/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); + } } /**
