CtanJobManager.java

/*
 * Copyright © 2026 The CTAN Team and individual authors
 *
 * This file is distributed under the 3-clause BSD license.
 * See file LICENSE for details.
 */

package org.ctan.site.services.jobs;

import java.util.List;
import java.util.stream.Collectors;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;

import io.dropwizard.jobs.Job;

/**
 * The class <code>CtanJobManager</code> contains the TODO gene.
 *
 * @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
 */
public class CtanJobManager {

    /**
     * The method <code>getJobs</code> provides means to access the list of
     * jobs.
     *
     * @return the list of jobs
     */
    public static List<Job> getJobs() {

        return List.of(
        // TODO
        // new CatalogueUpdateJob(
        // new CatalogueImportService(null, null, null, null, null,
        // null))
        );
    }

    /**
     * The method <code>getScheduler</code> provides means to TODO gene.
     *
     * @return the scheduler
     * @throws SchedulerException in case of an error
     */
    public static Scheduler getScheduler() throws SchedulerException {

        return new StdSchedulerFactory().getAllSchedulers()
            .stream().filter(schedulerToCheck -> {
                try {
                    return schedulerToCheck.isStarted()
                        && !schedulerToCheck.getJobGroupNames().isEmpty();
                } catch (SchedulerException e) {
                    throw new RuntimeException(e);
                }
            }).collect(Collectors.toList()).get(0);
    }

    // private void x (Scheduler scheduler) {
    // scheduler.
    // }
}