Subversion Repositories SmartDukaan

Rev

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

Rev 26558 Rev 27013
Line 9... Line 9...
9
import org.springframework.context.annotation.Bean;
9
import org.springframework.context.annotation.Bean;
10
import org.springframework.context.annotation.ComponentScan;
10
import org.springframework.context.annotation.ComponentScan;
11
import org.springframework.context.annotation.Configuration;
11
import org.springframework.context.annotation.Configuration;
12
import org.springframework.format.FormatterRegistry;
12
import org.springframework.format.FormatterRegistry;
13
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
13
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
-
 
14
import org.springframework.http.MediaType;
14
import org.springframework.http.converter.HttpMessageConverter;
15
import org.springframework.http.converter.HttpMessageConverter;
15
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
16
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-
 
17
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
16
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
18
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
17
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
19
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
18
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
20
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
19
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
21
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
20
 
22
 
Line 27... Line 29...
27
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
29
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
28
import com.spice.profitmandi.web.interceptor.RoleInterceptor;
30
import com.spice.profitmandi.web.interceptor.RoleInterceptor;
29
 
31
 
30
@EnableWebMvc
32
@EnableWebMvc
31
@Configuration
33
@Configuration
32
@ComponentScan({"com.spice.profitmandi.*"})
34
@ComponentScan({ "com.spice.profitmandi.*" })
33
public class WebConfig extends WebMvcConfigurerAdapter{
35
public class WebConfig extends WebMvcConfigurerAdapter {
34
	
36
 
35
	private static final String RESOURCES_PATTERN="/resources/**";
37
	private static final String RESOURCES_PATTERN = "/resources/**";
36
	private static final String RESOURCES_LOCATION="/resources/";
38
	private static final String RESOURCES_LOCATION = "/resources/";
37
	
39
 
38
	@Autowired
40
	@Autowired
39
	AuthenticationInterceptor authenticationInterceptor;
41
	AuthenticationInterceptor authenticationInterceptor;
40
	
42
 
41
	@Autowired
43
	@Autowired
42
	RoleInterceptor roleInterceptor;
44
	RoleInterceptor roleInterceptor;
43
	
45
 
44
	@Override
46
	@Override
45
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
47
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
46
	   registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
48
		registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
47
	}
49
	}
48
	
50
 
49
	@Override
51
	@Override
50
	public void addInterceptors(InterceptorRegistry registry) {
52
	public void addInterceptors(InterceptorRegistry registry) {
51
		//registry.addInterceptor()
53
		// registry.addInterceptor()
52
		registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns(
54
		registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns("/hdfctest/**",
53
				"/hdfctest/**", "/hdfc/**", "/spicemoney/callback",
-
 
54
				"/login", "/login/","/forgetPassword","/forgetPassword/", "/", "/checkplans", "/12dashboard34"
55
				"/hdfc/**", "/spicemoney/callback", "/login", "/login/", "/forgetPassword", "/forgetPassword/", "/",
55
				);
-
 
56
		registry.addInterceptor(roleInterceptor).excludePathPatterns(
56
				"/checkplans", "/12dashboard34");
57
				"/hdfctest/**", "/hdfc/**", "/spicemoney/callback",
57
		registry.addInterceptor(roleInterceptor).excludePathPatterns("/hdfctest/**", "/hdfc/**", "/spicemoney/callback",
58
				"/login", "/login/", "/register", "/register/","/forgetPassword","/forgetPassword/", "/","", "/12dashboard34");
58
				"/login", "/login/", "/register", "/register/", "/forgetPassword", "/forgetPassword/", "/", "",
-
 
59
				"/12dashboard34");
59
	}
60
	}
60
	
61
 
61
	@Override
62
	@Override
62
    public void addFormatters(FormatterRegistry registry) {
63
	public void addFormatters(FormatterRegistry registry) {
63
        DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
64
		DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
64
        registrar.setUseIsoFormat(true);
65
		registrar.setUseIsoFormat(true);
65
        registrar.registerFormatters(registry);
66
		registrar.registerFormatters(registry);
66
    }
67
	}
67
 
68
 
68
	
-
 
69
	
-
 
70
	@Override
69
	@Override
71
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
70
	public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
72
        converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
71
		converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
73
    }
72
	}
74
	
73
 
75
	@Bean
74
	@Bean
76
	public ObjectMapper objectMapper() {
75
	public ObjectMapper objectMapper() {
77
		DateTimeFormatter df = new DateTimeFormatterBuilder()
76
		DateTimeFormatter df = new DateTimeFormatterBuilder().parseCaseInsensitive()
78
                .parseCaseInsensitive()
-
 
79
                .append(DateTimeFormatter.ISO_LOCAL_DATE)
77
				.append(DateTimeFormatter.ISO_LOCAL_DATE).optionalStart().appendLiteral('T').optionalEnd()
80
                .optionalStart()
-
 
81
                .appendLiteral('T')
-
 
82
                .optionalEnd()
-
 
83
                .appendLiteral(' ')
-
 
84
                .append(DateTimeFormatter.ISO_LOCAL_TIME)
78
				.appendLiteral(' ').append(DateTimeFormatter.ISO_LOCAL_TIME).toFormatter();
85
                .toFormatter();
-
 
86
		DateTimeFormatter sf = new DateTimeFormatterBuilder()
79
		DateTimeFormatter sf = new DateTimeFormatterBuilder().parseCaseInsensitive()
87
				.parseCaseInsensitive()
-
 
88
				.append(DateTimeFormatter.ISO_LOCAL_DATE)
-
 
89
				.appendLiteral('T')
-
 
90
				.append(DateTimeFormatter.ISO_LOCAL_TIME)
80
				.append(DateTimeFormatter.ISO_LOCAL_DATE).appendLiteral('T').append(DateTimeFormatter.ISO_LOCAL_TIME)
91
				.toFormatter();
81
				.toFormatter();
92
		LocalDateTimeSerializer serializer = new LocalDateTimeSerializer(sf);
82
		LocalDateTimeSerializer serializer = new LocalDateTimeSerializer(sf);
93
		LocalDateTimeDeserializer deserializer = new LocalDateTimeDeserializer(df);
83
		LocalDateTimeDeserializer deserializer = new LocalDateTimeDeserializer(df);
94
		JavaTimeModule jtm = new JavaTimeModule();
84
		JavaTimeModule jtm = new JavaTimeModule();
95
		jtm.addSerializer(LocalDateTime.class, serializer);
85
		jtm.addSerializer(LocalDateTime.class, serializer);
96
		jtm.addDeserializer(LocalDateTime.class, deserializer);
86
		jtm.addDeserializer(LocalDateTime.class, deserializer);
97
		ObjectMapper mapper = new ObjectMapper()
-
 
98
				   .registerModule(new ParameterNamesModule())
87
		ObjectMapper mapper = new ObjectMapper().registerModule(new ParameterNamesModule())
99
				   .registerModule(new Jdk8Module())
-
 
100
				   .registerModule(jtm); // new module, NOT JSR310Module
88
				.registerModule(new Jdk8Module()).registerModule(jtm); // new module, NOT JSR310Module
101
		return mapper;
89
		return mapper;
102
	}
90
	}
-
 
91
 
-
 
92
	@Override
-
 
93
	public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
-
 
94
		configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
103
	
95
	}
-
 
96
 
104
}
97
}