annotate src/main/java/de/intevation/lada/rest/KommentarMService.java @ 1042:3a5a9a0492d1 schema-update

Fixed warnings.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 05 Sep 2016 10:18:38 +0200
parents 1c41c7b8f7c2
children
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
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
26 import de.intevation.lada.model.land.KommentarM;
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
27 import de.intevation.lada.model.land.Messung;
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 */
827
5bdd1631a451 !!!CAUTION!!! changed services path!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 802
diff changeset
69 @Path("rest/mkommentar")
478
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 }
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
119 Messung messung = defaultRepo.getByIdPlain(
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
120 Messung.class,
802
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");
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
123 if (!authorization.isAuthorized(request, messung, RequestMethod.GET, Messung.class)) {
833
fa922101a462 Refactored Authorization.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 827
diff changeset
124 return new Response(false, 699, null);
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
125 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
126
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
127 QueryBuilder<KommentarM> builder =
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
128 new QueryBuilder<KommentarM>(
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 defaultRepo.entityManager("land"),
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
130 KommentarM.class);
556
4017d2c8dd24 Renamed all 'messungId' url parameters to 'messungsId'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 478
diff changeset
131 builder.and("messungsId", messungId);
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
132 return authorization.filter(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
133 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
134 defaultRepo.filter(builder.getQuery(), "land"),
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
135 KommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
139 * Get a single KommentarM object by id.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
140 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
141 * The id is appended to the URL as a path parameter.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
142 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
143 * Example: http://example.com/mkommentar/{id}
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 *
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
145 * @return Response object containing a single KommentarM.
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 @GET
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 @Path("/{id}")
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 public Response getById(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
152 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 @PathParam("id") String id
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 ) {
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
155 Response response =
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
156 defaultRepo.getById(KommentarM.class, Integer.valueOf(id), "land");
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
157 KommentarM kommentar = (KommentarM)response.getData();
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
158 Messung messung = defaultRepo.getByIdPlain(
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
159 Messung.class,
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
160 kommentar.getMessungsId(),
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
161 "land");
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
162 if (!authorization.isAuthorized(request, messung, RequestMethod.GET, Messung.class)) {
833
fa922101a462 Refactored Authorization.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 827
diff changeset
163 return new Response(false, 699, null);
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
164 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
165
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
166 return authorization.filter(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
167 request,
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
168 response,
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
169 KommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
172 /**
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
173 * Create a KommentarM object.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
174 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
175 * 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
176 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
177 * <pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
178 * <code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
179 * {
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
180 * messungsId: [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
181 * erzeuger: [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
182 * text: [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
183 * datum: [date]
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
184 * owner: [boolean],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
185 * }
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
186 * </code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
187 * </pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
188 * @return A response object containing the created KommentarM.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
189 */
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 @POST
639
e0484b039812 Fixed path for POST requests on kommentarm service.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 631
diff changeset
191 @Path("/")
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
192 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
193 public Response create(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
194 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
195 @Context HttpServletRequest request,
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
196 KommentarM kommentar
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
197 ) {
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
198 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
199 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
200 kommentar,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
201 RequestMethod.POST,
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
202 KommentarM.class)
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
203 ) {
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
204 return new Response(false, 699, null);
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
205 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 /* Persist the new object*/
601
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
207 return authorization.filter(
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
208 request,
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
209 defaultRepo.create(kommentar, "land"),
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
210 KommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
211 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
212
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
213 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
214 * Update an existing KommentarM object.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
215 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
216 * The object to update should come as JSON formatted string.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
217 * <pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
218 * <code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
219 * {
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
220 * "id": [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
221 * "owner": [boolean],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
222 * "messungsId": [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
223 * "erzeuger": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
224 * "text": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
225 * "datum": [date]
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
226 * }
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
227 * </code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
228 * </pre>
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 *
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
230 * @return Response object containing the updated KommentarM object.
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
232 @PUT
557
61ce3ce0100e Allow /{id} in urls on PUT requests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 556
diff changeset
233 @Path("/{id}")
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
235 public Response update(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
237 @Context HttpServletRequest request,
1042
3a5a9a0492d1 Fixed warnings.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1028
diff changeset
238 @PathParam("id") String id,
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
239 KommentarM kommentar
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 ) {
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
241 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
242 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
243 kommentar,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
244 RequestMethod.PUT,
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
245 KommentarM.class)
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
246 ) {
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
247 return new Response(false, 699, null);
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 }
601
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
249 return authorization.filter(
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
250 request,
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
251 defaultRepo.update(kommentar, "land"),
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
252 KommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
253 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
254
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
255 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
256 * Delete an existing KommentarM object by id.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
257 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
258 * The id is appended to the URL as a path parameter.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
259 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
260 * Example: http://example.com/mkommentar/{id}
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
261 *
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
262 * @return Response object.
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
263 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264 @DELETE
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
265 @Path("/{id}")
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
266 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 public Response delete(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
268 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
269 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
270 @PathParam("id") String id
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
271 ) {
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
272 /* Get the object by id*/
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
273 Response kommentar =
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
274 defaultRepo.getById(KommentarM.class, Integer.valueOf(id), "land");
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
275 KommentarM kommentarObj = (KommentarM)kommentar.getData();
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
276 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
277 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
278 kommentarObj,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
279 RequestMethod.DELETE,
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
280 KommentarM.class)
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
281 ) {
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
282 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
283 }
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
284 return defaultRepo.delete(kommentarObj, "land");
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
285 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
286 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)