Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/rest/QueryService.java @ 265:6c26e6474c0f
Added service to fetch sql query configurations.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Wed, 24 Jul 2013 09:09:57 +0200 |
parents | |
children | 2e86f535f290 |
comparison
equal
deleted
inserted
replaced
264:543c2ae3bb39 | 265:6c26e6474c0f |
---|---|
1 package de.intevation.lada.rest; | |
2 | |
3 import java.util.ArrayList; | |
4 | |
5 import javax.enterprise.context.RequestScoped; | |
6 import javax.inject.Inject; | |
7 import javax.inject.Named; | |
8 import javax.ws.rs.GET; | |
9 import javax.ws.rs.Path; | |
10 import javax.ws.rs.Produces; | |
11 import javax.ws.rs.core.Context; | |
12 import javax.ws.rs.core.HttpHeaders; | |
13 import javax.ws.rs.core.UriInfo; | |
14 | |
15 import de.intevation.lada.auth.Authentication; | |
16 import de.intevation.lada.auth.AuthenticationException; | |
17 import de.intevation.lada.model.LOrt; | |
18 | |
19 /** | |
20 * This class produces a RESTful service to read, write and update | |
21 * LOrt objects. | |
22 * | |
23 * @author <a href="mailto:torsten.irlaender@intevation.de">Torsten Irländer</a> | |
24 */ | |
25 @Path("/query") | |
26 @RequestScoped | |
27 public class QueryService | |
28 { | |
29 /** | |
30 * The authorization module. | |
31 */ | |
32 @Inject | |
33 @Named("ldapauth") | |
34 private Authentication authentication; | |
35 | |
36 /** | |
37 * Request SQL-Queries | |
38 * | |
39 * Query parameters are used for the filter in form of key-value pairs. | |
40 * | |
41 * @param info The URL query parameters. | |
42 * @param headers The HTTP header containing authorization information. | |
43 * @return Response object. | |
44 */ | |
45 @GET | |
46 @Produces("text/json") | |
47 public Response filter( | |
48 @Context UriInfo info, | |
49 @Context HttpHeaders headers | |
50 ) { | |
51 try { | |
52 if (!authentication.isAuthorizedUser(headers)) { | |
53 return new Response(false, 699, new ArrayList<LOrt>()); | |
54 } | |
55 String queries = this.loadQueryConfig(); | |
56 Response response = new Response(true, 200, queries); | |
57 return response; | |
58 } | |
59 catch(AuthenticationException ae) { | |
60 return new Response(false, 699, new ArrayList<LOrt>()); | |
61 } | |
62 } | |
63 | |
64 private String loadQueryConfig() { | |
65 String query = "[]"; | |
66 return query; | |
67 } | |
68 } |