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

Kai Reinhard
14.54.2018 41daf2acb8954a168a3ef370ba9633a41b51ac11
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
package de.micromata.borgbutler.json.borg;
 
import com.fasterxml.jackson.annotation.JsonProperty;
import de.micromata.borgbutler.config.BorgRepoConfig;
import de.micromata.borgbutler.config.ConfigurationHandler;
import lombok.Getter;
import lombok.Setter;
 
/**
 * Part of Borg json objects to refer objects to repositories.
 */
public class BorgRepository {
    /**
     * A name describing this config. Only used for displaying purposes. This is automatically set with the name
     * of the repository configuration.
     *
     * @see BorgRepoConfig#getName()
     */
    @Getter
    @Setter
    String name;
    @Getter
    private String id;
    @Getter
    @JsonProperty("last_modified")
    private String lastModified;
    @Getter
    private String location;
 
    /**
     * Sets also the name for this repository if available in the configuration.
     *
     * @param location
     * @return
     */
    public BorgRepository setLocation(String location) {
        this.location = location;
        // It's ugly but efficiently ;-)
        BorgRepoConfig repoConfig = ConfigurationHandler.getConfiguration().getRepoConfig(location);
        if (repoConfig != null) {
            this.name = repoConfig.getName();
        }
        return this;
    }
}