[Lada-commits] [PATCH 2 of 5] Avoid NPE in "orts typ" while validating

Wald Commits scm-commit at wald.intevation.org
Wed Jan 8 15:02:33 CET 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1389189857 -3600
# Node ID deafba50e9319a6825d0974722f2f2e6c9938729
# Parent  6a5b506f4559adc205d8414d4e7d5b655c78ffb7
Avoid NPE in "orts typ" while validating.

diff -r 6a5b506f4559 -r deafba50e931 src/main/java/de/intevation/lada/validation/LOrtValidator.java
--- a/src/main/java/de/intevation/lada/validation/LOrtValidator.java	Wed Jan 08 15:03:08 2014 +0100
+++ b/src/main/java/de/intevation/lada/validation/LOrtValidator.java	Wed Jan 08 15:04:17 2014 +0100
@@ -71,7 +71,7 @@
      * @param warnings
      */
     private void validateVerwaltungseinheit(LOrt ort, Map<String, Integer> warnings) {
-        if (!ort.getOrtsTyp().equals("E")) {
+        if (!"E".equals(ort.getOrtsTyp())) {
             return;
         }
         QueryBuilder<Ort> ortBuilder =
@@ -84,6 +84,10 @@
                 readonlyRepo.getEntityManager(), SVerwaltungseinheit.class);
         veBuilder.and("gemId", orte.get(0).getGemId());
         Response ver = readonlyRepo.filter(veBuilder.getQuery());
+        if (((List<SVerwaltungseinheit>)ver.getData()).isEmpty()) {
+            warnings.put("verwaltungseinheit", 653);
+            return;
+        }
         SVerwaltungseinheit ve = ((List<SVerwaltungseinheit>)ver.getData()).get(0);
         QueryBuilder<DeVg> vg =
             new QueryBuilder<DeVg>(readonlyRepo.getEntityManager(), DeVg.class);


More information about the Lada-commits mailing list