Changed some ResponseEntities
This commit is contained in:
parent
67a2defe41
commit
01d860542b
@ -109,8 +109,8 @@ public class Controller {
|
|||||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
||||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalParameterException("There is no cacheAccesDefinition with the ID " + 0);
|
return ResponseEntity.status(404).body("There is no cacheAccesDefinition with the ID " + 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bearbeitetRepository.save(bearbeitet);
|
bearbeitetRepository.save(bearbeitet);
|
||||||
|
|
||||||
@ -147,11 +147,11 @@ public class Controller {
|
|||||||
@RequestMapping("/api/createStation")
|
@RequestMapping("/api/createStation")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity createStation(@RequestParam String description,
|
public ResponseEntity createStation(@RequestParam String description,
|
||||||
@RequestParam String lattitude,
|
@RequestParam String latitude,
|
||||||
@RequestParam String longitude,
|
@RequestParam String longitude,
|
||||||
@RequestParam String solution) {
|
@RequestParam String solution) {
|
||||||
|
|
||||||
if (description.length() == 0 || lattitude.length() == 0 || longitude.length() == 0 || solution.length() == 0) {
|
if (description.length() == 0 || latitude.length() == 0 || longitude.length() == 0 || solution.length() == 0) {
|
||||||
return ResponseEntity.status(400).body("At least one Argument was empty");
|
return ResponseEntity.status(400).body("At least one Argument was empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,9 +159,9 @@ public class Controller {
|
|||||||
double longi;
|
double longi;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
latti = Double.valueOf(lattitude);
|
latti = Double.valueOf(latitude);
|
||||||
if (latti < -90 || latti > 90) {
|
if (latti < -90 || latti > 90) {
|
||||||
return ResponseEntity.status(400).body("Lattitude has to be between -90 and 90 Degree");
|
return ResponseEntity.status(400).body("Latitude has to be between -90 and 90 Degree");
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return ResponseEntity.status(400).body("Latitude has to be a decimal");
|
return ResponseEntity.status(400).body("Latitude has to be a decimal");
|
||||||
@ -198,6 +198,9 @@ public class Controller {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity checkAdmin(@RequestParam String token) {
|
public ResponseEntity checkAdmin(@RequestParam String token) {
|
||||||
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
||||||
|
if(user == null){
|
||||||
|
return ResponseEntity.status(404).body("User was not found");
|
||||||
|
}
|
||||||
for (Role role : user.getRoles()) {
|
for (Role role : user.getRoles()) {
|
||||||
if (role.getId() == 0) { // is admin
|
if (role.getId() == 0) { // is admin
|
||||||
return ResponseEntity.status(200).body("User is Admin");
|
return ResponseEntity.status(200).body("User is Admin");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user