CatalogueUpdateJob.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.jobs;

import java.io.IOException;

import org.ctan.site.services.catalogue.CatalogueImportService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.dropwizard.jobs.Job;
import io.dropwizard.jobs.annotations.On;
import lombok.NonNull;

/**
 * The class <code>CatalogueUpdateJob</code> contains the TODO gene.
 *
 * @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
 */
@On(value = "35 * * * * *")
public class CatalogueUpdateJob extends Job {

    /**
     * The field <code>service</code> contains the underlying service.
     */
    private CatalogueImportService service;

    /**
     * This is the constructor for <code>CatalogueUpdateTask</code>.
     *
     * @param service the underlying service
     */
    @SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW")
    public CatalogueUpdateJob(@NonNull CatalogueImportService service) {

        this.service = service;
    }

    /**
     * {@inheritDoc}
     *
     * @see io.dropwizard.jobs.Job#doJob(org.quartz.JobExecutionContext)
     */
    @Override
    public void doJob(JobExecutionContext context)
        throws JobExecutionException {

        try {
            service.update();
        } catch (IOException e) {
            throw new JobExecutionException(e);
        }
    }

}