# HG changeset patch # User Raimund Renkert # Date 1373895526 -7200 # Node ID 8f27440a5f49cb504c501ddb30855d83232c4f1b # Parent 7a1bbd96cecde11c928d482ead2228457322c789 'DELETE' for LKommentarM service. diff -r 7a1bbd96cecd -r 8f27440a5f49 src/main/java/de/intevation/lada/rest/LKommentarMService.java --- 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()); } } + + /** + * 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 builder = + new QueryBuilder( + repository.getEntityManager(), + LKommentarM.class); + builder.and("kId", kId) + .and("messungsId", messungsId) + .and("probeId", probeId); + Response response = repository.filter(builder.getQuery()); + List list = (List)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()); + } + catch(AuthenticationException ae) { + return new Response(false, 699, new ArrayList()); + } + } }