changeset 1288:d73cfd90ffc0

Fixed authorization for messprogramm ortszuordnung.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 08 Feb 2017 12:24:34 +0100
parents 3383ca19f7a5
children 788311087838
files src/main/java/de/intevation/lada/model/land/OrtszuordnungMp.java src/main/java/de/intevation/lada/util/auth/MessprogrammIdAuthorizer.java
diffstat 2 files changed, 43 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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;
+    }
 }
--- 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);
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)