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 : _MIGRATED_PORTAL_KEYS) {
062 String oldKey = keys[0];
063 String newKey = keys[1];
064
065 verifyMigratedPortalProperty(oldKey, newKey);
066 }
067
068 for (String[] keys : _RENAMED_PORTAL_KEYS) {
069 String oldKey = keys[0];
070 String newKey = keys[1];
071
072 verifyRenamedPortalProperty(oldKey, newKey);
073 }
074
075 for (String key : _OBSOLETE_PORTAL_KEYS) {
076 verifyObsoletePortalProperty(key);
077 }
078
079 for (String[] keys : _MODULARIZED_PORTAL_KEYS) {
080 String oldKey = keys[0];
081 String newKey = keys[1];
082 String moduleName = keys[2];
083
084 verifyModularizedPortalProperty(oldKey, newKey, moduleName);
085 }
086
087
088
089 StoreFactory.checkProperties();
090
091
092
093 verifyLDAPProperties();
094 }
095
096 protected boolean isPortalProperty(String key) {
097 String value = PropsUtil.get(key);
098
099 if (value != null) {
100 return true;
101 }
102
103 return false;
104 }
105
106 protected void verifyLDAPProperties() throws Exception {
107 long[] companyIds = PortalInstances.getCompanyIdsBySQL();
108
109 for (long companyId : companyIds) {
110 UnicodeProperties properties = new UnicodeProperties();
111
112 long[] ldapServerIds = StringUtil.split(
113 PrefsPropsUtil.getString(companyId, "ldap.server.ids"), 0L);
114
115 for (long ldapServerId : ldapServerIds) {
116 String postfix = LDAPSettingsUtil.getPropertyPostfix(
117 ldapServerId);
118
119 for (String key : _LDAP_KEYS) {
120 String value = PrefsPropsUtil.getString(
121 companyId, key + postfix, null);
122
123 if (value == null) {
124 properties.put(key + postfix, StringPool.BLANK);
125 }
126 }
127 }
128
129 if (!properties.isEmpty()) {
130 CompanyLocalServiceUtil.updatePreferences(
131 companyId, properties);
132 }
133 }
134 }
135
136 protected void verifyMigratedPortalProperty(String oldKey, String newKey)
137 throws Exception {
138
139 if (isPortalProperty(oldKey)) {
140 _log.error(
141 "Portal property \"" + oldKey +
142 "\" was migrated to the system property \"" + newKey +
143 "\"");
144 }
145 }
146
147 protected void verifyMigratedSystemProperty(String oldKey, String newKey)
148 throws Exception {
149
150 String value = SystemProperties.get(oldKey);
151
152 if (value != null) {
153 _log.error(
154 "System property \"" + oldKey +
155 "\" was migrated to the portal property \"" + newKey +
156 "\"");
157 }
158 }
159
160 protected void verifyModularizedPortalProperty(
161 String oldKey, String newKey, String moduleName)
162 throws Exception {
163
164 if (isPortalProperty(oldKey)) {
165 _log.error(
166 "Portal property \"" + oldKey + "\" was modularized to " +
167 moduleName + " as \"" + newKey);
168 }
169 }
170
171 protected void verifyObsoletePortalProperty(String key) throws Exception {
172 if (isPortalProperty(key)) {
173 _log.error("Portal property \"" + key + "\" is obsolete");
174 }
175 }
176
177 protected void verifyObsoleteSystemProperty(String key) throws Exception {
178 String value = SystemProperties.get(key);
179
180 if (value != null) {
181 _log.error("System property \"" + key + "\" is obsolete");
182 }
183 }
184
185 protected void verifyRenamedPortalProperty(String oldKey, String newKey)
186 throws Exception {
187
188 if (isPortalProperty(oldKey)) {
189 _log.error(
190 "Portal property \"" + oldKey + "\" was renamed to \"" +
191 newKey + "\"");
192 }
193 }
194
195 protected void verifyRenamedSystemProperty(String oldKey, String newKey)
196 throws Exception {
197
198 String value = SystemProperties.get(oldKey);
199
200 if (value != null) {
201 _log.error(
202 "System property \"" + oldKey + "\" was renamed to \"" +
203 newKey + "\"");
204 }
205 }
206
207 private static final String[] _LDAP_KEYS = {
208 PropsKeys.LDAP_CONTACT_CUSTOM_MAPPINGS, PropsKeys.LDAP_CONTACT_MAPPINGS,
209 PropsKeys.LDAP_USER_CUSTOM_MAPPINGS
210 };
211
212 private static final String[][] _MIGRATED_PORTAL_KEYS = new String[][] {
213 new String[] {
214 "finalize.manager.thread.enabled",
215 "com.liferay.portal.kernel.memory.FinalizeManager.thread.enabled"
216 }
217 };
218
219 private static final String[][] _MIGRATED_SYSTEM_KEYS = new String[][] {
220 new String[] {
221 "com.liferay.filters.compression.CompressionFilter",
222 "com.liferay.portal.servlet.filters.gzip.GZipFilter"
223 },
224 new String[] {
225 "com.liferay.filters.strip.StripFilter",
226 "com.liferay.portal.servlet.filters.strip.StripFilter"
227 },
228 new String[] {
229 "com.liferay.util.Http.max.connections.per.host",
230 "com.liferay.portal.util.HttpImpl.max.connections.per.host"
231 },
232 new String[] {
233 "com.liferay.util.Http.max.total.connections",
234 "com.liferay.portal.util.HttpImpl.max.total.connections"
235 },
236 new String[] {
237 "com.liferay.util.Http.proxy.auth.type",
238 "com.liferay.portal.util.HttpImpl.proxy.auth.type"
239 },
240 new String[] {
241 "com.liferay.util.Http.proxy.ntlm.domain",
242 "com.liferay.portal.util.HttpImpl.proxy.ntlm.domain"
243 },
244 new String[] {
245 "com.liferay.util.Http.proxy.ntlm.host",
246 "com.liferay.portal.util.HttpImpl.proxy.ntlm.host"
247 },
248 new String[] {
249 "com.liferay.util.Http.proxy.password",
250 "com.liferay.portal.util.HttpImpl.proxy.password"
251 },
252 new String[] {
253 "com.liferay.util.Http.proxy.username",
254 "com.liferay.portal.util.HttpImpl.proxy.username"
255 },
256 new String[] {
257 "com.liferay.util.Http.timeout",
258 "com.liferay.portal.util.HttpImpl.timeout"
259 },
260 new String[] {
261 "com.liferay.util.format.PhoneNumberFormat",
262 "phone.number.format.impl"
263 },
264 new String[] {
265 "com.liferay.util.servlet.UploadServletRequest.max.size",
266 "com.liferay.portal.upload.UploadServletRequestImpl.max.size"
267 },
268 new String[] {
269 "com.liferay.util.servlet.UploadServletRequest.temp.dir",
270 "com.liferay.portal.upload.UploadServletRequestImpl.temp.dir"
271 },
272 new String[] {
273 "com.liferay.util.servlet.fileupload.LiferayFileItem." +
274 "threshold.size",
275 "com.liferay.portal.upload.LiferayFileItem.threshold.size"
276 },
277 new String[] {
278 "com.liferay.util.servlet.fileupload.LiferayInputStream." +
279 "threshold.size",
280 "com.liferay.portal.upload.LiferayInputStream.threshold.size"
281 }
282 };
283
284 private static final String[][] _MODULARIZED_PORTAL_KEYS = {
285 new String[] {
286 "polls.publish.to.live.by.default", "publish.to.live.by.default",
287 "com.liferay.polls.service"
288 }
289 };
290
291 private static final String[] _OBSOLETE_PORTAL_KEYS = new String[] {
292 "amazon.access.key.id", "amazon.associate.tag",
293 "amazon.secret.access.key",
294 "asset.entry.increment.view.counter.enabled", "auth.max.failures.limit",
295 "buffered.increment.parallel.queue.size",
296 "buffered.increment.serial.queue.size", "cas.validate.url",
297 "cluster.executor.heartbeat.interval",
298 "com.liferay.filters.doubleclick.DoubleClickFilter",
299 "com.liferay.portal.servlet.filters.doubleclick.DoubleClickFilter",
300 "com.liferay.portal.servlet.filters.validhtml.ValidHtmlFilter",
301 "commons.pool.enabled", "convert.processes",
302 "dl.file.entry.read.count.enabled",
303 "dynamic.data.lists.template.language.parser[ftl]",
304 "dynamic.data.lists.template.language.parser[vm]",
305 "dynamic.data.lists.template.language.parser[xsl]",
306 "dynamic.data.mapping.template.language.types",
307 "editor.wysiwyg.portal-web.docroot.html.portlet.asset_publisher." +
308 "configuration.jsp",
309 "editor.wysiwyg.portal-web.docroot.html.portlet.blogs.configuration." +
310 "jsp",
311 "editor.wysiwyg.portal-web.docroot.html.portlet.bookmarks." +
312 "configuration.jsp",
313 "editor.wysiwyg.portal-web.docroot.html.portlet.document_library." +
314 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
315 "configuration.jsp",
316 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
317 "configuration.jsp",
318 "editor.wysiwyg.portal-web.docroot.html.portlet.login.configuration." +
319 "jsp",
320 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
321 "configuration.jsp",
322 "editor.wysiwyg.portal-web.docroot.html.portlet.portal_settings." +
323 "email_notifications.jsp",
324 "ehcache.statistics.enabled", "index.filter.search.limit",
325 "invitation.email.max.recipients", "invitation.email.message.body",
326 "invitation.email.message.subject", "javax.persistence.validation.mode",
327 "jbi.workflow.url", "json.deserializer.strict.mode",
328 "journal.article.form.translate",
329 "journal.template.language.parser[css]",
330 "journal.template.language.parser[ftl]",
331 "journal.template.language.parser[vm]",
332 "journal.template.language.parser[xsl]",
333 "journal.template.language.types", "jpa.configs",
334 "jpa.database.platform", "jpa.database.type", "jpa.load.time.weaver",
335 "jpa.provider", "jpa.provider.property.eclipselink.allow-zero-id",
336 "jpa.provider.property.eclipselink.logging.level",
337 "jpa.provider.property.eclipselink.logging.timestamp", "layout.types",
338 "lucene.analyzer", "lucene.store.jdbc.auto.clean.up",
339 "lucene.store.jdbc.auto.clean.up.enabled",
340 "lucene.store.jdbc.auto.clean.up.interval",
341 "lucene.store.jdbc.dialect.db2", "lucene.store.jdbc.dialect.derby",
342 "lucene.store.jdbc.dialect.hsqldb", "lucene.store.jdbc.dialect.jtds",
343 "lucene.store.jdbc.dialect.microsoft",
344 "lucene.store.jdbc.dialect.mysql", "lucene.store.jdbc.dialect.oracle",
345 "lucene.store.jdbc.dialect.postgresql",
346 "memory.cluster.scheduler.lock.cache.enabled",
347 "message.boards.email.message.added.signature",
348 "message.boards.email.message.updated.signature",
349 "message.boards.thread.locking.enabled",
350 "nested.portlets.layout.template.default",
351 "nested.portlets.layout.template.unsupported", "portal.ctx",
352 "portal.security.manager.enable", "permissions.list.filter",
353 "permissions.thread.local.cache.max.size",
354 "permissions.user.check.algorithm", "persistence.provider",
355 "scheduler.classes", "schema.run.minimal", "shard.available.names",
356 "velocity.engine.resource.manager",
357 "velocity.engine.resource.manager.cache.enabled",
358 "webdav.storage.class", "webdav.storage.show.edit.url",
359 "webdav.storage.show.view.url", "webdav.storage.tokens",
360 "wiki.email.page.added.signature", "wiki.email.page.updated.signature",
361 "xss.allow"
362 };
363
364 private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
365 "com.liferay.util.Http.proxy.host", "com.liferay.util.Http.proxy.port",
366 "com.liferay.util.XSSUtil.regexp.pattern"
367 };
368
369 private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
370 new String[] {
371 "amazon.license.0", "amazon.access.key.id"
372 },
373 new String[] {
374 "amazon.license.1", "amazon.access.key.id"
375 },
376 new String[] {
377 "amazon.license.2", "amazon.access.key.id"
378 },
379 new String[] {
380 "amazon.license.3", "amazon.access.key.id"
381 },
382 new String[] {
383 "cdn.host", "cdn.host.http"
384 },
385 new String[] {
386 "com.liferay.portal.servlet.filters.compression.CompressionFilter",
387 "com.liferay.portal.servlet.filters.gzip.GZipFilter"
388 },
389 new String[] {
390 "default.guest.friendly.url",
391 "default.guest.public.layout.friendly.url"
392 },
393 new String[] {
394 "default.guest.layout.column", "default.guest.public.layout.column"
395 },
396 new String[] {
397 "default.guest.layout.name", "default.guest.public.layout.name"
398 },
399 new String[] {
400 "default.guest.layout.template.id",
401 "default.guest.public.layout.template.id"
402 },
403 new String[] {
404 "default.user.layout.column", "default.user.public.layout.column"
405 },
406 new String[] {
407 "default.user.layout.name", "default.user.public.layout.name"
408 },
409 new String[] {
410 "default.user.layout.template.id",
411 "default.user.public.layout.template.id"
412 },
413 new String[] {
414 "default.user.private.layout.lar",
415 "default.user.private.layouts.lar"
416 },
417 new String[] {
418 "default.user.public.layout.lar", "default.user.public.layouts.lar"
419 },
420 new String[] {
421 "dl.hook.cmis.credentials.password",
422 "dl.store.cmis.credentials.password"
423 },
424 new String[] {
425 "dl.hook.cmis.credentials.username",
426 "dl.store.cmis.credentials.username"
427 },
428 new String[] {
429 "dl.hook.cmis.repository.url", "dl.store.cmis.repository.url"
430 },
431 new String[] {
432 "dl.hook.cmis.system.root.dir", "dl.store.cmis.system.root.dir"
433 },
434 new String[] {
435 "dl.hook.file.system.root.dir", "dl.store.file.system.root.dir"
436 },
437 new String[] {
438 "dl.hook.impl", "dl.store.impl"
439 },
440 new String[] {
441 "dl.hook.jcr.fetch.delay", "dl.store.jcr.fetch.delay"
442 },
443 new String[] {
444 "dl.hook.jcr.fetch.max.failures", "dl.store.jcr.fetch.max.failures"
445 },
446 new String[] {
447 "dl.hook.jcr.move.version.labels",
448 "dl.store.jcr.move.version.labels"
449 },
450 new String[] {
451 "dl.hook.s3.access.key", "dl.store.s3.access.key"
452 },
453 new String[] {
454 "dl.hook.s3.bucket.name", "dl.store.s3.bucket.name"
455 },
456 new String[] {
457 "dl.hook.s3.secret.key", "dl.store.s3.secret.key"
458 },
459 new String[] {
460 "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
461 "edit_configuration.jsp",
462 "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
463 "configuration.jsp"
464 },
465 new String[] {
466 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
467 "edit_configuration.jsp",
468 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
469 "configuration.jsp"
470 },
471 new String[] {
472 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
473 "edit_configuration.jsp",
474 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
475 "configuration.jsp"
476 },
477 new String[] {
478 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
479 "edit_configuration.jsp",
480 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
481 "configuration.jsp"
482 },
483 new String[] {
484 "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
485 "edit_configuration.jsp",
486 "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
487 "configuration.jsp"
488 },
489 new String[] {
490 "field.editable.com.liferay.portal.model.User.emailAddress",
491 "field.editable.user.types"
492 },
493 new String[] {
494 "field.editable.com.liferay.portal.model.User.screenName",
495 "field.editable.user.types"
496 },
497 new String[] {
498 "icon.menu.max.display.items", "menu.max.display.items"
499 },
500 new String[] {
501 "journal.error.template.freemarker", "journal.error.template[ftl]"
502 },
503 new String[] {
504 "journal.error.template.velocity", "journal.error.template[vm]"
505 },
506 new String[] {
507 "journal.error.template.xsl", "journal.error.template[xsl]"
508 },
509 new String[] {
510 "journal.template.freemarker.restricted.variables",
511 "freemarker.engine.restricted.variables"
512 },
513 new String[] {
514 "journal.template.velocity.restricted.variables",
515 "velocity.engine.restricted.variables"
516 },
517 new String[] {
518 "portal.instance.http.port",
519 "portal.instance.http.inet.socket.address"
520 },
521 new String[] {
522 "portal.instance.https.port",
523 "portal.instance.https.inet.socket.address"
524 },
525 new String[] {
526 "referer.url.domains.allowed", "redirect.url.domains.allowed"
527 },
528 new String[] {
529 "referer.url.ips.allowed", "redirect.url.ips.allowed"
530 },
531 new String[] {
532 "referer.url.security.mode", "redirect.url.security.mode"
533 },
534 new String[] {
535 "tags.asset.increment.view.counter.enabled",
536 "asset.entry.increment.view.counter.enabled"
537 }
538 };
539
540 private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
541 new String[] {
542 "com.liferay.portal.kernel.util.StringBundler.unsafe.create." +
543 "threshold",
544 "com.liferay.portal.kernel.util.StringBundler.threadlocal.buffer." +
545 "limit",
546 }
547 };
548
549 private static final Log _log = LogFactoryUtil.getLog(
550 VerifyProperties.class);
551
552 }