| Line 35... |
Line 35... |
| 35 |
|
35 |
|
| 36 |
@Configuration
|
36 |
@Configuration
|
| 37 |
@EnableWebMvc
|
37 |
@EnableWebMvc
|
| 38 |
@EnableSwagger2
|
38 |
@EnableSwagger2
|
| 39 |
@ComponentScan("com.spice.profitmandi.*")
|
39 |
@ComponentScan("com.spice.profitmandi.*")
|
| 40 |
public class WebMVCConfig extends WebMvcConfigurerAdapter{
|
40 |
public class WebMVCConfig extends WebMvcConfigurerAdapter {
|
| 41 |
|
41 |
|
| 42 |
private static final String RESOURCES_PATTERN="/resources/**";
|
42 |
private static final String RESOURCES_PATTERN = "/resources/**";
|
| 43 |
private static final String RESOURCES_LOCATION="/resources/";
|
43 |
private static final String RESOURCES_LOCATION = "/resources/";
|
| 44 |
|
- |
|
| 45 |
|
44 |
|
| 46 |
private static final Logger log = LogManager.getLogger(WebMVCConfig.class);
|
45 |
private static final Logger log = LogManager.getLogger(WebMVCConfig.class);
|
| 47 |
|
46 |
|
| 48 |
@Autowired
|
47 |
@Autowired
|
| 49 |
SimpleCORSInterceptor simpleCORSInterceptor;
|
48 |
SimpleCORSInterceptor simpleCORSInterceptor;
|
| 50 |
|
49 |
|
| 51 |
@Autowired
|
50 |
@Autowired
|
| 52 |
AuthenticationInterceptor authenticationInterceptor;
|
51 |
AuthenticationInterceptor authenticationInterceptor;
|
| 53 |
|
52 |
|
| 54 |
@Bean
|
53 |
@Bean
|
| 55 |
public Docket api() {
|
54 |
public Docket api() {
|
| 56 |
return new Docket(DocumentationType.SWAGGER_2).select()
|
55 |
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
|
| 57 |
.apis(RequestHandlerSelectors.any())
|
- |
|
| 58 |
.paths(PathSelectors.any()).build()
|
56 |
.paths(PathSelectors.any()).build().apiInfo(apiInfo());
|
| 59 |
.apiInfo(apiInfo());
|
- |
|
| 60 |
}
|
57 |
}
|
| 61 |
|
58 |
|
| 62 |
@Override
|
59 |
@Override
|
| 63 |
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
60 |
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
| 64 |
registry.addResourceHandler("swagger-ui.html")
|
- |
|
| 65 |
.addResourceLocations("classpath:/META-INF/resources/");
|
61 |
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
|
| 66 |
registry.addResourceHandler("/webjars/**")
|
- |
|
| 67 |
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
62 |
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
| 68 |
registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
|
63 |
registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
|
| 69 |
}
|
64 |
}
|
| 70 |
|
65 |
|
| 71 |
@Override
|
66 |
@Override
|
| 72 |
public void addInterceptors(InterceptorRegistry registry) {
|
67 |
public void addInterceptors(InterceptorRegistry registry) {
|
| 73 |
registry.addInterceptor(simpleCORSInterceptor).addPathPatterns("/**").excludePathPatterns("/swagger-ui.html",
|
68 |
registry.addInterceptor(simpleCORSInterceptor).addPathPatterns("/**").excludePathPatterns("/swagger-ui.html",
|
| 74 |
ProfitMandiConstants.URL_PAYU_PAY_RESPONSE, ProfitMandiConstants.URL_PAYU_PAY_CANCELLED,
|
69 |
ProfitMandiConstants.URL_PAYU_PAY_RESPONSE, ProfitMandiConstants.URL_PAYU_PAY_CANCELLED,
|
| 75 |
ProfitMandiConstants.URL_CCAVENUE_PAY_RESPONSE, ProfitMandiConstants.URL_CCAVENUE_PAY_CANCELLED,
|
70 |
ProfitMandiConstants.URL_CCAVENUE_PAY_RESPONSE, ProfitMandiConstants.URL_CCAVENUE_PAY_CANCELLED,
|
| 76 |
ProfitMandiConstants.URL_POST_OFFICE);
|
71 |
ProfitMandiConstants.URL_POST_OFFICE, ProfitMandiConstants.URL_NEW_LEAD);
|
| 77 |
|
72 |
|
| 78 |
registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**")
|
73 |
registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**")
|
| 79 |
.excludePathPatterns(ProfitMandiConstants.URL_ADMIN_TOKEN)
|
74 |
.excludePathPatterns(ProfitMandiConstants.URL_ADMIN_TOKEN).excludePathPatterns("/**/swagger*/**")
|
| 80 |
.excludePathPatterns("/**/swagger*/**").excludePathPatterns("/v2/**").excludePathPatterns("/document")
|
75 |
.excludePathPatterns("/v2/**").excludePathPatterns("/document")
|
| 81 |
.excludePathPatterns(ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, ProfitMandiConstants.URL_USER_GOOGLE_LOGIN + "/", ProfitMandiConstants.URL_VERIFY_OTP)
|
76 |
.excludePathPatterns(ProfitMandiConstants.URL_USER_GOOGLE_LOGIN,
|
| 82 |
.excludePathPatterns("/store/token")
|
77 |
ProfitMandiConstants.URL_USER_GOOGLE_LOGIN + "/", ProfitMandiConstants.URL_VERIFY_OTP)
|
| 83 |
.excludePathPatterns("/gc/**");
|
78 |
.excludePathPatterns("/store/token").excludePathPatterns("/gc/**");
|
| 84 |
|
79 |
|
| 85 |
//registry to check api access on basis of UserInfo
|
80 |
// registry to check api access on basis of UserInfo
|
| 86 |
}
|
81 |
}
|
| 87 |
|
82 |
|
| 88 |
@Override
|
83 |
@Override
|
| 89 |
public void addCorsMappings(CorsRegistry registry) {
|
84 |
public void addCorsMappings(CorsRegistry registry) {
|
| 90 |
registry.addMapping("/**").allowedOrigins("*").allowedMethods("*").
|
85 |
registry.addMapping("/**").allowedOrigins("*").allowedMethods("*").allowedHeaders("*").allowCredentials(false);
|
| 91 |
allowedHeaders("*").allowCredentials(false);
|
- |
|
| 92 |
}
|
86 |
}
|
| 93 |
|
87 |
|
| 94 |
private ApiInfo apiInfo() {
|
88 |
private ApiInfo apiInfo() {
|
| 95 |
@SuppressWarnings("deprecation")
|
89 |
@SuppressWarnings("deprecation")
|
| 96 |
ApiInfo apiInfo = new ApiInfo(
|
- |
|
| 97 |
"ProfitMandi API",
|
- |
|
| 98 |
"Api's for profitmandi app",
|
90 |
ApiInfo apiInfo = new ApiInfo("ProfitMandi API", "Api's for profitmandi app", "API TOS", "Terms of service",
|
| 99 |
"API TOS",
|
- |
|
| 100 |
"Terms of service",
|
- |
|
| 101 |
"New Spice Solutions Pvt. Ltd.",
|
91 |
"New Spice Solutions Pvt. Ltd.", "License of API", "API license URL");
|
| 102 |
"License of API",
|
- |
|
| 103 |
"API license URL");
|
- |
|
| 104 |
return apiInfo;
|
92 |
return apiInfo;
|
| 105 |
}
|
93 |
}
|
| 106 |
|
- |
|
| 107 |
|
94 |
|
| 108 |
@Override
|
95 |
@Override
|
| 109 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
96 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
| - |
|
97 |
|
| - |
|
98 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
| - |
|
99 |
super.configureMessageConverters(converters);
|
| - |
|
100 |
}
|
| 110 |
|
101 |
|
| 111 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
- |
|
| 112 |
super.configureMessageConverters(converters);
|
- |
|
| 113 |
}
|
- |
|
| 114 |
@Bean
|
102 |
@Bean
|
| 115 |
public ObjectMapper objectMapper() {
|
103 |
public ObjectMapper objectMapper() {
|
| 116 |
ObjectMapper objectMapper = new ObjectMapper();
|
104 |
ObjectMapper objectMapper = new ObjectMapper();
|
| 117 |
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
105 |
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
| 118 |
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
106 |
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
| 119 |
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
107 |
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
| 120 |
objectMapper.registerModule(javaTimeModule);
|
108 |
objectMapper.registerModule(javaTimeModule);
|
| 121 |
return objectMapper;
|
109 |
return objectMapper;
|
| 122 |
}
|
110 |
}
|
| 123 |
|
- |
|
| 124 |
|
111 |
|
| 125 |
@Override
|
112 |
@Override
|
| 126 |
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
113 |
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
| 127 |
configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
|
114 |
configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
|
| 128 |
}
|
115 |
}
|