001
014
015 package com.liferay.portal.verify;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.PropsKeys;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.kernel.util.StringUtil;
022 import com.liferay.portal.kernel.util.SystemProperties;
023 import com.liferay.portal.kernel.util.UnicodeProperties;
024 import com.liferay.portal.security.ldap.LDAPSettingsUtil;
025 import com.liferay.portal.service.CompanyLocalServiceUtil;
026 import com.liferay.portal.util.PortalInstances;
027 import com.liferay.portal.util.PrefsPropsUtil;
028 import com.liferay.portal.util.PropsUtil;
029 import com.liferay.portlet.documentlibrary.store.StoreFactory;
030
031
034 public class VerifyProperties extends VerifyProcess {
035
036 @Override
037 protected void doVerify() throws Exception {
038
039
040
041 for (String[] keys : _MIGRATED_SYSTEM_KEYS) {
042 String oldKey = keys[0];
043 String newKey = keys[1];
044
045 verifyMigratedSystemProperty(oldKey, newKey);
046 }
047
048 for (String[] keys : _RENAMED_SYSTEM_KEYS) {
049 String oldKey = keys[0];
050 String newKey = keys[1];
051
052 verifyRenamedSystemProperty(oldKey, newKey);
053 }
054
055 for (String key : _OBSOLETE_SYSTEM_KEYS) {
056 verifyObsoleteSystemProperty(key);
057 }
058
059
060
061 for (String[] keys : _RENAMED_PORTAL_KEYS) {
062 String oldKey = keys[0];
063 String newKey = keys[1];
064
065 verifyRenamedPortalProperty(oldKey, newKey);
066 }
067
068 for (String key : _OBSOLETE_PORTAL_KEYS) {
069 verifyObsoletePortalProperty(key);
070 }
071
072
073
074 StoreFactory.checkProperties();
075
076
077
078 verifyLDAPProperties();
079 }
080
081 protected void verifyLDAPProperties() throws Exception {
082 long[] companyIds = PortalInstances.getCompanyIdsBySQL();
083
084 for (long companyId : companyIds) {
085 UnicodeProperties properties = new UnicodeProperties();
086
087 long[] ldapServerIds = StringUtil.split(
088 PrefsPropsUtil.getString(companyId, "ldap.server.ids"), 0L);
089
090 for (long ldapServerId : ldapServerIds) {
091 String postfix = LDAPSettingsUtil.getPropertyPostfix(
092 ldapServerId);
093
094 for (String key : _LDAP_KEYS) {
095 String value = PrefsPropsUtil.getString(
096 companyId, key + postfix, null);
097
098 if (value == null) {
099 properties.put(key + postfix, StringPool.BLANK);
100 }
101 }
102 }
103
104 if (!properties.isEmpty()) {
105 CompanyLocalServiceUtil.updatePreferences(
106 companyId, properties);
107 }
108 }
109 }
110
111 protected void verifyMigratedSystemProperty(String oldKey, String newKey)
112 throws Exception {
113
114 String value = SystemProperties.get(oldKey);
115
116 if (value != null) {
117 _log.error(
118 "System property \"" + oldKey +
119 "\" was migrated to the portal property \"" + newKey +
120 "\"");
121 }
122 }
123
124 protected void verifyObsoletePortalProperty(String key) throws Exception {
125 String value = PropsUtil.get(key);
126
127 if (value != null) {
128 _log.error("Portal property \"" + key + "\" is obsolete");
129 }
130 }
131
132 protected void verifyObsoleteSystemProperty(String key) throws Exception {
133 String value = SystemProperties.get(key);
134
135 if (value != null) {
136 _log.error("System property \"" + key + "\" is obsolete");
137 }
138 }
139
140 protected void verifyRenamedPortalProperty(String oldKey, String newKey)
141 throws Exception {
142
143 String value = PropsUtil.get(oldKey);
144
145 if (value != null) {
146 _log.error(
147 "Portal property \"" + oldKey + "\" was renamed to \"" +
148 newKey + "\"");
149 }
150 }
151
152 protected void verifyRenamedSystemProperty(String oldKey, String newKey)
153 throws Exception {
154
155 String value = SystemProperties.get(oldKey);
156
157 if (value != null) {
158 _log.error(
159 "System property \"" + oldKey + "\" was renamed to \"" +
160 newKey + "\"");
161 }
162 }
163
164 private static final String[] _LDAP_KEYS = {
165 PropsKeys.LDAP_CONTACT_CUSTOM_MAPPINGS, PropsKeys.LDAP_CONTACT_MAPPINGS,
166 PropsKeys.LDAP_USER_CUSTOM_MAPPINGS
167 };
168
169 private static final String[][] _MIGRATED_SYSTEM_KEYS = new String[][] {
170 new String[] {
171 "com.liferay.filters.compression.CompressionFilter",
172 "com.liferay.portal.servlet.filters.gzip.GZipFilter"
173 },
174 new String[] {
175 "com.liferay.filters.doubleclick.DoubleClickFilter",
176 "com.liferay.portal.servlet.filters.doubleclick.DoubleClickFilter"
177 },
178 new String[] {
179 "com.liferay.filters.strip.StripFilter",
180 "com.liferay.portal.servlet.filters.strip.StripFilter"
181 },
182 new String[] {
183 "com.liferay.util.Http.max.connections.per.host",
184 "com.liferay.portal.util.HttpImpl.max.connections.per.host"
185 },
186 new String[] {
187 "com.liferay.util.Http.max.total.connections",
188 "com.liferay.portal.util.HttpImpl.max.total.connections"
189 },
190 new String[] {
191 "com.liferay.util.Http.proxy.auth.type",
192 "com.liferay.portal.util.HttpImpl.proxy.auth.type"
193 },
194 new String[] {
195 "com.liferay.util.Http.proxy.ntlm.domain",
196 "com.liferay.portal.util.HttpImpl.proxy.ntlm.domain"
197 },
198 new String[] {
199 "com.liferay.util.Http.proxy.ntlm.host",
200 "com.liferay.portal.util.HttpImpl.proxy.ntlm.host"
201 },
202 new String[] {
203 "com.liferay.util.Http.proxy.password",
204 "com.liferay.portal.util.HttpImpl.proxy.password"
205 },
206 new String[] {
207 "com.liferay.util.Http.proxy.username",
208 "com.liferay.portal.util.HttpImpl.proxy.username"
209 },
210 new String[] {
211 "com.liferay.util.Http.timeout",
212 "com.liferay.portal.util.HttpImpl.timeout"
213 },
214 new String[] {
215 "com.liferay.util.format.PhoneNumberFormat",
216 "phone.number.format.impl"
217 },
218 new String[] {
219 "com.liferay.util.servlet.UploadServletRequest.max.size",
220 "com.liferay.portal.upload.UploadServletRequestImpl.max.size"
221 },
222 new String[] {
223 "com.liferay.util.servlet.UploadServletRequest.temp.dir",
224 "com.liferay.portal.upload.UploadServletRequestImpl.temp.dir"
225 },
226 new String[] {
227 "com.liferay.util.servlet.fileupload.LiferayFileItem." +
228 "threshold.size",
229 "com.liferay.portal.upload.LiferayFileItem.threshold.size"
230 },
231 new String[] {
232 "com.liferay.util.servlet.fileupload.LiferayInputStream." +
233 "threshold.size",
234 "com.liferay.portal.upload.LiferayInputStream.threshold.size"
235 }
236 };
237
238 private static final String[] _OBSOLETE_PORTAL_KEYS = new String[] {
239 "asset.entry.increment.view.counter.enabled", "auth.max.failures.limit",
240 "buffered.increment.parallel.queue.size",
241 "buffered.increment.serial.queue.size", "cas.validate.url",
242 "cluster.executor.heartbeat.interval", "commons.pool.enabled",
243 "dl.file.entry.read.count.enabled",
244 "dynamic.data.mapping.template.language.types", "jbi.workflow.url",
245 "journal.template.language.types", "lucene.analyzer",
246 "lucene.store.jdbc.auto.clean.up",
247 "lucene.store.jdbc.auto.clean.up.enabled",
248 "lucene.store.jdbc.auto.clean.up.interval",
249 "lucene.store.jdbc.dialect.db2", "lucene.store.jdbc.dialect.derby",
250 "lucene.store.jdbc.dialect.hsqldb", "lucene.store.jdbc.dialect.jtds",
251 "lucene.store.jdbc.dialect.microsoft",
252 "lucene.store.jdbc.dialect.mysql", "lucene.store.jdbc.dialect.oracle",
253 "lucene.store.jdbc.dialect.postgresql",
254 "message.boards.thread.locking.enabled",
255 "portal.security.manager.enable", "scheduler.classes",
256 "shard.available.names", "velocity.engine.resource.manager",
257 "velocity.engine.resource.manager.cache.enabled",
258 "webdav.storage.class", "webdav.storage.show.edit.url",
259 "webdav.storage.show.view.url", "webdav.storage.tokens", "xss.allow"
260 };
261
262 private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
263 "com.liferay.util.Http.proxy.host", "com.liferay.util.Http.proxy.port",
264 "com.liferay.util.XSSUtil.regexp.pattern"
265 };
266
267 private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
268 new String[] {
269 "amazon.license.0", "amazon.access.key.id"
270 },
271 new String[] {
272 "amazon.license.1", "amazon.access.key.id"
273 },
274 new String[] {
275 "amazon.license.2", "amazon.access.key.id"
276 },
277 new String[] {
278 "amazon.license.3", "amazon.access.key.id"
279 },
280 new String[] {
281 "cdn.host", "cdn.host.http"
282 },
283 new String[] {
284 "com.liferay.portal.servlet.filters.compression.CompressionFilter",
285 "com.liferay.portal.servlet.filters.gzip.GZipFilter"
286 },
287 new String[] {
288 "default.guest.friendly.url",
289 "default.guest.public.layout.friendly.url"
290 },
291 new String[] {
292 "default.guest.layout.column", "default.guest.public.layout.column"
293 },
294 new String[] {
295 "default.guest.layout.name", "default.guest.public.layout.name"
296 },
297 new String[] {
298 "default.guest.layout.template.id",
299 "default.guest.public.layout.template.id"
300 },
301 new String[] {
302 "default.user.layout.column", "default.user.public.layout.column"
303 },
304 new String[] {
305 "default.user.layout.name", "default.user.public.layout.name"
306 },
307 new String[] {
308 "default.user.layout.template.id",
309 "default.user.public.layout.template.id"
310 },
311 new String[] {
312 "default.user.private.layout.lar",
313 "default.user.private.layouts.lar"
314 },
315 new String[] {
316 "default.user.public.layout.lar", "default.user.public.layouts.lar"
317 },
318 new String[] {
319 "dl.hook.cmis.credentials.password",
320 "dl.store.cmis.credentials.password"
321 },
322 new String[] {
323 "dl.hook.cmis.credentials.username",
324 "dl.store.cmis.credentials.username"
325 },
326 new String[] {
327 "dl.hook.cmis.repository.url", "dl.store.cmis.repository.url"
328 },
329 new String[] {
330 "dl.hook.cmis.system.root.dir", "dl.store.cmis.system.root.dir"
331 },
332 new String[] {
333 "dl.hook.file.system.root.dir", "dl.store.file.system.root.dir"
334 },
335 new String[] {
336 "dl.hook.impl", "dl.store.impl"
337 },
338 new String[] {
339 "dl.hook.jcr.fetch.delay", "dl.store.jcr.fetch.delay"
340 },
341 new String[] {
342 "dl.hook.jcr.fetch.max.failures", "dl.store.jcr.fetch.max.failures"
343 },
344 new String[] {
345 "dl.hook.jcr.move.version.labels",
346 "dl.store.jcr.move.version.labels"
347 },
348 new String[] {
349 "dl.hook.s3.access.key", "dl.store.s3.access.key"
350 },
351 new String[] {
352 "dl.hook.s3.bucket.name", "dl.store.s3.bucket.name"
353 },
354 new String[] {
355 "dl.hook.s3.secret.key", "dl.store.s3.secret.key"
356 },
357 new String[] {
358 "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
359 "edit_configuration.jsp",
360 "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
361 "configuration.jsp"
362 },
363 new String[] {
364 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
365 "edit_configuration.jsp",
366 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
367 "configuration.jsp"
368 },
369 new String[] {
370 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
371 "edit_configuration.jsp",
372 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
373 "configuration.jsp"
374 },
375 new String[] {
376 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
377 "edit_configuration.jsp",
378 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
379 "configuration.jsp"
380 },
381 new String[] {
382 "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
383 "edit_configuration.jsp",
384 "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
385 "configuration.jsp"
386 },
387 new String[] {
388 "referer.url.domains.allowed", "redirect.url.domains.allowed"
389 },
390 new String[] {
391 "referer.url.ips.allowed", "redirect.url.ips.allowed"
392 },
393 new String[] {
394 "referer.url.security.mode", "redirect.url.security.mode"
395 },
396 new String[] {
397 "tags.asset.increment.view.counter.enabled",
398 "asset.entry.increment.view.counter.enabled"
399 }
400 };
401
402 private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
403 new String[] {
404 "com.liferay.portal.kernel.util.StringBundler.unsafe.create." +
405 "threshold",
406 "com.liferay.portal.kernel.util.StringBundler.threadlocal.buffer." +
407 "limit",
408 }
409 };
410
411 private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
412
413 }