Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/rest/StatusService.java @ 595:746e03da9fad
Use timestamp locker in REST services.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 25 Mar 2015 16:20:01 +0100 |
parents | a04658486ede |
children | ddab1ecb2898 |
comparison
equal
deleted
inserted
replaced
594:b2af88e8eb15 | 595:746e03da9fad |
---|---|
21 import javax.ws.rs.core.HttpHeaders; | 21 import javax.ws.rs.core.HttpHeaders; |
22 import javax.ws.rs.core.MediaType; | 22 import javax.ws.rs.core.MediaType; |
23 import javax.ws.rs.core.MultivaluedMap; | 23 import javax.ws.rs.core.MultivaluedMap; |
24 import javax.ws.rs.core.UriInfo; | 24 import javax.ws.rs.core.UriInfo; |
25 | 25 |
26 import de.intevation.lada.lock.LockConfig; | |
27 import de.intevation.lada.lock.LockType; | |
28 import de.intevation.lada.lock.ObjectLocker; | |
26 import de.intevation.lada.model.land.LStatus; | 29 import de.intevation.lada.model.land.LStatus; |
27 import de.intevation.lada.util.annotation.AuthorizationConfig; | 30 import de.intevation.lada.util.annotation.AuthorizationConfig; |
28 import de.intevation.lada.util.annotation.RepositoryConfig; | 31 import de.intevation.lada.util.annotation.RepositoryConfig; |
29 import de.intevation.lada.util.auth.Authorization; | 32 import de.intevation.lada.util.auth.Authorization; |
30 import de.intevation.lada.util.auth.AuthorizationType; | 33 import de.intevation.lada.util.auth.AuthorizationType; |
40 | 43 |
41 /* The data repository granting read/write access.*/ | 44 /* The data repository granting read/write access.*/ |
42 @Inject | 45 @Inject |
43 @RepositoryConfig(type=RepositoryType.RW) | 46 @RepositoryConfig(type=RepositoryType.RW) |
44 private Repository defaultRepo; | 47 private Repository defaultRepo; |
48 | |
49 @Inject | |
50 @LockConfig(type=LockType.TIMESTAMP) | |
51 private ObjectLocker lock; | |
45 | 52 |
46 /* The authorization module.*/ | 53 /* The authorization module.*/ |
47 @Inject | 54 @Inject |
48 @AuthorizationConfig(type=AuthorizationType.OPEN_ID) | 55 @AuthorizationConfig(type=AuthorizationType.OPEN_ID) |
49 private Authorization authorization; | 56 private Authorization authorization; |
135 RequestMethod.PUT, | 142 RequestMethod.PUT, |
136 LStatus.class) | 143 LStatus.class) |
137 ) { | 144 ) { |
138 return new Response(false, 699, null); | 145 return new Response(false, 699, null); |
139 } | 146 } |
147 if (lock.isLocked(status)) { | |
148 return new Response(false, 697, null); | |
149 } | |
140 Response response = defaultRepo.update(status, "land"); | 150 Response response = defaultRepo.update(status, "land"); |
141 Response updated = defaultRepo.getById( | 151 Response updated = defaultRepo.getById( |
142 LStatus.class, | 152 LStatus.class, |
143 ((LStatus)response.getData()).getId(), "land"); | 153 ((LStatus)response.getData()).getId(), "land"); |
144 return updated; | 154 return updated; |
167 RequestMethod.DELETE, | 177 RequestMethod.DELETE, |
168 LStatus.class) | 178 LStatus.class) |
169 ) { | 179 ) { |
170 return new Response(false, 699, null); | 180 return new Response(false, 699, null); |
171 } | 181 } |
182 if (lock.isLocked(obj)) { | |
183 return new Response(false, 697, null); | |
184 } | |
172 /* Delete the object*/ | 185 /* Delete the object*/ |
173 return defaultRepo.delete(obj, "land"); | 186 return defaultRepo.delete(obj, "land"); |
174 } | 187 } |
175 } | 188 } |