[Lada-commits] [PATCH 1 of 3] fixed delete probe service
Wald Commits
scm-commit at wald.intevation.org
Fri Jul 10 18:37:34 CEST 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1436545767 -7200
# Node ID d74b5b1190aea9d907ece09d9f2f69544559d3ef
# Parent 51d8d5bacf687047b93cc092bc1aa202ce789aa8
fixed delete probe service.
diff -r 51d8d5bacf68 -r d74b5b1190ae src/main/java/de/intevation/lada/rest/ProbeService.java
--- a/src/main/java/de/intevation/lada/rest/ProbeService.java Fri Jul 10 14:54:21 2015 +0200
+++ b/src/main/java/de/intevation/lada/rest/ProbeService.java Fri Jul 10 18:29:27 2015 +0200
@@ -14,6 +14,7 @@
import java.util.List;
import java.util.Map;
+import javax.ejb.EJBTransactionRolledbackException;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.json.Json;
@@ -22,6 +23,7 @@
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.persistence.Query;
+import javax.persistence.TransactionRequiredException;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -507,7 +509,14 @@
/* Delete the probe translation object*/
defaultRepo.delete(probeTransObj, "land");
/* Delete the probe object*/
- Response response = defaultRepo.delete(probeObj, "land");
- return response;
+ try {
+ Response response = defaultRepo.delete(probeObj, "land");
+ return response;
+ }
+ catch(IllegalArgumentException | EJBTransactionRolledbackException |
+ TransactionRequiredException e) {
+ defaultRepo.update(probeTransObj, "land");
+ return new Response(false, 600, "");
+ }
}
}
diff -r 51d8d5bacf68 -r d74b5b1190ae src/main/java/de/intevation/lada/util/data/DataTransaction.java
--- a/src/main/java/de/intevation/lada/util/data/DataTransaction.java Fri Jul 10 14:54:21 2015 +0200
+++ b/src/main/java/de/intevation/lada/util/data/DataTransaction.java Fri Jul 10 18:29:27 2015 +0200
@@ -14,6 +14,7 @@
import javax.inject.Inject;
import javax.persistence.EntityExistsException;
import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
import javax.persistence.Query;
import javax.persistence.TransactionRequiredException;
@@ -84,7 +85,8 @@
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void removeFromDatabase(Object object, String dataSource)
throws IllegalArgumentException,
- TransactionRequiredException
+ TransactionRequiredException,
+ EJBTransactionRolledbackException
{
EntityManager em = emp.entityManager(dataSource);
em.remove(
diff -r 51d8d5bacf68 -r d74b5b1190ae src/main/java/de/intevation/lada/util/data/DefaultRepository.java
--- a/src/main/java/de/intevation/lada/util/data/DefaultRepository.java Fri Jul 10 14:54:21 2015 +0200
+++ b/src/main/java/de/intevation/lada/util/data/DefaultRepository.java Fri Jul 10 18:29:27 2015 +0200
@@ -118,7 +118,7 @@
*/
@Override
public Response delete(Object object, String dataSource) {
- Response response = new Response(true, 200, null);
+ Response response = new Response(true, 200, "");
try {
transaction.removeFromDatabase(object, dataSource);
}
More information about the Lada-commits
mailing list