Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/util/auth/MessungIdAuthorizer.java @ 1028:1c41c7b8f7c2 schema-update
Updated server application to new database model. THIS IS STILL WIP!!!
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 08 Jul 2016 15:32:36 +0200 |
parents | f5b4784d9173 |
children |
comparison
equal
deleted
inserted
replaced
1027:9971471d562c | 1028:1c41c7b8f7c2 |
---|---|
10 import java.lang.reflect.InvocationTargetException; | 10 import java.lang.reflect.InvocationTargetException; |
11 import java.lang.reflect.Method; | 11 import java.lang.reflect.Method; |
12 import java.util.ArrayList; | 12 import java.util.ArrayList; |
13 import java.util.List; | 13 import java.util.List; |
14 | 14 |
15 import de.intevation.lada.model.land.LMessung; | 15 import de.intevation.lada.model.land.Messung; |
16 import de.intevation.lada.model.land.LProbe; | 16 import de.intevation.lada.model.land.Probe; |
17 import de.intevation.lada.model.land.LStatusProtokoll; | 17 import de.intevation.lada.model.land.StatusProtokoll; |
18 import de.intevation.lada.model.stammdaten.MessStelle; | |
19 import de.intevation.lada.model.stammdaten.StatusKombi; | |
18 import de.intevation.lada.util.rest.RequestMethod; | 20 import de.intevation.lada.util.rest.RequestMethod; |
19 import de.intevation.lada.util.rest.Response; | 21 import de.intevation.lada.util.rest.Response; |
20 | 22 |
21 public class MessungIdAuthorizer extends BaseAuthorizer { | 23 public class MessungIdAuthorizer extends BaseAuthorizer { |
22 | 24 |
40 IllegalArgumentException | | 42 IllegalArgumentException | |
41 InvocationTargetException e | 43 InvocationTargetException e |
42 ) { | 44 ) { |
43 return false; | 45 return false; |
44 } | 46 } |
45 LMessung messung = repository.getByIdPlain(LMessung.class, id, "land"); | 47 Messung messung = repository.getByIdPlain(Messung.class, id, "land"); |
46 LProbe probe = repository.getByIdPlain( | 48 Probe probe = repository.getByIdPlain( |
47 LProbe.class, | 49 Probe.class, |
48 messung.getProbeId(), | 50 messung.getProbeId(), |
49 "land"); | 51 "land"); |
50 if (messung.getStatus() == null) { | 52 if (messung.getStatus() == null) { |
51 return false; | 53 return false; |
52 } | 54 } |
53 LStatusProtokoll status = repository.getByIdPlain( | 55 StatusProtokoll status = repository.getByIdPlain( |
54 LStatusProtokoll.class, | 56 StatusProtokoll.class, |
55 messung.getStatus(), | 57 messung.getStatus(), |
56 "land"); | 58 "land"); |
59 StatusKombi kombi = repository.getByIdPlain( | |
60 StatusKombi.class, | |
61 status.getStatusKombi(), | |
62 "stamm"); | |
57 return (method == RequestMethod.POST || | 63 return (method == RequestMethod.POST || |
58 method == RequestMethod.PUT || | 64 method == RequestMethod.PUT || |
59 method == RequestMethod.DELETE || | 65 method == RequestMethod.DELETE || |
60 status.getStatusWert() != 0) && | 66 kombi.getStatusWert().getId() != 0) && |
61 getAuthorization(userInfo, probe); | 67 getAuthorization(userInfo, probe); |
62 } | 68 } |
63 | 69 |
64 @SuppressWarnings("unchecked") | 70 @SuppressWarnings("unchecked") |
65 @Override | 71 @Override |
96 Class<T> clazz | 102 Class<T> clazz |
97 ) { | 103 ) { |
98 try { | 104 try { |
99 Method getMessungsId = clazz.getMethod("getMessungsId"); | 105 Method getMessungsId = clazz.getMethod("getMessungsId"); |
100 Integer id = (Integer)getMessungsId.invoke(data); | 106 Integer id = (Integer)getMessungsId.invoke(data); |
101 LMessung messung = repository.getByIdPlain( | 107 Messung messung = repository.getByIdPlain( |
102 LMessung.class, | 108 Messung.class, |
103 id, | 109 id, |
104 "land"); | 110 "land"); |
105 LProbe probe = repository.getByIdPlain( | 111 Probe probe = repository.getByIdPlain( |
106 LProbe.class, | 112 Probe.class, |
107 messung.getProbeId(), | 113 messung.getProbeId(), |
108 "land"); | 114 "land"); |
109 | 115 |
110 boolean readOnly = true; | 116 boolean readOnly = true; |
111 boolean owner = false; | 117 boolean owner = false; |
118 MessStelle mst = repository.getByIdPlain(MessStelle.class, probe.getMstId(), "stamm"); | |
112 if (!userInfo.getNetzbetreiber().contains( | 119 if (!userInfo.getNetzbetreiber().contains( |
113 probe.getNetzbetreiberId())) { | 120 mst.getNetzbetreiberId())) { |
114 owner = false; | 121 owner = false; |
115 readOnly = true; | 122 readOnly = true; |
116 } | 123 } |
117 else { | 124 else { |
118 if (userInfo.belongsTo(probe.getMstId(), probe.getLaborMstId())) { | 125 if (userInfo.belongsTo(probe.getMstId(), probe.getLaborMstId())) { |