]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/CertificateOwner.java
UPD: Cleanup User-class.
[gigi.git] / src / org / cacert / gigi / dbObjects / CertificateOwner.java
index 9560224e3601283bce748b51033ba29b2365112a..84acca2eefb7d55e8f670e29147d8686c93ef1ab 100644 (file)
@@ -12,11 +12,16 @@ public abstract class CertificateOwner implements IdCachable {
 
     private int id;
 
-    public CertificateOwner(int id) {
+    protected CertificateOwner(int id) {
         this.id = id;
     }
 
-    public CertificateOwner() {}
+    protected CertificateOwner() {
+        GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO `certOwners` DEFAULT VALUES");
+        ps.execute();
+        id = ps.lastInsertId();
+        myCache.put(this);
+    }
 
     public int getId() {
         return id;
@@ -43,20 +48,6 @@ public abstract class CertificateOwner implements IdCachable {
         return u;
     }
 
-    protected int insert() {
-        synchronized (User.class) {
-            if (id != 0) {
-                throw new Error("refusing to insert");
-            }
-            GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO `certOwners` DEFAULT VALUES");
-            ps.execute();
-            id = ps.lastInsertId();
-            myCache.put(this);
-        }
-
-        return id;
-    }
-
     public Domain[] getDomains() {
         GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT `id` FROM `domains` WHERE `memid`=? AND `deleted` IS NULL");
         ps.setInt(1, getId());