1
|
package eu.dnetlib.uoaadmintoolslibrary.controllers;
|
2
|
|
3
|
import eu.dnetlib.uoaadmintoolslibrary.configuration.GlobalVars;
|
4
|
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.GoogleConfig;
|
5
|
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.MailConfig;
|
6
|
import org.apache.log4j.Logger;
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
import org.springframework.security.access.prepost.PreAuthorize;
|
9
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
10
|
import org.springframework.web.bind.annotation.RequestMapping;
|
11
|
import org.springframework.web.bind.annotation.RequestMethod;
|
12
|
import org.springframework.web.bind.annotation.RestController;
|
13
|
|
14
|
import java.util.HashMap;
|
15
|
import java.util.Map;
|
16
|
|
17
|
@RestController
|
18
|
@CrossOrigin(origins = "*")
|
19
|
@RequestMapping("/admin-tools-library")
|
20
|
public class AdminToolsLibraryCheckDeployController {
|
21
|
@Autowired
|
22
|
private MailConfig mailConfig;
|
23
|
|
24
|
@Autowired
|
25
|
private GoogleConfig googleConfig;
|
26
|
|
27
|
@Autowired
|
28
|
private GlobalVars globalVars;
|
29
|
|
30
|
private final Logger log = Logger.getLogger(this.getClass());
|
31
|
|
32
|
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)
|
33
|
public String hello() {
|
34
|
log.debug("Hello from uoa-admin-tools-library!");
|
35
|
return "Hello from uoa-admin-tools-library!";
|
36
|
}
|
37
|
|
38
|
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
39
|
@RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET)
|
40
|
public Map<String, String> checkEverything() {
|
41
|
Map<String, String> response = new HashMap<>();
|
42
|
response.put("admintoolslibrary.mail.auth",mailConfig.getAuth());
|
43
|
response.put("admintoolslibrary.mail.sslProtocols",mailConfig.getSslProtocols());
|
44
|
response.put("admintoolslibrary.mail.from", mailConfig.getFrom());
|
45
|
response.put("admintoolslibrary.mail.host", mailConfig.getHost());
|
46
|
response.put("admintoolslibrary.mail.port", mailConfig.getPort());
|
47
|
response.put("admintoolslibrary.mail.username", mailConfig.getUsername() == null ? null : "[unexposed value]");
|
48
|
response.put("admintoolslibrary.mail.password", mailConfig.getPassword() == null ? null : "[unexposed value]");
|
49
|
response.put("admintoolslibrary.google.secret", googleConfig.getSecret() == null ? null : "[unexposed value]");
|
50
|
|
51
|
if(globalVars.date != null) {
|
52
|
response.put("Date of deploy", globalVars.date.toString());
|
53
|
}
|
54
|
if(globalVars.getBuildDate() != null) {
|
55
|
response.put("Date of build", globalVars.getBuildDate());
|
56
|
}
|
57
|
// response.put("Define also", "admintoolslibrary.mail.username, " +
|
58
|
// "admintoolslibrary.mail.password, admintoolslibrary.google.secret");
|
59
|
return response;
|
60
|
}
|
61
|
}
|
62
|
|