changeset 779:64adf06df02f

Use status to get readonly flag for messungen.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 13 Nov 2015 13:41:36 +0100
parents 574391f1d88f
children ec231b0c343d
files src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java	Fri Nov 13 13:40:25 2015 +0100
+++ b/src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java	Fri Nov 13 13:41:36 2015 +0100
@@ -150,12 +150,7 @@
             }
             else if (method == RequestMethod.PUT ||
                      method == RequestMethod.DELETE) {
-                Response messResponse =
-                    repository.getById(LMessung.class, messung.getId(), "land");
-                LMessung messungDb = (LMessung)messResponse.getData();
-                boolean fertigChanged =
-                    !messung.getFertig().equals(messungDb.getFertig());
-                return (!messung.getFertig() || fertigChanged) &&
+                return !this.isMessungReadOnly(messung) &&
                     getAuthorization(userInfo, probe);
             }
         }
@@ -195,7 +190,7 @@
                             messung.getProbeId(),
                             "land");
                     LProbe probe = (LProbe)pResponse.getData();
-                    return !messung.getFertig() &&
+                    return !this.isMessungReadOnly(messung) &&
                         getAuthorization(userInfo, probe);
                 }
             }
@@ -356,7 +351,7 @@
                 else {
                     owner = false;
                 }
-                readOnly = messung.getFertig();
+                readOnly = this.isMessungReadOnly(messung);
             }
 
             Method setOwner = clazz.getMethod("setOwner", boolean.class);
@@ -602,4 +597,15 @@
         }
         return false;
     }
+
+    private boolean isMessungReadOnly(LMessung messung) {
+        if (messung.getStatus() == null) {
+            return false;
+        }
+        LStatusProtokoll status = repository.getByIdPlain(
+            LStatusProtokoll.class,
+            messung.getStatus(),
+            "land");
+        return (status.getStatusWert() != 0 && status.getStatusWert() != 4);
+    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)