| 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;
|
| 33756 |
ranu |
5 |
import com.spice.profitmandi.web.interceptor.PostInterceptor;
|
| 30275 |
amit.gupta |
6 |
import com.spice.profitmandi.web.interceptor.RoleInterceptor;
|
| 21561 |
ashik.ali |
7 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 32773 |
raveendra. |
8 |
import org.springframework.context.annotation.Bean;
|
| 21555 |
kshitij.so |
9 |
import org.springframework.context.annotation.ComponentScan;
|
|
|
10 |
import org.springframework.context.annotation.Configuration;
|
| 23886 |
amit.gupta |
11 |
import org.springframework.format.FormatterRegistry;
|
|
|
12 |
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
| 27013 |
amit.gupta |
13 |
import org.springframework.http.MediaType;
|
| 23878 |
amit.gupta |
14 |
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
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 |
|
| 30275 |
amit.gupta |
21 |
import java.util.List;
|
| 32773 |
raveendra. |
22 |
import java.util.Locale;
|
| 21561 |
ashik.ali |
23 |
|
| 21555 |
kshitij.so |
24 |
@EnableWebMvc
|
|
|
25 |
@Configuration
|
| 32916 |
amit.gupta |
26 |
@ComponentScan({"com.spice.profitmandi.*"})
|
| 27013 |
amit.gupta |
27 |
public class WebConfig extends WebMvcConfigurerAdapter {
|
|
|
28 |
|
| 32916 |
amit.gupta |
29 |
private static final String RESOURCES_PATTERN = "/resources/**";
|
|
|
30 |
private static final String RESOURCES_LOCATION = "/resources/";
|
| 27013 |
amit.gupta |
31 |
|
| 32916 |
amit.gupta |
32 |
@Autowired
|
|
|
33 |
AuthenticationInterceptor authenticationInterceptor;
|
| 27013 |
amit.gupta |
34 |
|
| 33756 |
ranu |
35 |
//This interceptor is to ensures only single POST Request is passed at a moment
|
|
|
36 |
//based on idempotency key provided through client side
|
| 32916 |
amit.gupta |
37 |
@Autowired
|
| 33756 |
ranu |
38 |
PostInterceptor postInterceptor;
|
|
|
39 |
|
|
|
40 |
@Autowired
|
| 32916 |
amit.gupta |
41 |
RoleInterceptor roleInterceptor;
|
| 27013 |
amit.gupta |
42 |
|
| 32916 |
amit.gupta |
43 |
@Autowired
|
|
|
44 |
ObjectMapper objectMapper;
|
| 31281 |
amit.gupta |
45 |
|
| 32916 |
amit.gupta |
46 |
@Override
|
|
|
47 |
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
48 |
registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
|
|
|
49 |
}
|
| 27013 |
amit.gupta |
50 |
|
| 32916 |
amit.gupta |
51 |
@Override
|
|
|
52 |
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
53 |
// registry.addInterceptor()
|
|
|
54 |
registry.addInterceptor(localeChangeInterceptor());
|
|
|
55 |
registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns("/hdfctest/**",
|
|
|
56 |
"/hdfc/**", "/spicemoney/callback", "/login", "/login/", "/forgetPassword", "/forgetPassword/", "/",
|
|
|
57 |
"/checkplans", "/12dashboard34", "/mandii", "/imei/validate", "/fundfina/**", "/virtualaccount/push-credits", "/wa-invoice-send/**",
|
| 35033 |
amit |
58 |
"/click2call/report-handler", "/click2call/report-handler/recording-url", "/click2call/push-call-log-handler", "/wa-listen", "/upsellPayment/callback", "/sales/logix");
|
| 34481 |
ranu |
59 |
registry.addInterceptor(roleInterceptor).excludePathPatterns("/hdfctest/**", "/hdfc/**", "/spicemoney/callback", "/upsellPayment/callback", "/click2call/report-handler/recording-url", "/click2call/push-call-log-handler", "/click2call/report-handler",
|
| 32916 |
amit.gupta |
60 |
"/login", "/login/", "/register", "/register/", "/forgetPassword", "/forgetPassword/", "/", "",
|
| 35033 |
amit |
61 |
"/12dashboard34", "/mandii", "/imei/validate", "/fundfina/**", "/virtualaccount/push-credits", "/wa-invoice-send/**", "/wa-listen", "/sendInvoiceOnWhatsApp", "/sales/logix");
|
| 33760 |
ranu |
62 |
registry.addInterceptor(postInterceptor).addPathPatterns("/**").excludePathPatterns("/reports/**", "/hdfctest/**",
|
|
|
63 |
"/hdfc/**", "/spicemoney/callback", "/login", "/login/", "/forgetPassword", "/forgetPassword/", "/", "/checkplans", "/12dashboard34", "/mandii", "/imei/validate", "/fundfina/**", "/virtualaccount/push-credits", "/wa-invoice-send/**",
|
| 35033 |
amit |
64 |
"/click2call/report-handler", "/click2call/report-handler/recording-url", "/click2call/push-call-log-handler", "/wa-listen", "/upsellPayment/callback", "/sales/logix");
|
| 32916 |
amit.gupta |
65 |
}
|
| 27013 |
amit.gupta |
66 |
|
| 32916 |
amit.gupta |
67 |
@Override
|
|
|
68 |
public void addFormatters(FormatterRegistry registry) {
|
|
|
69 |
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
|
|
70 |
registrar.setUseIsoFormat(true);
|
|
|
71 |
registrar.registerFormatters(registry);
|
|
|
72 |
}
|
| 23886 |
amit.gupta |
73 |
|
| 32916 |
amit.gupta |
74 |
@Override
|
|
|
75 |
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|
|
76 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
|
|
|
77 |
}
|
| 27013 |
amit.gupta |
78 |
|
|
|
79 |
|
| 32916 |
amit.gupta |
80 |
@Override
|
|
|
81 |
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
|
|
82 |
configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
83 |
}
|
| 27013 |
amit.gupta |
84 |
|
| 32916 |
amit.gupta |
85 |
@Bean
|
|
|
86 |
public LocaleResolver localeResolver() {
|
|
|
87 |
SessionLocaleResolver slr = new SessionLocaleResolver();
|
|
|
88 |
slr.setDefaultLocale(Locale.US);
|
|
|
89 |
return slr;
|
|
|
90 |
}
|
| 32773 |
raveendra. |
91 |
|
| 32916 |
amit.gupta |
92 |
@Bean
|
|
|
93 |
public LocaleChangeInterceptor localeChangeInterceptor() {
|
|
|
94 |
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
|
|
|
95 |
lci.setParamName("lang");
|
|
|
96 |
return lci;
|
|
|
97 |
}
|
| 32773 |
raveendra. |
98 |
|
|
|
99 |
|
| 32793 |
amit.gupta |
100 |
/*@Override
|
| 32773 |
raveendra. |
101 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|
|
102 |
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
|
|
103 |
stringConverter.setSupportedMediaTypes(Arrays.asList(new MediaType("text", "plain", StandardCharsets.UTF_8)));
|
|
|
104 |
converters.add(stringConverter);
|
|
|
105 |
|
|
|
106 |
// Add other converters ...
|
|
|
107 |
}
|
| 32793 |
amit.gupta |
108 |
*/
|
| 32773 |
raveendra. |
109 |
|
| 21555 |
kshitij.so |
110 |
}
|