diff --git a/base/ca/src/main/java/com/netscape/cmscore/dbs/SerialNumberUpdateTask.java b/base/ca/src/main/java/com/netscape/cmscore/dbs/SerialNumberUpdateTask.java index 58714f44c8f..f808bf929d7 100644 --- a/base/ca/src/main/java/com/netscape/cmscore/dbs/SerialNumberUpdateTask.java +++ b/base/ca/src/main/java/com/netscape/cmscore/dbs/SerialNumberUpdateTask.java @@ -22,26 +22,19 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; -import com.netscape.cmscore.request.RequestRepository; +import org.dogtagpki.server.ca.CAEngine; public class SerialNumberUpdateTask implements Runnable { public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(SerialNumberUpdateTask.class); - CertificateRepository certRepository; - RequestRepository requestRepository; - + CAEngine engine; int interval; ScheduledExecutorService executorService; - public SerialNumberUpdateTask( - CertificateRepository certRepository, - RequestRepository requestRepository, - int interval) { - - this.certRepository = certRepository; - this.requestRepository = requestRepository; + public SerialNumberUpdateTask(CAEngine engine, int interval) { + this.engine = engine; this.interval = interval; } @@ -56,22 +49,10 @@ public Thread newThread(Runnable r) { executorService.scheduleWithFixedDelay(this, 0, interval, TimeUnit.SECONDS); } - public synchronized void updateSerialNumbers() throws Exception { - - logger.info("SerialNumberUpdateTask: Updating serial number counter"); - certRepository.updateCounter(); - - logger.info("SerialNumberUpdateTask: Checking serial number ranges"); - certRepository.checkRanges(); - - logger.info("SerialNumberUpdateTask: Checking request ID ranges"); - requestRepository.checkRanges(); - } - @Override public void run() { try { - updateSerialNumbers(); + engine.updateSerialNumbers(); } catch (Exception e) { logger.warn("SerialNumberUpdateTask: " + e.getMessage(), e); diff --git a/base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java b/base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java index fafb1f6a536..53876fd8723 100644 --- a/base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java +++ b/base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java @@ -991,13 +991,22 @@ public void startSerialNumberUpdateTask() throws Exception { logger.info("CAEngine: Starting serial number update task"); - serialNumberUpdateTask = new SerialNumberUpdateTask( - certificateRepository, - requestRepository, - interval); + serialNumberUpdateTask = new SerialNumberUpdateTask(this, interval); serialNumberUpdateTask.start(); } + public synchronized void updateSerialNumbers() throws Exception { + + logger.info("CAEngine: Updating serial number counter"); + certificateRepository.updateCounter(); + + logger.info("CAEngine: Checking serial number ranges"); + certificateRepository.checkRanges(); + + logger.info("CAEngine: Checking request ID ranges"); + requestRepository.checkRanges(); + } + @Override public void initSubsystems() throws Exception {