[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).
This commit is contained in:
Konstantina Galouni 2021-04-22 09:09:16 +00:00
parent 9c57010ca3
commit 62cb461196
2 changed files with 38 additions and 5 deletions

View File

@ -1,21 +1,54 @@
package eu.dnetlib.uoaadmintoolslibrary.controllers; package eu.dnetlib.uoaadmintoolslibrary.controllers;
import com.mongodb.BasicDBObject;
import com.mongodb.CommandResult;
import com.mongodb.DBObject;
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.GoogleConfig;
import eu.dnetlib.uoaadmintoolslibrary.configuration.properties.MailConfig;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@RequestMapping("/admin-tools-library") @RequestMapping("/admin-tools-library")
public class AdminToolsLibraryCheckDeployController { public class AdminToolsLibraryCheckDeployController {
@Autowired
private MailConfig mailConfig;
@Autowired
private GoogleConfig googleConfig;
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = Logger.getLogger(this.getClass());
@RequestMapping(value = "", method = RequestMethod.GET) @RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)
public String hello() { public String hello() {
log.debug("Hello from uoa-admin-tools-library!"); log.debug("Hello from uoa-admin-tools-library!");
return "Hello from uoa-admin-tools-library!"; return "Hello from uoa-admin-tools-library!";
} }
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
@RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET)
public Map<String, String> checkEverything() {
Map<String, String> response = new HashMap<>();
response.put("admintoolslibrary.mail.auth",mailConfig.getAuth());
response.put("admintoolslibrary.mail.from", mailConfig.getAuth());
response.put("admintoolslibrary.mail.host", mailConfig.getHost());
response.put("admintoolslibrary.mail.port", mailConfig.getPort());
response.put("admintoolslibrary.mail.username", mailConfig.getUsername() == null ? null : "[unexposed value]");
response.put("admintoolslibrary.mail.password", mailConfig.getPassword() == null ? null : "[unexposed value]");
response.put("admintoolslibrary.google.secret", googleConfig.getSecret() == null ? null : "[unexposed value]");
// response.put("Define also", "admintoolslibrary.mail.username, " +
// "admintoolslibrary.mail.password, admintoolslibrary.google.secret");
return response;
}
} }

View File

@ -27,10 +27,10 @@ public class PortalPage {
// private Boolean openaire; // private Boolean openaire;
// Posiitions where help texts are allowed for this page // Posiitions where help texts are allowed for this page
private Boolean top; private Boolean top = false;
private Boolean bottom; private Boolean bottom = false;
private Boolean left; private Boolean left = false;
private Boolean right; private Boolean right = false;
public PortalPage() {} public PortalPage() {}