Search in sources :

Example 1 with CustomRequestMappingHandlerMapping

use of org.hisp.dhis.webapi.mvc.CustomRequestMappingHandlerMapping 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 CustomRequestMappingHandlerMapping

use of org.hisp.dhis.webapi.mvc.CustomRequestMappingHandlerMapping in project dhis2-core by dhis2.

the class WebMvcConfig method createRequestMappingHandlerMapping.

@Override
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
    CustomRequestMappingHandlerMapping mapping = new CustomRequestMappingHandlerMapping();
    mapping.setOrder(0);
    mapping.setContentNegotiationManager(mvcContentNegotiationManager());
    return mapping;
}
Also used : CustomRequestMappingHandlerMapping(org.hisp.dhis.webapi.mvc.CustomRequestMappingHandlerMapping)

Aggregations

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