> -----Original Message-----
> From: Sergey Beryozkin [mailto:[email protected]]
> Sent: Wednesday, April 27, 2011 2:14 AM
> To: [email protected]
> Subject: Re: How to append file extent to end of path, before query
> parameters?
>
> Hi
>
>
> >> Can you add ".extent" as a path segment to the builder instance ?
> >> Example,
> >>
> >> builder.path(".extent");
> >> builder.query("param", "junk");
> >> builder.build();
> >>
> >> Will it work for you ?
> >
> > Afraid not.
> >
> > For instance, here's an approximation of my @Path:
> >
> > @Path("stuff/{productId}/{zip}")
> >
> > Here's a paraphrased version of the method that builds the URL:
> >
> > private String buildStuffURL(String productId, String zip) {
> > UriBuilder builder =
> getUriInfo().getBaseUriBuilder().path(getClass()).path(getMethodMap().g
> et("getStuff")).path(buildFileExtent());
> > return builder.build(productId, zip).toString();
> > }
> >
> > The ".path(buildFileExtent)" is what I added on your advice (I used
> to just append "buildFileExtent()" to the end of "zip", which is not
> optimal).
> >
> > What I get is this (minus "http://"):
> >
> > host:port/initialpath/stuff/1/98077/.en-us.xml
> >
> > I needed to have this:
> >
> > host:port/initialpath/stuff/1/98077.en-us.xml
> >
>
> The following should work then :
>
> .path(getMethodMap().get("getStuff") + buildFileExtent());
Hmm, that produced a different problem.
The first line in the old code looks something like this:
UriBuilder builder =
getUriInfo().getBaseUriBuilder().path(getClass()).path(getMethodMap().get("stuff"));
With the old code, after the initial construction of the Builder, the "paths"
list in the debugger view showed approximately this:
[stuff, {productId}, {zip}]
After putting in arguments (appending the extent manually to the zip), I ended
up with approximately this:
http://localhost:9000/service/rest/junk/stuff/1/98077.en-us.json?somearg=value
This is fine, except for the inconvenience of how I have to add the extent.
I then followed your suggestion and changed the first line to this (removing
"buildFileExtent()" from the later code to add the arguments):
UriBuilder builder =
getUriInfo().getBaseUriBuilder().path(getClass()).path(getMethodMap().get("stuff")
+ buildFileExtent());
After this line, instead of the previous array value, the "paths" list was now
this:
[public mypackage.GetStuffResponse
mypackage.Controller.getStuff(java.lang.String,java.lang.String,boolean,java.lang.String).en-us.json]
So, it's obvious that just appending a string to the end of a method signature
string confuses the "path()" method. I'm guessing it used that signature to
get the "@Path" annotation somehow, so when the signature was corrupted, it
couldn't find it, so it punted.