| 21561 |
ashik.ali |
1 |
package com.spice.profitmandi.web.config;
|
| 21555 |
kshitij.so |
2 |
|
| 30275 |
amit.gupta |
3 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
4 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
|
|
5 |
import com.spice.profitmandi.web.interceptor.RoleInterceptor;
|
| 21561 |
ashik.ali |
6 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 32773 |
raveendra. |
7 |
import org.springframework.context.annotation.Bean;
|
| 21555 |
kshitij.so |
8 |
import org.springframework.context.annotation.ComponentScan;
|
|
|
9 |
import org.springframework.context.annotation.Configuration;
|
| 23886 |
amit.gupta |
10 |
import org.springframework.format.FormatterRegistry;
|
|
|
11 |
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
| 27013 |
amit.gupta |
12 |
import org.springframework.http.MediaType;
|
| 23878 |
amit.gupta |
13 |
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
14 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
| 32773 |
raveendra. |
15 |
import org.springframework.web.servlet.LocaleResolver;
|
| 30275 |
amit.gupta |
16 |
import org.springframework.web.servlet.config.annotation.*;
|
| 32773 |
raveendra. |
17 |
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
|
|
18 |
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
| 21555 |
kshitij.so |
19 |
|
| 30275 |
amit.gupta |
20 |
import java.util.List;
|
| 32773 |
raveendra. |
21 |
import java.util.Locale;
|
| 21561 |
ashik.ali |
22 |
|
| 21555 |
kshitij.so |
23 |
@EnableWebMvc
|
|
|
24 |
@Configuration
|
| 32916 |
amit.gupta |
25 |
@ComponentScan({"com.spice.profitmandi.*"})
|
| 27013 |
amit.gupta |
26 |
public class WebConfig extends WebMvcConfigurerAdapter {
|
|
|
27 |
|
| 32916 |
amit.gupta |
28 |
private static final String RESOURCES_PATTERN = "/resources/**";
|
|
|
29 |
private static final String RESOURCES_LOCATION = "/resources/";
|
| 27013 |
amit.gupta |
30 |
|
| 32916 |
amit.gupta |
31 |
@Autowired
|
|
|
32 |
AuthenticationInterceptor authenticationInterceptor;
|
| 27013 |
amit.gupta |
33 |
|
| 32916 |
amit.gupta |
34 |
@Autowired
|
|
|
35 |
RoleInterceptor roleInterceptor;
|
| 27013 |
amit.gupta |
36 |
|
| 32916 |
amit.gupta |
37 |
@Autowired
|
|
|
38 |
ObjectMapper objectMapper;
|
| 31281 |
amit.gupta |
39 |
|
| 32916 |
amit.gupta |
40 |
@Override
|
|
|
41 |
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
42 |
registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
|
|
|
43 |
}
|
| 27013 |
amit.gupta |
44 |
|
| 32916 |
amit.gupta |
45 |
@Override
|
|
|
46 |
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
47 |
// registry.addInterceptor()
|
|
|
48 |
registry.addInterceptor(localeChangeInterceptor());
|
|
|
49 |
registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns("/hdfctest/**",
|
|
|
50 |
"/hdfc/**", "/spicemoney/callback", "/login", "/login/", "/forgetPassword", "/forgetPassword/", "/",
|
|
|
51 |
"/checkplans", "/12dashboard34", "/mandii", "/imei/validate", "/fundfina/**", "/virtualaccount/push-credits", "/wa-invoice-send/**",
|
| 33693 |
ranu |
52 |
"/click2call/report-handler", "/click2call/report-handler/recording-url", "/wa-listen", "/upsellPayment/callback");
|
|
|
53 |
registry.addInterceptor(roleInterceptor).excludePathPatterns("/hdfctest/**", "/hdfc/**", "/spicemoney/callback", "/upsellPayment/callback", "/click2call/report-handler/recording-url", "/click2call/report-handler",
|
| 32916 |
amit.gupta |
54 |
"/login", "/login/", "/register", "/register/", "/forgetPassword", "/forgetPassword/", "/", "",
|
|
|
55 |
"/12dashboard34", "/mandii", "/imei/validate", "/fundfina/**", "/virtualaccount/push-credits", "/wa-invoice-send/**", "/wa-listen");
|
|
|
56 |
}
|
| 27013 |
amit.gupta |
57 |
|
| 32916 |
amit.gupta |
58 |
@Override
|
|
|
59 |
public void addFormatters(FormatterRegistry registry) {
|
|
|
60 |
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
|
|
61 |
registrar.setUseIsoFormat(true);
|
|
|
62 |
registrar.registerFormatters(registry);
|
|
|
63 |
}
|
| 23886 |
amit.gupta |
64 |
|
| 32916 |
amit.gupta |
65 |
@Override
|
|
|
66 |
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|
|
67 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
|
|
|
68 |
}
|
| 27013 |
amit.gupta |
69 |
|
|
|
70 |
|
| 32916 |
amit.gupta |
71 |
@Override
|
|
|
72 |
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
|
|
73 |
configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
74 |
}
|
| 27013 |
amit.gupta |
75 |
|
| 32916 |
amit.gupta |
76 |
@Bean
|
|
|
77 |
public LocaleResolver localeResolver() {
|
|
|
78 |
SessionLocaleResolver slr = new SessionLocaleResolver();
|
|
|
79 |
slr.setDefaultLocale(Locale.US);
|
|
|
80 |
return slr;
|
|
|
81 |
}
|
| 32773 |
raveendra. |
82 |
|
| 32916 |
amit.gupta |
83 |
@Bean
|
|
|
84 |
public LocaleChangeInterceptor localeChangeInterceptor() {
|
|
|
85 |
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
|
|
|
86 |
lci.setParamName("lang");
|
|
|
87 |
return lci;
|
|
|
88 |
}
|
| 32773 |
raveendra. |
89 |
|
|
|
90 |
|
| 32793 |
amit.gupta |
91 |
/*@Override
|
| 32773 |
raveendra. |
92 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|
|
93 |
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
|
|
94 |
stringConverter.setSupportedMediaTypes(Arrays.asList(new MediaType("text", "plain", StandardCharsets.UTF_8)));
|
|
|
95 |
converters.add(stringConverter);
|
|
|
96 |
|
|
|
97 |
// Add other converters ...
|
|
|
98 |
}
|
| 32793 |
amit.gupta |
99 |
*/
|
| 32773 |
raveendra. |
100 |
|
| 21555 |
kshitij.so |
101 |
}
|