Mercurial > lada > lada-server
changeset 1237:e49c006b9076
Handle errors in OrtFactory and pass them to the client.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 13 Dec 2016 20:06:57 +0100 |
parents | d67b10dc5d4b |
children | a81de70d321d |
files | src/main/java/de/intevation/lada/rest/stamm/OrtService.java |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/stamm/OrtService.java Tue Dec 13 19:05:53 2016 +0100 +++ b/src/main/java/de/intevation/lada/rest/stamm/OrtService.java Tue Dec 13 20:06:57 2016 +0100 @@ -26,6 +26,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; +import de.intevation.lada.importer.ReportItem; import de.intevation.lada.factory.OrtFactory; import de.intevation.lada.model.stammdaten.Filter; import de.intevation.lada.model.stammdaten.Ort; @@ -279,6 +280,15 @@ } ortFactory.transformCoordinates(ort); + if (ortFactory.hasErrors()) { + Violation factoryErrs = new Violation(); + for (ReportItem err : ortFactory.getErrors()) { + factoryErrs.addError(err.getKey(), err.getCode()); + } + Response response = new Response(false, 604, ort); + response.setErrors(factoryErrs.getErrors()); + return response; + } Response response = repository.create(ort, "stamm"); if(violation.hasWarnings()) { response.setWarnings(violation.getWarnings()); @@ -340,6 +350,15 @@ } ortFactory.transformCoordinates(ort); + if (ortFactory.hasErrors()) { + Violation factoryErrs = new Violation(); + for (ReportItem err : ortFactory.getErrors()) { + factoryErrs.addError(err.getKey(), err.getCode()); + } + Response response = new Response(false, 604, ort); + response.setErrors(factoryErrs.getErrors()); + return response; + } Response response = repository.update(ort, "stamm"); if(violation.hasWarnings()) { response.setWarnings(violation.getWarnings());