[Lada-commits] [PATCH] Fixed authorization for messprogramm ortszuordnung

Wald Commits scm-commit at wald.intevation.org
Wed Feb 8 12:24:37 CET 2017


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1486553074 -3600
# Node ID d73cfd90ffc0aad8edc4bf851e5ca3716e8f44ce
# Parent  3383ca19f7a5cf6fcc44aea107dc60033e96227f
Fixed authorization for messprogramm ortszuordnung.

diff -r 3383ca19f7a5 -r d73cfd90ffc0 src/main/java/de/intevation/lada/model/land/OrtszuordnungMp.java
--- a/src/main/java/de/intevation/lada/model/land/OrtszuordnungMp.java	Wed Feb 08 12:01:07 2017 +0100
+++ b/src/main/java/de/intevation/lada/model/land/OrtszuordnungMp.java	Wed Feb 08 12:24:34 2017 +0100
@@ -16,6 +16,7 @@
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
+import javax.persistence.Transient;
 
 
 /**
@@ -45,9 +46,15 @@
 
     private String ortszusatztext;
 
-    @Column(name="tree_modified")
+    @Column(name="tree_modified", insertable=false, updatable=false)
     private Timestamp treeModified;
 
+    @Transient
+    private boolean owner;
+
+    @Transient
+    private boolean readonly;
+
     public OrtszuordnungMp() {
     }
 
@@ -107,4 +114,31 @@
         this.treeModified = treeModified;
     }
 
+    /**
+     * @return the owner
+     */
+    public boolean isOwner() {
+        return owner;
+    }
+
+    /**
+     * @param owner the owner to set
+     */
+    public void setOwner(boolean owner) {
+        this.owner = owner;
+    }
+
+    /**
+     * @return the readonly
+     */
+    public boolean isReadonly() {
+        return readonly;
+    }
+
+    /**
+     * @param readonly the readonly to set
+     */
+    public void setReadonly(boolean readonly) {
+        this.readonly = readonly;
+    }
 }
diff -r 3383ca19f7a5 -r d73cfd90ffc0 src/main/java/de/intevation/lada/util/auth/MessprogrammIdAuthorizer.java
--- a/src/main/java/de/intevation/lada/util/auth/MessprogrammIdAuthorizer.java	Wed Feb 08 12:01:07 2017 +0100
+++ b/src/main/java/de/intevation/lada/util/auth/MessprogrammIdAuthorizer.java	Wed Feb 08 12:24:34 2017 +0100
@@ -13,7 +13,6 @@
 import java.util.List;
 
 import de.intevation.lada.model.land.Messprogramm;
-import de.intevation.lada.model.land.Probe;
 import de.intevation.lada.model.stammdaten.MessStelle;
 import de.intevation.lada.util.rest.RequestMethod;
 import de.intevation.lada.util.rest.Response;
@@ -84,33 +83,33 @@
         Class<T> clazz
     ) {
         try {
-            Method getProbeId = clazz.getMethod("getProbeId");
+            Method getMessprogrammId = clazz.getMethod("getMessprogrammId");
             Integer id = null;
-            if (getProbeId != null) {
-                id = (Integer) getProbeId.invoke(data);
+            if (getMessprogrammId != null) {
+                id = (Integer) getMessprogrammId.invoke(data);
             }
             else {
                 return null;
             }
-            Probe probe =
-                (Probe)repository.getById(Probe.class, id, "land").getData();
+            Messprogramm messprogramm =
+                (Messprogramm)repository.getById(Messprogramm.class, id, "land").getData();
 
             boolean readOnly = true;
             boolean owner = false;
-            MessStelle mst = repository.getByIdPlain(MessStelle.class, probe.getMstId(), "stamm");
+            MessStelle mst = repository.getByIdPlain(MessStelle.class, messprogramm.getMstId(), "stamm");
             if (!userInfo.getNetzbetreiber().contains(
                     mst.getNetzbetreiberId())) {
                 owner = false;
                 readOnly = true;
             }
             else {
-                if (userInfo.belongsTo(probe.getMstId(), probe.getLaborMstId())) {
+                if (userInfo.belongsTo(messprogramm.getMstId(), messprogramm.getLaborMstId())) {
                     owner = true;
                 }
                 else {
                     owner = false;
                 }
-                readOnly = this.isProbeReadOnly(id);
+                readOnly = owner;
             }
 
             Method setOwner = clazz.getMethod("setOwner", boolean.class);


More information about the Lada-commits mailing list