Mercurial > lada > lada-server
changeset 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 | 543c2ae3bb39 |
children | 2e86f535f290 |
files | src/main/java/de/intevation/lada/rest/QueryService.java |
diffstat | 1 files changed, 68 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/rest/QueryService.java Wed Jul 24 09:09:57 2013 +0200 @@ -0,0 +1,68 @@ +package de.intevation.lada.rest; + +import java.util.ArrayList; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.UriInfo; + +import de.intevation.lada.auth.Authentication; +import de.intevation.lada.auth.AuthenticationException; +import de.intevation.lada.model.LOrt; + +/** + * This class produces a RESTful service to read, write and update + * LOrt objects. + * + * @author <a href="mailto:torsten.irlaender@intevation.de">Torsten Irländer</a> + */ +@Path("/query") +@RequestScoped +public class QueryService +{ + /** + * The authorization module. + */ + @Inject + @Named("ldapauth") + private Authentication authentication; + + /** + * Request SQL-Queries + * + * Query parameters are used for the filter in form of key-value pairs. + * + * @param info The URL query parameters. + * @param headers The HTTP header containing authorization information. + * @return Response object. + */ + @GET + @Produces("text/json") + public Response filter( + @Context UriInfo info, + @Context HttpHeaders headers + ) { + try { + if (!authentication.isAuthorizedUser(headers)) { + return new Response(false, 699, new ArrayList<LOrt>()); + } + String queries = this.loadQueryConfig(); + Response response = new Response(true, 200, queries); + return response; + } + catch(AuthenticationException ae) { + return new Response(false, 699, new ArrayList<LOrt>()); + } + } + + private String loadQueryConfig() { + String query = "[]"; + return query; + } +}