users@jersey.java.net

How to get the path to the parent resource from UriBuilder

From: Martin Grotzke <martin.grotzke_at_javakaffee.de>
Date: Fri, 22 Feb 2008 18:14:08 +0100

Hi,

is it possible to "navigate" to get the path to the parent resource from
UriBuilder?

E.g. I have a resource with path "/parent/pId/child/cId" where pId is
the identifier of a "parent" resource and cId the id of "child". Then I
want to get "/parent/pId/child/" from UriBuilder. Is there any
possibility to achieve this? (Ok, I could cut off everything that
follows the last slash, but that doesn't feel good :))

Right now I do the following, but this requires a lot of "knowledge"
about the context of a resource:

_uriInfo.getBaseUriBuilder()
.path( ParentResource.class )
.path( "{p1}" )
.path( "child/" )
.build( "pId" ).toString()

Thanx for your help,
cheers,
Martin