You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gabo Manuel <km...@solegysystems.com> on 2009/02/03 09:52:07 UTC

Re: [JAX-RS][PathParam] object field injection

Hi Sergey,

Just to note down what I did from your suggestions.

Currently, I am using 2.2 snapshot. I have modified the code as follows:

1. I have defined the method as follows:

    @GET
    @Path("/{search:search.*}")
    public WSAccounts getAccounts(
            @PathParam("search")
            SearchFilter sf) {

2. SearchFilter now has a constructor that accepts a String as parameter.

As a result, the code is able to handle the following cases freely:

/search/accountid%3D%271%27+and+balance+between+1+and+2/accountid/1/10
/search/accountid%3D%271%27+and+balance+between+1+and+2
/search?wherecondition=accountid%3D%271%27+and+balance+between+1+and+2&sortstring=accountid&startingrow=1&lastrow=10
/search?wherecondition=accountid%3D%271%27+and+balance+between+1+and+2

wherein defaults may be loaded in the samples 2 and 4 above.

Again, my thanks!

Gabo

Sergey Beryozkin wrote:
> Hi Gabo
>
>> Hi Sergey,
>>
>> > It's correct. Given that you're running a 2.1.4-snapshot, you may
>> want to try
>> > @Path(value="/search/{params}", unlimited=true)
>>
>> Is there a way that the excess/pattern is not captured? Also, I think 
>> the keyword is limited, I'm assuming the value would be false.
>
> Yes, sorry, it should be limited=false.
>
> Please note you can only set a limited value on with 0.8 api, on 2.1.x.
> Another thing, when using arbitrary regular expressions, you probably 
> don't want to use 'limited=false' at all, but rather use just 
> @Path(value="/search{bar:.*}")
>
> Note the syntax of the expression, {bar:.*}, the 'bar' is seperated by 
> ':' from a regular expression.
>
> So, to summarize, on 2.2-snapshot line you can only use custom regular 
> expressions to customize the way some matching is done.
> On 2.1-snapshot, you can use either regular expressions, or in cases 
> where a greedy all-capturing match is needed, limited=false.
> For ex,
> @Path(value="/search{bar:.*}")
> @Path(value="/search{bar},limited=false)
>
> Please try the 2.1.4-SNAPSHOT which Dan released last Friday if you'd 
> like to try the arbitrary reg expressions, otherwise try using 
> limited=false
>
> Cheers, Sergey
>
>
>
>>
>>    @Path(value="/search{.*}", limited=false)
>> results to: Exception in thread "main" 
>> java.util.regex.PatternSyntaxException: Illegal repetition near index 6
>> /search{\.*}(/.*)?
>>
>> which is simply hints that the name is required as specified in the 
>> docs:
>> http://www.jboss.org/file-access/default/members/resteasy/freezone/docs/1.0-beta-9/javadocs/javax/ws/rs/Path.html 
>>
>>
>>    @Path(value="/search.*", limited=false)
>>    @Path(value="/search", limited=false)
>> results to: org.apache.cxf.interceptor.Fault: .No operation matching 
>> request path /search/additional/path/here
>>
>> Gabo
>>
>>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.176 / Virus Database: 270.9.18/1848 - Release Date: 12/14/2008 12:28 PM
>
>   

Re: [JAX-RS][PathParam] object field injection

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

great it's working - I'd also credit the jaxrs experts who came up with the feature and a cxf user who said a couple of months ago 
arbitrary regexs were not supported :-)

Thanks, Sergey

> Hi Sergey,
>
> Just to note down what I did from your suggestions.
>
> Currently, I am using 2.2 snapshot. I have modified the code as follows:
>
> 1. I have defined the method as follows:
>
>    @GET
>    @Path("/{search:search.*}")
>    public WSAccounts getAccounts(
>            @PathParam("search")
>            SearchFilter sf) {
>
> 2. SearchFilter now has a constructor that accepts a String as parameter.
>
> As a result, the code is able to handle the following cases freely:
>
> /search/accountid%3D%271%27+and+balance+between+1+and+2/accountid/1/10
> /search/accountid%3D%271%27+and+balance+between+1+and+2
> /search?wherecondition=accountid%3D%271%27+and+balance+between+1+and+2&sortstring=accountid&startingrow=1&lastrow=10
> /search?wherecondition=accountid%3D%271%27+and+balance+between+1+and+2
>
> wherein defaults may be loaded in the samples 2 and 4 above.
>
> Again, my thanks!
>
> Gabo
>
> Sergey Beryozkin wrote:
>> Hi Gabo
>>
>>> Hi Sergey,
>>>
>>> > It's correct. Given that you're running a 2.1.4-snapshot, you may
>>> want to try
>>> > @Path(value="/search/{params}", unlimited=true)
>>>
>>> Is there a way that the excess/pattern is not captured? Also, I think the keyword is limited, I'm assuming the value would be 
>>> false.
>>
>> Yes, sorry, it should be limited=false.
>>
>> Please note you can only set a limited value on with 0.8 api, on 2.1.x.
>> Another thing, when using arbitrary regular expressions, you probably don't want to use 'limited=false' at all, but rather use 
>> just @Path(value="/search{bar:.*}")
>>
>> Note the syntax of the expression, {bar:.*}, the 'bar' is seperated by ':' from a regular expression.
>>
>> So, to summarize, on 2.2-snapshot line you can only use custom regular expressions to customize the way some matching is done.
>> On 2.1-snapshot, you can use either regular expressions, or in cases where a greedy all-capturing match is needed, limited=false.
>> For ex,
>> @Path(value="/search{bar:.*}")
>> @Path(value="/search{bar},limited=false)
>>
>> Please try the 2.1.4-SNAPSHOT which Dan released last Friday if you'd like to try the arbitrary reg expressions, otherwise try 
>> using limited=false
>>
>> Cheers, Sergey
>>
>>
>>
>>>
>>>    @Path(value="/search{.*}", limited=false)
>>> results to: Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition near index 6
>>> /search{\.*}(/.*)?
>>>
>>> which is simply hints that the name is required as specified in the docs:
>>> http://www.jboss.org/file-access/default/members/resteasy/freezone/docs/1.0-beta-9/javadocs/javax/ws/rs/Path.html
>>>
>>>    @Path(value="/search.*", limited=false)
>>>    @Path(value="/search", limited=false)
>>> results to: org.apache.cxf.interceptor.Fault: .No operation matching request path /search/additional/path/here
>>>
>>> Gabo
>>>
>>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - http://www.avg.com Version: 8.0.176 / Virus Database: 270.9.18/1848 - Release Date: 12/14/2008 12:28 PM
>>
>>
>