Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/rest/LKommentarMService.java @ 247:8f27440a5f49
'DELETE' for LKommentarM service.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 15 Jul 2013 15:38:46 +0200 |
parents | 7a1bbd96cecd |
children | 1cdb6b8a0843 |
comparison
equal
deleted
inserted
replaced
246:7a1bbd96cecd | 247:8f27440a5f49 |
---|---|
153 } | 153 } |
154 catch(AuthenticationException ae) { | 154 catch(AuthenticationException ae) { |
155 return new Response(false, 699, new ArrayList<LKommentarM>()); | 155 return new Response(false, 699, new ArrayList<LKommentarM>()); |
156 } | 156 } |
157 } | 157 } |
158 | |
159 /** | |
160 * Delete a LKommentarM object. | |
161 * | |
162 * @param kId The object id. | |
163 * @param messungsId The LProbe id. | |
164 * @param statusId The LStatus id | |
165 * @param headers The HTTP header containing authorization information. | |
166 * @return Response object. | |
167 */ | |
168 @DELETE | |
169 @Path("/{kId}/{messungsId}/{probeId}") | |
170 public Response delete( | |
171 @PathParam("kId") String kId, | |
172 @PathParam("messungsId") String messungsId, | |
173 @PathParam("probeId") String probeId, | |
174 @Context HttpHeaders headers | |
175 ) { | |
176 try { | |
177 if (authentication.hasAccess(headers, probeId)) { | |
178 QueryBuilder<LKommentarM> builder = | |
179 new QueryBuilder<LKommentarM>( | |
180 repository.getEntityManager(), | |
181 LKommentarM.class); | |
182 builder.and("kId", kId) | |
183 .and("messungsId", messungsId) | |
184 .and("probeId", probeId); | |
185 Response response = repository.filter(builder.getQuery()); | |
186 List<LKommentarM> list = (List<LKommentarM>)response.getData(); | |
187 if (!list.isEmpty()) { | |
188 repository.delete(list.get(0)); | |
189 return new Response(true, 200, null); | |
190 } | |
191 return new Response(false, 600, null); | |
192 } | |
193 return new Response(false, 698, new ArrayList<LKommentarM>()); | |
194 } | |
195 catch(AuthenticationException ae) { | |
196 return new Response(false, 699, new ArrayList<LKommentarM>()); | |
197 } | |
198 } | |
158 } | 199 } |