changeset 242:04021a8122ba

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 15 Jul 2013 10:47:56 +0200
parents c00ee4e49d7d (diff) a31daefe49ea (current diff)
children 6a85146d76f5
files
diffstat 1 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/LOrtService.java	Fri Jul 12 15:55:54 2013 +0200
+++ b/src/main/java/de/intevation/lada/rest/LOrtService.java	Mon Jul 15 10:47:56 2013 +0200
@@ -7,10 +7,12 @@
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.ws.rs.Consumes;
+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;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
@@ -153,4 +155,41 @@
             return new Response(false, 699, new ArrayList<LOrt>());
         }
     }
+
+    /**
+     * Delete a LZusatzwert object.
+     *
+     * @param pzsId     The object id.
+     * @param probeId   The LProbe id.
+     * @param headers   The HTTP header containing authorization information.
+     * @return Response object.
+     */
+    @DELETE
+    @Path("/{ortId}")
+    public Response delete(
+        @PathParam("ortId") String ortId,
+        @Context HttpHeaders headers
+    ) {
+        try {
+            QueryBuilder<LOrt> builder =
+                new QueryBuilder<LOrt>(
+                    repository.getEntityManager(),
+                    LOrt.class);
+            builder.and("POrtId", ortId);
+            Response response = repository.filter(builder.getQuery());
+            List<LOrt> list = (List<LOrt>)response.getData();
+            if (!list.isEmpty()) {
+                LOrt ort = list.get(0);
+                if (authentication.hasAccess(headers, ort.getProbeId())) {
+                    repository.delete(list.get(0));
+                    return new Response(true, 200, null);
+                }
+                return new Response(false, 698, null);
+            }
+            return new Response(false, 600, null);
+        }
+        catch(AuthenticationException ae) {
+            return new Response(false, 699, new ArrayList<LOrt>());
+        }
+    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)