[Trunk | Admin Tools]:
1. AdminToolsCheckDeployController.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. Layout.java: Commented all fields for layout configuration (e.g. mainColor, buttons,...) and added an Object layoutOptions which includes any required options.
This commit is contained in:
parent
c4f63e0d78
commit
b2254975da
|
@ -1,19 +1,66 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.CommandResult;
|
||||
import com.mongodb.DBObject;
|
||||
import eu.dnetlib.uoaadmintools.configuration.mongo.MongoConnection;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.ManagersApiConfig;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.MongoConfig;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class AdminToolsCheckDeployController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||
@Autowired
|
||||
private MongoConnection mongoConnection;
|
||||
|
||||
@Autowired
|
||||
private MongoConfig mongoConfig;
|
||||
|
||||
@Autowired
|
||||
private ManagersApiConfig managersApiConfig;
|
||||
|
||||
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)
|
||||
public String hello() {
|
||||
log.debug("Hello from uoa-admin-tools!");
|
||||
return "Hello from uoa-admin-tools!";
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET)
|
||||
public Map<String, String> checkEverything() {
|
||||
Map<String, String> response = new HashMap<>();
|
||||
|
||||
MongoTemplate mt = mongoConnection.getMongoTemplate();
|
||||
DBObject ping = new BasicDBObject("ping", "1");
|
||||
try {
|
||||
CommandResult answer = mt.getDb().command(ping);
|
||||
response.put("Mongo try: error", answer.getErrorMessage());
|
||||
} catch (Exception e) {
|
||||
response.put("Mongo catch: error", e.getMessage());
|
||||
}
|
||||
|
||||
response.put("admintool.mongodb.database", mongoConfig.getDatabase());
|
||||
response.put("admintool.mongodb.host", mongoConfig.getHost());
|
||||
response.put("admintool.mongodb.port", mongoConfig.getPort()+"");
|
||||
response.put("admintool.mongodb.username", mongoConfig.getUsername() == null ? null : "[unexposed value]");
|
||||
response.put("admintool.mongodb.password", mongoConfig.getPassword() == null ? null : "[unexposed value]");
|
||||
// response.put("Define also", "admintool.mongodb.username, admintool.mongodb.password");
|
||||
|
||||
response.put("admintool.managers.api.id", managersApiConfig.getId());
|
||||
response.put("admintool.managers.api.email", managersApiConfig.getEmail());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,25 +12,26 @@ public class Layout {
|
|||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
private String mainColor;
|
||||
private String secondaryColor;
|
||||
private Panel panel;
|
||||
private Box box;
|
||||
private Links links;
|
||||
private Buttons buttons;
|
||||
// private String mainColor;
|
||||
// private String secondaryColor;
|
||||
// private Panel panel;
|
||||
// private Box box;
|
||||
// private Links links;
|
||||
// private Buttons buttons;
|
||||
|
||||
private String portalPid;
|
||||
private Object layoutOptions;
|
||||
|
||||
public Layout() { }
|
||||
|
||||
public Layout(String id, String mainColor, String secondaryColor, Panel panel, Box box, Links links, Buttons buttons, String portalPid) {
|
||||
this.id = id;
|
||||
this.mainColor = mainColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
this.panel = panel;
|
||||
this.box = box;
|
||||
this.links = links;
|
||||
this.buttons = buttons;
|
||||
// this.mainColor = mainColor;
|
||||
// this.secondaryColor = secondaryColor;
|
||||
// this.panel = panel;
|
||||
// this.box = box;
|
||||
// this.links = links;
|
||||
// this.buttons = buttons;
|
||||
|
||||
this.portalPid = portalPid;
|
||||
}
|
||||
|
@ -43,53 +44,53 @@ public class Layout {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMainColor() {
|
||||
return mainColor;
|
||||
}
|
||||
|
||||
public void setMainColor(String mainColor) {
|
||||
this.mainColor = mainColor;
|
||||
}
|
||||
|
||||
public String getSecondaryColor() {
|
||||
return secondaryColor;
|
||||
}
|
||||
|
||||
public void setSecondaryColor(String secondaryColor) {
|
||||
this.secondaryColor = secondaryColor;
|
||||
}
|
||||
|
||||
public Panel getPanel() {
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void setPanel(Panel panel) {
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
public Box getBox() {
|
||||
return box;
|
||||
}
|
||||
|
||||
public void setBox(Box box) {
|
||||
this.box = box;
|
||||
}
|
||||
|
||||
public Links getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(Links links) {
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
public Buttons getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void setButtons(Buttons buttons) {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
// public String getMainColor() {
|
||||
// return mainColor;
|
||||
// }
|
||||
//
|
||||
// public void setMainColor(String mainColor) {
|
||||
// this.mainColor = mainColor;
|
||||
// }
|
||||
//
|
||||
// public String getSecondaryColor() {
|
||||
// return secondaryColor;
|
||||
// }
|
||||
//
|
||||
// public void setSecondaryColor(String secondaryColor) {
|
||||
// this.secondaryColor = secondaryColor;
|
||||
// }
|
||||
//
|
||||
// public Panel getPanel() {
|
||||
// return panel;
|
||||
// }
|
||||
//
|
||||
// public void setPanel(Panel panel) {
|
||||
// this.panel = panel;
|
||||
// }
|
||||
//
|
||||
// public Box getBox() {
|
||||
// return box;
|
||||
// }
|
||||
//
|
||||
// public void setBox(Box box) {
|
||||
// this.box = box;
|
||||
// }
|
||||
//
|
||||
// public Links getLinks() {
|
||||
// return links;
|
||||
// }
|
||||
//
|
||||
// public void setLinks(Links links) {
|
||||
// this.links = links;
|
||||
// }
|
||||
//
|
||||
// public Buttons getButtons() {
|
||||
// return buttons;
|
||||
// }
|
||||
//
|
||||
// public void setButtons(Buttons buttons) {
|
||||
// this.buttons = buttons;
|
||||
// }
|
||||
|
||||
public String getPortalPid() {
|
||||
return portalPid;
|
||||
|
@ -98,4 +99,12 @@ public class Layout {
|
|||
public void setPortalPid(String portalPid) {
|
||||
this.portalPid = portalPid;
|
||||
}
|
||||
|
||||
public Object getLayoutOptions() {
|
||||
return layoutOptions;
|
||||
}
|
||||
|
||||
public void setLayoutOptions(Object layoutOptions) {
|
||||
this.layoutOptions = layoutOptions;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue