annotate src/main/java/de/intevation/lada/rest/KommentarMService.java @ 821:487c6d8c9d7b statusworkflow

No authorization is given if all objects are requested.
author Tom Gottfried <tom@intevation.de>
date Wed, 09 Dec 2015 16:51:31 +0100
parents b04e55896104
children 2fe625c91ab3
rev   line source
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
629
3bbfdef05ee1 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
3bbfdef05ee1 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
3bbfdef05ee1 Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 package de.intevation.lada.rest;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 import javax.enterprise.context.RequestScoped;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import javax.inject.Inject;
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
12 import javax.servlet.http.HttpServletRequest;
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 import javax.ws.rs.DELETE;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import javax.ws.rs.GET;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import javax.ws.rs.POST;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import javax.ws.rs.PUT;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import javax.ws.rs.Path;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 import javax.ws.rs.PathParam;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 import javax.ws.rs.Produces;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 import javax.ws.rs.core.Context;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 import javax.ws.rs.core.HttpHeaders;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 import javax.ws.rs.core.MediaType;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 import javax.ws.rs.core.MultivaluedMap;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 import javax.ws.rs.core.UriInfo;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 import de.intevation.lada.model.land.LKommentarM;
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
27 import de.intevation.lada.model.land.LMessung;
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 import de.intevation.lada.util.annotation.AuthorizationConfig;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 import de.intevation.lada.util.annotation.RepositoryConfig;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 import de.intevation.lada.util.auth.Authorization;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 import de.intevation.lada.util.auth.AuthorizationType;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 import de.intevation.lada.util.data.QueryBuilder;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 import de.intevation.lada.util.data.Repository;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 import de.intevation.lada.util.data.RepositoryType;
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
35 import de.intevation.lada.util.rest.RequestMethod;
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 import de.intevation.lada.util.rest.Response;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
38 /**
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
39 * REST service for KommentarM objects.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
40 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
41 * The services produce data in the application/json media type.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
42 * All HTTP methods use the authorization module to determine if the user is
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
43 * allowed to perform the requested action.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
44 * A typical response holds information about the action performed and the data.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
45 * <pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
46 * <code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
47 * {
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
48 * "success": [boolean];
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
49 * "message": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
50 * "data":[{
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
51 * "messungsId": [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
52 * "datum": [timestamp],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
53 * "erzeuger": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
54 * "id": [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
55 * "text": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
56 * "owner": [boolean],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
57 * "readonly": [boolean]
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
58 * }],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
59 * "errors": [object],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
60 * "warnings": [object],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
61 * "readonly": [boolean],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
62 * "totalCount": [number]
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
63 * }
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
64 * </code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
65 * </pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
66 *
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
67 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
68 */
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 @Path("mkommentar")
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 @RequestScoped
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 public class KommentarMService {
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
73 /**
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
74 * The data repository granting read/write access.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
75 */
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 @Inject
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 @RepositoryConfig(type=RepositoryType.RW)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 private Repository defaultRepo;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
80 /**
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
81 * The authorization module.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
82 */
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 @Inject
722
c81881dac97e Switch to shibboleth authorization in all REST-services.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 639
diff changeset
84 @AuthorizationConfig(type=AuthorizationType.HEADER)
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 private Authorization authorization;
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
88 * Get all KommentarM objects.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
89 * <p>
821
487c6d8c9d7b No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents: 802
diff changeset
90 * The requested objects have to be filtered using an URL parameter named
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
91 * messungsId.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
92 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
93 * Example: http://example.com/mkommentar?messungsId=[ID]
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 *
821
487c6d8c9d7b No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents: 802
diff changeset
95 * @return Response object containing filtered KommentarM objects.
487c6d8c9d7b No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents: 802
diff changeset
96 * Status-Code 699 if parameter is missing or requested objects are
487c6d8c9d7b No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents: 802
diff changeset
97 * not authorized.
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 @GET
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 @Path("/")
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 public Response get(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
104 @Context UriInfo info,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
105 @Context HttpServletRequest request
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 ) {
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 MultivaluedMap<String, String> params = info.getQueryParameters();
556
4017d2c8dd24 Renamed all 'messungId' url parameters to 'messungsId'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 478
diff changeset
108 if (params.isEmpty() || !params.containsKey("messungsId")) {
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
109 return new Response(false, 699, null);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 }
556
4017d2c8dd24 Renamed all 'messungId' url parameters to 'messungsId'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 478
diff changeset
111 String messungId = params.getFirst("messungsId");
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
112 int id;
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
113 try {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
114 id = Integer.valueOf(messungId);
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
115 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
116 catch(NumberFormatException nfe) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
117 return new Response(false, 699, null);
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
118 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
119 LMessung messung = defaultRepo.getByIdPlain(
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
120 LMessung.class,
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
121 id,
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
122 "land");
821
487c6d8c9d7b No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents: 802
diff changeset
123 if (!authorization.isAuthorized(
487c6d8c9d7b No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents: 802
diff changeset
124 authorization.getInfo(request), messung)) {
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
125 if (!authorization.isAuthorized(id, LMessung.class)) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
126 return new Response(false, 699, null);
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
127 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
128 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
129
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 QueryBuilder<LKommentarM> builder =
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 new QueryBuilder<LKommentarM>(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 defaultRepo.entityManager("land"),
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 LKommentarM.class);
556
4017d2c8dd24 Renamed all 'messungId' url parameters to 'messungsId'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 478
diff changeset
134 builder.and("messungsId", messungId);
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
135 return authorization.filter(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
136 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
137 defaultRepo.filter(builder.getQuery(), "land"),
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
138 LKommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
142 * Get a single KommentarM object by id.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
143 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
144 * The id is appended to the URL as a path parameter.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
145 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
146 * Example: http://example.com/mkommentar/{id}
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 *
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
148 * @return Response object containing a single KommentarM.
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 @GET
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 @Path("/{id}")
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 public Response getById(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
155 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 @PathParam("id") String id
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 ) {
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
158 Response response =
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
159 defaultRepo.getById(LKommentarM.class, Integer.valueOf(id), "land");
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
160 LKommentarM kommentar = (LKommentarM)response.getData();
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
161 LMessung messung = defaultRepo.getByIdPlain(
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
162 LMessung.class,
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
163 kommentar.getMessungsId(),
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
164 "land");
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
165 if (!authorization.isAuthorized(authorization.getInfo(request), messung)) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
166 if (!authorization.isAuthorized(messung.getId(), LMessung.class)) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
167 return new Response(false, 699, null);
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
168 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
169 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
170
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
171 return authorization.filter(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
172 request,
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
173 response,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
174 LKommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
177 /**
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
178 * Create a KommentarM object.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
179 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
180 * The new object is embedded in the post data as JSON formatted string.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
181 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
182 * <pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
183 * <code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
184 * {
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
185 * messungsId: [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
186 * erzeuger: [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
187 * text: [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
188 * datum: [date]
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
189 * owner: [boolean],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
190 * }
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
191 * </code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
192 * </pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
193 * @return A response object containing the created KommentarM.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
194 */
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
195 @POST
639
e0484b039812 Fixed path for POST requests on kommentarm service.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 631
diff changeset
196 @Path("/")
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
197 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198 public Response create(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
200 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
201 LKommentarM kommentar
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
202 ) {
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
203 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
204 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
205 kommentar,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
206 RequestMethod.POST,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
207 LKommentarM.class)
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
208 ) {
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
209 return new Response(false, 699, null);
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
210 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
211 /* Persist the new object*/
601
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
212 return authorization.filter(
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
213 request,
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
214 defaultRepo.create(kommentar, "land"),
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
215 LKommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
216 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
217
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
218 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
219 * Update an existing KommentarM object.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
220 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
221 * The object to update should come as JSON formatted string.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
222 * <pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
223 * <code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
224 * {
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
225 * "id": [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
226 * "owner": [boolean],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
227 * "messungsId": [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
228 * "erzeuger": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
229 * "text": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
230 * "datum": [date]
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
231 * }
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
232 * </code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
233 * </pre>
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234 *
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
235 * @return Response object containing the updated KommentarM object.
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237 @PUT
557
61ce3ce0100e Allow /{id} in urls on PUT requests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 556
diff changeset
238 @Path("/{id}")
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
239 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 public Response update(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
242 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
243 LKommentarM kommentar
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
244 ) {
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
245 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
246 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
247 kommentar,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
248 RequestMethod.PUT,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
249 LKommentarM.class)
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
250 ) {
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
251 return new Response(false, 699, null);
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
252 }
601
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
253 return authorization.filter(
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
254 request,
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
255 defaultRepo.update(kommentar, "land"),
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
256 LKommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
258
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
259 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
260 * Delete an existing KommentarM object by id.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
261 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
262 * The id is appended to the URL as a path parameter.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
263 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
264 * Example: http://example.com/mkommentar/{id}
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
265 *
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
266 * @return Response object.
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
268 @DELETE
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
269 @Path("/{id}")
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
270 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
271 public Response delete(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
272 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
273 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
274 @PathParam("id") String id
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
275 ) {
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
276 /* Get the object by id*/
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
277 Response kommentar =
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
278 defaultRepo.getById(LKommentarM.class, Integer.valueOf(id), "land");
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
279 LKommentarM kommentarObj = (LKommentarM)kommentar.getData();
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
280 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
281 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
282 kommentarObj,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
283 RequestMethod.DELETE,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
284 LKommentarM.class)
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
285 ) {
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
286 return new Response(false, 699, null);
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
287 }
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
288 return defaultRepo.delete(kommentarObj, "land");
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
289 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
290 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)