[Trunk | Monitor Service]:
1. MonitorServiceCheckDeployController.java: [NEW] Controller added and a. "hello()" method (@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)) which just prints and returns a greeting message. b. "checkEverything()" method @RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET) only accessible by PORTAL ADMINS which checks connection with db and prints properties. 2. TestController.java: Comment "index()" method with @RequestMapping("/"). 3. IndicatorController.java: [Bug fix] a. Added a check when the value of an indicator path parameter is null b. When an indicator path parameter from a default profile is deleted, delete this parameter also from all profiles based on this default.
This commit is contained in:
parent
ac869dd75b
commit
0c9bc6f006
|
@ -268,24 +268,32 @@ public class IndicatorController {
|
|||
}
|
||||
//if (indicatorPath.getParameters().size() != indicatorPathBasedOnDefault.getParameters().size()) {
|
||||
//log.debug("Different number of parameters");
|
||||
for (Map.Entry<String, String> parameter : indicatorPath.getParameters().entrySet()) {
|
||||
log.debug("\nindicatorPath: parameter.getKey(): "+parameter.getKey()+" - value: "+parameter.getValue()
|
||||
+"\nindicatorPathBasedOnDefault:parameters:key: "+ indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())
|
||||
+"\noldIndicatorPath:parameters:key: "+ (oldIndicatorPath.getParameters() == null ? "null" : oldIndicatorPath.getParameters().get(parameter.getKey())));
|
||||
if (!indicatorPathBasedOnDefault.getParameters().containsKey(parameter.getKey())
|
||||
|| (oldIndicatorPath.getParameters() == null
|
||||
|| (oldIndicatorPath.getParameters().get(parameter.getKey()).equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey()))
|
||||
&& !parameter.getValue().equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey()))))
|
||||
) {
|
||||
indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue());
|
||||
changed = true;
|
||||
}
|
||||
// else if(parameter.getKey().equals("type")) {
|
||||
// indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue());
|
||||
// changed = true;
|
||||
// }
|
||||
for (Map.Entry<String, String> parameter : indicatorPath.getParameters().entrySet()) {
|
||||
log.debug("\nindicatorPath: parameter.getKey(): "+parameter.getKey()+" - value: "+parameter.getValue()
|
||||
+"\nindicatorPathBasedOnDefault:parameters:key: "+ indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())
|
||||
+"\noldIndicatorPath:parameters:key: "+ (oldIndicatorPath.getParameters() == null ? "null" : oldIndicatorPath.getParameters().get(parameter.getKey())));
|
||||
if (!indicatorPathBasedOnDefault.getParameters().containsKey(parameter.getKey())
|
||||
|| (oldIndicatorPath.getParameters() == null || oldIndicatorPath.getParameters().get(parameter.getKey()) == null
|
||||
|| (oldIndicatorPath.getParameters().get(parameter.getKey()).equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey()))
|
||||
&& !parameter.getValue().equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey()))))
|
||||
) {
|
||||
indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue());
|
||||
changed = true;
|
||||
}
|
||||
// TODO when deleting indicator path parameters... ???
|
||||
// else if(parameter.getKey().equals("type")) {
|
||||
// indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue());
|
||||
// changed = true;
|
||||
// }
|
||||
}
|
||||
|
||||
// When deleting indicator path parameters in a default profile, delete them also from all children profiles
|
||||
if(oldIndicatorPath.getParameters() != null && indicatorPath.getParameters().size() < oldIndicatorPath.getParameters().size()) {
|
||||
for (Map.Entry<String, String> parameter : oldIndicatorPath.getParameters().entrySet()) {
|
||||
if(!indicatorPath.getParameters().containsKey(parameter.getKey())) {
|
||||
indicatorPathBasedOnDefault.getParameters().remove(parameter.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
parameterMapping(indicatorPathBasedOnDefault, stakeholder);
|
||||
//}
|
||||
}
|
||||
|
@ -347,7 +355,7 @@ public class IndicatorController {
|
|||
changed = true;
|
||||
}
|
||||
}
|
||||
// TODO when deleting indicator path json path strings...
|
||||
// TODO when deleting indicator path json path strings... --> is this done? (line 327)
|
||||
}
|
||||
log.debug("After jsonPath check: " + changed);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.CommandResult;
|
||||
import com.mongodb.DBObject;
|
||||
import eu.dnetlib.uoamonitorservice.configuration.mongo.MongoConnection;
|
||||
import eu.dnetlib.uoamonitorservice.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 MonitorServiceCheckDeployController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private MongoConnection mongoConnection;
|
||||
|
||||
@Autowired
|
||||
private MongoConfig mongoConfig;
|
||||
|
||||
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET)
|
||||
public String hello() {
|
||||
log.debug("Hello from uoa-monitor-service!");
|
||||
return "Hello from uoa-monitor-service!";
|
||||
}
|
||||
|
||||
@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("monitorservice.mongodb.database", mongoConfig.getDatabase());
|
||||
response.put("monitorservice.mongodb.host", mongoConfig.getHost());
|
||||
response.put("monitorservice.mongodb.port", mongoConfig.getPort()+"");
|
||||
response.put("monitorservice.mongodb.username", mongoConfig.getUsername() == null ? null : "[unexposed value]");
|
||||
response.put("monitorservice.mongodb.password", mongoConfig.getPassword() == null ? null : "[unexposed value]");
|
||||
// response.put("Define also", "monitorservice.mongodb.username, monitorservice.mongodb.password");
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -17,10 +17,10 @@ public class TestController {
|
|||
@Autowired
|
||||
private StakeholderDAO stakeholderDAO;
|
||||
|
||||
@RequestMapping("/")
|
||||
public String index() {
|
||||
return "Greetings from Spring Boot!";
|
||||
}
|
||||
// @RequestMapping("/")
|
||||
// public String index() {
|
||||
// return "Greetings from Spring Boot!";
|
||||
// }
|
||||
|
||||
// Check ExceptionHandler
|
||||
@RequestMapping(value = "/test-error1", method = RequestMethod.GET)
|
||||
|
|
Loading…
Reference in New Issue