use of org.springframework.http.converter.StringHttpMessageConverter in project books by aidanwhiteley.
the class GoogleBooksDaoSync method searchGoogBooksByTitle.
public BookSearchResult searchGoogBooksByTitle(String title) {
String encodedTitle;
encodedTitle = URLEncoder.encode(title, StandardCharsets.UTF_8);
googleBooksRestTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
final String searchString = googleBooksApiConfig.getSearchUrl() + encodedTitle + "&" + googleBooksApiConfig.getCountryCode() + "&" + googleBooksApiConfig.getMaxResults();
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Google Books API called with API called: {}", searchString);
}
BookSearchResult result = googleBooksRestTemplate.getForObject(searchString, BookSearchResult.class);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Result of Google Books API call: {}", result);
}
return result;
}
use of org.springframework.http.converter.StringHttpMessageConverter in project plumdo-work by wengwh.
the class CustomerErrorHandler method restTemplate.
@Bean
@ConditionalOnMissingBean({ RestOperations.class, RestTemplate.class })
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory());
restTemplate.setErrorHandler(new CustomerErrorHandler());
List<HttpMessageConverter<?>> messageConverters = restTemplate.getMessageConverters();
messageConverters.removeIf(converter -> converter instanceof StringHttpMessageConverter);
messageConverters.add(new StringHttpMessageConverter(Charset.forName(CoreConstant.DEFAULT_CHARSET)));
return restTemplate;
}
use of org.springframework.http.converter.StringHttpMessageConverter in project tutorials by eugenp.
the class WebConfig method configureMessageConverters.
//
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.indentOutput(true).dateFormat(new SimpleDateFormat("dd-MM-yyyy hh:mm"));
messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build()));
messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build()));
messageConverters.add(createXmlHttpMessageConverter());
// messageConverters.add(new MappingJackson2HttpMessageConverter());
messageConverters.add(new ProtobufHttpMessageConverter());
messageConverters.add(new KryoHttpMessageConverter());
messageConverters.add(new StringHttpMessageConverter());
super.configureMessageConverters(messageConverters);
}
use of org.springframework.http.converter.StringHttpMessageConverter in project new-cloud by xie-summer.
the class QQOAuth2Template method createRestTemplate.
/**
* 坑,日志debug模式才打印出来 处理qq返回的text/html 类型数据
*
* @return
*/
@Override
protected RestTemplate createRestTemplate() {
RestTemplate restTemplate = super.createRestTemplate();
restTemplate.getMessageConverters().add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
return restTemplate;
}
use of org.springframework.http.converter.StringHttpMessageConverter in project ontrack by nemerosa.
the class WebConfig method configureMessageConverters.
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.clear();
// Plain text
converters.add(new StringHttpMessageConverter());
// Documents
converters.add(new DocumentHttpMessageConverter());
// JSON
converters.add(new ResourceHttpMessageConverter(uriBuilder, securityService, resourceModules));
}
Aggregations