1 |
54525
|
panagiotis
|
package eu.dnetlib.repo.manager.config;
|
2 |
50372
|
panagiotis
|
|
3 |
51239
|
panagiotis
|
import org.apache.log4j.Logger;
|
4 |
50372
|
panagiotis
|
import org.springframework.beans.factory.annotation.Value;
|
5 |
54840
|
panagiotis
|
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
6 |
|
|
import org.springframework.context.annotation.*;
|
7 |
51239
|
panagiotis
|
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
8 |
54840
|
panagiotis
|
import org.springframework.http.HttpHeaders;
|
9 |
|
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
10 |
50372
|
panagiotis
|
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
11 |
|
|
import org.springframework.session.web.http.CookieSerializer;
|
12 |
|
|
import org.springframework.session.web.http.DefaultCookieSerializer;
|
13 |
54840
|
panagiotis
|
import org.springframework.web.client.RestTemplate;
|
14 |
50372
|
panagiotis
|
|
15 |
|
|
import javax.annotation.PostConstruct;
|
16 |
|
|
|
17 |
|
|
@Configuration
|
18 |
|
|
@EnableRedisHttpSession
|
19 |
54840
|
panagiotis
|
@EnableAspectJAutoProxy
|
20 |
|
|
@EnableCircuitBreaker
|
21 |
52781
|
panagiotis
|
@PropertySource(value = {"classpath:application.properties"} )
|
22 |
57648
|
antonis.le
|
@ComponentScan(basePackages = {
|
23 |
|
|
"org.eurocris.openaire.cris.validator.service",
|
24 |
|
|
"eu.dnetlib.repo.manager.*"})
|
25 |
50372
|
panagiotis
|
public class Config {
|
26 |
|
|
|
27 |
51239
|
panagiotis
|
private static Logger LOGGER = Logger.getLogger(Config.class);
|
28 |
50372
|
panagiotis
|
|
29 |
56761
|
ioannis.di
|
@Value("${redis.host}")
|
30 |
50372
|
panagiotis
|
private String host;
|
31 |
|
|
|
32 |
|
|
@Value("${redis.port:6379}")
|
33 |
|
|
private String port;
|
34 |
|
|
|
35 |
51330
|
panagiotis
|
@Value("${redis.password}")
|
36 |
50372
|
panagiotis
|
private String password;
|
37 |
|
|
|
38 |
53003
|
panagiotis
|
@Value("${aai.mode}")
|
39 |
|
|
private String aai_mode;
|
40 |
|
|
|
41 |
50372
|
panagiotis
|
@PostConstruct
|
42 |
|
|
private void init(){
|
43 |
56761
|
ioannis.di
|
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
44 |
50372
|
panagiotis
|
}
|
45 |
|
|
|
46 |
|
|
@Bean
|
47 |
56761
|
ioannis.di
|
public JedisConnectionFactory connectionFactory() {
|
48 |
51239
|
panagiotis
|
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
49 |
|
|
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
50 |
|
|
jedisConnectionFactory.setHostName(host);
|
51 |
|
|
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
52 |
56761
|
ioannis.di
|
jedisConnectionFactory.setUsePool(true);
|
53 |
51239
|
panagiotis
|
if(password != null) jedisConnectionFactory.setPassword(password);
|
54 |
|
|
return jedisConnectionFactory;
|
55 |
50372
|
panagiotis
|
}
|
56 |
|
|
|
57 |
|
|
@Bean
|
58 |
|
|
public CookieSerializer cookieSerializer() {
|
59 |
|
|
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
60 |
52465
|
panagiotis
|
serializer.setCookieName("openAIRESession");
|
61 |
|
|
serializer.setCookiePath("/");
|
62 |
53003
|
panagiotis
|
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
63 |
|
|
serializer.setDomainName(".openaire.eu");
|
64 |
52781
|
panagiotis
|
// serializer.setDomainName(".athenarc.gr");
|
65 |
51239
|
panagiotis
|
LOGGER.info("Serializer : " + serializer);
|
66 |
50372
|
panagiotis
|
return serializer;
|
67 |
|
|
}
|
68 |
|
|
|
69 |
54840
|
panagiotis
|
@Bean
|
70 |
|
|
public RestTemplate restTemplate() {
|
71 |
|
|
RestTemplate restTemplate = new RestTemplate();
|
72 |
|
|
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
73 |
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
74 |
|
|
httpHeaders.set("Content-Type", "application/json");
|
75 |
|
|
return restTemplate;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
50372
|
panagiotis
|
}
|