changeset 202:ab7bb9e326f5

Implemented 'update' for 'kommentare'.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 02 Jul 2013 09:49:07 +0200
parents 419af5d9cced
children d67665feb765
files src/main/java/de/intevation/lada/data/LKommentarPRepository.java src/main/java/de/intevation/lada/rest/LKommentarService.java
diffstat 2 files changed, 28 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/data/LKommentarPRepository.java	Tue Jul 02 08:19:14 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/LKommentarPRepository.java	Tue Jul 02 09:49:07 2013 +0200
@@ -58,7 +58,32 @@
 
     @Override
     public Response update(Object object) {
-        return new Response(false, 698, new ArrayList<LKommentarP>());
+        if (!(object instanceof LKommentarP)) {
+            return new Response(false, 602, object);
+        }
+        LKommentarP kommentar = (LKommentarP)object;
+        Response response = new Response(true, 200, kommentar);
+        try {
+            manager.update(kommentar);
+            return response;
+        }
+        catch (EntityExistsException eee) {
+            response.setSuccess(false);
+            response.setMessage(601);
+        }
+        catch (IllegalArgumentException iae) {
+            response.setSuccess(false);
+            response.setMessage(602);
+        }
+        catch (TransactionRequiredException tre) {
+            response.setSuccess(false);
+            response.setMessage(603);
+        }
+        catch (EJBTransactionRolledbackException te) {
+            response.setSuccess(false);
+            response.setMessage(604);
+        }
+        return response;
     }
 
     @Override
--- a/src/main/java/de/intevation/lada/rest/LKommentarService.java	Tue Jul 02 08:19:14 2013 +0200
+++ b/src/main/java/de/intevation/lada/rest/LKommentarService.java	Tue Jul 02 09:49:07 2013 +0200
@@ -82,16 +82,8 @@
     @Path("/{kId}/{probeId}")
     @Produces("text/json")
     @Consumes("application/json")
-    public String update(LKommentarP kommentar) {
-        return "[{success: true}]";
-        //String response = repository.delete(id);
-        //if (response.isEmpty()) {
-        //    return "[{success: true}]";
-        //}
-        //else {
-        //    return "[{success: false," +
-        //        " error: " + response + "}]";
-        //}
+    public Response update(LKommentarP kommentar) {
+        return repository.update(kommentar);
     }
 
     /**
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)