[Lada-commits] [PATCH 6 of 8] Handle errors in OrtFactory and pass them to the client

Wald Commits scm-commit at wald.intevation.org
Tue Dec 13 20:36:31 CET 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1481656017 -3600
# Node ID e49c006b9076a23d5c83c4af7e7dbd49b685c1b4
# Parent  d67b10dc5d4b87787ea68c787efe8423a1d6dbac
Handle errors in OrtFactory and pass them to the client.

diff -r d67b10dc5d4b -r e49c006b9076 src/main/java/de/intevation/lada/rest/stamm/OrtService.java
--- 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());


More information about the Lada-commits mailing list