1 /*
2 * Copyright 2012-2025 CodeLibs Project and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.codelibs.fess.mylasta.direction;
17
18 import org.lastaflute.core.direction.ObjectiveConfig;
19 import org.lastaflute.core.direction.exception.ConfigPropertyNotFoundException;
20
21 /**
22 * @author FreeGen
23 */
24 public interface FessEnv {
25
26 /** The key of the configuration. e.g. warm */
27 String lasta_di_SMART_DEPLOY_MODE = "lasta_di.smart.deploy.mode";
28
29 /** The key of the configuration. e.g. true */
30 String DEVELOPMENT_HERE = "development.here";
31
32 /** The key of the configuration. e.g. Local Development */
33 String ENVIRONMENT_TITLE = "environment.title";
34
35 /** The key of the configuration. e.g. false */
36 String FRAMEWORK_DEBUG = "framework.debug";
37
38 /** The key of the configuration. e.g. 0 */
39 String TIME_ADJUST_TIME_MILLIS = "time.adjust.time.millis";
40
41 /** The key of the configuration. e.g. true */
42 String MAIL_SEND_MOCK = "mail.send.mock";
43
44 /** The key of the configuration. e.g. localhost:25 */
45 String MAIL_SMTP_SERVER_MAIN_HOST_AND_PORT = "mail.smtp.server.main.host.and.port";
46
47 /** The key of the configuration. e.g. [Test] */
48 String MAIL_SUBJECT_TEST_PREFIX = "mail.subject.test.prefix";
49
50 /** The key of the configuration. e.g. root@localhost */
51 String MAIL_RETURN_PATH = "mail.return.path";
52
53 /**
54 * Get the value of property as {@link String}.
55 * @param propertyKey The key of the property. (NotNull)
56 * @return The value of found property. (NotNull: if not found, exception)
57 * @throws ConfigPropertyNotFoundException When the property is not found.
58 */
59 String get(String propertyKey);
60
61 /**
62 * Is the property true?
63 * @param propertyKey The key of the property which is boolean type. (NotNull)
64 * @return The determination, true or false. (if not found, exception)
65 * @throws ConfigPropertyNotFoundException When the property is not found.
66 */
67 boolean is(String propertyKey);
68
69 /**
70 * Get the value for the key 'lasta_di.smart.deploy.mode'. <br>
71 * The value is, e.g. warm <br>
72 * comment: The mode of Lasta Di's smart-deploy, should be cool in production (e.g. hot, cool, warm)
73 * @return The value of found property. (NotNull: if not found, exception but basically no way)
74 */
75 String getLastaDiSmartDeployMode();
76
77 /**
78 * Get the value for the key 'development.here'. <br>
79 * The value is, e.g. true <br>
80 * comment: Is development environment here? (used for various purpose, you should set false if unknown)
81 * @return The value of found property. (NotNull: if not found, exception but basically no way)
82 */
83 String getDevelopmentHere();
84
85 /**
86 * Is the property for the key 'development.here' true? <br>
87 * The value is, e.g. true <br>
88 * comment: Is development environment here? (used for various purpose, you should set false if unknown)
89 * @return The determination, true or false. (if not found, exception but basically no way)
90 */
91 boolean isDevelopmentHere();
92
93 /**
94 * Get the value for the key 'environment.title'. <br>
95 * The value is, e.g. Local Development <br>
96 * comment: The title of environment (e.g. local or integration or production)
97 * @return The value of found property. (NotNull: if not found, exception but basically no way)
98 */
99 String getEnvironmentTitle();
100
101 /**
102 * Get the value for the key 'framework.debug'. <br>
103 * The value is, e.g. false <br>
104 * comment: Does it enable the Framework internal debug? (true only when emergency)
105 * @return The value of found property. (NotNull: if not found, exception but basically no way)
106 */
107 String getFrameworkDebug();
108
109 /**
110 * Is the property for the key 'framework.debug' true? <br>
111 * The value is, e.g. false <br>
112 * comment: Does it enable the Framework internal debug? (true only when emergency)
113 * @return The determination, true or false. (if not found, exception but basically no way)
114 */
115 boolean isFrameworkDebug();
116
117 /**
118 * Get the value for the key 'time.adjust.time.millis'. <br>
119 * The value is, e.g. 0 <br>
120 * comment: <br>
121 * one day: 86400000, three days: 259200000, five days: 432000000, one week: 604800000, one year: 31556926000<br>
122 * special script :: absolute mode: $(2014/07/10), relative mode: addDay(3).addMonth(4)<br>
123 * The milliseconds for (relative or absolute) adjust time (set only when test) @LongType *dynamic in development
124 * @return The value of found property. (NotNull: if not found, exception but basically no way)
125 */
126 String getTimeAdjustTimeMillis();
127
128 /**
129 * Get the value for the key 'time.adjust.time.millis' as {@link Long}. <br>
130 * The value is, e.g. 0 <br>
131 * comment: <br>
132 * one day: 86400000, three days: 259200000, five days: 432000000, one week: 604800000, one year: 31556926000<br>
133 * special script :: absolute mode: $(2014/07/10), relative mode: addDay(3).addMonth(4)<br>
134 * The milliseconds for (relative or absolute) adjust time (set only when test) @LongType *dynamic in development
135 * @return The value of found property. (NotNull: if not found, exception but basically no way)
136 * @throws NumberFormatException When the property is not long.
137 */
138 Long getTimeAdjustTimeMillisAsLong();
139
140 /**
141 * Get the value for the key 'mail.send.mock'. <br>
142 * The value is, e.g. true <br>
143 * comment: Does it send mock mail? (true: no send actually, logging only)
144 * @return The value of found property. (NotNull: if not found, exception but basically no way)
145 */
146 String getMailSendMock();
147
148 /**
149 * Is the property for the key 'mail.send.mock' true? <br>
150 * The value is, e.g. true <br>
151 * comment: Does it send mock mail? (true: no send actually, logging only)
152 * @return The determination, true or false. (if not found, exception but basically no way)
153 */
154 boolean isMailSendMock();
155
156 /**
157 * Get the value for the key 'mail.smtp.server.main.host.and.port'. <br>
158 * The value is, e.g. localhost:25 <br>
159 * comment: SMTP server settings for main: host:port
160 * @return The value of found property. (NotNull: if not found, exception but basically no way)
161 */
162 String getMailSmtpServerMainHostAndPort();
163
164 /**
165 * Get the value for the key 'mail.subject.test.prefix'. <br>
166 * The value is, e.g. [Test] <br>
167 * comment: The prefix of subject to show test environment or not
168 * @return The value of found property. (NotNull: if not found, exception but basically no way)
169 */
170 String getMailSubjectTestPrefix();
171
172 /**
173 * Get the value for the key 'mail.return.path'. <br>
174 * The value is, e.g. root@localhost <br>
175 * comment: The common return path of all mail
176 * @return The value of found property. (NotNull: if not found, exception but basically no way)
177 */
178 String getMailReturnPath();
179
180 /**
181 * The simple implementation for configuration.
182 * @author FreeGen
183 */
184 public static class SimpleImpl extends ObjectiveConfig implements FessEnv {
185
186 /** The serial version UID for object serialization. (Default) */
187 private static final long serialVersionUID = 1L;
188
189 public String getLastaDiSmartDeployMode() {
190 return get(FessEnv.lasta_di_SMART_DEPLOY_MODE);
191 }
192
193 public String getDevelopmentHere() {
194 return get(FessEnv.DEVELOPMENT_HERE);
195 }
196
197 public boolean isDevelopmentHere() {
198 return is(FessEnv.DEVELOPMENT_HERE);
199 }
200
201 public String getEnvironmentTitle() {
202 return get(FessEnv.ENVIRONMENT_TITLE);
203 }
204
205 public String getFrameworkDebug() {
206 return get(FessEnv.FRAMEWORK_DEBUG);
207 }
208
209 public boolean isFrameworkDebug() {
210 return is(FessEnv.FRAMEWORK_DEBUG);
211 }
212
213 public String getTimeAdjustTimeMillis() {
214 return get(FessEnv.TIME_ADJUST_TIME_MILLIS);
215 }
216
217 public Long getTimeAdjustTimeMillisAsLong() {
218 return getAsLong(FessEnv.TIME_ADJUST_TIME_MILLIS);
219 }
220
221 public String getMailSendMock() {
222 return get(FessEnv.MAIL_SEND_MOCK);
223 }
224
225 public boolean isMailSendMock() {
226 return is(FessEnv.MAIL_SEND_MOCK);
227 }
228
229 public String getMailSmtpServerMainHostAndPort() {
230 return get(FessEnv.MAIL_SMTP_SERVER_MAIN_HOST_AND_PORT);
231 }
232
233 public String getMailSubjectTestPrefix() {
234 return get(FessEnv.MAIL_SUBJECT_TEST_PREFIX);
235 }
236
237 public String getMailReturnPath() {
238 return get(FessEnv.MAIL_RETURN_PATH);
239 }
240
241 @Override
242 protected java.util.Map<String, String> prepareGeneratedDefaultMap() {
243 java.util.Map<String, String> defaultMap = super.prepareGeneratedDefaultMap();
244 defaultMap.put(FessEnv.lasta_di_SMART_DEPLOY_MODE, "warm");
245 defaultMap.put(FessEnv.DEVELOPMENT_HERE, "true");
246 defaultMap.put(FessEnv.ENVIRONMENT_TITLE, "Local Development");
247 defaultMap.put(FessEnv.FRAMEWORK_DEBUG, "false");
248 defaultMap.put(FessEnv.TIME_ADJUST_TIME_MILLIS, "0");
249 defaultMap.put(FessEnv.MAIL_SEND_MOCK, "true");
250 defaultMap.put(FessEnv.MAIL_SMTP_SERVER_MAIN_HOST_AND_PORT, "localhost:25");
251 defaultMap.put(FessEnv.MAIL_SUBJECT_TEST_PREFIX, "[Test]");
252 defaultMap.put(FessEnv.MAIL_RETURN_PATH, "root@localhost");
253 return defaultMap;
254 }
255 }
256 }