]> WPIA git - gigi.git/commitdiff
upd: factor out ping-delay for domains to constant
authorFelix Dörre <felix@dogcraft.de>
Fri, 17 Jun 2016 15:37:02 +0000 (17:37 +0200)
committerFelix Dörre <felix@dogcraft.de>
Sat, 18 Jun 2016 13:56:20 +0000 (15:56 +0200)
Change-Id: Ib7dba946ea9e9d7741c11fe6fb1c143d91e92c72

src/org/cacert/gigi/dbObjects/DomainPingConfiguration.java

index baa7b7b00b69c1affad4e21391f67e425f08b01a..d63aff9b6fb81b250f9fded5649f64c2d689fcb6 100644 (file)
@@ -14,6 +14,8 @@ import org.cacert.gigi.output.template.SprintfCommand;
 
 public class DomainPingConfiguration implements IdCachable {
 
 
 public class DomainPingConfiguration implements IdCachable {
 
+    private static final int REPING_MINIMUM_DELAY = 5 * 60 * 1000;
+
     private int id;
 
     private Domain target;
     private int id;
 
     private Domain target;
@@ -88,12 +90,13 @@ public class DomainPingConfiguration implements IdCachable {
 
     public synchronized void requestReping() throws GigiApiException {
         Date lastExecution = getLastExecution();
 
     public synchronized void requestReping() throws GigiApiException {
         Date lastExecution = getLastExecution();
-        if (lastExecution.getTime() + 5 * 60 * 1000 < System.currentTimeMillis()) {
+        if (lastExecution.getTime() + REPING_MINIMUM_DELAY < System.currentTimeMillis()) {
             Gigi.notifyPinger(this);
             return;
         }
         Map<String, Object> data = new HashMap<String, Object>();
             Gigi.notifyPinger(this);
             return;
         }
         Map<String, Object> data = new HashMap<String, Object>();
-        data.put("data", new Date(lastExecution.getTime() + 5 * 60 * 1000));
-        throw new GigiApiException(new Scope(new SprintfCommand("Reping is only allowed after 5 minutes, yours end at {0}.", Arrays.asList("${data}")), data));
+        data.put("delay", REPING_MINIMUM_DELAY / 60 / 1000);
+        data.put("data", new Date(lastExecution.getTime() + REPING_MINIMUM_DELAY));
+        throw new GigiApiException(new Scope(new SprintfCommand("Reping is only allowed after {0} minutes, yours end at {1}.", Arrays.asList("${delay}", "${data}")), data));
     }
 }
     }
 }