X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FDomain.java;h=6b0e82830d07a2f9e0c4121a0910c3217d7674aa;hp=c165c4abdbcaedc7e1e457715a5a021090304a19;hb=b47144d6f3bf6b6eb1ec477de9d2af38256f074f;hpb=787dc5faad7c6829b0e9b699767fc6e13c17999e diff --git a/src/org/cacert/gigi/dbObjects/Domain.java b/src/org/cacert/gigi/dbObjects/Domain.java index c165c4ab..6b0e8283 100644 --- a/src/org/cacert/gigi/dbObjects/Domain.java +++ b/src/org/cacert/gigi/dbObjects/Domain.java @@ -52,10 +52,12 @@ public class Domain implements IdCachable, Verifyable { } public Domain(User owner, String suffix) throws GigiApiException { - checkCertifyableDomain(suffix, owner.isInGroup(Group.CODESIGNING)); - this.owner = owner; - this.suffix = suffix; - + synchronized (Domain.class) { + checkCertifyableDomain(suffix, owner.isInGroup(Group.CODESIGNING)); + this.owner = owner; + this.suffix = suffix; + insert(); + } } public static void checkCertifyableDomain(String s, boolean hasPunycodeRight) throws GigiApiException { @@ -126,19 +128,17 @@ public class Domain implements IdCachable, Verifyable { } } - public void insert() throws GigiApiException { - synchronized (Domain.class) { - if (id != 0) { - throw new GigiApiException("already inserted."); - } - checkInsert(suffix); - GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO `domains` SET memid=?, domain=?"); - ps.setInt(1, owner.getId()); - ps.setString(2, suffix); - ps.execute(); - id = ps.lastInsertId(); - myCache.put(this); + private void insert() throws GigiApiException { + if (id != 0) { + throw new GigiApiException("already inserted."); } + checkInsert(suffix); + GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO `domains` SET memid=?, domain=?"); + ps.setInt(1, owner.getId()); + ps.setString(2, suffix); + ps.execute(); + id = ps.lastInsertId(); + myCache.put(this); } public void delete() throws GigiApiException {