I left out a step in the first example I typed. You have to explicitly
getTargetRef() ... I did this in the second block of code but omitted it in
the first. So, that example, corrected is:
response.redirectTemporary(
new Reference(
request.getResourceRef ().getParentRef().getParentRef(),
"group/" + groupId
).getTargetRef()
);
your test case code would then be:
final String baseHref = "http://localhost:8080/app/api";
final String path = "group/1";
final Reference ref = new Reference(new Reference(baseHref), path)
.getTargetRef();
System.out.println(ref);
... and that would yield the information you want.
For what you are doing, getRootRef() may be much easier than trying to
process relative references, which would require you to know where you are
in the hierarchy.
I still think it would be helpful if the Response redirect* methods handled
relative references more transparently ... it is an extremely common use
case to need to do this inside a Resource, and I feel it shouldn't be
necessary to master the Reference API to do it correctly.
Cheers,
- Rob
On 12/16/07, Pavel Kolesnikov <[EMAIL PROTECTED]> wrote:
>
> Thank Rob, but the constructor Reference(Reference, String) does not
> seem to work, it actually produces a Reference instance that seem to
> completely ignore the first argument.
>