Mercurial > lada > lada-server
changeset 1318:6fbfb8f0927a
Audit trail: handle request with non-existant numeric ID.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 22 Mar 2017 15:03:35 +0100 |
parents | 84bb7e2aecb1 |
children | d3113d594013 |
files | src/main/java/de/intevation/lada/rest/AuditTrailService.java |
diffstat | 1 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/AuditTrailService.java Fri Mar 17 13:25:57 2017 +0100 +++ b/src/main/java/de/intevation/lada/rest/AuditTrailService.java Wed Mar 22 15:03:35 2017 +0100 @@ -152,13 +152,19 @@ "\"message\":698,\"data\":null}"; return ret; } + Integer pId = null; + String ret = "{\"success\": false," + + "\"message\":600,\"data\":null}"; try { pId = Integer.valueOf(id); } catch(NumberFormatException nfe) { - String ret = "{\"success\": false," + - "\"message\":600,\"data\":null}"; + return ret; + } + // Get the plain probe object to have the hauptproben_nr. + Probe probe = repository.getByIdPlain(Probe.class, pId, "land"); + if (probe == null) { return ret; } @@ -174,9 +180,6 @@ List<AuditTrailProbe> audit = repository.filterPlain(builder.getQuery(), "land"); - // Get the plain probe object to have the hauptproben_nr. - // If only subobjects - Probe probe = repository.getByIdPlain(Probe.class, pId, "land"); // Create an empty JsonObject ObjectMapper mapper = new ObjectMapper(); ObjectNode responseNode = mapper.createObjectNode(); @@ -264,15 +267,21 @@ "\"message\":698,\"data\":null}"; return ret; } + Integer mId = null; + String ret = "{\"success\": false," + + "\"message\":600,\"data\":null}"; try { mId = Integer.valueOf(id); } catch(NumberFormatException nfe) { - String ret = "{\"success\": false," + - "\"message\":600,\"data\":null}"; return ret; } + Messung messung = repository.getByIdPlain(Messung.class, mId, "land"); + if (messung == null) { + return ret; + } + QueryBuilder<AuditTrailMessung> builder = new QueryBuilder<AuditTrailMessung>( repository.entityManager("land"), @@ -284,7 +293,6 @@ List<AuditTrailMessung> audit = repository.filterPlain(builder.getQuery(), "land"); - Messung messung = repository.getByIdPlain(Messung.class, mId, "land"); // Create an empty JsonObject ObjectMapper mapper = new ObjectMapper(); ObjectNode responseNode = mapper.createObjectNode();