[Lada-commits] [PATCH 2 of 3] Use status to get readonly flag for messungen

Wald Commits scm-commit at wald.intevation.org
Fri Nov 13 13:42:23 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1447418496 -3600
# Node ID 64adf06df02f21592c4ceaf6165c379374375c21
# Parent  574391f1d88f355d9b32a4509263222f9856cfba
Use status to get readonly flag for messungen.

diff -r 574391f1d88f -r 64adf06df02f src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java
--- 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);
+    }
 }


More information about the Lada-commits mailing list