1
|
package eu.dnetlib.uoamonitorservice.controllers;
|
2
|
|
3
|
|
4
|
import eu.dnetlib.uoamonitorservice.dao.StakeholderDAO;
|
5
|
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
6
|
import org.apache.log4j.Logger;
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
import org.springframework.web.bind.annotation.*;
|
9
|
|
10
|
import java.util.List;
|
11
|
|
12
|
@RestController
|
13
|
@CrossOrigin(origins = "*")
|
14
|
public class TestController {
|
15
|
private final Logger log = Logger.getLogger(this.getClass());
|
16
|
|
17
|
@Autowired
|
18
|
private StakeholderDAO stakeholderDAO;
|
19
|
|
20
|
// @RequestMapping("/")
|
21
|
// public String index() {
|
22
|
// return "Greetings from Spring Boot!";
|
23
|
// }
|
24
|
|
25
|
// Check ExceptionHandler
|
26
|
@RequestMapping(value = "/test-error1", method = RequestMethod.GET)
|
27
|
public Stakeholder getFirstStakeholder() {
|
28
|
List<Stakeholder> stakeholders;
|
29
|
stakeholders = stakeholderDAO.findAll();
|
30
|
|
31
|
return stakeholders.get(0);
|
32
|
}
|
33
|
|
34
|
@RequestMapping(value = "/test-error2", method = RequestMethod.GET)
|
35
|
public String getParam(@RequestParam String param) {
|
36
|
return param;
|
37
|
}
|
38
|
|
39
|
@RequestMapping(value = "/test-error3", method = RequestMethod.GET)
|
40
|
public String getSubstringOfNull() {
|
41
|
String str = null;
|
42
|
return str.substring(2);
|
43
|
}
|
44
|
}
|