Actually, the problem seems to do with the fact that UriBuilderImpl has assumed
that unencoded
"** Web Query" contains template variables...
pdq.getName() returns a decoded (query sequence).
One possible option is to add @Encoded to the corresponding QueryParam declaration and then pass this (still encoded) value to
UriBuilder but the problem here is that some of the characters which may not be valid in queries and thus are encoded may be valid
in path components, so no need to encode them there. It should still work though...
See, if UriBuilder.path(String value) will attempt to encode the value then it may loose the information about the template
parameters a given path value may contain. ex, "bar{id}".
So try either preserving the encoded information, when getting it from the
query param, or do
builder.path(org.apache.cxf.jaxrs.utils.HttpUtils.pathEncode(pdq.getName()));
cheers, Sergey
Hi John
If encoded values are present then you need to use
UriBuilder.buildEncoded()
give it a try please. CXF JAXRS proxy-based api always uses
UriBuilder.buildEncoded()
Sergey
----- Original Message -----
From: "John Klassa" <[email protected]>
To: <[email protected]>
Sent: Thursday, December 17, 2009 1:32 PM
Subject: bug in URITemplate?
This code:
return getBaseURI(info) + UriBuilder.fromResource(SearchResource.class)
.path(pdq.getOwner())
.path(pdq.getName())
.build()
.toString();
dies thusly:
java.util.regex.Pattern.error(Pattern.java:1713)
java.util.regex.Pattern.sequence(Pattern.java:1878)
java.util.regex.Pattern.expr(Pattern.java:1752)
java.util.regex.Pattern.compile(Pattern.java:1460)
java.util.regex.Pattern.<init>(Pattern.java:1133)
java.util.regex.Pattern.compile(Pattern.java:823)
org.apache.cxf.jaxrs.model.URITemplate.<init>(URITemplate.java:89)
org.apache.cxf.jaxrs.impl.UriBuilderImpl.substituteVarargs(UriBuilderImpl.java:131)
org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuild(UriBuilderImpl.java:80)
org.apache.cxf.jaxrs.impl.UriBuilderImpl.build(UriBuilderImpl.java:74)
com.cisco.cdets.wsapi.resources.SearchResource.buildURI(SearchResource.java:132)
when the getName() call happens to return something like "** Web Query" (with asterisks). I had assumed that the CXF methods
would URL escape the information I pass in, in situations like this... I'm guessing that's either not the case, or perhaps
there's a bug?
As a best practice, in general, should I be escaping these sorts of values
myself?
FWIW, I'm using CXF 2.2.3.
Thanks!