Workspace-repos unrecognizable by path running on Windows
Problem:
File uploads of dmx-csv, dmx-upload-dialog and dmx-images not being able to run on windows when per_workspace
repsitories are ON
.
When per_workspaces=ON
repos are configured, files.pathPrefix()
returns e.g. /workspace-1359\
, also on Windows.
Furthermore, when using a correct folder path e.g. \workspace-1359\
the filesPlugin cannot read the workspace-id from that path.
Here is what callig the files.pathPrefix()
returns on WIN /workspace-1359
.
Trying to store a file in the repo in the following way:
StoredFile storedFile = files.storeFile(file, files.pathPrefix() + File.separator);
Logs the following error message:
INFORMATION: Storing file "notes.csv" (application/vnd.ms-excel, 149 bytes) at repository path "/workspace-1359\"
Jul 12, 2020 9:04:23 AM systems.dmx.accesscontrol.AccessControlPlugin checkDiskQuota
INFORMATION: ### Checking disk quota of user "admin" SKIPPED -- disk quota is disabled
Jul 12, 2020 9:04:23 AM systems.dmx.core.util.UniversalExceptionMapper logException
SCHWERWIEGEND: Request "POST /csv/import" failed. Responding with 500 (Internal Server Error). The original exception/error is:
java.lang.RuntimeException: Uploading CSV file "notes.csv" (application/vnd.ms-excel, 149 bytes) FAILED
at systems.dmx.plugins.csv.CsvPlugin.uploadCSV(CsvPlugin.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceObjectRule.accept(ResourceObjectRule.java:100)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1480)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1411)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1360)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1350)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:339)
at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:300)
at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:93)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:50)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:76)
at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:49)
at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: Storing file "notes.csv" (application/vnd.ms-excel, 149 bytes) at repository path "/workspace-1359\" failed
at systems.dmx.files.FilesPlugin.storeFile(FilesPlugin.java:206)
at systems.dmx.plugins.csv.CsvPlugin.uploadCSV(CsvPlugin.java:65)
... 51 more
Caused by: java.lang.RuntimeException: Creating workspace assignment for File/Folder topic or folder association failed
at systems.dmx.files.FilesPlugin.createWorkspaceAssignment(FilesPlugin.java:677)
at systems.dmx.files.FilesPlugin.createFileOrFolderTopic(FilesPlugin.java:634)
at systems.dmx.files.FilesPlugin.createFileTopic(FilesPlugin.java:590)
at systems.dmx.files.FilesPlugin.storeFile(FilesPlugin.java:201)
... 52 more
Caused by: java.lang.RuntimeException: No workspace recognized in repository path "\workspace-1359\notes-2.csv"
at systems.dmx.files.FilesPlugin.getWorkspaceId(FilesPlugin.java:902)
at systems.dmx.files.FilesPlugin.createWorkspaceAssignment(FilesPlugin.java:674)
... 55 more
We might be fine if we use Java's File.seperator
there to construct a Windows-compatible subfolder (workspace-id) name.
FYI @jri
Edited by Malte Reißig