[Lada-commits] [PATCH 7 of 8] Use timestamp locker in REST services
Wald Commits
scm-commit at wald.intevation.org
Wed Mar 25 16:26:29 CET 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1427296801 -3600
# Node ID 746e03da9fad9988aba69d7eb17ae48b37e94df4
# Parent b2af88e8eb15fb1b19e399a9c2dd9712ae8c98ce
Use timestamp locker in REST services.
diff -r b2af88e8eb15 -r 746e03da9fad src/main/java/de/intevation/lada/rest/MessungService.java
--- a/src/main/java/de/intevation/lada/rest/MessungService.java Wed Mar 25 16:18:34 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/MessungService.java Wed Mar 25 16:20:01 2015 +0100
@@ -7,6 +7,8 @@
*/
package de.intevation.lada.rest;
+import java.sql.Timestamp;
+import java.util.Date;
import java.util.List;
import javax.enterprise.context.RequestScoped;
@@ -25,6 +27,9 @@
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
+import de.intevation.lada.lock.LockConfig;
+import de.intevation.lada.lock.LockType;
+import de.intevation.lada.lock.ObjectLocker;
import de.intevation.lada.model.land.LMessung;
import de.intevation.lada.model.land.MessungTranslation;
import de.intevation.lada.util.annotation.AuthorizationConfig;
@@ -46,6 +51,10 @@
@RepositoryConfig(type=RepositoryType.RW)
private Repository defaultRepo;
+ @Inject
+ @LockConfig(type=LockType.TIMESTAMP)
+ private ObjectLocker lock;
+
/* The authorization module.*/
@Inject
@AuthorizationConfig(type=AuthorizationType.OPEN_ID)
@@ -150,6 +159,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(messung)) {
+ return new Response(false, 697, null);
+ }
Response response = defaultRepo.update(messung, "land");
Response updated = defaultRepo.getById(
LMessung.class,
@@ -182,6 +194,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(messung)) {
+ return new Response(false, 697, null);
+ }
/* Create a query and request the messungTranslation object for the
* messung*/
QueryBuilder<MessungTranslation> builder =
diff -r b2af88e8eb15 -r 746e03da9fad src/main/java/de/intevation/lada/rest/MesswertService.java
--- a/src/main/java/de/intevation/lada/rest/MesswertService.java Wed Mar 25 16:18:34 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/MesswertService.java Wed Mar 25 16:20:01 2015 +0100
@@ -25,6 +25,9 @@
import org.apache.log4j.Logger;
+import de.intevation.lada.lock.LockConfig;
+import de.intevation.lada.lock.LockType;
+import de.intevation.lada.lock.ObjectLocker;
import de.intevation.lada.model.land.LMesswert;
import de.intevation.lada.util.annotation.AuthorizationConfig;
import de.intevation.lada.util.annotation.RepositoryConfig;
@@ -49,6 +52,10 @@
@RepositoryConfig(type=RepositoryType.RW)
private Repository defaultRepo;
+ @Inject
+ @LockConfig(type=LockType.TIMESTAMP)
+ private ObjectLocker lock;
+
/* The authorization module.*/
@Inject
@AuthorizationConfig(type=AuthorizationType.OPEN_ID)
@@ -144,6 +151,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(messwert)) {
+ return new Response(false, 697, null);
+ }
Response response = defaultRepo.update(messwert, "land");
Response updated = defaultRepo.getById(
LMesswert.class,
@@ -176,6 +186,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(messwert)) {
+ return new Response(false, 697, null);
+ }
/* Delete the messwert object*/
return defaultRepo.delete(messwertObj, "land");
}
diff -r b2af88e8eb15 -r 746e03da9fad src/main/java/de/intevation/lada/rest/OrtService.java
--- a/src/main/java/de/intevation/lada/rest/OrtService.java Wed Mar 25 16:18:34 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/OrtService.java Wed Mar 25 16:20:01 2015 +0100
@@ -25,6 +25,9 @@
import org.apache.log4j.Logger;
+import de.intevation.lada.lock.LockConfig;
+import de.intevation.lada.lock.LockType;
+import de.intevation.lada.lock.ObjectLocker;
import de.intevation.lada.model.land.LOrt;
import de.intevation.lada.util.annotation.AuthorizationConfig;
import de.intevation.lada.util.annotation.RepositoryConfig;
@@ -49,6 +52,10 @@
@RepositoryConfig(type=RepositoryType.RW)
private Repository defaultRepo;
+ @Inject
+ @LockConfig(type=LockType.TIMESTAMP)
+ private ObjectLocker lock;
+
/* The authorization module.*/
@Inject
@AuthorizationConfig(type=AuthorizationType.OPEN_ID)
@@ -142,6 +149,9 @@
LOrt.class)) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(ort)) {
+ return new Response(false, 697, null);
+ }
Response response = defaultRepo.update(ort, "land");
Response updated = defaultRepo.getById(
LOrt.class,
@@ -173,6 +183,9 @@
LOrt.class)) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(ortObj)) {
+ return new Response(false, 697, null);
+ }
/* Delete the messwert object*/
return defaultRepo.delete(ortObj, "land");
}
diff -r b2af88e8eb15 -r 746e03da9fad src/main/java/de/intevation/lada/rest/ProbeService.java
--- a/src/main/java/de/intevation/lada/rest/ProbeService.java Wed Mar 25 16:18:34 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/ProbeService.java Wed Mar 25 16:20:01 2015 +0100
@@ -8,7 +8,9 @@
package de.intevation.lada.rest;
import java.io.StringReader;
+import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -36,6 +38,9 @@
import org.apache.log4j.Logger;
+import de.intevation.lada.lock.LockConfig;
+import de.intevation.lada.lock.LockType;
+import de.intevation.lada.lock.ObjectLocker;
import de.intevation.lada.model.land.LProbe;
import de.intevation.lada.model.land.ProbeTranslation;
import de.intevation.lada.query.QueryTools;
@@ -77,6 +82,10 @@
private Authorization authorization;
@Inject
+ @LockConfig(type=LockType.TIMESTAMP)
+ private ObjectLocker lock;
+
+ @Inject
@ValidationConfig(type="Probe")
private Validator validator;
@@ -243,6 +252,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(probe)) {
+ return new Response(false, 697, null);
+ }
Violation violation = validator.validate(probe);
if (violation.hasErrors()) {
Response response = new Response(false, 604, null);
diff -r b2af88e8eb15 -r 746e03da9fad src/main/java/de/intevation/lada/rest/StatusService.java
--- a/src/main/java/de/intevation/lada/rest/StatusService.java Wed Mar 25 16:18:34 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/StatusService.java Wed Mar 25 16:20:01 2015 +0100
@@ -23,6 +23,9 @@
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
+import de.intevation.lada.lock.LockConfig;
+import de.intevation.lada.lock.LockType;
+import de.intevation.lada.lock.ObjectLocker;
import de.intevation.lada.model.land.LStatus;
import de.intevation.lada.util.annotation.AuthorizationConfig;
import de.intevation.lada.util.annotation.RepositoryConfig;
@@ -43,6 +46,10 @@
@RepositoryConfig(type=RepositoryType.RW)
private Repository defaultRepo;
+ @Inject
+ @LockConfig(type=LockType.TIMESTAMP)
+ private ObjectLocker lock;
+
/* The authorization module.*/
@Inject
@AuthorizationConfig(type=AuthorizationType.OPEN_ID)
@@ -137,6 +144,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(status)) {
+ return new Response(false, 697, null);
+ }
Response response = defaultRepo.update(status, "land");
Response updated = defaultRepo.getById(
LStatus.class,
@@ -169,6 +179,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(obj)) {
+ return new Response(false, 697, null);
+ }
/* Delete the object*/
return defaultRepo.delete(obj, "land");
}
diff -r b2af88e8eb15 -r 746e03da9fad src/main/java/de/intevation/lada/rest/ZusatzwertService.java
--- a/src/main/java/de/intevation/lada/rest/ZusatzwertService.java Wed Mar 25 16:18:34 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/ZusatzwertService.java Wed Mar 25 16:20:01 2015 +0100
@@ -23,6 +23,9 @@
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
+import de.intevation.lada.lock.LockConfig;
+import de.intevation.lada.lock.LockType;
+import de.intevation.lada.lock.ObjectLocker;
import de.intevation.lada.model.land.LZusatzWert;
import de.intevation.lada.util.annotation.AuthorizationConfig;
import de.intevation.lada.util.annotation.RepositoryConfig;
@@ -43,6 +46,10 @@
@RepositoryConfig(type=RepositoryType.RW)
private Repository defaultRepo;
+ @Inject
+ @LockConfig(type=LockType.TIMESTAMP)
+ private ObjectLocker lock;
+
/* The authorization module.*/
@Inject
@AuthorizationConfig(type=AuthorizationType.OPEN_ID)
@@ -137,6 +144,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(zusatzwert)) {
+ return new Response(false, 697, null);
+ }
Response response = defaultRepo.update(zusatzwert, "land");
Response updated = defaultRepo.getById(
LZusatzWert.class,
@@ -169,6 +179,9 @@
) {
return new Response(false, 699, null);
}
+ if (lock.isLocked(obj)) {
+ return new Response(false, 697, null);
+ }
/* Delete the object*/
return defaultRepo.delete(obj, "land");
}
More information about the Lada-commits
mailing list