]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/Domain.java
upd: allow deletion of ping configurations
[gigi.git] / src / org / cacert / gigi / dbObjects / Domain.java
index 78ebc9bbf78ff3f96edee4b8ef27a3888925f183..e5d66a93f08f0ca5ea31638b0fd9951aae7122a5 100644 (file)
@@ -171,7 +171,7 @@ public class Domain implements IdCachable, Verifyable {
         LinkedList<DomainPingConfiguration> configs = this.configs;
         if (configs == null) {
             configs = new LinkedList<>();
-            try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT id FROM pingconfig WHERE domainid=?")) {
+            try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT id FROM pingconfig WHERE domainid=? AND `deleted` IS NULL")) {
                 ps.setInt(1, id);
                 GigiResultSet rs = ps.executeQuery();
                 while (rs.next()) {
@@ -194,6 +194,14 @@ public class Domain implements IdCachable, Verifyable {
         configs = null;
     }
 
+    public void clearPings() throws GigiApiException {
+        try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `pingconfig` SET `deleted`=CURRENT_TIMESTAMP WHERE `deleted` is NULL AND `domainid`=?")) {
+            ps.setInt(1, id);
+            ps.execute();
+        }
+        configs = null;
+    }
+
     public synchronized void verify(String hash) throws GigiApiException {
         try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `domainPinglog` SET `state`='success' WHERE `challenge`=? AND `state`='open' AND `configId` IN (SELECT `id` FROM `pingconfig` WHERE `domainid`=? AND `type`='email')")) {
             ps.setString(1, hash);