changeset 473:8d703ac5ad65

Added services for proben kommentar.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 17 Feb 2015 16:44:53 +0100
parents 716152f4197a
children 1c8061b90b41
files src/main/java/de/intevation/lada/rest/KommentarPService.java
diffstat 1 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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");
+    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)