changeset 755:6b4764c19ced

Added stub to filter reachable status values.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 02 Nov 2015 10:01:01 +0100
parents 9d34aca4fb07
children d4d765729a04
files src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java
diffstat 1 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java	Mon Nov 02 09:58:50 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java	Mon Nov 02 10:01:01 2015 +0100
@@ -7,8 +7,12 @@
  */
 package de.intevation.lada.rest.stamm;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.enterprise.context.RequestScoped;
 import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -16,10 +20,15 @@
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.UriInfo;
 
 import de.intevation.lada.model.stamm.StatusWert;
+import de.intevation.lada.util.annotation.AuthorizationConfig;
 import de.intevation.lada.util.annotation.RepositoryConfig;
+import de.intevation.lada.util.auth.Authorization;
+import de.intevation.lada.util.auth.AuthorizationType;
+import de.intevation.lada.util.auth.UserInfo;
 import de.intevation.lada.util.data.Repository;
 import de.intevation.lada.util.data.RepositoryType;
 import de.intevation.lada.util.rest.Response;
@@ -59,6 +68,10 @@
     @RepositoryConfig(type=RepositoryType.RO)
     private Repository defaultRepo;
 
+    @Inject
+    @AuthorizationConfig(type=AuthorizationType.HEADER)
+    private Authorization authorization;
+
     /**
      * Get all StatusWert objects.
      * <p>
@@ -71,9 +84,18 @@
     @Produces(MediaType.APPLICATION_JSON)
     public Response get(
         @Context HttpHeaders headers,
+        @Context HttpServletRequest request,
         @Context UriInfo info
     ) {
-        return defaultRepo.getAll(StatusWert.class, "stamm");
+        MultivaluedMap<String, String> params = info.getQueryParameters();
+        if (params.isEmpty() || !params.containsKey("messungsId")) {
+            return defaultRepo.getAll(StatusWert.class, "stamm");
+        }
+        UserInfo user = authorization.getInfo(request);
+        int messungsId = Integer.valueOf(params.getFirst("messungsId"));
+        List<StatusWert> werte = getReachable(messungsId, user);
+        Response response = new Response(true, 200, werte);
+        return response;
     }
 
     /**
@@ -97,4 +119,11 @@
             Integer.valueOf(id),
             "stamm");
     }
+
+    private List<StatusWert> getReachable(int messungsId, UserInfo user) {
+        List<StatusWert> list = new ArrayList<StatusWert>();
+        // TODO get reachable status values from db using the current status and
+        // the user info.
+        return list;
+    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)