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?

I think the Parents attribute was considered optional in the doc because we weren't sure if it was possible to implement this on all possible file system clients. I would implement "cd .." using the Parents attribute and if a particular file system doesn't support it then "cd .." wouldn't do anything (like you get on a regular command line at the root of a file system). In the documentation for the Parents attribute we even mention implementing ".." links as the example usage. I thought our Orion file system implementation provided Parents consistently. If not can you enter a bug and I'll take a look.

John



Kris De Volder <kdvolder@xxxxxxxxxx>
Sent by: orion-dev-bounces@xxxxxxxxxxx

03/01/2012 09:02 PM

Please respond to
Orion developer discussions <orion-dev@xxxxxxxxxxx>

To
Orion developer discussions <orion-dev@xxxxxxxxxxx>
cc
Subject
[orion-dev] Proper way to determine the parent of a directory?





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



Back to the top