package be.iminds.ilabt.jfed.highlevel.jobs;

import be.iminds.ilabt.jfed.experiment.Experiment;
import be.iminds.ilabt.jfed.highlevel.controller.TaskThread;
import be.iminds.ilabt.jfed.highlevel.jobs.states.JobStateFactory;
import be.iminds.ilabt.jfed.highlevel.tasks.HighLevelTaskFactory;
import be.iminds.ilabt.jfed.lowlevel.api.user_spec.UserSpec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;

/**
 * User: twalcari
 * Date: 11/27/2015
 * Time: 16:58
 */
public class EditSshKeysJob extends AbstractJob<Void> {
    private static final Logger LOG = LoggerFactory.getLogger(EditSshKeysJob.class);

    private final Collection<UserSpec> userSpecs;


    private final JobStateFactory jobStateFactory;

    public EditSshKeysJob(Experiment experiment, Collection<UserSpec> userSpecs, HighLevelTaskFactory hltf, TaskThread tt,
                          JobStateFactory jobStateFactory) {
        super("Edit SSH keys in " + experiment.getName(), experiment, hltf, tt);
        this.userSpecs = userSpecs;
        this.jobStateFactory = jobStateFactory;
    }

    @Override
    public Void execute() throws Exception {
        setAndRunState(jobStateFactory.createUpdateSshKeysState(EditSshKeysJob.this, userSpecs));

        return null;
    }
}
