comparison src/main/java/de/intevation/lada/rest/StatusService.java @ 628:21a49dc9984d

Code documentation.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 22 Apr 2015 14:03:53 +0200
parents ddab1ecb2898
children 3ec358698b4d
comparison
equal deleted inserted replaced
627:9a6d8c174e78 628:21a49dc9984d
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz 1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH 2 * Software engineering by Intevation GmbH
3 * 3 *
4 * This file is Free Software under the GNU GPL (v>=3) 4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out 5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details. 6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */ 7 */
8 package de.intevation.lada.rest; 8 package de.intevation.lada.rest;
9 9
10 import javax.enterprise.context.RequestScoped; 10 import javax.enterprise.context.RequestScoped;
11 import javax.inject.Inject; 11 import javax.inject.Inject;
35 import de.intevation.lada.util.data.Repository; 35 import de.intevation.lada.util.data.Repository;
36 import de.intevation.lada.util.data.RepositoryType; 36 import de.intevation.lada.util.data.RepositoryType;
37 import de.intevation.lada.util.rest.RequestMethod; 37 import de.intevation.lada.util.rest.RequestMethod;
38 import de.intevation.lada.util.rest.Response; 38 import de.intevation.lada.util.rest.Response;
39 39
40 /**
41 * REST service for Status objects.
42 * <p>
43 * The services produce data in the application/json media type.
44 * All HTTP methods use the authorization module to determine if the user is
45 * allowed to perform the requested action.
46 * A typical response holds information about the action performed and the data.
47 * <pre>
48 * <code>
49 * {
50 * "success": [boolean];
51 * "message": [string],
52 * "data":[{
53 * "id": [number],
54 * "erzeuger": [string],
55 * "messungsId": [number],
56 * "status": [number],
57 * "owner": [boolean],
58 * "readonly": [boolean],
59 * "treeModified": [timestamp],
60 * "parentModified": [timestamp],
61 * "sdatum": [timestamp],
62 * "skommentar": [string]
63 * }],
64 * "errors": [object],
65 * "warnings": [object],
66 * "readonly": [boolean],
67 * "totalCount": [number]
68 * }
69 * </code>
70 * </pre>
71 *
72 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
73 */
40 @Path("status") 74 @Path("status")
41 @RequestScoped 75 @RequestScoped
42 public class StatusService { 76 public class StatusService {
43 77
44 /* The data repository granting read/write access.*/ 78 /**
79 * The data repository granting read/write access.
80 */
45 @Inject 81 @Inject
46 @RepositoryConfig(type=RepositoryType.RW) 82 @RepositoryConfig(type=RepositoryType.RW)
47 private Repository defaultRepo; 83 private Repository defaultRepo;
48 84
85 /**
86 * The object lock mechanism.
87 */
49 @Inject 88 @Inject
50 @LockConfig(type=LockType.TIMESTAMP) 89 @LockConfig(type=LockType.TIMESTAMP)
51 private ObjectLocker lock; 90 private ObjectLocker lock;
52 91
53 /* The authorization module.*/ 92 /**
93 * The authorization module.
94 */
54 @Inject 95 @Inject
55 @AuthorizationConfig(type=AuthorizationType.OPEN_ID) 96 @AuthorizationConfig(type=AuthorizationType.OPEN_ID)
56 private Authorization authorization; 97 private Authorization authorization;
57 98
58 /** 99 /**
59 * Get all objects. 100 * Get all Status objects.
60 * 101 * <p>
61 * @return Response object containing all messung objects. 102 * The requested objects can be filtered using a URL parameter named
103 * probeId.
104 * <p>
105 * Example: http://example.com/status?messungsId=[ID]
106 *
107 * @return Response object containing all Status objects.
62 */ 108 */
63 @GET 109 @GET
64 @Path("/") 110 @Path("/")
65 @Produces(MediaType.APPLICATION_JSON) 111 @Produces(MediaType.APPLICATION_JSON)
66 public Response get( 112 public Response get(
83 defaultRepo.filter(builder.getQuery(), "land"), 129 defaultRepo.filter(builder.getQuery(), "land"),
84 LStatus.class); 130 LStatus.class);
85 } 131 }
86 132
87 /** 133 /**
88 * Get an object by id. 134 * Get a single Status object by id.
89 * 135 * <p>
90 * @return Response object containing a single messung. 136 * The id is appended to the URL as a path parameter.
137 * <p>
138 * Example: http://example.com/status/{id}
139 *
140 * @return Response object containing a single Status.
91 */ 141 */
92 @GET 142 @GET
93 @Path("/{id}") 143 @Path("/{id}")
94 @Produces(MediaType.APPLICATION_JSON) 144 @Produces(MediaType.APPLICATION_JSON)
95 public Response getById( 145 public Response getById(
101 request, 151 request,
102 defaultRepo.getById(LStatus.class, Integer.valueOf(id), "land"), 152 defaultRepo.getById(LStatus.class, Integer.valueOf(id), "land"),
103 LStatus.class); 153 LStatus.class);
104 } 154 }
105 155
156 /**
157 * Create a Status object.
158 * <p>
159 * The new object is embedded in the post data as JSON formatted string.
160 * <p>
161 * <pre>
162 * <code>
163 * {
164 * "owner": [boolean],
165 * "messungsId": [number],
166 * "erzeuger": [string],
167 * "status": [number],
168 * "skommentar": [string],
169 * "treeModified":null,
170 * "parentModified":null,
171 * "sdatum": [date]
172 * }
173 * </code>
174 * </pre>
175 *
176 * @return A response object containing the created Status.
177 */
106 @POST 178 @POST
107 @Path("/") 179 @Path("/")
108 @Produces(MediaType.APPLICATION_JSON) 180 @Produces(MediaType.APPLICATION_JSON)
109 public Response create( 181 public Response create(
110 @Context HttpHeaders headers, 182 @Context HttpHeaders headers,
125 defaultRepo.create(status, "land"), 197 defaultRepo.create(status, "land"),
126 LStatus.class); 198 LStatus.class);
127 } 199 }
128 200
129 /** 201 /**
130 * Update an existing object. 202 * Update an existing Status object.
131 * 203 * <p>
132 * @return Response object containing the updated probe object. 204 * The object to update should come as JSON formatted string.
205 * <pre>
206 * <code>
207 * {
208 * "id": [number],
209 * "owner": [boolean],
210 * "messungsId": [number],
211 * "erzeuger": [string],
212 * "status": [number],
213 * "skommentar": [string],
214 * "treeModified": [timestamp],
215 * "parentModified": [timestamp],
216 * "sdatum": [date]
217 * }
218 * </code>
219 * </pre>
220 *
221 * @return Response object containing the updated Status object.
133 */ 222 */
134 @PUT 223 @PUT
135 @Path("/{id}") 224 @Path("/{id}")
136 @Produces(MediaType.APPLICATION_JSON) 225 @Produces(MediaType.APPLICATION_JSON)
137 public Response update( 226 public Response update(
159 updated, 248 updated,
160 LStatus.class); 249 LStatus.class);
161 } 250 }
162 251
163 /** 252 /**
164 * Delete an existing object by id. 253 * Delete an existing Status object by id.
254 * <p>
255 * The id is appended to the URL as a path parameter.
256 * <p>
257 * Example: http://example.com/status/{id}
165 * 258 *
166 * @return Response object. 259 * @return Response object.
167 */ 260 */
168 @DELETE 261 @DELETE
169 @Path("/{id}") 262 @Path("/{id}")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)