1 /*
2 * Copyright 2012-2021 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: The milliseconds for (relative or absolute) adjust time (set only when test) @LongType *dynamic in development
121 * @return The value of found property. (NotNull: if not found, exception but basically no way)
122 */
123 String getTimeAdjustTimeMillis();
124
125 /**
126 * Get the value for the key 'time.adjust.time.millis' as {@link Long}. <br>
127 * The value is, e.g. 0 <br>
128 * comment: The milliseconds for (relative or absolute) adjust time (set only when test) @LongType *dynamic in development
129 * @return The value of found property. (NotNull: if not found, exception but basically no way)
130 * @throws NumberFormatException When the property is not long.
131 */
132 Long getTimeAdjustTimeMillisAsLong();
133
134 /**
135 * Get the value for the key 'mail.send.mock'. <br>
136 * The value is, e.g. true <br>
137 * comment: Does it send mock mail? (true: no send actually, logging only)
138 * @return The value of found property. (NotNull: if not found, exception but basically no way)
139 */
140 String getMailSendMock();
141
142 /**
143 * Is the property for the key 'mail.send.mock' true? <br>
144 * The value is, e.g. true <br>
145 * comment: Does it send mock mail? (true: no send actually, logging only)
146 * @return The determination, true or false. (if not found, exception but basically no way)
147 */
148 boolean isMailSendMock();
149
150 /**
151 * Get the value for the key 'mail.smtp.server.main.host.and.port'. <br>
152 * The value is, e.g. localhost:25 <br>
153 * comment: SMTP server settings for main: host:port
154 * @return The value of found property. (NotNull: if not found, exception but basically no way)
155 */
156 String getMailSmtpServerMainHostAndPort();
157
158 /**
159 * Get the value for the key 'mail.subject.test.prefix'. <br>
160 * The value is, e.g. [Test] <br>
161 * comment: The prefix of subject to show test environment or not
162 * @return The value of found property. (NotNull: if not found, exception but basically no way)
163 */
164 String getMailSubjectTestPrefix();
165
166 /**
167 * Get the value for the key 'mail.return.path'. <br>
168 * The value is, e.g. root@localhost <br>
169 * comment: The common return path of all mail
170 * @return The value of found property. (NotNull: if not found, exception but basically no way)
171 */
172 String getMailReturnPath();
173
174 /**
175 * The simple implementation for configuration.
176 * @author FreeGen
177 */
178 public static class SimpleImpl extends ObjectiveConfig implements FessEnv {
179
180 /** The serial version UID for object serialization. (Default) */
181 private static final long serialVersionUID = 1L;
182
183 public String getLastaDiSmartDeployMode() {
184 return get(FessEnv.lasta_di_SMART_DEPLOY_MODE);
185 }
186
187 public String getDevelopmentHere() {
188 return get(FessEnv.DEVELOPMENT_HERE);
189 }
190
191 public boolean isDevelopmentHere() {
192 return is(FessEnv.DEVELOPMENT_HERE);
193 }
194
195 public String getEnvironmentTitle() {
196 return get(FessEnv.ENVIRONMENT_TITLE);
197 }
198
199 public String getFrameworkDebug() {
200 return get(FessEnv.FRAMEWORK_DEBUG);
201 }
202
203 public boolean isFrameworkDebug() {
204 return is(FessEnv.FRAMEWORK_DEBUG);
205 }
206
207 public String getTimeAdjustTimeMillis() {
208 return get(FessEnv.TIME_ADJUST_TIME_MILLIS);
209 }
210
211 public Long getTimeAdjustTimeMillisAsLong() {
212 return getAsLong(FessEnv.TIME_ADJUST_TIME_MILLIS);
213 }
214
215 public String getMailSendMock() {
216 return get(FessEnv.MAIL_SEND_MOCK);
217 }
218
219 public boolean isMailSendMock() {
220 return is(FessEnv.MAIL_SEND_MOCK);
221 }
222
223 public String getMailSmtpServerMainHostAndPort() {
224 return get(FessEnv.MAIL_SMTP_SERVER_MAIN_HOST_AND_PORT);
225 }
226
227 public String getMailSubjectTestPrefix() {
228 return get(FessEnv.MAIL_SUBJECT_TEST_PREFIX);
229 }
230
231 public String getMailReturnPath() {
232 return get(FessEnv.MAIL_RETURN_PATH);
233 }
234
235 @Override
236 protected java.util.Map<String, String> prepareGeneratedDefaultMap() {
237 java.util.Map<String, String> defaultMap = super.prepareGeneratedDefaultMap();
238 defaultMap.put(FessEnv.lasta_di_SMART_DEPLOY_MODE, "warm");
239 defaultMap.put(FessEnv.DEVELOPMENT_HERE, "true");
240 defaultMap.put(FessEnv.ENVIRONMENT_TITLE, "Local Development");
241 defaultMap.put(FessEnv.FRAMEWORK_DEBUG, "false");
242 defaultMap.put(FessEnv.TIME_ADJUST_TIME_MILLIS, "0");
243 defaultMap.put(FessEnv.MAIL_SEND_MOCK, "true");
244 defaultMap.put(FessEnv.MAIL_SMTP_SERVER_MAIN_HOST_AND_PORT, "localhost:25");
245 defaultMap.put(FessEnv.MAIL_SUBJECT_TEST_PREFIX, "[Test]");
246 defaultMap.put(FessEnv.MAIL_RETURN_PATH, "root@localhost");
247 return defaultMap;
248 }
249 }
250 }