try { LogConfiguration logconfiguration = loadLogConfiguration(caid);    if (logconfiguration.logEvent(event)) { if (logconfiguration.useLogDB()) { try {  if (certificate != null) { String uniquecertificatesnr = certificate.getSerialNumber().toString(16) + "," + CertTools.getIssuerDN(certificate); logentryhome.create(this.getAndIncrementRowCount(), admin.getAdminType(), admin.getAdminData(), caid, module, time, username, uniquecertificatesnr, event, comment); } else logentryhome.create(this.getAndIncrementRowCount(), admin.getAdminType(), admin.getAdminData(), caid, module, time, username, null, event, comment); } catch (javax.ejb.DuplicateKeyException dke) { this.getAndIncrementRowCount(); } } if (logconfiguration.useExternalLogDevices()) {  Iterator i = logdevices.iterator(); while (i.hasNext()) { ((ILogDevice) i.next()).log(admin, caid, module, time, username, certificate, event, comment); } } } } catch (Exception e) { throw new EJBException(e); }
doLog(admin, caid, module, time, username, certificate, event, comment, null);
    public void log(Admin admin, int caid, int module, Date time, String username, X509Certificate certificate, int event, String comment) {        try {            LogConfiguration logconfiguration = loadLogConfiguration(caid);            // Get logging configuration            if (logconfiguration.logEvent(event)) {                if (logconfiguration.useLogDB()) {                    try {                        // Log to the local database.                        if (certificate != null) {                            String uniquecertificatesnr = certificate.getSerialNumber().toString(16) + "," + CertTools.getIssuerDN(certificate);                            logentryhome.create(this.getAndIncrementRowCount(), admin.getAdminType(), admin.getAdminData(), caid, module, time, username,                                    uniquecertificatesnr, event, comment);                        } else                            logentryhome.create(this.getAndIncrementRowCount(), admin.getAdminType(), admin.getAdminData(), caid, module, time, username,                                    null, event, comment);                    } catch (javax.ejb.DuplicateKeyException dke) {                        this.getAndIncrementRowCount();                    }                }                if (logconfiguration.useExternalLogDevices()) {                    // Log to external devices. I.e Log4j etc                    Iterator i = logdevices.iterator();                    while (i.hasNext()) {                        ((ILogDevice) i.next()).log(admin, caid, module, time, username, certificate, event, comment);                    }                }            }        } catch (Exception e) {            throw new EJBException(e);        }    } // log