changeset 247:8f27440a5f49

'DELETE' for LKommentarM service.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 15 Jul 2013 15:38:46 +0200
parents 7a1bbd96cecd
children 04b5f401e871
files src/main/java/de/intevation/lada/rest/LKommentarMService.java
diffstat 1 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/LKommentarMService.java	Mon Jul 15 15:36:54 2013 +0200
+++ b/src/main/java/de/intevation/lada/rest/LKommentarMService.java	Mon Jul 15 15:38:46 2013 +0200
@@ -155,4 +155,45 @@
             return new Response(false, 699, new ArrayList<LKommentarM>());
         }
     }
+
+    /**
+     * Delete a LKommentarM object.
+     *
+     * @param kId          The object id.
+     * @param messungsId   The LProbe id.
+     * @param statusId     The LStatus id
+     * @param headers   The HTTP header containing authorization information.
+     * @return Response object.
+     */
+    @DELETE
+    @Path("/{kId}/{messungsId}/{probeId}")
+    public Response delete(
+        @PathParam("kId") String kId,
+        @PathParam("messungsId") String messungsId,
+        @PathParam("probeId") String probeId,
+        @Context HttpHeaders headers
+    ) {
+        try {
+            if (authentication.hasAccess(headers, probeId)) {
+                QueryBuilder<LKommentarM> builder =
+                    new QueryBuilder<LKommentarM>(
+                        repository.getEntityManager(),
+                        LKommentarM.class);
+                builder.and("kId", kId)
+                    .and("messungsId", messungsId)
+                    .and("probeId", probeId);
+                Response response = repository.filter(builder.getQuery());
+                List<LKommentarM> list = (List<LKommentarM>)response.getData();
+                if (!list.isEmpty()) {
+                    repository.delete(list.get(0));
+                    return new Response(true, 200, null);
+                }
+                return new Response(false, 600, null);
+            }
+            return new Response(false, 698, new ArrayList<LKommentarM>());
+        }
+        catch(AuthenticationException ae) {
+            return new Response(false, 699, new ArrayList<LKommentarM>());
+        }
+    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)