changeset 397:414534a2c23d

Set readonly flag for proben using the mstId as criteria.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 17 Dec 2013 12:10:44 +0100
parents 6ba7630c7e52
children 2cec94fcab05 6a5b506f4559
files src/main/java/de/intevation/lada/data/LProbeRepository.java src/main/java/de/intevation/lada/rest/LProbeService.java
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/data/LProbeRepository.java	Mon Dec 16 11:23:40 2013 +0100
+++ b/src/main/java/de/intevation/lada/data/LProbeRepository.java	Tue Dec 17 12:10:44 2013 +0100
@@ -75,7 +75,8 @@
         String sql,
         List<String> filters,
         List<String> results,
-        MultivaluedMap<String, String> params) {
+        MultivaluedMap<String, String> params,
+        List<String> msts) {
         Query query = em.createNativeQuery(sql);
         for (String filter: filters) {
             List<String> param = params.get(filter);
@@ -89,17 +90,20 @@
         List<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
         for (Object[] row: result) {
             Map<String, Object> set = new HashMap<String, Object>();
+            boolean ro = false;
             for (int i = 0; i < row.length; i++) {
                 set.put(results.get(i), row[i]);
                 if (results.get(i).equals("probeId")) {
                     if (authorization.isReadOnly((String)row[i])) {
-                        set.put("readonly", Boolean.TRUE);
-                    }
-                    else {
-                        set.put("readonly", Boolean.FALSE);
+                    	ro = true;
                     }
                 }
+                if (results.get(i).equals("mstId") &&
+                	!msts.contains((String)row[i])) {
+                	ro = true;
+                }
             }
+            set.put("readonly", ro);
             res.add(set);
         }
         return new Response(true, 200, res);
--- a/src/main/java/de/intevation/lada/rest/LProbeService.java	Mon Dec 16 11:23:40 2013 +0100
+++ b/src/main/java/de/intevation/lada/rest/LProbeService.java	Tue Dec 17 12:10:44 2013 +0100
@@ -121,6 +121,7 @@
                 if (auth.getMst().contains(mstId)) {
                     return response;
                 }
+                p.setReadonly(true);
                 return response;
             }
             return new Response(false, 698, new ArrayList<LProbe>());
@@ -205,7 +206,8 @@
             }
             subselect += "or readonly = true) as lp";
             sql = sql.replace("l_probe", subselect);
-            return lpr.filterFree(sql, filters, results, params);
+            List<String> msts = auth.getMst();
+            return lpr.filterFree(sql, filters, results, params, msts);
         }
         catch(AuthenticationException ae) {
             return new Response(false, 699, new ArrayList<LProbe>());
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)