2014-04-22 15:13 GMT+02:00 Sergey Beryozkin <[email protected]>:
> Hi
>
> It is not possible to control it at the JAX-RS filter level; you can for
> XML, but using the CXF specific approach, unfortunately the idea of managing
> the 'typed' entity streams at the filter level was not supported, example,
> InputStream vs XMLStreamReader, etc.
>
> So, add a basic custom XMLStreamReaderm, example,
>
> import javax.xml.stream.XMLStreamReader;
>
> import org.apache.cxf.staxutils.DepthXMLStreamReader;
>
> public class CustomXmlStreamReader extends DepthXMLStreamReader {
>     public CustomXmlStreamReader(XMLStreamReader reader) {
>         super(reader);
>     }
>
> }
>
> and then extend JSONProvider and provide this implementation

Thanks, but I guess it's more complicated

Mapping null to "" is performed by fixNull() method in
com.sun.xml.bind.v2.runtime.unmarshaller.StAXConnector and it's called
during unmarshalling process

Finallly , I made a custom RequestHandler.

http://pastebin.com/HSY06TGb

It has got some drawbacks:

- if you are using schema-validation and your schema supports nillable
+ required fields, this filter doesn't work properly, because the
filter removes all field:null


Thanks and regards



>
> Cheers, Sergey
>
>
> On 22/04/14 12:42, Jose María Zaragoza wrote:
>>
>> Hello:
>>
>> I'm using CXF 2.7.8
>>
>> I've created a REST service . Format for POST messages is JSON
>>
>> Sometimes , the service receives null values
>>
>> { .... , ·"field": null , .....}
>>
>>
>> I want to develop a JAXRS filter to remove this fields.
>> So, I need to modify message . I would like to know if :
>>
>> is there any JAXRS template to extract JSON fields and remove them
>> dynamically ?
>> other choice?
>> something as Transformation Feature ?
>>
>>
>> Example Filter :
>>
>> @Override
>> public Response handleRequest(Message  message, ClassResourceInfo
>> resourceClass)
>> {
>> @SuppressWarnings("unchecked")
>> MetadataMap<String, String> map =  (MetadataMap<String, String>)
>> message.get("jaxrs.template.???????");
>>
>>   if(null != map)
>>          {
>>
>>          for (Map.Entry<String, List<String>> entry: map.entrySet())
>>          {
>>          System.out.println("key:" + entry.getKey() + "- value:" +
>> entry.getValue());
>>          }
>>
>>          }
>>     return null;
>>
>> }
>>
>>
>> Regards
>>
>

Reply via email to