[Lada-commits] [PATCH 4 of 4] Added services for proben kommentar

Wald Commits scm-commit at wald.intevation.org
Tue Feb 17 16:44:02 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1424187893 -3600
# Node ID 8d703ac5ad65196dc451a4460a97c9c05c4d24f3
# Parent  716152f4197ad533b472a6039ad8fb45bd7b1ddc
Added services for proben kommentar.

diff -r 716152f4197a -r 8d703ac5ad65 src/main/java/de/intevation/lada/rest/KommentarPService.java
--- a/src/main/java/de/intevation/lada/rest/KommentarPService.java	Tue Feb 17 16:44:34 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/KommentarPService.java	Tue Feb 17 16:44:53 2015 +0100
@@ -9,7 +9,10 @@
 
 import javax.enterprise.context.RequestScoped;
 import javax.inject.Inject;
+import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
@@ -107,4 +110,57 @@
             Integer.valueOf(id),
             "land");
     }
+
+    @POST
+    @Path("/")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response create(
+        @Context HttpHeaders headers,
+        LKommentarP kommentar
+    ) {
+        if (!authentication.isAuthenticated(headers)) {
+            return new Response(false, 699, null);
+        }
+        /* Persist the new object*/
+        return defaultRepo.create(kommentar, "land");
+    }
+
+    /**
+     * Update an existing messung object.
+     *
+     * @return Response object containing the updated probe object.
+     */
+    @PUT
+    @Path("/")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response update(@Context HttpHeaders headers, LKommentarP kommentar) {
+        if (!authentication.isAuthenticated(headers)) {
+            logger.debug("User is not authenticated!");
+            return new Response(false, 699, null);
+        }
+        return defaultRepo.update(kommentar, "land");
+    }
+
+    /**
+     * Delete an existing object by id.
+     *
+     * @return Response object.
+     */
+    @DELETE
+    @Path("/{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response delete(
+        @Context HttpHeaders headers,
+        @PathParam("id") String id
+    ) {
+        if (!authentication.isAuthenticated(headers)) {
+            logger.debug("User is not authenticated!");
+            return new Response(false, 699, null);
+        }
+        /* Get the object by id*/
+        Response kommentar =
+            defaultRepo.getById(LKommentarP.class, Integer.valueOf(id), "land");
+        LKommentarP kommentarObj = (LKommentarP)kommentar.getData();
+        return defaultRepo.delete(kommentarObj, "land");
+    }
 }


More information about the Lada-commits mailing list