Subversion Repositories SmartDukaan

Rev

Rev 23949 | Rev 23965 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23949 Rev 23954
Line 1... Line 1...
1
package com.spice.profitmandi.web.config;
1
package com.spice.profitmandi.web.config;
2
 
2
 
3
import java.time.LocalDateTime;
-
 
4
import java.time.format.DateTimeFormatter;
-
 
5
import java.time.format.DateTimeFormatterBuilder;
-
 
6
import java.util.List;
3
import java.util.List;
7
 
4
 
-
 
5
import org.apache.logging.log4j.LogManager;
-
 
6
import org.apache.logging.log4j.Logger;
8
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.context.annotation.Bean;
8
import org.springframework.context.annotation.Bean;
10
import org.springframework.context.annotation.ComponentScan;
9
import org.springframework.context.annotation.ComponentScan;
11
import org.springframework.context.annotation.Configuration;
10
import org.springframework.context.annotation.Configuration;
12
import org.springframework.http.converter.HttpMessageConverter;
11
import org.springframework.http.converter.HttpMessageConverter;
Line 14... Line 13...
14
import org.springframework.web.servlet.config.annotation.CorsRegistry;
13
import org.springframework.web.servlet.config.annotation.CorsRegistry;
15
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
14
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
16
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
15
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
17
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
16
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
18
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
17
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
19
 
-
 
20
import com.fasterxml.jackson.databind.ObjectMapper;
18
import com.fasterxml.jackson.databind.ObjectMapper;
21
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
19
import com.fasterxml.jackson.databind.SerializationFeature;
22
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
20
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
23
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
-
 
24
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
-
 
25
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
-
 
26
import com.spice.profitmandi.common.model.ProfitMandiConstants;
21
import com.spice.profitmandi.common.model.ProfitMandiConstants;
27
import com.spice.profitmandi.common.web.interceptor.SimpleCORSInterceptor;
22
import com.spice.profitmandi.common.web.interceptor.SimpleCORSInterceptor;
28
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
23
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
29
 
-
 
30
import springfox.documentation.builders.PathSelectors;
24
import springfox.documentation.builders.PathSelectors;
31
import springfox.documentation.builders.RequestHandlerSelectors;
25
import springfox.documentation.builders.RequestHandlerSelectors;
32
import springfox.documentation.service.ApiInfo;
26
import springfox.documentation.service.ApiInfo;
33
import springfox.documentation.spi.DocumentationType;
27
import springfox.documentation.spi.DocumentationType;
34
import springfox.documentation.spring.web.plugins.Docket;
28
import springfox.documentation.spring.web.plugins.Docket;
Line 40... Line 34...
40
@ComponentScan("com.spice.profitmandi.*")
34
@ComponentScan("com.spice.profitmandi.*")
41
public class WebMVCConfig extends WebMvcConfigurerAdapter{
35
public class WebMVCConfig extends WebMvcConfigurerAdapter{
42
	
36
	
43
	private static final String RESOURCES_PATTERN="/resources/**";
37
	private static final String RESOURCES_PATTERN="/resources/**";
44
	private static final String RESOURCES_LOCATION="/resources/";
38
	private static final String RESOURCES_LOCATION="/resources/";
-
 
39
	
-
 
40
	
45
	public static final DateTimeFormatter FORMATTER =DateTimeFormatter.ofPattern("dd::MM::yyyy");
41
	private static final Logger log = LogManager.getLogger(WebMVCConfig.class);
46
	
42
	
47
	@Autowired
43
	@Autowired
48
	SimpleCORSInterceptor simpleCORSInterceptor;
44
	SimpleCORSInterceptor simpleCORSInterceptor;
49
 
45
 
50
	@Autowired
46
	@Autowired
Line 93... Line 89...
93
	      "License of API",
89
	      "License of API",
94
	      "API license URL");
90
	      "API license URL");
95
	    return apiInfo;
91
	    return apiInfo;
96
	}
92
	}
97
	
93
	
-
 
94
	
98
	@Override
95
	@Override
99
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
96
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-
 
97
 
100
        converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
98
        converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
-
 
99
        super.configureMessageConverters(converters);
101
    }
100
    }
102
	
-
 
103
	@Bean
101
	@Bean
104
	public ObjectMapper objectMapper() {
102
	public ObjectMapper objectMapper() {
105
		DateTimeFormatter f = new DateTimeFormatterBuilder()
103
	    ObjectMapper objectMapper = new ObjectMapper();
106
                .parseCaseInsensitive()
-
 
107
                .append(DateTimeFormatter.ISO_LOCAL_DATE)
-
 
108
                .appendLiteral('T')
-
 
109
                .append(DateTimeFormatter.ISO_LOCAL_TIME)
-
 
110
                .toFormatter();
-
 
111
		LocalDateTimeSerializer serializer = new LocalDateTimeSerializer(f);
104
	    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
112
		LocalDateTimeDeserializer deserializer = new LocalDateTimeDeserializer(f);
-
 
113
		JavaTimeModule jtm = new JavaTimeModule();
105
	    JavaTimeModule javaTimeModule = new JavaTimeModule();
114
		jtm.addSerializer(LocalDateTime.class, serializer);
-
 
115
		jtm.addDeserializer(LocalDateTime.class, deserializer);
-
 
116
		ObjectMapper mapper = new ObjectMapper()
-
 
117
				   .registerModule(new ParameterNamesModule())
-
 
118
				   .registerModule(new   Jdk8Module())
106
	    objectMapper.registerModule(javaTimeModule);
119
				   .registerModule(jtm);
-
 
120
		return mapper;
107
	    return objectMapper;
121
	}
108
	}
-
 
109
 
122
}
110
}
123
111