org.carlspring.strongbox.providers.io.RepositoryPath#toUri simplified
@@ -21,6 +21,8 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import org.apache.commons.io.FilenameUtils;
+
/**
* This implementation decorates storage {@link Path} implementation, which can be an "Cloud Path" or common
* "File System Path".
@@ -234,31 +236,21 @@ public class RepositoryPath
return uri;
}
- RepositoryPath thisPath = this;
- if (!isAbsolute())
- {
- thisPath = thisPath.toAbsolutePath();
- }
-
Repository repository = getFileSystem().getRepository();
Storage storage = repository.getStorage();
- URI result;
try
{
- result = new URI(StorageFileSystemProvider.STRONGBOX_SCHEME,
+ uri = new URI(StorageFileSystemProvider.STRONGBOX_SCHEME,
null,
- "/" + storage.getId() + "/" + repository.getId() + "/",
+ "/" + storage.getId() + "/" + repository.getId() + "/" +
+ FilenameUtils.separatorsToUnix(relativize().toString()),
null);
}
catch (URISyntaxException e)
{
- return null;
+ uri = null;
}
-
- RootRepositoryPath root = getFileSystem().getRootDirectory();
- URI pathToken = root.getTarget().toUri().relativize(thisPath.getTarget().toUri());
-
- return uri = result.resolve(pathToken);
+ return uri;
}
public RepositoryPath toAbsolutePath()
