1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package fr.ifremer.coser.web;
23
24 import fr.ifremer.coser.CoserBusinessConfig;
25 import org.nuiton.config.ConfigOptionDef;
26 import org.nuiton.util.Version;
27
28 import static org.nuiton.i18n.I18n.n;
29
30
31
32
33
34
35
36
37
38
39 public class CoserWebConfig extends CoserBusinessConfig {
40
41 public CoserWebConfig() {
42
43 loadDefaultOptions(CoserWebOption.values());
44 }
45
46 public String getApplicationVersion() {
47 String result = getOption(CoserWebOption.APPLICATION_VERSION.key);
48 return result;
49 }
50
51
52
53
54
55
56 public String getAdminEmail() {
57 String result = getOption(CoserWebOption.ADMIN_EMAIL.key);
58 return result;
59 }
60
61
62
63
64
65
66 public String getAdminLogin() {
67 String result = getOption(CoserWebOption.ADMIN_LOGIN.key);
68 return result;
69 }
70
71
72
73
74
75
76 public String getAdminPassword() {
77 String result = getOption(CoserWebOption.ADMIN_PASSWORD.key);
78 return result;
79 }
80
81
82
83
84
85
86 public String getAnalyticsId() {
87 String result = getOption(CoserWebOption.ANALYTICS_ID.key);
88 return result;
89 }
90
91 public enum CoserWebOption implements ConfigOptionDef {
92
93
94 CONTEXT_NAME(APP_NAME, null, String.class, "coser"),
95
96 ENCODING_HACK(CONTEXT_NAME.getDefaultValue() + "." + CONFIG_ENCODING, null, String.class, "UTF-8"),
97 CONFIG_FILE(CONTEXT_NAME.defaultValue + "." + CONFIG_FILE_NAME, n("coser.config.config.file.description"), String.class, "coserweb.properties"),
98 APPLICATION_VERSION("coser.application.version", n("coser.config.application.version.description"), Version.class, null),
99 ADMIN_EMAIL("coser.admin.email", n("coser.config.config.file.description"), String.class, "harmonie@ifremer.fr"),
100 ADMIN_LOGIN("coser.admin.login", n("coser.config.admin.login.description"), String.class, null),
101 ADMIN_PASSWORD("coser.admin.password", n("coser.config.admin.password.description"), String.class, null),
102 ANALYTICS_ID("coser.analytics.id", n("coser.config.analytics.id.description"), String.class, "UA-27739588-1");
103
104 private final String key;
105
106 private final String description;
107
108 private final String defaultValue;
109
110 private final Class<?> type;
111
112 private CoserWebOption(String key, String description, Class<?> type, String defaultValue) {
113 this.key = key;
114 this.description = description;
115 this.defaultValue = defaultValue;
116 this.type = type;
117 }
118
119 public String getDefaultValue() {
120 return defaultValue;
121 }
122
123 @Override
124 public boolean isTransient() {
125 return false;
126 }
127
128 @Override
129 public boolean isFinal() {
130 return false;
131 }
132
133 @Override
134 public void setDefaultValue(String defaultValue) {
135
136 }
137
138 @Override
139 public void setTransient(boolean isTransient) {
140
141 }
142
143 @Override
144 public void setFinal(boolean isFinal) {
145
146 }
147
148 public String getDescription() {
149 return description;
150 }
151
152 public String getKey() {
153 return key;
154 }
155
156 @Override
157 public Class<?> getType() {
158 return type;
159 }
160 }
161 }