mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
28.27.2018 de7d8d4cfbf9fe9fa6dcc7fd054301f52e47f9eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package de.micromata.borgbutler.jobs;
 
import org.apache.commons.exec.CommandLine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.io.File;
 
public class TestJob extends AbstractCommandLineJob {
    private Logger log = LoggerFactory.getLogger(TestJob.class);
    private int time;
    private File counterScript;
    private int failOn = -1;
 
    TestJob(int time, File counterScript) {
        this(time, -1, counterScript);
    }
 
    TestJob(int time, int failOn, File counterScript) {
        this.time = time;
        this.failOn = failOn;
        this.counterScript = counterScript;
    }
 
    @Override
    public Object getId() {
        return time;
    }
 
    @Override
    protected CommandLine buildCommandLine() {
        CommandLine commandLine = new CommandLine(counterScript.getAbsolutePath());
        commandLine.addArgument(String.valueOf(this.time));
        commandLine.addArgument(String.valueOf(this.failOn));
        return commandLine;
    }
 
    @Override
    protected void afterFailure(Exception ex) {
        if (failOn < 0 && getStatus() != Status.CANCELLED) {
            log.error("Error while executing script '" + getCommandLineAsString() + "': " + ex.getMessage(), ex);
        }
    }
}