Filtering is applied even for POST requests

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Filtering is applied even for POST requests

Amghari, Mohamed

Hi Team,

 

I have an issue when trying to put in place the “selectable entity filtering”. I have an Abstract class like following one:

    public AbstractApplication(String binderResourceFileName, Feature defaultOneInWorstCase,

                               String... prefixPackages) {

 

        super();

 

        property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);

 

        // Register entity-filtering selectable feature.

        register(SelectableEntityFilteringFeature.class);

        property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select");

 

        register(JacksonFeature.class);

 

 

…..

 

Before registering the “selectable entity filtering” all was working fine, I tested that a lot.

 

And after registering “selectable entity filtering” I have the following error:

 

[2016-02-15 17:25:36] - DEBUG EntityMapper:116 [http-bio-8080-exec-3] Preparing query INSERT INTO

[2016-02-15 17:25:43] - ERROR JsonMappingExceptionMapper:29 [http-bio-8080-exec-3] Malformed Json!

com.fasterxml.jackson.databind.JsonMappingException: Can not resolve PropertyFilter with id 'java.util.HashMap'; no FilterProvider configured

      at com.fasterxml.jackson.databind.ser.std.StdSerializer.findPropertyFilter(StdSerializer.java:285)

      at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:459)

      at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:29)

      at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:129)

      at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:851)

      at com.fasterxml.jackson.jaxrs.base.ProviderBase.writeTo(ProviderBase.java:650)

      at org.glassfish.jersey.jackson.internal.FilteringJacksonJaxbJsonProvider.writeTo(FilteringJacksonJaxbJsonProvider.java:135)

      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)

      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)

      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)

      at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106)

      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)

      at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86)

 

It seems that the issue comes from the StdSerializer.findPropertyFilter(StdSerializer.java:285)

    protected PropertyFilter findPropertyFilter(SerializerProvider provider,

            Object filterId, Object valueToFilter)

        throws JsonMappingException

    {

        FilterProvider filters = provider.getFilterProvider();

        // Not ok to miss the provider, if a filter is declared to be needed.

        if (filters == null) {

            throw new JsonMappingException("Can not resolve PropertyFilter with id '"+filterId+"'; no FilterProvider configured");

        }

        PropertyFilter filter = filters.findPropertyFilter(filterId, valueToFilter);

        // But whether unknown ids are ok just depends on filter provider; if we get null that's fine

        return filter;

    }

 

 

I don’t understand why the filtering is activated even in POST requests ? The strange thing is I didn’t put the “select” query parameter in the request!

Could you please help ?

 

 

POST to : http://server:port/api/v1/service     

JSON:

{

                "ownerID": "10",

               

                "addresses": [{

                                "addressType": "Origin",

                                "addressLines": [{

                                                "addressLine": "Line 1"

                                },

                                {

                                                "addressLine": "Line 2"

                                },

                                {

                                                "addressLine": "Line 3"

                                }],

                                "postalCode": "12345",

                },

                {

                                "addressType": "Destination",

                                "addressLines": [{

                                                "addressLine": "Line 1"

                                },

                                {

                                                "addressLine": "Line 2"

                                },

                                {

                                                "addressLine": "Line 3"

                                }],

                                "postalCode": "12345",

                }],

                "metaData": {

                                "prop1": "value of prop 1"

                }

}

 

The metaData is mapped as an HashMap in the Pojo class.

 

 

Best regards,

Mohamed Amghari

Loading...