Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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


Back to the top