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