annotate src/main/java/de/intevation/lada/rest/KommentarMService.java @ 827:5bdd1631a451

!!!CAUTION!!! changed services path! REST servies now listening on /rest/* Importer/Exporter now listening on /data/$FORMAT/*
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 18 Dec 2015 17:47:14 +0100
parents b04e55896104
children fa922101a462
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 */
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>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
90 * The requested objects can be filtered using a URL parameter named
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 *
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
95 * @return Response object containing all (filtered) KommentarM objects.
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 @GET
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 @Path("/")
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 public Response get(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
102 @Context UriInfo info,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
103 @Context HttpServletRequest request
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 ) {
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 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
106 if (params.isEmpty() || !params.containsKey("messungsId")) {
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
107 return new Response(false, 699, null);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 }
556
4017d2c8dd24 Renamed all 'messungId' url parameters to 'messungsId'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 478
diff changeset
109 String messungId = params.getFirst("messungsId");
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
110 int id;
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
111 try {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
112 id = Integer.valueOf(messungId);
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
113 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
114 catch(NumberFormatException nfe) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
115 return new Response(false, 699, null);
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
116 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
117 LMessung messung = defaultRepo.getByIdPlain(
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
118 LMessung.class,
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
119 id,
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
120 "land");
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
121 if (!authorization.isAuthorized(authorization.getInfo(request), messung)) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
122 if (!authorization.isAuthorized(id, LMessung.class)) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
123 return new Response(false, 699, null);
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
124 }
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
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 QueryBuilder<LKommentarM> builder =
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 new QueryBuilder<LKommentarM>(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 defaultRepo.entityManager("land"),
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 LKommentarM.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"),
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
135 LKommentarM.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 =
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
156 defaultRepo.getById(LKommentarM.class, Integer.valueOf(id), "land");
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
157 LKommentarM kommentar = (LKommentarM)response.getData();
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
158 LMessung messung = defaultRepo.getByIdPlain(
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
159 LMessung.class,
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");
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
162 if (!authorization.isAuthorized(authorization.getInfo(request), messung)) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
163 if (!authorization.isAuthorized(messung.getId(), LMessung.class)) {
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
164 return new Response(false, 699, null);
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
165 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
166 }
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
167
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
168 return authorization.filter(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
169 request,
802
b04e55896104 Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 722
diff changeset
170 response,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
171 LKommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
173
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
174 /**
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
175 * Create a KommentarM object.
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 * 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
178 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
179 * <pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
180 * <code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
181 * {
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
182 * messungsId: [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
183 * erzeuger: [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
184 * text: [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
185 * datum: [date]
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
186 * owner: [boolean],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
187 * }
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
188 * </code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
189 * </pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
190 * @return A response object containing the created KommentarM.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
191 */
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
192 @POST
639
e0484b039812 Fixed path for POST requests on kommentarm service.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 631
diff changeset
193 @Path("/")
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
194 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
195 public Response create(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
196 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
197 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198 LKommentarM kommentar
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199 ) {
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
200 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
201 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
202 kommentar,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
203 RequestMethod.POST,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
204 LKommentarM.class)
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
205 ) {
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 return new Response(false, 699, null);
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
207 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
208 /* Persist the new object*/
601
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
209 return authorization.filter(
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
210 request,
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
211 defaultRepo.create(kommentar, "land"),
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
212 LKommentarM.class);
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
213 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
214
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
215 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
216 * Update an existing KommentarM object.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
217 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
218 * The object to update should come as JSON formatted string.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
219 * <pre>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
220 * <code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
221 * {
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
222 * "id": [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
223 * "owner": [boolean],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
224 * "messungsId": [number],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
225 * "erzeuger": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
226 * "text": [string],
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
227 * "datum": [date]
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
228 * }
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
229 * </code>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
230 * </pre>
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 *
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
232 * @return Response object containing the updated KommentarM object.
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
233 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234 @PUT
557
61ce3ce0100e Allow /{id} in urls on PUT requests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 556
diff changeset
235 @Path("/{id}")
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237 public Response update(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
238 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
239 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 LKommentarM kommentar
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241 ) {
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
242 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
243 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
244 kommentar,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
245 RequestMethod.PUT,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
246 LKommentarM.class)
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
247 ) {
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 return new Response(false, 699, null);
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
249 }
601
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
250 return authorization.filter(
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
251 request,
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
252 defaultRepo.update(kommentar, "land"),
ddab1ecb2898 Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 582
diff changeset
253 LKommentarM.class);
478
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
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
256 /**
627
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
257 * Delete an existing KommentarM object by id.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
258 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
259 * The id is appended to the URL as a path parameter.
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
260 * <p>
9a6d8c174e78 Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 601
diff changeset
261 * Example: http://example.com/mkommentar/{id}
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
262 *
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
263 * @return Response object.
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264 */
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
265 @DELETE
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
266 @Path("/{id}")
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 @Produces(MediaType.APPLICATION_JSON)
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
268 public Response delete(
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
269 @Context HttpHeaders headers,
582
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
270 @Context HttpServletRequest request,
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
271 @PathParam("id") String id
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
272 ) {
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
273 /* Get the object by id*/
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
274 Response kommentar =
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
275 defaultRepo.getById(LKommentarM.class, Integer.valueOf(id), "land");
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
276 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
277 if (!authorization.isAuthorized(
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
278 request,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
279 kommentarObj,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
280 RequestMethod.DELETE,
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
281 LKommentarM.class)
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
282 ) {
a04658486ede Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 557
diff changeset
283 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
284 }
478
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
285 return defaultRepo.delete(kommentarObj, "land");
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
286 }
808983286514 Added services for messung kommentar.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
287 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)