TSK-1112 Changed @RequestMapping to @PostMapping / @GetMapping / ...

TSK-1112 deleted suppressWarnings

TSK-1112 Removed duplicated method
This commit is contained in:
Sofie Hofmann 2020-02-17 13:15:18 +01:00
parent 2bed17cc62
commit 9546ff37b2
4 changed files with 25 additions and 19 deletions

View File

@ -3,7 +3,8 @@ package pro.taskana;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -27,7 +28,7 @@ public class TaskanaTestController {
@Autowired private TaskanaEngine taskanaEngine; @Autowired private TaskanaEngine taskanaEngine;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@RequestMapping("/schema") @GetMapping(path = "/schema")
public @ResponseBody String schema() { public @ResponseBody String schema() {
String schema = jdbcTemplate.queryForObject("SELECT SCHEMA()", String.class); String schema = jdbcTemplate.queryForObject("SELECT SCHEMA()", String.class);
System.err.println("current schema: " + schema); System.err.println("current schema: " + schema);
@ -35,19 +36,19 @@ public class TaskanaTestController {
} }
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
@RequestMapping("/workbaskets") @GetMapping(path = "/workbaskets")
public @ResponseBody Integer workbaskets() { public @ResponseBody Integer workbaskets() {
return getWorkbaskets(); return getWorkbaskets();
} }
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
@RequestMapping("/customdb-tests") @GetMapping(path = "/customdb-tests")
public @ResponseBody Integer customdbTests() { public @ResponseBody Integer customdbTests() {
return getCustomdbTests(); return getCustomdbTests();
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@RequestMapping("/transaction") @GetMapping(path = "/transaction")
public @ResponseBody String transaction( public @ResponseBody String transaction(
@RequestParam(value = "rollback", defaultValue = "false") String rollback) @RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
@ -55,7 +56,7 @@ public class TaskanaTestController {
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key", "workbasket")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key", "workbasket"));
int workbaskets = getWorkbaskets(); int workbaskets = getWorkbaskets();
if (Boolean.valueOf(rollback)) { if (Boolean.parseBoolean(rollback)) {
throw new RuntimeException("workbaskets: " + workbaskets); throw new RuntimeException("workbaskets: " + workbaskets);
} else { } else {
return "workbaskets: " + workbaskets; return "workbaskets: " + workbaskets;
@ -63,7 +64,7 @@ public class TaskanaTestController {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@RequestMapping("/transaction-many") @GetMapping(path = "/transaction-many")
public @ResponseBody String transactionMany( public @ResponseBody String transactionMany(
@RequestParam(value = "rollback", defaultValue = "false") String rollback) @RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
@ -72,7 +73,7 @@ public class TaskanaTestController {
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2"));
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key3", "workbasket3")); taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key3", "workbasket3"));
if (Boolean.valueOf(rollback)) { if (Boolean.parseBoolean(rollback)) {
throw new RuntimeException("workbaskets: " + getWorkbaskets()); throw new RuntimeException("workbaskets: " + getWorkbaskets());
} else { } else {
return "workbaskets: " + getWorkbaskets(); return "workbaskets: " + getWorkbaskets();
@ -80,7 +81,7 @@ public class TaskanaTestController {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@RequestMapping("/customdb") @GetMapping(path = "/customdb")
public @ResponseBody String transactionCustomdb( public @ResponseBody String transactionCustomdb(
@RequestParam(value = "rollback", defaultValue = "false") String rollback) @RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
@ -91,7 +92,7 @@ public class TaskanaTestController {
jdbcTemplate.execute("INSERT INTO CUSTOMDB.TEST VALUES ('1', 'test')"); jdbcTemplate.execute("INSERT INTO CUSTOMDB.TEST VALUES ('1', 'test')");
jdbcTemplate.execute("INSERT INTO CUSTOMDB.TEST VALUES ('2', 'test2')"); jdbcTemplate.execute("INSERT INTO CUSTOMDB.TEST VALUES ('2', 'test2')");
if (Boolean.valueOf(rollback)) { if (Boolean.parseBoolean(rollback)) {
throw new RuntimeException( throw new RuntimeException(
"workbaskets: " + getWorkbaskets() + ", tests: " + getCustomdbTests()); "workbaskets: " + getWorkbaskets() + ", tests: " + getCustomdbTests());
} else { } else {
@ -100,7 +101,7 @@ public class TaskanaTestController {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@RequestMapping("/cleanup") @DeleteMapping(path = "/cleanup")
public @ResponseBody String cleanup() { public @ResponseBody String cleanup() {
jdbcTemplate.execute("DELETE FROM WORKBASKET"); jdbcTemplate.execute("DELETE FROM WORKBASKET");
jdbcTemplate.execute("DELETE FROM CUSTOMDB.TEST"); jdbcTemplate.execute("DELETE FROM CUSTOMDB.TEST");

View File

@ -1,13 +1,13 @@
package pro.taskana.rest.controllers; package pro.taskana.rest.controllers;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.GetMapping;
/** The view controller. */ /** The view controller. */
@Controller @Controller
public class ViewController { public class ViewController {
@RequestMapping({"", "taskana/**"}) @GetMapping(path = {"", "taskana/**"})
public String index() { public String index() {
return "forward:/index.html"; return "forward:/index.html";
} }

View File

@ -3,16 +3,22 @@ package pro.taskana.wildfly.security;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.view.RedirectView; import org.springframework.web.servlet.view.RedirectView;
/** The loginError controller. */ /** The loginError controller. */
@Controller @Controller
public class LoginErrorController { public class LoginErrorController {
@PostMapping @GetMapping(path = "/loginerror")
@GetMapping public RedirectView loginErrorGet() {
@RequestMapping("/loginerror") return loginError();
}
@PostMapping(path = "/loginerror")
public RedirectView loginErrorPost() {
return loginError();
}
public RedirectView loginError() { public RedirectView loginError() {
return new RedirectView("/login?error", true); return new RedirectView("/login?error", true);
} }

View File

@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -206,7 +205,7 @@ public class TaskController extends AbstractPagingController {
return result; return result;
} }
@RequestMapping(path = Mapping.URL_TASKS_ID_TRANSFER_WORKBASKETID) @PostMapping(path = Mapping.URL_TASKS_ID_TRANSFER_WORKBASKETID)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> transferTask( public ResponseEntity<TaskResource> transferTask(
@PathVariable String taskId, @PathVariable String workbasketId) @PathVariable String taskId, @PathVariable String workbasketId)