changeset 373:bc6d0785986f

Catch persistence exception in case the probe is incomplete.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 24 Sep 2013 14:00:31 +0200
parents 3d2c53a10ee6
children 958b7ffbbfcc
files src/main/java/de/intevation/lada/data/importer/LAFWriter.java
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/data/importer/LAFWriter.java	Tue Sep 24 13:08:13 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/importer/LAFWriter.java	Tue Sep 24 14:00:31 2013 +0200
@@ -10,8 +10,12 @@
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
 import javax.persistence.Query;
 
+import org.hibernate.HibernateException;
+import org.postgresql.util.PSQLException;
+
 import de.intevation.lada.auth.AuthenticationResponse;
 import de.intevation.lada.data.Repository;
 import de.intevation.lada.model.LKommentarM;
@@ -125,7 +129,13 @@
             errors.add(new ReportData("probeId", "missing", 673));
             return false;
         }
-        persist(probe);
+        try {
+            persist(probe);
+        }
+        catch (PersistenceException e) {
+            errors.add(new ReportData("probe", "writing", 670));
+            return false;
+        }
         return true;
     }
 
@@ -319,7 +329,8 @@
      * @param probe The {@link LProbe} object.
      */
     @TransactionAttribute(TransactionAttributeType.REQUIRED)
-    private void persist(LProbe probe) {
+    private void persist(LProbe probe)
+    throws PersistenceException {
         String queryColumns = "insert into l_probe (probe_id, ba_id, test," +
             " datenbasis_id, netzbetreiber_id, mst_id, probenart_id, umw_id";
         String queryParameter = " values (:probe_id, :ba_id, :test," +
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)