annotate src/main/java/de/intevation/lada/rest/LZusatzwertService.java @ 366:567ce7697fc7 0.5

Code documentation.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 10 Sep 2013 15:55:54 +0200
parents 2098db2e8fbd
children 183f8116d9a6
rev   line source
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.lada.rest;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
192
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
4 import java.util.List;
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6 import javax.enterprise.context.RequestScoped;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import javax.inject.Inject;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 import javax.inject.Named;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import javax.ws.rs.Consumes;
192
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
10 import javax.ws.rs.DELETE;
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import javax.ws.rs.GET;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import javax.ws.rs.POST;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import javax.ws.rs.PUT;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import javax.ws.rs.Path;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 import javax.ws.rs.PathParam;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 import javax.ws.rs.Produces;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 import javax.ws.rs.core.Context;
208
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
18 import javax.ws.rs.core.HttpHeaders;
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 import javax.ws.rs.core.MultivaluedMap;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 import javax.ws.rs.core.UriInfo;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21
232
d8a3d188046f Renamed package authentication to auth.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
22 import de.intevation.lada.auth.Authentication;
d8a3d188046f Renamed package authentication to auth.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
23 import de.intevation.lada.auth.AuthenticationException;
182
a2e04ab2cd44 Use the new filter and query builder and have authentication for LProbeInfo objects.
Raimund Renkert <rrenkert@intevation.de>
parents: 175
diff changeset
24 import de.intevation.lada.data.QueryBuilder;
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 import de.intevation.lada.data.Repository;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 import de.intevation.lada.model.LZusatzWert;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 /**
210
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
29 * This class produces a RESTful service to read, write and update
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
30 * LZusatzwert objects.
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 *
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 */
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 @Path("/zusatzwert")
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 @RequestScoped
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 public class LZusatzwertService
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 {
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 /**
263
2098db2e8fbd Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 261
diff changeset
39 * The Repository for LZusatzwert.
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 */
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 @Inject
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 @Named("lzusatzwertrepository")
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 private Repository repository;
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44
210
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
45 /**
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
46 * The authorization module.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
47 */
208
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
48 @Inject
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
49 @Named("ldapauth")
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
50 private Authentication authentication;
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52 /**
263
2098db2e8fbd Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 261
diff changeset
53 * Request LZusatzwert via a filter.
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 *
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55 * Query parameters are used for the filter in form of key-value pairs.
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 *
210
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
57 * @param info The URL query parameters.
366
567ce7697fc7 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 263
diff changeset
58 * @param headers The HTTP header containing authorization information.
210
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
59 * @return Response object.
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 */
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 @GET
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 @Produces("text/json")
208
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
63 public Response filter(
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
64 @Context UriInfo info,
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
65 @Context HttpHeaders headers
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
66 ) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
67 try {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
68 if (!authentication.isAuthorizedUser(headers)) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
69 return new Response(false, 699, new ArrayList<LZusatzWert>());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
70 }
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
71 MultivaluedMap<String, String> params = info.getQueryParameters();
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
72 if (params.isEmpty() || !params.containsKey("probeId")) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
73 return new Response(false, 609, new ArrayList<LZusatzWert>());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
74 }
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
75 String probeId = params.getFirst("probeId");
261
07c4186cbfab Enable read access on all objects for authorized users.
Raimund Renkert <rrenkert@intevation.de>
parents: 232
diff changeset
76 QueryBuilder<LZusatzWert> builder =
07c4186cbfab Enable read access on all objects for authorized users.
Raimund Renkert <rrenkert@intevation.de>
parents: 232
diff changeset
77 new QueryBuilder<LZusatzWert>(
07c4186cbfab Enable read access on all objects for authorized users.
Raimund Renkert <rrenkert@intevation.de>
parents: 232
diff changeset
78 repository.getEntityManager(), LZusatzWert.class);
07c4186cbfab Enable read access on all objects for authorized users.
Raimund Renkert <rrenkert@intevation.de>
parents: 232
diff changeset
79 builder.and("probeId", probeId);
07c4186cbfab Enable read access on all objects for authorized users.
Raimund Renkert <rrenkert@intevation.de>
parents: 232
diff changeset
80 return repository.filter(builder.getQuery());
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 }
208
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
82 catch(AuthenticationException ae) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
83 return new Response(false, 699, new ArrayList<LZusatzWert>());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
84 }
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 }
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86
210
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
87 /**
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
88 * Update a LZusatzwert object.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
89 *
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
90 * @param zusatzwert The LZusatzwert object to update.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
91 * @param headers The HTTP header containing authorization information.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
92 * @return Response object.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
93 */
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 @PUT
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 @Produces("text/json")
175
0474c86a2f4a Fix for issue 15. Changed model and REST interface for Zusatzwerte
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 152
diff changeset
96 @Path("/{pzsId}/{probeId}")
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 @Consumes("application/json")
208
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
98 public Response update(
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
99 LZusatzWert zusatzwert,
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
100 @Context HttpHeaders headers
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
101 ) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
102 try {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
103 String probeId = zusatzwert.getProbeId();
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
104 if (authentication.hasAccess(headers, probeId)) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
105 return repository.update(zusatzwert);
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
106 }
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
107 return new Response(false, 698, new ArrayList<LZusatzWert>());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
108 }
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
109 catch(AuthenticationException ae) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
110 return new Response(false, 699, new ArrayList<LZusatzWert>());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
111 }
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 }
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113
210
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
114 /**
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
115 * Create a new LZusatzwert object.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
116 *
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
117 * @param zusatzwert The new LZusatzwert object.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
118 * @param headers THe HTTP header containing authorization information.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
119 * @return Response object.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
120 */
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 @POST
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 @Produces("text/json")
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123 @Consumes("application/json")
208
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
124 public Response create(
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
125 LZusatzWert zusatzwert,
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
126 @Context HttpHeaders headers
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
127 ) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
128 try {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
129 String probeId = zusatzwert.getProbeId();
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
130 if (authentication.hasAccess(headers, probeId)) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
131 return repository.create(zusatzwert);
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
132 }
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
133 return new Response(false, 698, new ArrayList<LZusatzWert>());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
134 }
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
135 catch(AuthenticationException ae) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
136 return new Response(false, 699, new ArrayList<LZusatzWert>());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
137 }
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138 }
192
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
139
210
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
140 /**
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
141 * Delete a LZusatzwert object.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
142 *
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
143 * @param pzsId The object id.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
144 * @param probeId The LProbe id.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
145 * @param headers The HTTP header containing authorization information.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
146 * @return Response object.
a305412206a3 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 208
diff changeset
147 */
192
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
148 @DELETE
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
149 @Path("/{pzsId}/{probeId}")
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
150 public Response delete(
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
151 @PathParam("pzsId") String pzsId,
208
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
152 @PathParam("probeId") String probeId,
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
153 @Context HttpHeaders headers
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
154 ) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
155 try {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
156 if (authentication.hasAccess(headers, probeId)) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
157 QueryBuilder<LZusatzWert> builder =
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
158 new QueryBuilder<LZusatzWert>(
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
159 repository.getEntityManager(),
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
160 LZusatzWert.class);
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
161 builder.and("pzsId", pzsId).and("probeId", probeId);
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
162 Response response = repository.filter(builder.getQuery());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
163 List<LZusatzWert> list = (List<LZusatzWert>)response.getData();
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
164 if (!list.isEmpty()) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
165 repository.delete(list.get(0));
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
166 return new Response(true, 200, null);
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
167 }
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
168 return new Response(false, 600, null);
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
169 }
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
170 return new Response(false, 698, new ArrayList<LZusatzWert>());
192
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
171 }
208
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
172 catch(AuthenticationException ae) {
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
173 return new Response(false, 699, new ArrayList<LZusatzWert>());
832e67663fd9 Added authorization to all services.
Raimund Renkert <rrenkert@intevation.de>
parents: 192
diff changeset
174 }
192
0ae1ee3d8db3 New service interface to delete a 'zusatzwert'.
Raimund Renkert <rrenkert@intevation.de>
parents: 182
diff changeset
175 }
152
53f6d290a559 New service for LZusatzWert objects.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
176 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)