comparison src/main/java/de/intevation/lada/rest/stamm/ProbenzusatzService.java @ 516:f921a0db3729

Added probenzusatz services.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 19 Feb 2015 14:13:22 +0100
parents
children b3eee6414310
comparison
equal deleted inserted replaced
515:12f7cc76a969 516:f921a0db3729
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8 package de.intevation.lada.rest.stamm;
9
10 import javax.enterprise.context.RequestScoped;
11 import javax.inject.Inject;
12 import javax.ws.rs.GET;
13 import javax.ws.rs.Path;
14 import javax.ws.rs.PathParam;
15 import javax.ws.rs.Produces;
16 import javax.ws.rs.core.Context;
17 import javax.ws.rs.core.HttpHeaders;
18 import javax.ws.rs.core.MediaType;
19 import javax.ws.rs.core.UriInfo;
20
21 import org.apache.log4j.Logger;
22
23 import de.intevation.lada.model.stamm.ProbenZusatz;
24 import de.intevation.lada.util.annotation.AuthenticationConfig;
25 import de.intevation.lada.util.annotation.AuthorizationConfig;
26 import de.intevation.lada.util.annotation.RepositoryConfig;
27 import de.intevation.lada.util.auth.Authentication;
28 import de.intevation.lada.util.auth.AuthenticationType;
29 import de.intevation.lada.util.auth.Authorization;
30 import de.intevation.lada.util.auth.AuthorizationType;
31 import de.intevation.lada.util.data.Repository;
32 import de.intevation.lada.util.data.RepositoryType;
33 import de.intevation.lada.util.rest.Response;
34
35 @Path("probenzusatz")
36 @RequestScoped
37 public class ProbenzusatzService {
38
39 /* The logger used in this class.*/
40 @Inject
41 private Logger logger;
42
43 /* The data repository granting read/write access.*/
44 @Inject
45 @RepositoryConfig(type=RepositoryType.RO)
46 private Repository defaultRepo;
47
48 /* The authentication module.*/
49 @Inject
50 @AuthenticationConfig(type=AuthenticationType.NONE)
51 private Authentication authentication;
52
53 /* The authorization module.*/
54 @Inject
55 @AuthorizationConfig(type=AuthorizationType.NONE)
56 private Authorization authorization;
57
58 /**
59 * Get all objects.
60 *
61 * @return Response object containing all objects.
62 */
63 @GET
64 @Path("/")
65 @Produces(MediaType.APPLICATION_JSON)
66 public Response get(
67 @Context HttpHeaders headers,
68 @Context UriInfo info
69 ) {
70 if (!authentication.isAuthenticated(headers)) {
71 logger.debug("User is not authenticated!");
72 return new Response(false, 699, null);
73 }
74 return defaultRepo.getAll(ProbenZusatz.class, "stamm");
75 }
76
77 /**
78 * Get an object by id.
79 *
80 * @return Response object containing a single object.
81 */
82 @GET
83 @Path("/{id}")
84 @Produces(MediaType.APPLICATION_JSON)
85 public Response getById(
86 @Context HttpHeaders headers,
87 @PathParam("id") String id
88 ) {
89 if (!authentication.isAuthenticated(headers)) {
90 logger.debug("User is not authenticated!");
91 return new Response(false, 699, null);
92 }
93 return defaultRepo.getById(
94 ProbenZusatz.class,
95 id,
96 "stamm");
97 }
98 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)