Some bugs and missing features in Reference:
new Reference("/foo/", "bar");
Expected is "/foo/bar", result is:
java.lang.IllegalArgumentException: Relative references are only usable when a
base reference is set.
The base reference is set, it's just not absolute. The error message should be
changed.
I don't see why I'd need an absolute URI if I want to work with the
path/hierarchical part of a reference. This makes URI building brittle because
you have to use string manipulation: new Reference("/foo" + "/" + "bar") If
there is another, preferred way how hierarchical paths can be constructed, I
haven't found it.
The opposite, navigating upwards in the hierarchical part, is broken as well:
new Reference("/foo/bar").getParentRef().toString()
This produces: "null://null/foo/"
The reason is this code in Reference#getParentRef():
parentRef = getHostIdentifier()
+ path.substring(0, path.lastIndexOf('/') + 1);
I didn't ask for any scheme/host part to be added, I only need the parent path.
The code should probably check isAbsolute() before adding getHostIdentifier()
or not.
So are Restlet users manually splitting and concatenating strings to build URIs?
P.S. There should be a section about URI navigation and construction in Restlet
in Action. The methods getParentRef() and getTargetRef() aren't even mentioned
properly.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2948600