Revision 60956
Added by Konstantina Galouni almost 3 years ago
AdminToolsLibraryCheckDeployController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.uoaadmintoolslibrary.controllers; |
2 | 2 |
|
3 |
import com.mongodb.BasicDBObject; |
|
4 |
import com.mongodb.CommandResult; |
|
5 |
import com.mongodb.DBObject; |
|
6 |
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.GoogleConfig; |
|
7 |
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.MailConfig; |
|
3 | 8 |
import org.apache.log4j.Logger; |
9 |
import org.springframework.beans.factory.annotation.Autowired; |
|
10 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
4 | 11 |
import org.springframework.web.bind.annotation.CrossOrigin; |
5 | 12 |
import org.springframework.web.bind.annotation.RequestMapping; |
6 | 13 |
import org.springframework.web.bind.annotation.RequestMethod; |
7 | 14 |
import org.springframework.web.bind.annotation.RestController; |
8 | 15 |
|
16 |
import java.util.HashMap; |
|
17 |
import java.util.Map; |
|
18 |
|
|
9 | 19 |
@RestController |
10 | 20 |
@CrossOrigin(origins = "*") |
11 | 21 |
@RequestMapping("/admin-tools-library") |
12 | 22 |
public class AdminToolsLibraryCheckDeployController { |
23 |
@Autowired |
|
24 |
private MailConfig mailConfig; |
|
25 |
|
|
26 |
@Autowired |
|
27 |
private GoogleConfig googleConfig; |
|
28 |
|
|
13 | 29 |
private final Logger log = Logger.getLogger(this.getClass()); |
14 | 30 |
|
15 |
@RequestMapping(value = "", method = RequestMethod.GET)
|
|
31 |
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)
|
|
16 | 32 |
public String hello() { |
17 | 33 |
log.debug("Hello from uoa-admin-tools-library!"); |
18 | 34 |
return "Hello from uoa-admin-tools-library!"; |
19 | 35 |
} |
36 |
|
|
37 |
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)") |
|
38 |
@RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET) |
|
39 |
public Map<String, String> checkEverything() { |
|
40 |
Map<String, String> response = new HashMap<>(); |
|
41 |
response.put("admintoolslibrary.mail.auth",mailConfig.getAuth()); |
|
42 |
response.put("admintoolslibrary.mail.from", mailConfig.getAuth()); |
|
43 |
response.put("admintoolslibrary.mail.host", mailConfig.getHost()); |
|
44 |
response.put("admintoolslibrary.mail.port", mailConfig.getPort()); |
|
45 |
response.put("admintoolslibrary.mail.username", mailConfig.getUsername() == null ? null : "[unexposed value]"); |
|
46 |
response.put("admintoolslibrary.mail.password", mailConfig.getPassword() == null ? null : "[unexposed value]"); |
|
47 |
response.put("admintoolslibrary.google.secret", googleConfig.getSecret() == null ? null : "[unexposed value]"); |
|
48 |
|
|
49 |
// response.put("Define also", "admintoolslibrary.mail.username, " + |
|
50 |
// "admintoolslibrary.mail.password, admintoolslibrary.google.secret"); |
|
51 |
return response; |
|
52 |
} |
|
20 | 53 |
} |
21 | 54 |
|
Also available in: Unified diff
[Trunk | Admin Tools Library]:
1. AdminToolsLibraryCheckDeployController.java:
a. In "hello()" method added @RequestMapping (except for existing ""), "/health_check".
b. Added method "checkEverything()" (/health_chech/advanced) only accessible by PORTAL ADMINS which checks connection with db and prints properties.
2. PortalPage.java: Added default value "false" for position fields (top, bottom, left, right).