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

Kai Reinhard
15.39.2018 60b424b101e42fa1aadb9300f32a842c9681a092
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
package de.micromata.borgbutler.server;
 
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.beans.Transient;
 
public class ServerConfiguration {
    private static Logger log = LoggerFactory.getLogger(ServerConfiguration.class);
    private final static String[] SUPPORTED_LANGUAGES = {"en", "de"};
    private static String applicationHome;
 
    private int port;
    @Getter
    @Setter
    private boolean showTestData = true;
    private boolean webDevelopmentMode = false;
    private boolean templatesDirModified = false;
 
    public static ServerConfiguration getDefault() {
        return ServerConfigurationHandler.getDefaultConfiguration();
    }
 
    public static String[] getSupportedLanguages() {
        return SUPPORTED_LANGUAGES;
    }
 
    public static String getApplicationHome() {
        if (applicationHome == null) {
            applicationHome = System.getProperty("applicationHome");
            if (StringUtils.isBlank(applicationHome)) {
                applicationHome = System.getProperty("user.dir");
                log.info("applicationHome is not given as JVM   parameter. Using current working dir (OK for start in IDE): " + applicationHome);
            }
        }
        return applicationHome;
    }
 
    public void resetModifiedFlag() {
        templatesDirModified = false;
    }
 
    @Transient
    public boolean isTemplatesDirModified() {
        return templatesDirModified;
    }
 
    public int getPort() {
        return port;
    }
 
    public void setPort(int port) {
        this.port = port;
    }
 
    /**
     * If true, CrossOriginFilter will be set.
     */
    public boolean isWebDevelopmentMode() {
        return webDevelopmentMode;
    }
 
    public void setWebDevelopmentMode(boolean webDevelopmentMode) {
        this.webDevelopmentMode = webDevelopmentMode;
    }
 
    public void copyFrom(ServerConfiguration other) {
        this.port = other.port;
        this.showTestData = other.showTestData;
        this.webDevelopmentMode = other.webDevelopmentMode;
    }
}