From 81bb301742ddafdc58b63ab6d32f70b46097c789 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 9 Apr 2019 19:10:43 +0300 Subject: Use preconfigured ObjectMapper for ActivityPub client --- .../juick/server/configuration/ActivityPubClientConfig.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main/java/com/juick/server') diff --git a/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java b/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java index d7d49355..65bfeade 100644 --- a/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java +++ b/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java @@ -1,9 +1,11 @@ package com.juick.server.configuration; +import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.server.api.activity.model.Activity; import com.juick.server.helpers.HeaderRequestInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.client.RestTemplate; import javax.inject.Inject; @@ -13,9 +15,18 @@ import java.util.Collections; public class ActivityPubClientConfig { @Inject ActivityPubClientErrorHandler activityPubClientErrorHandler; + @Inject + ObjectMapper jsonMapper; + @Bean + public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() { + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + converter.setObjectMapper(jsonMapper); + return converter; + } @Bean public RestTemplate apClient() { RestTemplate restTemplate = new RestTemplate(); + restTemplate.getMessageConverters().add(0, mappingJacksonHttpMessageConverter()); restTemplate.setErrorHandler(activityPubClientErrorHandler); restTemplate.setInterceptors(Collections.singletonList( new HeaderRequestInterceptor("Accept", Activity.ACTIVITY_MEDIA_TYPE))); -- cgit v1.2.3