You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Woonsan Ko <wo...@yahoo.com> on 2011/10/20 16:20:47 UTC

Is _type parameter name configurable?

Hi,

Is it possible to change (configure) the "_type" parameter [1] name to something else?
I want to use (or allow) a different name such as "fmt" instead.
Or is there any way to customize this?

Thanks!

Woonsan

[1] http://cxf.apache.org/docs/jax-rs.html

Re: Is _type parameter name configurable?

Posted by Woonsan Ko <wo...@yahoo.com>.
Thank you so much, Sergey!
My client wants to use a different name which they have used with a legacy solution.
Thanks again for detailed explanation!

Cheers,

Woonsan


----- Original Message -----
> From: Sergey Beryozkin <sb...@gmail.com>
> To: users@cxf.apache.org
> Cc: 
> Sent: Thursday, October 20, 2011 5:34 PM
> Subject: Re: Is _type parameter name configurable?
> 
> Hi
> 
> On 20/10/11 15:20, Woonsan Ko wrote:
>>  Hi,
>> 
>>  Is it possible to change (configure) the "_type" parameter [1] 
> name to something else?
>>  I want to use (or allow) a different name such as "fmt" instead.
> 
> We've been following the convention that so called system queries should 
> start from '_' for them not to interfere with application queries such 
> 'type', 'format', etc
> 
>>  Or is there any way to customize this?
>> 
> 
> Probably the simplest way at the moment is to register custom CXF in interceptor 
> which will replace 'fmt' with '_type', for example:
> 
> public class UpdateQueryInterceptor extends 
> AbstractPhaseInterceptor<Message> {
> 
>     public UpdateQueryInterceptor() {
>         super(Phase.UNMARSHAL);
>     }
>     public void handleMessage(Message message) {
>        String query = (String)message.get(Message.QUERY_STRING);
>        int index = query.indexOf("fmt=");
>        if (index != -1) {
>            String newQuery;
>            if (index > 0) {
>               newQuery = query.substring(0, index);
>            }
>            newQuery += "_type";
>            newQuery += query.substring(index + 3);
>            message.put(Message.QUERY_STRING, newQuery);
>        }
> 
>     }
> }
> etc...
> and register it within jaxrs:inInterceptors
> 
> HTH, Sergey
> 
>>  Thanks!
>> 
>>  Woonsan
>> 
>>  [1] http://cxf.apache.org/docs/jax-rs.html
>

Re: Is _type parameter name configurable?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On 20/10/11 15:20, Woonsan Ko wrote:
> Hi,
>
> Is it possible to change (configure) the "_type" parameter [1] name to something else?
> I want to use (or allow) a different name such as "fmt" instead.

We've been following the convention that so called system queries should 
start from '_' for them not to interfere with application queries such 
'type', 'format', etc

> Or is there any way to customize this?
>

Probably the simplest way at the moment is to register custom CXF in 
interceptor which will replace 'fmt' with '_type', for example:

public class UpdateQueryInterceptor extends 
AbstractPhaseInterceptor<Message> {

     public UpdateQueryInterceptor() {
         super(Phase.UNMARSHAL);
     }
     public void handleMessage(Message message) {
        String query = (String)message.get(Message.QUERY_STRING);
        int index = query.indexOf("fmt=");
        if (index != -1) {
            String newQuery;
            if (index > 0) {
               newQuery = query.substring(0, index);
            }
            newQuery += "_type";
            newQuery += query.substring(index + 3);
            message.put(Message.QUERY_STRING, newQuery);
        }

     }
}
etc...
and register it within jaxrs:inInterceptors

HTH, Sergey

> Thanks!
>
> Woonsan
>
> [1] http://cxf.apache.org/docs/jax-rs.html