// Path: src/main/java/org/springframework/social/tumblr/api/impl/json/TumblrModule.java
// public class TumblrModule extends SimpleModule {
//     public TumblrModule() {
//         super("TumblrModule", new Version(1, 0, 0, null, "org.springframework.social", "spring-social-tumblr"));
//     }
// 
//     @Override
//     public void setupModule(SetupContext context) {
//         context.setMixInAnnotations(TumblrResponse.class, TumblrResponseMixin.class);
//         context.setMixInAnnotations(UserInfo.class, UserInfoMixin.class);
//         context.setMixInAnnotations(UserInfoBlog.class, UserInfoBlogMixin.class);
//         context.setMixInAnnotations(BlogInfo.class, BlogInfoMixin.class);
//         context.setMixInAnnotations(Followers.class, FollowersMixin.class);
//         context.setMixInAnnotations(Following.class, FollowingMixin.class);
//         context.setMixInAnnotations(Posts.class, PostsMixin.class);
//         context.setMixInAnnotations(Post.class, PostMixin.class);
//         context.setMixInAnnotations(Likes.class, LikesMixin.class);
//     }
// }
// 
// Path: src/main/java/org/springframework/social/tumblr/api/impl/json/TumblrResponse.java
// public class TumblrResponse {
// 
//     private int status;
//     private String message;
//     private String responseJson;
// 
//     public int getStatus() {
//         return status;
//     }
// 
//     public void setStatus(int status) {
//         this.status = status;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     public void setMessage(String message) {
//         this.message = message;
//     }
// 
//     public String getResponseJson() {
//         return responseJson;
//     }
// 
//     public void setResponseJson(String responseJson) {
//         this.responseJson = responseJson;
//     }
// }


import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.social.tumblr.api.impl.json.TumblrModule;
import org.springframework.social.tumblr.api.impl.json.TumblrResponse;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
import java.io.EOFException;
import java.io.IOException;
import java.lang.reflect.Type;
package org.springframework.social.tumblr.api.impl;



public class TumblrHttpMessageConverter extends MappingJackson2HttpMessageConverter {

    private ObjectMapper objectMapper = new ObjectMapper();

    public TumblrHttpMessageConverter() {
        objectMapper.registerModule(new TumblrModule());
//        objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        setObjectMapper(objectMapper);
    }

    @Override
    public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
        try {
            TumblrResponse tumblrResponse = objectMapper.readValue(inputMessage.getBody(), TumblrResponse.class);
            checkResponse(tumblrResponse);
            Object result;
            if (TumblrResponse.class.equals(type)) {
                // don't parse the response json, callee is going to process is manually
                result = tumblrResponse;
            } else {
                // parse the response json into an instance of the given class
                JavaType javaType = getJavaType(type, contextClass);
                result = objectMapper.readValue(tumblrResponse.getResponseJson(), javaType);
            }
// Path: src/main/java/org/springframework/social/tumblr/api/impl/json/TumblrModule.java
// public class TumblrModule extends SimpleModule {
//     public TumblrModule() {
//         super("TumblrModule", new Version(1, 0, 0, null, "org.springframework.social", "spring-social-tumblr"));
//     }
// 
//     @Override
//     public void setupModule(SetupContext context) {
//         context.setMixInAnnotations(TumblrResponse.class, TumblrResponseMixin.class);
//         context.setMixInAnnotations(UserInfo.class, UserInfoMixin.class);
//         context.setMixInAnnotations(UserInfoBlog.class, UserInfoBlogMixin.class);
//         context.setMixInAnnotations(BlogInfo.class, BlogInfoMixin.class);
//         context.setMixInAnnotations(Followers.class, FollowersMixin.class);
//         context.setMixInAnnotations(Following.class, FollowingMixin.class);
//         context.setMixInAnnotations(Posts.class, PostsMixin.class);
//         context.setMixInAnnotations(Post.class, PostMixin.class);
//         context.setMixInAnnotations(Likes.class, LikesMixin.class);
//     }
// }
// 
// Path: src/main/java/org/springframework/social/tumblr/api/impl/json/TumblrResponse.java
// public class TumblrResponse {
// 
//     private int status;
//     private String message;
//     private String responseJson;
// 
//     public int getStatus() {
//         return status;
//     }
// 
//     public void setStatus(int status) {
//         this.status = status;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     public void setMessage(String message) {
//         this.message = message;
//     }
// 
//     public String getResponseJson() {
//         return responseJson;
//     }
// 
//     public void setResponseJson(String responseJson) {
//         this.responseJson = responseJson;
//     }
// }


// Path: src/main/java/org/springframework/social/tumblr/api/impl/TumblrHttpMessageConverter.java
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.social.tumblr.api.impl.json.TumblrModule;
import org.springframework.social.tumblr.api.impl.json.TumblrResponse;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
import java.io.EOFException;
import java.io.IOException;
import java.lang.reflect.Type;

package org.springframework.social.tumblr.api.impl;



public class TumblrHttpMessageConverter extends MappingJackson2HttpMessageConverter {

    private ObjectMapper objectMapper = new ObjectMapper();

    public TumblrHttpMessageConverter() {
        objectMapper.registerModule(new TumblrModule());
//        objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        setObjectMapper(objectMapper);
    }

    @Override
    public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
        try {
            TumblrResponse tumblrResponse = objectMapper.readValue(inputMessage.getBody(), TumblrResponse.class);
            checkResponse(tumblrResponse);
            Object result;
            if (TumblrResponse.class.equals(type)) {
                // don't parse the response json, callee is going to process is manually
                result = tumblrResponse;
            } else {
                // parse the response json into an instance of the given class
                JavaType javaType = getJavaType(type, contextClass);
                result = objectMapper.readValue(tumblrResponse.getResponseJson(), javaType);
            }
            return result;