Ticket #1044 (closed Defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Retyping File into Icon when per-workspace repos are on

Reported by: jri Owned by: jri
Priority: Major Milestone: Release 4.8.5
Component: DeepaMehta Standard Distribution Version: 4.8.4
Keywords: Cc: dgf, Malte, JuergeN
Complexity: 3 Area:
Module: deepamehta-files

Description

Rendering of File and Icon topics may break if per-workspace file repos are activated. The file repo authorization check fails due to ambiguous Path topics.

Ambiguous Path topics are accidentally produced this way:

  1. Retype a File into Icon. Note: despite Path is not part of the Icon type definition (which is a simple one) the Icon remains connected with the former File topic's Path topic.
  2. Reveal the original File again through the file browser. Now DM creates a new File topic along with a new Path topic, instead of reusing the Icon's Path topic. The result is 2 Path topics representing the same path. This causes an "Ambiguity" exception when checking the user's authorization for that path. The server responds with 500. The File/Icon? can't be rendered.
SEVERE: Request "GET /filerepo/%2Fworkspace-25476%2FDM_category_32x32-01.png" failed. Responding with 500 (Internal Server Error). The original exception/error is:
java.lang.RuntimeException: An error occurred in the StaticResourceFilterListener of plugin "DeepaMehta 4 Files"
	at de.deepamehta.core.impl.EventManager.dispatchEvent(EventManager.java:96)
	...
Caused by: java.lang.RuntimeException: Checking authorization for repository path "/workspace-25476/DM_category_32x32-01.png" failed
	at de.deepamehta.files.FilesPlugin.checkAuthorization(FilesPlugin.java:792)
	at de.deepamehta.files.FilesPlugin.staticResourceFilter(FilesPlugin.java:472)
	...
Caused by: java.lang.RuntimeException: Fetching topic failed (key="dm4.files.path", value="/workspace-25476/DM_category_32x32-01.png")
	at de.deepamehta.core.impl.PersistenceLayer.getTopicByValue(PersistenceLayer.java:90)
	...
Caused by: java.util.NoSuchElementException: More than one element in org.neo4j.index.impl.lucene.LuceneIndex$1@704aea73. First element is 'Node[73097]' and the second element is 'Node[74149]'

Note: if per-workspace is switched off the ambiguous Path topics doesn't cause an error as no path-based authorization check is performed.

Change History

comment:1 Changed 4 years ago by jri

  • Status changed from new to accepted

comment:2 Changed 4 years ago by Jörg Richter <jri@…>

In 0f112104fc6983aa9f82a673a4ad2c1dccb1fa7f/deepamehta:

Files fix: reuse Path topics on retype (#1044).

Retyping File topics into Icon topics works also for per-workspace file repos.

See #1044.

comment:3 Changed 4 years ago by jri

There is still a problem: if you retype a File into Icon the original File topic does not exist anymore. As a consequence the authorization check for /filerepo requests fails with 500 and the Webclient can't display the icon.

Server-side exception:

SEVERE: Request "GET /filerepo//workspace-1853/upload.png" failed. Responding with 500 (Internal Server Error). The original exception/error is:
java.lang.RuntimeException: An error occurred in the StaticResourceFilterListener of plugin "DeepaMehta 4 Files"
	...
Caused by: java.lang.RuntimeException: Checking authorization for repository path "/workspace-1853/upload.png" failed
	at de.deepamehta.files.FilesPlugin.checkAuthorization(FilesPlugin.java:802)
	at de.deepamehta.files.FilesPlugin.staticResourceFilter(FilesPlugin.java:472)
	...
Caused by: java.lang.RuntimeException: Missing File topic for repository path "/workspace-1853/upload.png"
	at de.deepamehta.files.FilesPlugin.checkAuthorization(FilesPlugin.java:796)
	...

Workaround: after retyping reveal the original image file again (through DM file browser). This will recreate the File topic.

There is no easy solution to this. DM's icon handling approach (retyping File topics!) should be reconsidered from start. Actually it was a quick hack long time ago. Now in the face of DM's access controlled file repos a proper design is needed.

Thank you JuergeN for reporting!

comment:4 Changed 4 years ago by jri

The proposed short-term solution is this: an Icon topic will no longer be created by retyping a File topic. Instead a File topic provides an explicit "Create Icon" command. If chosen DM creates an Icon topic based on the File's path. The File topic is not changed in any way.

Note: the user must not delete the File topic as it is needed for the permission check when the file (=icon) is accessed. (In case of per-workspace repos this applies to all File topics anyways.)

The "Retype" command is about to be removed from the topic context menu (#1057).

comment:5 Changed 4 years ago by Jörg Richter <jri@…>

In 76e46185cacdac48df5e287f7e3a7a7b59f159d0/deepamehta:

Add File command: "Create Icon" (#1044).

A File topic which represents an image provides a "Create Icon" command.
If chosen DM creates an Icon topic based on the File's path.
The File topic is not changed in any way.

See #1044.

comment:6 Changed 4 years ago by jri

  • Status changed from accepted to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.