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