ArchiveFilesUpdateTask.java

/*
 * Copyright © 2025 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.tasks;

import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import org.ctan.site.services.texarchive.ArchiveFilesUpdateService;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.dropwizard.servlets.tasks.Task;
import lombok.NonNull;

/**
 * The class <code>ArchiveFilesUpdateTask</code> contains the task to start the
 * update action from the archive files.
 *
 * @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
 */
public class ArchiveFilesUpdateTask extends Task {

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

    /**
     * This is the constructor for <code>ArchiveFilesUpdateTask</code>.
     *
     * @param service the underlying service
     */
    @SuppressFBWarnings(value = {"CT_CONSTRUCTOR_THROW", "EI_EXPOSE_REP2"})
    public ArchiveFilesUpdateTask(@NonNull ArchiveFilesUpdateService service) {

        super("archive-files-update");
        this.service = service;
    }

    /**
     * {@inheritDoc}
     *
     * @see io.dropwizard.servlets.tasks.Task#execute(java.util.Map,
     *     java.io.PrintWriter)
     */
    @Override
    public void execute(Map<String, List<String>> parameters,
        PrintWriter output)
        throws Exception {

        output.print("### Archive Files Update Task ####\n");
        service.update();
        output.print("### Archive Files Update Completed ####\n");
    }
}