/*
 * oxTrust is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.gluu.oxtrust.service.scim2.jackson.provider;

import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

import org.codehaus.jackson.Version;
import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.module.SimpleModule;
import org.gluu.oxtrust.model.scim2.Constants;
import org.gluu.oxtrust.model.scim2.User;
import org.gluu.oxtrust.service.scim2.jackson.custom.UserDeserializer;
import org.gluu.oxtrust.service.scim2.jackson.custom.UserSerializer;
import org.slf4j.Logger;

/**
 * RESTEasy custom Jackson provider-interceptor for registration of custom serializers and deserializers
 * specifically for SCIM 2.0.
 *
 * @author Val Pecaoco
 */
@Provider
@Consumes({Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON})
@Produces({Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON})
@Named("customJacksonProviderScim2")
public class CustomJacksonProviderScim2 extends JacksonJaxbJsonProvider implements ContextResolver<ObjectMapper> {

    @Inject
    private Logger log;

    public CustomJacksonProviderScim2() {

        super();

        log.info(" CustomJacksonProviderScim2() ");

        ObjectMapper mapper = _mapperConfig.getDefaultMapper();
        mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
        mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);

        SimpleModule customJacksonModule = new SimpleModule("CustomJacksonModuleScim2", new Version(1, 0, 0, ""));

        customJacksonModule.addSerializer(User.class, new UserSerializer());
        customJacksonModule.addDeserializer(User.class, new UserDeserializer());

        mapper.registerModule(customJacksonModule);
    }

    @Override
    public ObjectMapper getContext(Class<?> aClass) {
        return _mapperConfig.getDefaultMapper();
    }
}

@@ -976,16 +976,48 @@
 .Logger;
+%0Aimport org.slf4j.LoggerFactory;
 %0A%0A/**%0A *
@@ -1482,24 +1482,99 @@
 tMapper%3E %7B%0A%0A
+/*%0A * Try to enable in next RestEasy releases. Now the value is null%0A */%0A//
     @Inject%0A
@@ -1573,16 +1573,18 @@
 @Inject%0A
+//
     priv
@@ -1598,16 +1598,100 @@
 ger log;
+%0A    private Logger log = LoggerFactory.getLogger(CustomJacksonProviderScim2.class);
 %0A%0A    pu

Disable CID in JacksonJaxbJsonProvider due to problems with Logger injections