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

doc
Kai Reinhard
14.38.2021 d90060ae470941fdaff448963ba9efe1a3654c07
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package de.micromata.borgbutler;
 
import de.micromata.borgbutler.config.BorgRepoConfig;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.io.File;
 
/**
 * Represents a command to be queued for executing.
 */
public class BorgCommand {
    private Logger log = LoggerFactory.getLogger(BorgCommand.class);
 
    private File workingDir;
    private String[] args;
    private String[] params;
    private BorgRepoConfig repoConfig;
    private String command;
    private String archive;
    /**
     * For displaying and information purposes for the user only, when browsing the current command queue.
     */
    private String description;
    /**
     * The result of the call will be written to this String.
     */
    private String response;
 
    BorgCommand setArgs(String... args) {
        this.args = args;
        return this;
    }
 
    BorgCommand setParams(String... params) {
        this.params = params;
        return this;
    }
 
    public String getRepoArchive() {
        if (archive == null) {
            if (repoConfig == null) {
                return null;
            }
            return repoConfig.getRepo();
        }
        return repoConfig.getRepo() + "::" + archive;
    }
 
    /**
     *
     * @return Abbreviated response e. g. for logging an error.
     */
    public String getAbbreviatedResponse() {
        return StringUtils.abbreviate(response, 1000);
    }
 
    public File getWorkingDir() {
        return this.workingDir;
    }
 
    public String[] getArgs() {
        return this.args;
    }
 
    public String[] getParams() {
        return this.params;
    }
 
    public BorgRepoConfig getRepoConfig() {
        return this.repoConfig;
    }
 
    public String getCommand() {
        return this.command;
    }
 
    public String getArchive() {
        return this.archive;
    }
 
    public String getDescription() {
        return this.description;
    }
 
    public String getResponse() {
        return this.response;
    }
 
    public BorgCommand setWorkingDir(File workingDir) {
        this.workingDir = workingDir;
        return this;
    }
 
    public BorgCommand setRepoConfig(BorgRepoConfig repoConfig) {
        this.repoConfig = repoConfig;
        return this;
    }
 
    public BorgCommand setCommand(String command) {
        this.command = command;
        return this;
    }
 
    public BorgCommand setArchive(String archive) {
        this.archive = archive;
        return this;
    }
 
    public BorgCommand setDescription(String description) {
        this.description = description;
        return this;
    }
 
    BorgCommand setResponse(String response) {
        this.response = response;
        return this;
    }
}