Search in sources :

Example 1 with CustomPathExtensionContentNegotiationStrategy

use of org.hisp.dhis.webapi.view.CustomPathExtensionContentNegotiationStrategy in project dhis2-core by dhis2.

the class MvcTestConfig method requestMappingHandlerMapping.

@Bean
public CustomRequestMappingHandlerMapping requestMappingHandlerMapping(FormattingConversionService mvcConversionService, ResourceUrlProvider mvcResourceUrlProvider) {
    CustomPathExtensionContentNegotiationStrategy pathExtensionNegotiationStrategy = new CustomPathExtensionContentNegotiationStrategy(mediaTypeMap);
    pathExtensionNegotiationStrategy.setUseRegisteredExtensionsOnly(true);
    ContentNegotiationManager manager = new ContentNegotiationManager(Arrays.asList(pathExtensionNegotiationStrategy, new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.APPLICATION_JSON)));
    CustomRequestMappingHandlerMapping mapping = new CustomRequestMappingHandlerMapping();
    mapping.setOrder(0);
    mapping.setContentNegotiationManager(manager);
    TestInterceptorRegistry registry = new TestInterceptorRegistry();
    addInterceptors(registry);
    registry.addInterceptor(new ConversionServiceExposingInterceptor(mvcConversionService));
    registry.addInterceptor(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider));
    mapping.setInterceptors(registry.getInterceptors().toArray());
    return mapping;
}
Also used : ContentNegotiationManager(org.springframework.web.accept.ContentNegotiationManager) ResourceUrlProviderExposingInterceptor(org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor) ConversionServiceExposingInterceptor(org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor) CustomRequestMappingHandlerMapping(org.hisp.dhis.webapi.mvc.CustomRequestMappingHandlerMapping) FixedContentNegotiationStrategy(org.springframework.web.accept.FixedContentNegotiationStrategy) HeaderContentNegotiationStrategy(org.springframework.web.accept.HeaderContentNegotiationStrategy) CustomPathExtensionContentNegotiationStrategy(org.hisp.dhis.webapi.view.CustomPathExtensionContentNegotiationStrategy) Bean(org.springframework.context.annotation.Bean)

Example 2 with CustomPathExtensionContentNegotiationStrategy

use of org.hisp.dhis.webapi.view.CustomPathExtensionContentNegotiationStrategy in project dhis2-core by dhis2.

the class WebMvcConfig method mvcContentNegotiationManager.

@Primary
@Bean
@Override
public ContentNegotiationManager mvcContentNegotiationManager() {
    CustomPathExtensionContentNegotiationStrategy pathExtensionNegotiationStrategy = new CustomPathExtensionContentNegotiationStrategy(mediaTypeMap);
    pathExtensionNegotiationStrategy.setUseRegisteredExtensionsOnly(true);
    return new ContentNegotiationManager(Arrays.asList(pathExtensionNegotiationStrategy, new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.APPLICATION_JSON)));
}
Also used : ContentNegotiationManager(org.springframework.web.accept.ContentNegotiationManager) FixedContentNegotiationStrategy(org.springframework.web.accept.FixedContentNegotiationStrategy) HeaderContentNegotiationStrategy(org.springframework.web.accept.HeaderContentNegotiationStrategy) CustomPathExtensionContentNegotiationStrategy(org.hisp.dhis.webapi.view.CustomPathExtensionContentNegotiationStrategy) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Aggregations

CustomPathExtensionContentNegotiationStrategy (org.hisp.dhis.webapi.view.CustomPathExtensionContentNegotiationStrategy)2 Bean (org.springframework.context.annotation.Bean)2 ContentNegotiationManager (org.springframework.web.accept.ContentNegotiationManager)2 FixedContentNegotiationStrategy (org.springframework.web.accept.FixedContentNegotiationStrategy)2 HeaderContentNegotiationStrategy (org.springframework.web.accept.HeaderContentNegotiationStrategy)2 CustomRequestMappingHandlerMapping (org.hisp.dhis.webapi.mvc.CustomRequestMappingHandlerMapping)1 Primary (org.springframework.context.annotation.Primary)1 ConversionServiceExposingInterceptor (org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor)1 ResourceUrlProviderExposingInterceptor (org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor)1