1 package org.cacert.gigi.dbObjects;
3 import org.cacert.gigi.database.DatabaseConnection;
4 import org.cacert.gigi.database.GigiPreparedStatement;
5 import org.cacert.gigi.database.GigiResultSet;
7 public class DomainPingConfiguration implements IdCachable {
9 public static enum PingType {
10 EMAIL, DNS, HTTP, SSL;
15 private Domain target;
17 private PingType type;
21 private DomainPingConfiguration(int id) {
22 GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT id, domainid, type, info FROM pingconfig WHERE id=?");
25 GigiResultSet rs = ps.executeQuery();
27 throw new IllegalArgumentException("Invalid pingconfig id " + id);
29 this.id = rs.getInt("id");
30 target = Domain.getById(rs.getInt("domainid"));
31 type = PingType.valueOf(rs.getString("type").toUpperCase());
32 info = rs.getString("info");
40 public Domain getTarget() {
44 public PingType getType() {
48 public String getInfo() {
52 private static ObjectCache<DomainPingConfiguration> cache = new ObjectCache<>();
54 public static synchronized DomainPingConfiguration getById(int id) {
55 DomainPingConfiguration res = cache.get(id);
57 cache.put(res = new DomainPingConfiguration(id));
62 public void requestReping() {
63 GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("UPDATE pingconfig set reping='y' WHERE id=?");