Mercurial > lada > lada-server
changeset 956:539eb174bf23
Avoid NPE if requested object does not exist.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 25 May 2016 18:10:14 +0200 |
parents | 58fc5b5fad4b |
children | 4657811fd133 |
files | src/main/java/de/intevation/lada/rest/OrtService.java src/main/java/de/intevation/lada/rest/stamm/OrtService.java |
diffstat | 2 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/OrtService.java Wed May 25 16:51:55 2016 +0200 +++ b/src/main/java/de/intevation/lada/rest/OrtService.java Wed May 25 18:10:14 2016 +0200 @@ -321,7 +321,6 @@ @Context HttpServletRequest request, @PathParam("id") String id ) { - /* Get the messwert object by id*/ Response object = defaultRepo.getById(LOrtszuordnung.class, Integer.valueOf(id), "land"); LOrtszuordnung ortObj = (LOrtszuordnung)object.getData(); @@ -335,7 +334,7 @@ if (lock.isLocked(ortObj)) { return new Response(false, 697, null); } - /* Delete the messwert object*/ + return defaultRepo.delete(ortObj, "land"); } }
--- a/src/main/java/de/intevation/lada/rest/stamm/OrtService.java Wed May 25 16:51:55 2016 +0200 +++ b/src/main/java/de/intevation/lada/rest/stamm/OrtService.java Wed May 25 18:10:14 2016 +0200 @@ -345,9 +345,12 @@ @Context HttpServletRequest request, @PathParam("id") String id ) { - /* Get the object by id*/ - Ort ort = - repository.getByIdPlain(Ort.class, Integer.valueOf(id), "stamm"); + Response response = + repository.getById(Ort.class, Integer.valueOf(id), "stamm"); + if (!response.getSuccess()) { + return response; + } + Ort ort = (Ort)response.getData(); if (!authorization.isAuthorized( request, ort, @@ -356,7 +359,7 @@ ) { return new Response(false, 699, ort); } - /* Delete the object*/ + return repository.delete(ort, "stamm"); } }