Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [orion-dev] Proper way to determine the parent of a directory?

No it's not a stupid question. I have a webdav implementaiton of the file service that had similar problems when displaying bread crumbs because I wasn't sure what to put in the "Parent" attribute.

Here's my understanding of the rules based on reverse-engineering when I recently worked on https://bugs.eclipse.org/bugs/show_bug.cgi?id=370897 .

The root is treated specially and is not treated like a parent to the project folders -- unfortunately I think this is anomaly of our initial implementation and not necessarily the long-term intent as there is no concept of "projects" in Orion. It's all just files and folders.

So as it stands right now here's what I found for "Parents"
1) If you're at the root "Parents" is undefined
2) If you're at an immediate child of the root then "Parents" is an empty array
3) All subsequent generations will add all ancestors to their "Parents" array up to but not including the root.

The UI and more specifically breadcrumb.js has the code to figure this stuff out. Not great but that's how it is right at this moment. FWIW I feel file access is fundamental so If we were working on something like a web shell that was doing file navigation I think the "cd" command would be built-in to the page so we could emulate this logic until we get around to seeing if we might improve our FileService API..
--
So... we recognize the file service api really could use some work and is one of those things put on todo lists since 0.3 and yet has not made it yet. At one point an idea being thrown around was to have the api much more closely aligned with the W3C File APIs only we might need to re-think if want to use promises or callbacks. It would be great to get a hand here...

-Simon

Inactive hide details for Kris De Volder ---03/01/2012 09:02:31 PM---I hope this isn't a stupid question. It seems this should Kris De Volder ---03/01/2012 09:02:31 PM---I hope this isn't a stupid question. It seems this should be simple but... I am *really* having trou


From:

Kris De Volder <kdvolder@xxxxxxxxxx>

To:

Orion developer discussions <orion-dev@xxxxxxxxxxx>

Date:

03/01/2012 09:02 PM

Subject:

[orion-dev] Proper way to determine the parent of a directory?

Sent by:

orion-dev-bounces@xxxxxxxxxxx




I hope this isn't a stupid question. It seems this should be simple but... I am *really* having trouble with this.

Cleaning up the gcli console code. I want to replace my hacky implementation of 'cd ..' which computes a parent directory location URI by finding the last slash in the current directory location URI.

I know this isn't how I am supposed to do this. Taken literally from the wiki page at
http://wiki.eclipse.org/Orion/Server_API:

> The relationship between resources is specified in links within
> response representations, rather than being inferred from the URI
> structure. For example a file's parent is specified by the Parent
> element in the response object, rather than by removing the last
> segment of the file's URI.

That sounds perfect. That sounds like how it should be :-)

However looking at the docs for fileClient API as well as the server api docs I can't really figure out how to *properly* get a directory's parent *reliably*:

1) fileClient API has a method to 'fetchChildren' but I don't see a 'fetchParent(s)' method.
2) on the server API docs I see that 'Parents' is an attribute... but it is optional and I can't rely on it??

> A client cannot rely on the existence of non-required attribute in a file representation from a given Orion server.
   
3) when I play with stuff in the debugger I do indeed find confirmation I should *not* rely on it. The Parents attribute is *not* always there when I would expect it to be there. E.g. I wouldn't expect it for the workspace/root but I would expect it for projects and directories within projects.

It seems some requests return File objects with 'Parents' but others return File objects without Parents. I'm not certain what the logic is behind this. Even if I may be able to discern a pattern (add ?depth=1 forces parents to be included?) I am uncertain I should rely on this information. Since it isn't documented, maybe this is just accidental and particular to a specific file service provider.

So... how do I, given a location URI for a directory, get the parent directory URI?

Kris
_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev



GIF image

GIF image


Back to the top