Revision 60960
Added by Konstantina Galouni over 3 years ago
modules/uoa-monitor-service/trunk/src/main/java/eu/dnetlib/uoamonitorservice/controllers/IndicatorController.java | ||
---|---|---|
268 | 268 |
} |
269 | 269 |
//if (indicatorPath.getParameters().size() != indicatorPathBasedOnDefault.getParameters().size()) { |
270 | 270 |
//log.debug("Different number of parameters"); |
271 |
for (Map.Entry<String, String> parameter : indicatorPath.getParameters().entrySet()) { |
|
272 |
log.debug("\nindicatorPath: parameter.getKey(): "+parameter.getKey()+" - value: "+parameter.getValue() |
|
273 |
+"\nindicatorPathBasedOnDefault:parameters:key: "+ indicatorPathBasedOnDefault.getParameters().get(parameter.getKey()) |
|
274 |
+"\noldIndicatorPath:parameters:key: "+ (oldIndicatorPath.getParameters() == null ? "null" : oldIndicatorPath.getParameters().get(parameter.getKey()))); |
|
275 |
if (!indicatorPathBasedOnDefault.getParameters().containsKey(parameter.getKey()) |
|
276 |
|| (oldIndicatorPath.getParameters() == null |
|
277 |
|| (oldIndicatorPath.getParameters().get(parameter.getKey()).equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())) |
|
278 |
&& !parameter.getValue().equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())))) |
|
279 |
) { |
|
280 |
indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue()); |
|
281 |
changed = true; |
|
271 |
for (Map.Entry<String, String> parameter : indicatorPath.getParameters().entrySet()) { |
|
272 |
log.debug("\nindicatorPath: parameter.getKey(): "+parameter.getKey()+" - value: "+parameter.getValue() |
|
273 |
+"\nindicatorPathBasedOnDefault:parameters:key: "+ indicatorPathBasedOnDefault.getParameters().get(parameter.getKey()) |
|
274 |
+"\noldIndicatorPath:parameters:key: "+ (oldIndicatorPath.getParameters() == null ? "null" : oldIndicatorPath.getParameters().get(parameter.getKey()))); |
|
275 |
if (!indicatorPathBasedOnDefault.getParameters().containsKey(parameter.getKey()) |
|
276 |
|| (oldIndicatorPath.getParameters() == null || oldIndicatorPath.getParameters().get(parameter.getKey()) == null |
|
277 |
|| (oldIndicatorPath.getParameters().get(parameter.getKey()).equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())) |
|
278 |
&& !parameter.getValue().equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())))) |
|
279 |
) { |
|
280 |
indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue()); |
|
281 |
changed = true; |
|
282 |
} |
|
283 |
// else if(parameter.getKey().equals("type")) { |
|
284 |
// indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue()); |
|
285 |
// changed = true; |
|
286 |
// } |
|
287 |
} |
|
288 |
|
|
289 |
// When deleting indicator path parameters in a default profile, delete them also from all children profiles |
|
290 |
if(oldIndicatorPath.getParameters() != null && indicatorPath.getParameters().size() < oldIndicatorPath.getParameters().size()) { |
|
291 |
for (Map.Entry<String, String> parameter : oldIndicatorPath.getParameters().entrySet()) { |
|
292 |
if(!indicatorPath.getParameters().containsKey(parameter.getKey())) { |
|
293 |
indicatorPathBasedOnDefault.getParameters().remove(parameter.getKey()); |
|
282 | 294 |
} |
283 |
// else if(parameter.getKey().equals("type")) { |
|
284 |
// indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue()); |
|
285 |
// changed = true; |
|
286 |
// } |
|
287 | 295 |
} |
288 |
// TODO when deleting indicator path parameters... ???
|
|
296 |
}
|
|
289 | 297 |
parameterMapping(indicatorPathBasedOnDefault, stakeholder); |
290 | 298 |
//} |
291 | 299 |
} |
... | ... | |
347 | 355 |
changed = true; |
348 | 356 |
} |
349 | 357 |
} |
350 |
// TODO when deleting indicator path json path strings... |
|
358 |
// TODO when deleting indicator path json path strings... --> is this done? (line 327)
|
|
351 | 359 |
} |
352 | 360 |
log.debug("After jsonPath check: " + changed); |
353 | 361 |
} |
modules/uoa-monitor-service/trunk/src/main/java/eu/dnetlib/uoamonitorservice/controllers/TestController.java | ||
---|---|---|
17 | 17 |
@Autowired |
18 | 18 |
private StakeholderDAO stakeholderDAO; |
19 | 19 |
|
20 |
@RequestMapping("/") |
|
21 |
public String index() { |
|
22 |
return "Greetings from Spring Boot!"; |
|
23 |
} |
|
20 |
// @RequestMapping("/")
|
|
21 |
// public String index() {
|
|
22 |
// return "Greetings from Spring Boot!";
|
|
23 |
// }
|
|
24 | 24 |
|
25 | 25 |
// Check ExceptionHandler |
26 | 26 |
@RequestMapping(value = "/test-error1", method = RequestMethod.GET) |
modules/uoa-monitor-service/trunk/src/main/java/eu/dnetlib/uoamonitorservice/controllers/MonitorServiceCheckDeployController.java | ||
---|---|---|
1 |
package eu.dnetlib.uoamonitorservice.controllers; |
|
2 |
|
|
3 |
import com.mongodb.BasicDBObject; |
|
4 |
import com.mongodb.CommandResult; |
|
5 |
import com.mongodb.DBObject; |
|
6 |
import eu.dnetlib.uoamonitorservice.configuration.mongo.MongoConnection; |
|
7 |
import eu.dnetlib.uoamonitorservice.configuration.properties.MongoConfig; |
|
8 |
import org.apache.log4j.Logger; |
|
9 |
import org.springframework.beans.factory.annotation.Autowired; |
|
10 |
import org.springframework.data.mongodb.core.MongoTemplate; |
|
11 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
12 |
import org.springframework.web.bind.annotation.CrossOrigin; |
|
13 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
14 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
15 |
import org.springframework.web.bind.annotation.RestController; |
|
16 |
|
|
17 |
import java.util.HashMap; |
|
18 |
import java.util.Map; |
|
19 |
|
|
20 |
@RestController |
|
21 |
@CrossOrigin(origins = "*") |
|
22 |
public class MonitorServiceCheckDeployController { |
|
23 |
private final Logger log = Logger.getLogger(this.getClass()); |
|
24 |
|
|
25 |
@Autowired |
|
26 |
private MongoConnection mongoConnection; |
|
27 |
|
|
28 |
@Autowired |
|
29 |
private MongoConfig mongoConfig; |
|
30 |
|
|
31 |
@RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET) |
|
32 |
public String hello() { |
|
33 |
log.debug("Hello from uoa-monitor-service!"); |
|
34 |
return "Hello from uoa-monitor-service!"; |
|
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 |
|
|
42 |
MongoTemplate mt = mongoConnection.getMongoTemplate(); |
|
43 |
DBObject ping = new BasicDBObject("ping", "1"); |
|
44 |
try { |
|
45 |
CommandResult answer = mt.getDb().command(ping); |
|
46 |
response.put("Mongo try: error", answer.getErrorMessage()); |
|
47 |
} catch (Exception e) { |
|
48 |
response.put("Mongo catch: error", e.getMessage()); |
|
49 |
} |
|
50 |
|
|
51 |
response.put("monitorservice.mongodb.database", mongoConfig.getDatabase()); |
|
52 |
response.put("monitorservice.mongodb.host", mongoConfig.getHost()); |
|
53 |
response.put("monitorservice.mongodb.port", mongoConfig.getPort()+""); |
|
54 |
response.put("monitorservice.mongodb.username", mongoConfig.getUsername() == null ? null : "[unexposed value]"); |
|
55 |
response.put("monitorservice.mongodb.password", mongoConfig.getPassword() == null ? null : "[unexposed value]"); |
|
56 |
// response.put("Define also", "monitorservice.mongodb.username, monitorservice.mongodb.password"); |
|
57 |
|
|
58 |
return response; |
|
59 |
} |
|
60 |
} |
Also available in: Unified diff
[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.