1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.framework.config.property; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.apache.log4j.Logger; |
20 | |
import org.kuali.rice.core.api.config.property.Config; |
21 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
22 | |
import org.kuali.rice.core.api.util.Truth; |
23 | |
|
24 | |
import java.io.IOException; |
25 | |
import java.util.HashMap; |
26 | |
import java.util.Map; |
27 | |
import java.util.Properties; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public abstract class AbstractBaseConfig implements org.kuali.rice.core.api.config.property.Config { |
37 | |
|
38 | 0 | private static final Logger LOG = Logger.getLogger(AbstractBaseConfig.class); |
39 | |
|
40 | |
public abstract Object getObject(String key); |
41 | |
|
42 | |
public abstract Map<String, Object> getObjects(); |
43 | |
|
44 | |
public abstract Properties getProperties(); |
45 | |
|
46 | |
public abstract String getProperty(String key); |
47 | |
|
48 | |
public abstract void parseConfig() throws IOException; |
49 | |
|
50 | |
public Map<String, String> getPropertiesWithPrefix(String prefix, boolean stripPrefix) { |
51 | 0 | Map<String, String> props = new HashMap<String, String>(); |
52 | 0 | for (Map.Entry<Object, Object> entry : getProperties().entrySet()) { |
53 | 0 | String key = (String) entry.getKey(); |
54 | 0 | if (StringUtils.isNotBlank(key) && key.trim().startsWith(prefix)) { |
55 | 0 | props.put(stripPrefix ? key.substring(prefix.length()) : key, (String) entry.getValue()); |
56 | |
} |
57 | 0 | } |
58 | 0 | return props; |
59 | |
} |
60 | |
|
61 | |
public String getAlternateOJBFile() { |
62 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.ALT_OJB_FILE); |
63 | |
} |
64 | |
|
65 | |
public String getAlternateSpringFile() { |
66 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.ALT_SPRING_FILE); |
67 | |
} |
68 | |
|
69 | |
public String getBaseWebServiceURL() { |
70 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.BASE_WEB_SERVICE_URL_WORKFLOW_CLIENT_FILE); |
71 | |
} |
72 | |
|
73 | |
public String getBaseWebServiceWsdlPath() { |
74 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.BASE_WEB_SERVICE_WSDL_PATH); |
75 | |
} |
76 | |
|
77 | |
public Boolean getBatchMode() { |
78 | 0 | return new Boolean(getProperty(org.kuali.rice.core.api.config.property.Config.BATCH_MODE)); |
79 | |
} |
80 | |
|
81 | |
@Override |
82 | |
public boolean getBooleanProperty(String key, boolean defaultValue) { |
83 | 0 | return Truth.strToBooleanIgnoreCase(getProperty(key), defaultValue).booleanValue(); |
84 | |
} |
85 | |
|
86 | |
@Override |
87 | |
public Boolean getBooleanProperty(String key) { |
88 | 0 | return Truth.strToBooleanIgnoreCase(getProperty(key)); |
89 | |
} |
90 | |
|
91 | |
@Override |
92 | |
public long getNumericProperty(String key, long defaultValue) { |
93 | 0 | Long propertyValue = getNumericProperty(key); |
94 | 0 | if (propertyValue == null) { |
95 | 0 | return defaultValue; |
96 | |
} else { |
97 | 0 | return propertyValue.longValue(); |
98 | |
} |
99 | |
} |
100 | |
|
101 | |
@Override |
102 | |
public Long getNumericProperty(String key) { |
103 | 0 | String propertyValue = getProperty(key); |
104 | 0 | if (StringUtils.isBlank(propertyValue)) { |
105 | 0 | return null; |
106 | |
} |
107 | 0 | return new Long(propertyValue); |
108 | |
} |
109 | |
|
110 | |
public String getClientWSDLFullPathAndFileName() { |
111 | 0 | return getProperty(Config.WSDL_LOCATION_WORKFLOW_CLIENT_FILE); |
112 | |
} |
113 | |
|
114 | |
public String getDailyEmailFirstDeliveryDate() { |
115 | 0 | return getProperty(Config.FIRST_DAILY_EMAIL_DELIVERY_DATE); |
116 | |
} |
117 | |
|
118 | |
public String getDefaultKewNoteClass() { |
119 | 0 | return getProperty(Config.DEFAULT_KEW_NOTE_CLASS); |
120 | |
} |
121 | |
|
122 | |
public Boolean getDevMode() { |
123 | 0 | return Boolean.valueOf(getProperty(Config.DEV_MODE)); |
124 | |
} |
125 | |
|
126 | |
public String getDocumentLockTimeout() { |
127 | 0 | return getProperty(Config.DOCUMENT_LOCK_TIMEOUT); |
128 | |
} |
129 | |
|
130 | |
public String getEDLConfigLocation() { |
131 | 0 | return getProperty(Config.EDL_CONFIG_LOCATION); |
132 | |
} |
133 | |
|
134 | |
public String getEmailConfigurationPath() { |
135 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.EMAIL_SECURITY_PATH); |
136 | |
} |
137 | |
|
138 | |
public Boolean getEmailReminderLifecycleEnabled() { |
139 | 0 | return Boolean.valueOf(getProperty(org.kuali.rice.core.api.config.property.Config.ENABLE_EMAIL_REMINDER_LIFECYCLE)); |
140 | |
} |
141 | |
|
142 | |
public String getEmbeddedPluginLocation() { |
143 | 0 | return getProperty(Config.EMBEDDED_PLUGIN_LOCATIAON); |
144 | |
} |
145 | |
|
146 | |
public String getEndPointUrl() { |
147 | |
|
148 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.SERVICE_SERVLET_URL); |
149 | |
} |
150 | |
|
151 | |
public String getEnvironment() { |
152 | 0 | return getProperty(Config.ENVIRONMENT); |
153 | |
} |
154 | |
|
155 | |
public String getProductionEnvironmentCode() { |
156 | 0 | return getProperty(Config.PROD_ENVIRONMENT_CODE); |
157 | |
} |
158 | |
|
159 | |
public boolean isProductionEnvironment() { |
160 | 0 | String env = getEnvironment(); |
161 | 0 | String prod = getProductionEnvironmentCode(); |
162 | |
|
163 | |
|
164 | 0 | return env != null && prod != null && StringUtils.equalsIgnoreCase(env, prod); |
165 | |
} |
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
public String getRiceVersion() { |
171 | 0 | return getProperty(Config.RICE_VERSION); |
172 | |
} |
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
public String getApplicationName() { |
178 | |
|
179 | 0 | String val = getProperty(APPLICATION_NAME); |
180 | 0 | if (val == null) { |
181 | 0 | val = getProperty(MODULE_NAME); |
182 | |
} |
183 | 0 | return val; |
184 | |
} |
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
public String getApplicationVersion() { |
190 | |
|
191 | 0 | String val = getProperty(APPLICATION_VERSION); |
192 | 0 | if (val == null) { |
193 | 0 | val = getProperty(VERSION); |
194 | |
} |
195 | 0 | return val; |
196 | |
} |
197 | |
|
198 | |
public String getKENBaseURL() { |
199 | 0 | return getProperty(Config.KEN_URL); |
200 | |
} |
201 | |
|
202 | |
public String getKEWBaseURL() { |
203 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.KEW_URL); |
204 | |
} |
205 | |
|
206 | |
public String getKIMBaseURL() { |
207 | 0 | return getProperty(Config.KIM_URL); |
208 | |
} |
209 | |
|
210 | |
public String getKRBaseURL() { |
211 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.KR_URL); |
212 | |
} |
213 | |
|
214 | |
public String getKeystoreAlias() { |
215 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.KEYSTORE_ALIAS); |
216 | |
} |
217 | |
|
218 | |
public String getKeystoreFile() { |
219 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.KEYSTORE_FILE); |
220 | |
} |
221 | |
|
222 | |
public String getKeystorePassword() { |
223 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.KEYSTORE_PASSWORD); |
224 | |
} |
225 | |
|
226 | |
public String getLog4jFileLocation() { |
227 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.LOG4J_SETTINGS_PATH); |
228 | |
} |
229 | |
|
230 | |
public String getLog4jReloadInterval() { |
231 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.LOG4J_SETTINGS_RELOADINTERVAL_MINS); |
232 | |
} |
233 | |
|
234 | |
public Boolean getOutBoxOn() { |
235 | |
|
236 | 0 | return Boolean.valueOf(getProperty(org.kuali.rice.core.api.config.property.Config.OUT_BOX_MODE)); |
237 | |
} |
238 | |
|
239 | |
public Integer getRefreshRate() { |
240 | |
|
241 | |
|
242 | |
Integer refreshRate; |
243 | |
try { |
244 | 0 | refreshRate = new Integer(ConfigContext.getCurrentContextConfig().getProperty(Config.REFRESH_RATE)); |
245 | 0 | } catch (NumberFormatException nfe) { |
246 | 0 | LOG.error("Couldn't parse property " + org.kuali.rice.core.api.config.property.Config.REFRESH_RATE + " to set bus refresh rate. Defaulting to 30 seconds."); |
247 | 0 | ConfigContext.getCurrentContextConfig().putProperty(org.kuali.rice.core.api.config.property.Config.REFRESH_RATE, "30"); |
248 | 0 | return 30; |
249 | 0 | } |
250 | 0 | return refreshRate; |
251 | |
} |
252 | |
|
253 | |
public String getTransactionTimeout() { |
254 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.TRANSACTION_TIMEOUT); |
255 | |
} |
256 | |
|
257 | |
public String getWebServicesConnectRetry() { |
258 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.WEB_SERVICE_CONNECT_RETRY); |
259 | |
} |
260 | |
|
261 | |
public String getWeeklyEmailFirstDeliveryDate() { |
262 | 0 | return getProperty(org.kuali.rice.core.api.config.property.Config.FIRST_WEEKLY_EMAIL_DELIVERY_DATE); |
263 | |
} |
264 | |
|
265 | |
public Boolean getXmlPipelineLifeCycleEnabled() { |
266 | 0 | return Boolean.valueOf(getProperty(Config.ENABLE_XML_PIPELINE_LIFECYCLE)); |
267 | |
} |
268 | |
} |