package au.gov.ga.geodesy.support.spring;

import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"au.gov.ga.geodesy.port.adapter.rest"})
public class GeodesyRestMvcConfig extends WebMvcConfigurerAdapter {

    @Bean
    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
        MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
        mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper());
        return mappingJackson2HttpMessageConverter;
    }

    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper objMapper = new ObjectMapper();
        objMapper.enable(SerializationFeature.INDENT_OUTPUT);
        return objMapper;
    }

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        super.configureMessageConverters(converters);
        converters.add(mappingJackson2HttpMessageConverter());
    }
}

@@ -234,16 +234,59 @@
 ration;%0A
+import org.springframework.http.MediaType;%0A
 import o
@@ -417,32 +417,119 @@
 ssageConverter;%0A
+import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;%0A
 import org.sprin
@@ -1799,11 +1799,263 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) %7B%0A        configurer%0A            .favorParameter(true)%0A            .useJaf(false)%0A            .mediaType(%22geodesyml%22, MediaType.APPLICATION_XML);%0A    %7D
 %0A%7D%0A

Set accepted content type via a request parameter