Rev 33759 | Rev 34481 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.config;import com.fasterxml.jackson.databind.ObjectMapper;import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;import com.spice.profitmandi.web.interceptor.PostInterceptor;import com.spice.profitmandi.web.interceptor.RoleInterceptor;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;import org.springframework.format.FormatterRegistry;import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;import org.springframework.http.MediaType;import org.springframework.http.converter.HttpMessageConverter;import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;import org.springframework.web.servlet.LocaleResolver;import org.springframework.web.servlet.config.annotation.*;import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;import org.springframework.web.servlet.i18n.SessionLocaleResolver;import java.util.List;import java.util.Locale;@EnableWebMvc@Configuration@ComponentScan({"com.spice.profitmandi.*"})public class WebConfig extends WebMvcConfigurerAdapter {private static final String RESOURCES_PATTERN = "/resources/**";private static final String RESOURCES_LOCATION = "/resources/";@AutowiredAuthenticationInterceptor authenticationInterceptor;//This interceptor is to ensures only single POST Request is passed at a moment//based on idempotency key provided through client side@AutowiredPostInterceptor postInterceptor;@AutowiredRoleInterceptor roleInterceptor;@AutowiredObjectMapper objectMapper;@Overridepublic void addResourceHandlers(ResourceHandlerRegistry registry) {registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);}@Overridepublic void addInterceptors(InterceptorRegistry registry) {// registry.addInterceptor()registry.addInterceptor(localeChangeInterceptor());registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns("/hdfctest/**","/hdfc/**", "/spicemoney/callback", "/login", "/login/", "/forgetPassword", "/forgetPassword/", "/","/checkplans", "/12dashboard34", "/mandii", "/imei/validate", "/fundfina/**", "/virtualaccount/push-credits", "/wa-invoice-send/**","/click2call/report-handler", "/click2call/report-handler/recording-url", "/wa-listen", "/upsellPayment/callback");registry.addInterceptor(roleInterceptor).excludePathPatterns("/hdfctest/**", "/hdfc/**", "/spicemoney/callback", "/upsellPayment/callback", "/click2call/report-handler/recording-url", "/click2call/report-handler","/login", "/login/", "/register", "/register/", "/forgetPassword", "/forgetPassword/", "/", "","/12dashboard34", "/mandii", "/imei/validate", "/fundfina/**", "/virtualaccount/push-credits", "/wa-invoice-send/**", "/wa-listen");registry.addInterceptor(postInterceptor).addPathPatterns("/**").excludePathPatterns("/reports/**", "/hdfctest/**","/hdfc/**", "/spicemoney/callback", "/login", "/login/", "/forgetPassword", "/forgetPassword/", "/", "/checkplans", "/12dashboard34", "/mandii", "/imei/validate", "/fundfina/**", "/virtualaccount/push-credits", "/wa-invoice-send/**","/click2call/report-handler", "/click2call/report-handler/recording-url", "/wa-listen", "/upsellPayment/callback");}@Overridepublic void addFormatters(FormatterRegistry registry) {DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();registrar.setUseIsoFormat(true);registrar.registerFormatters(registry);}@Overridepublic void extendMessageConverters(List<HttpMessageConverter<?>> converters) {converters.add(new MappingJackson2HttpMessageConverter(objectMapper));}@Overridepublic void configureContentNegotiation(ContentNegotiationConfigurer configurer) {configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);}@Beanpublic LocaleResolver localeResolver() {SessionLocaleResolver slr = new SessionLocaleResolver();slr.setDefaultLocale(Locale.US);return slr;}@Beanpublic LocaleChangeInterceptor localeChangeInterceptor() {LocaleChangeInterceptor lci = new LocaleChangeInterceptor();lci.setParamName("lang");return lci;}/*@Overridepublic void configureMessageConverters(List<HttpMessageConverter<?>> converters) {StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();stringConverter.setSupportedMediaTypes(Arrays.asList(new MediaType("text", "plain", StandardCharsets.UTF_8)));converters.add(stringConverter);// Add other converters ...}*/}