Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path issues under Windows #15

Closed
VolkerHartmann opened this issue Mar 22, 2022 · 1 comment
Closed

Path issues under Windows #15

VolkerHartmann opened this issue Mar 22, 2022 · 1 comment

Comments

@VolkerHartmann
Copy link
Collaborator

Describe the bug
While registering a Metadata Document with any self-provided Id, e.g. d1, I receive HTTP 400. The logfile gives me the following stacktrace:

java.nio.file.InvalidPathException: UNC path is missing sharename: /\d1
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:118) ~[na:na]
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) ~[na:na]
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92) ~[na:na]
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229) ~[na:na]
        at java.base/java.nio.file.Path.of(Path.java:147) ~[na:na]
        at java.base/java.nio.file.Paths.get(Paths.java:69) ~[na:na]
        at edu.kit.datamanager.repo.service.impl.IdBasedStorageService.createPath(IdBasedStorageService.java:66) ~[repo-core-1.0.0.jar!/:na]
        at edu.kit.datamanager.repo.util.PathUtils.substitutePathPattern(PathUtils.java:92) ~[repo-core-1.0.0.jar!/:na]
        at edu.kit.datamanager.repo.util.PathUtils.getDataUri(PathUtils.java:69) ~[repo-core-1.0.0.jar!/:na]
        at edu.kit.datamanager.repo.service.impl.SimpleDataVersioningService.write(SimpleDataVersioningService.java:67) ~[repo-core-1.0.0.jar!/:na]
        at edu.kit.datamanager.repo.service.impl.ContentInformationService.create(ContentInformationService.java:156) ~[repo-core-1.0.0.jar!/:na]

The issue happens at IdBasedStorageService.java#L66 where the path is build starting with "/", whereas all other elements are added with "[part]" under Windows, which results in path /\d1for our chosen identifier.

Another issue, but also related to how to include IDs in the path occurs, if someone uses a URL as Id. Using 'http://localhost:8080/d1' results in the following stacktrace:

2022-03-17 22:07:13.935 ERROR 34812 --- [nio-8040-exec-5] e.k.d.r.s.i.ContentInformationService    : Failed to write content using versioning service simple.

java.nio.file.InvalidPathException: Illegal character [:] in path at index 7: /\http\://l\ocal\host\:804\0/d1
        at java.base/sun.nio.fs.WindowsPathParser.nextSlash(WindowsPathParser.java:212) ~[na:na]
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:116) ~[na:na]
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) ~[na:na]
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92) ~[na:na]
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229) ~[na:na]
        at java.base/java.nio.file.Path.of(Path.java:147) ~[na:na]
        at java.base/java.nio.file.Paths.get(Paths.java:69) ~[na:na]
        at edu.kit.datamanager.repo.service.impl.IdBasedStorageService.createPath(IdBasedStorageService.java:66) ~[repo-core-1.0.0.jar!/:na]
        at edu.kit.datamanager.repo.util.PathUtils.substitutePathPattern(PathUtils.java:92) ~[repo-core-1.0.0.jar!/:na]
        at edu.kit.datamanager.repo.util.PathUtils.getDataUri(PathUtils.java:69) ~[repo-core-1.0.0.jar!/:na]
        at edu.kit.datamanager.repo.service.impl.SimpleDataVersioningService.write(SimpleDataVersioningService.java:67) ~[repo-core-1.0.0.jar!/:na]
        at edu.kit.datamanager.repo.service.impl.ContentInformationService.create(ContentInformationService.java:156) ~[repo-core-1.0.0.jar!/:na]
@VolkerHartmann
Copy link
Collaborator Author

Possible solution:
We should remove all characters from ID except a-z, A-Z and 0-9.
Challenges:

  1. There may be 2 different IDs with the same id: e.g.: my_special_id <-> my-special-id
  2. There may be an ID without any valid character: e.g.: Ü_ä

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant