Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 418707

Summary: Invalid use of fileClient read() API when opening editor page on a Directory
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ClientAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Silenio_Quarti, simon_kaegi
Version: 4.0   
Target Milestone: 4.0 RC2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2013-10-04 14:41:23 EDT
I noticed this while looking at bug 417880.

When the editor page loads on a resource, the metadata is fetched, so it can decide whether to show the folder view or the editor view. Currently this step is done by inputManager.js, which calls:

> fileClient.read(location, false)   // get contents
> fileClient.read(location, true)    // get metadata

When you load the editor page on a directory, the value that gets passed to read() is actually the directory's ChildrenLocation. (You can see this by inspecting the directory links in the left-hand nav -- the resources all end in "?depth=1", indicating a ChildrenLocation.) 

I believe this violates the fileClient API. AFAICT the following conditions hold:
1) read() only accepts a Location
2) fetchChildren() only accepts a ChildrenLocation

The current approach happens to work on the Orion filesystem, but in others it may fail.
Comment 1 Mark Macdonald CLA 2013-10-04 14:53:53 EDT
I think what needs to happen is: the resource passed to the page is the Location of the directory (or file), not the ChildrenLocation. inputManager should call read() on the Location and continue as before.
Comment 2 Mark Macdonald CLA 2013-10-04 15:02:06 EDT
One more thing to note:

3) read()ing the "contents" of a directory -- i.e. read(Directory.Location, false) -- is not defined.

It may be OK for the inputManager to keep doing this, but we must keep in mind that some filesystems may reject when this is called on a directory.
Comment 4 Simon Kaegi CLA 2013-10-15 23:34:40 EDT
Hrm.. looking at the code I see a lot of URL creation without using the URI Template. This will get the encoding wrong when there are characters that need to be uri encoded.