Search in sources :

Example 16 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project candlepin by candlepin.

the class SyncUtils method getObjectMapper.

public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
    AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
    mapper.setAnnotationIntrospector(pair);
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    // Filter specific things we do not want exported:
    SimpleFilterProvider filterProvider = new SimpleFilterProvider();
    filterProvider.setFailOnUnknownId(false);
    filterProvider = filterProvider.addFilter("EntitlementFilter", SimpleBeanPropertyFilter.serializeAllExcept("consumer"));
    mapper.setFilterProvider(filterProvider);
    mapper.registerModule(productCachedModule);
    if (config != null) {
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, config.getBoolean(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES));
    }
    return mapper;
}
Also used : JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) AnnotationIntrospector(com.fasterxml.jackson.databind.AnnotationIntrospector) JaxbAnnotationIntrospector(com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JaxbAnnotationIntrospector(com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector)

Example 17 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project drill by axbaretto.

the class DefaultSqlHandler method log.

protected void log(final String name, final PhysicalPlan plan, final Logger logger) throws JsonProcessingException {
    if (logger.isDebugEnabled()) {
        PropertyFilter filter = new SimpleBeanPropertyFilter.SerializeExceptFilter(Sets.newHashSet("password"));
        String planText = plan.unparse(context.getLpPersistence().getMapper().writer(new SimpleFilterProvider().addFilter("passwordFilter", filter)));
        logger.debug(name + " : \n" + planText);
    }
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) SimpleBeanPropertyFilter(com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter)

Example 18 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project drill by apache.

the class DefaultSqlHandler method log.

protected void log(final String name, final PhysicalPlan plan, final Logger logger) {
    if (logger.isDebugEnabled()) {
        PropertyFilter filter = new SimpleBeanPropertyFilter.SerializeExceptFilter(Sets.newHashSet("password"));
        String planText = plan.unparse(context.getLpPersistence().getMapper().writer(new SimpleFilterProvider().addFilter("passwordFilter", filter)));
        logger.debug(name + " : \n" + planText);
    }
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) SimpleBeanPropertyFilter(com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter) PropertyFilter(com.fasterxml.jackson.databind.ser.PropertyFilter)

Example 19 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project qpp-conversion-tool by CMSgov.

the class JsonWrapper method outfitMetadataFilter.

/**
 * Outfit the given {@link ObjectMapper} with a filter that will treat all metadata map entries as transient.
 *
 * @param om object mapper to modify
 */
private static void outfitMetadataFilter(ObjectMapper om) {
    SimpleFilterProvider filters = new SimpleFilterProvider();
    filters.addFilter(METADATA_FILTER_LABEL, new MetadataPropertyFilter());
    om.setAnnotationIntrospector(new JsonWrapperIntrospector(METADATA_FILTER_LABEL));
    om.setFilterProvider(filters);
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)

Example 20 with SimpleFilterProvider

use of com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider in project eureka by Netflix.

the class AbstractEurekaJacksonCodec method bindAmazonInfoFilter.

private void bindAmazonInfoFilter(ObjectMapper mapper) {
    SimpleFilterProvider filters = new SimpleFilterProvider();
    final String filterName = "exclude-amazon-info-entries";
    mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() {

        @Override
        public Object findFilterId(Annotated a) {
            if (Map.class.isAssignableFrom(a.getRawType())) {
                return filterName;
            }
            return super.findFilterId(a);
        }
    });
    filters.addFilter(filterName, new SimpleBeanPropertyFilter() {

        @Override
        protected boolean include(BeanPropertyWriter writer) {
            return true;
        }

        @Override
        protected boolean include(PropertyWriter writer) {
            return MINI_AMAZON_INFO_INCLUDE_KEYS.contains(writer.getName());
        }
    });
    mapper.setFilters(filters);
}
Also used : JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) Annotated(com.fasterxml.jackson.databind.introspect.Annotated) SimpleBeanPropertyFilter(com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter) Map(java.util.Map) BeanPropertyWriter(com.fasterxml.jackson.databind.ser.BeanPropertyWriter) BeanPropertyWriter(com.fasterxml.jackson.databind.ser.BeanPropertyWriter) PropertyWriter(com.fasterxml.jackson.databind.ser.PropertyWriter)

Aggregations

SimpleFilterProvider (com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)51 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)21 FilterProvider (com.fasterxml.jackson.databind.ser.FilterProvider)17 PropertyFilter (com.fasterxml.jackson.databind.ser.PropertyFilter)12 SimpleBeanPropertyFilter (com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter)11 Test (org.junit.Test)10 ApiPermissionFilter (io.gravitee.management.service.jackson.filter.ApiPermissionFilter)9 Before (org.junit.Before)9 Test (org.junit.jupiter.api.Test)7 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)6 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)4 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)4 HashSet (java.util.HashSet)4 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)3 JacksonAnnotationIntrospector (com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector)3 lombok.val (lombok.val)3 Log4jLogEvent (org.apache.logging.log4j.core.impl.Log4jLogEvent)3 AuthenticationProperties (org.apereo.cas.configuration.model.core.authentication.AuthenticationProperties)3 LdapAuthenticationProperties (org.apereo.cas.configuration.model.support.ldap.LdapAuthenticationProperties)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3