users@jersey.java.net

Re: 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:43:30 +0100

Really great, thanx!

Is there any documentation where I can look up the syntax of the
argument of path() (besides the source code :))?

I had a look in the jsr311 spec but didn't find s.th. relevant.

Thanx a lot,
cheers,
Martin


On Fri, 2008-02-22 at 18:30 +0100, Paul Sandoz wrote:
> Hi Martin,
>
> If you know there is a parent child relationship then i think you could
> do this in the child resource:
>
> _uriInfo.getAbsolutePathBuilder().
> path("..").
> build().normalize().toString();
>
> There has been a request to the EG to have parent() method on the
> builder which would make it easier than normalizing.
>
> Paul.
>
> Martin Grotzke wrote:
> > 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
> >
> >
>