Ticket #879 (closed Task: worksforme)

Opened 6 years ago

Last modified 6 years ago

question: how to store files through FilesService when per-workspace filerepos are active

Reported by: Malte Owned by: jri
Priority: Minor Milestone: Release 4.8
Component: DeepaMehta Standard Distribution Version: 4.7
Keywords: Cc:
Complexity: 3 Area:
Module:

Description

In relation to #821 i have problem using the FilesService? properly when the "per_workspace" option is set to "true".

INFORMATION: Storing file "tumblr_nmk0dgZaPd1qz7lxdo1_1280.jpg" (image/jpeg, 108793 bytes) at repository path "images"
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.files.FilesPlugin checkPath
INFORMATION: Checking path "/home/malted/Schreibtisch/filerepo-test/images"
  dm4.filerepo.path="/home/malted/Schreibtisch/filerepo-test" => PATH OK
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.files.FilesPlugin checkExistence
INFORMATION: Checking existence of "/home/malted/Schreibtisch/filerepo-test/images" => EXISTS
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.accesscontrol.AccessControlPlugin checkDiskQuota
INFORMATION: ### File size: 108793 bytes, user "admin" occupies 0 bytes, disk quota: 1048576000 bytes => QUOTA OK
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for topic 3126 (typeUri="dm4.files.file_name", uri="") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for association 3129 (typeUri="dm4.core.composition") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for topic 3131 (typeUri="dm4.files.path", uri="") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for association 3134 (typeUri="dm4.core.composition") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for topic 3136 (typeUri="dm4.files.media_type", uri="") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for association 3139 (typeUri="dm4.core.composition") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for topic 3141 (typeUri="dm4.files.size", uri="") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for association 3144 (typeUri="dm4.core.composition") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.plugins.workspaces.WorkspacesPlugin workspaceAssignmentIsSuppressed
INFORMATION: Standard workspace assignment for topic 3125 (typeUri="dm4.files.file", uri="") SUPPRESSED
Nov 10, 2015 11:35:20 PM de.deepamehta.core.util.UniversalExceptionMapper logException
SCHWERWIEGEND: Request "POST /images/upload?CKEditor=editor1&CKEditorFuncNum=0&langCode=en" failed. Responding with 500 (Internal Server Error). The original exception/error is:
java.lang.RuntimeException: java.lang.RuntimeException: Storing file "tumblr_nmk0dgZaPd1qz7lxdo1_1280.jpg" (image/jpeg, 108793 bytes) at repository path "images" failed
	at de.deepamehta.plugins.images.ImagePlugin.upload(ImagePlugin.java:64)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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:745)
Caused by: java.lang.RuntimeException: Storing file "tumblr_nmk0dgZaPd1qz7lxdo1_1280.jpg" (image/jpeg, 108793 bytes) at repository path "images" failed
	at de.deepamehta.plugins.files.FilesPlugin.storeFile(FilesPlugin.java:205)
	at de.deepamehta.plugins.images.ImagePlugin.upload(ImagePlugin.java:59)
	... 51 more
Caused by: java.lang.RuntimeException: Creating workspace assignment for File/Folder topic or folder association failed
	at de.deepamehta.plugins.files.FilesPlugin.createWorkspaceAssignment(FilesPlugin.java:623)
	at de.deepamehta.plugins.files.FilesPlugin.createFileOrFolderTopic(FilesPlugin.java:569)
	at de.deepamehta.plugins.files.FilesPlugin.createFileTopic(FilesPlugin.java:535)
	at de.deepamehta.plugins.files.FilesPlugin.storeFile(FilesPlugin.java:200)
	... 52 more
Caused by: java.lang.RuntimeException: No workspace recognized in repository path "/images/tumblr_nmk0dgZaPd1qz7lxdo1_1280.jpg"
	at de.deepamehta.plugins.files.FilesPlugin.createWorkspaceAssignment(FilesPlugin.java:615)
	... 55 more

The question i face is, do i have to construct the "workspace-1234" prefix by myself, e.g. through evaluating a request Cookie?

Change History

comment:1 in reply to: ↑ description Changed 6 years ago by jri

Replying to Malte:

The question i face is, do i have to construct the "workspace-1234" prefix by myself, e.g. through evaluating a request Cookie?

Yes, when per_workspace=true the repo paths passed to the FilesService? calls must contain the /workspace-1234 prefix already.

Yes, you could construct that prefix by checking both, the per_workspace flag, and the workspace cookie. But actually you must not do so as the FilesService? provides some support already.

When you pass "/" as repo path the respective FilesServices? call will add the /workspace-1234 prefix automatically (based on the cookie). So, to store a file in the "images" directory of the current workspace's file repo do this:

File repoDir = filesService.getFile("/");
filesService.storeFile(uploadedFile, repoDir + "/images/img1.png")

This works in both cases: per_workspace=true or false.

comment:2 Changed 6 years ago by Malte

As documented in #815#comment:26 this does not work for me.

Just to be clear and to not mix things up, here is another attempt:
When doing exactly that, while per_workspace=true i get the following error:

Nov 11, 2015 1:09:46 PM de.deepamehta.plugins.files.FilesPlugin storeFile
INFORMATION: Storing file "tumblr_my4lrkdoFe1s87u37o1_1280.jpg" (image/jpeg, 205700 bytes) at repository path "/images/tumblr_my4lrkdoFe1s87u37o1_1280.jpg"
Nov 11, 2015 1:09:46 PM de.deepamehta.plugins.files.FilesPlugin checkPath
INFORMATION: Checking path "/home/malted/Schreibtisch/filerepo-test/images/tumblr_my4lrkdoFe1s87u37o1_1280.jpg"
  dm4.filerepo.path="/home/malted/Schreibtisch/filerepo-test" => PATH OK
Nov 11, 2015 1:09:46 PM de.deepamehta.plugins.files.FilesPlugin checkExistence
INFORMATION: Checking existence of "/home/malted/Schreibtisch/filerepo-test/images/tumblr_my4lrkdoFe1s87u37o1_1280.jpg" => NOT FOUND
Nov 11, 2015 1:09:46 PM de.deepamehta.core.util.UniversalExceptionMapper logException
SCHWERWIEGEND: Request "POST /images/upload?CKEditor=editor1&CKEditorFuncNum=0&langCode=en" failed. Responding with 500 (Internal Server Error). The original exception/error is:
java.lang.RuntimeException: javax.ws.rs.WebApplicationException: java.lang.RuntimeException: Storing file "tumblr_my4lrkdoFe1s87u37o1_1280.jpg" (image/jpeg, 205700 bytes) at repository path "/images/tumblr_my4lrkdoFe1s87u37o1_1280.jpg" failed
	at de.deepamehta.plugins.images.ImagePlugin.upload(ImagePlugin.java:75)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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:745)
Caused by: javax.ws.rs.WebApplicationException: java.lang.RuntimeException: Storing file "tumblr_my4lrkdoFe1s87u37o1_1280.jpg" (image/jpeg, 205700 bytes) at repository path "/images/tumblr_my4lrkdoFe1s87u37o1_1280.jpg" failed
	at de.deepamehta.plugins.files.FilesPlugin.storeFile(FilesPlugin.java:203)
	at de.deepamehta.plugins.images.ImagePlugin.upload(ImagePlugin.java:60)
	... 51 more
Caused by: java.lang.RuntimeException: Storing file "tumblr_my4lrkdoFe1s87u37o1_1280.jpg" (image/jpeg, 205700 bytes) at repository path "/images/tumblr_my4lrkdoFe1s87u37o1_1280.jpg" failed
	... 53 more
Caused by: de.deepamehta.plugins.files.FileRepositoryException: File or directory "/home/malted/Schreibtisch/filerepo-test/images/tumblr_my4lrkdoFe1s87u37o1_1280.jpg" does not exist
	at de.deepamehta.plugins.files.FilesPlugin.checkExistence(FilesPlugin.java:720)
	at de.deepamehta.plugins.files.FilesPlugin.storeFile(FilesPlugin.java:193)
	... 52 more

Nov 11, 2015 1:09:46 PM de.deepamehta.core.impl.TransactionFactory$TransactionResourceFilter$2 filter
WARNUNG: ### Rollback transaction of AbstractSubResourceMethod(ImagePlugin#upload)

So this method does pretty certainly not work in both cases.

comment:3 Changed 6 years ago by jri

comment:4 Changed 6 years ago by jri

See this posting for a discussion of this problem:
http://lists.deepamehta.de/pipermail/devel-lists.deepamehta.de/2015-November/000605.html

See #884 for the aimed solution.

comment:5 Changed 6 years ago by jri

  • Status changed from new to closed
  • Resolution set to worksforme

#884 is meanwhile realized

Note: See TracTickets for help on using tickets.