changeset 199:585013ccc961

Added 'delete' and updated 'create' in LKommentarRepository.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 01 Jul 2013 17:09:17 +0200
parents 2eab59ea015e
children b3148356e373
files src/main/java/de/intevation/lada/data/LKommentarPRepository.java
diffstat 1 files changed, 31 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/data/LKommentarPRepository.java	Mon Jul 01 17:08:29 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/LKommentarPRepository.java	Mon Jul 01 17:09:17 2013 +0200
@@ -4,6 +4,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.ejb.EJBTransactionRolledbackException;
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.persistence.EntityExistsException;
@@ -31,20 +32,28 @@
             return new Response(false, 602, object);
         }
         LKommentarP kommentar = (LKommentarP)object;
+        Response response = new Response(true, 200, kommentar);
         try {
             manager.create(kommentar);
-            return new Response(true, 200, kommentar);
+            return response;
         }
         catch(EntityExistsException eee) {
-            return new Response(false, 601, kommentar);
+            response.setSuccess(false);
+            response.setMessage(601);
         }
         catch(IllegalArgumentException iae) {
-            return new Response(false, 602, kommentar);
+            response.setSuccess(false);
+            response.setMessage(602);
         }
         catch(TransactionRequiredException tre) {
-            logger.log(Level.INFO, "exception: " + tre);
-            return new Response(false, 603, kommentar);
+            response.setSuccess(false);
+            response.setMessage(603);
         }
+        catch (EJBTransactionRolledbackException te) {
+            response.setSuccess(false);
+            response.setMessage(604);
+        }
+        return response;
     }
 
     @Override
@@ -54,7 +63,22 @@
 
     @Override
     public Response delete(Object object) {
-        // TODO Auto-generated method stub
-        return null;
+        if (!(object instanceof LKommentarP)) {
+            return new Response(false, 602, null);
+        }
+        LKommentarP kommentar = (LKommentarP)object;
+        Response response = new Response(true, 200, null);
+        try {
+            manager.delete(kommentar);
+        }
+        catch (IllegalArgumentException iae) {
+            response.setSuccess(false);
+            response.setMessage(602);
+        }
+        catch (TransactionRequiredException tre) {
+            response.setSuccess(false);
+            response.setMessage(603);
+        }
+        return response;
     }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)