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 "auth.max.failures.limit", "cas.validate.url",
240 "cluster.executor.heartbeat.interval", "commons.pool.enabled",
241 "jbi.workflow.url", "lucene.analyzer",
242 "lucene.store.jdbc.auto.clean.up",
243 "lucene.store.jdbc.auto.clean.up.enabled",
244 "lucene.store.jdbc.auto.clean.up.interval",
245 "lucene.store.jdbc.dialect.db2", "lucene.store.jdbc.dialect.derby",
246 "lucene.store.jdbc.dialect.hsqldb", "lucene.store.jdbc.dialect.jtds",
247 "lucene.store.jdbc.dialect.microsoft",
248 "lucene.store.jdbc.dialect.mysql", "lucene.store.jdbc.dialect.oracle",
249 "lucene.store.jdbc.dialect.postgresql",
250 "message.boards.thread.locking.enabled",
251 "portal.security.manager.enable", "shard.available.names",
252 "webdav.storage.class", "webdav.storage.show.edit.url",
253 "webdav.storage.show.view.url", "webdav.storage.tokens", "xss.allow"
254 };
255
256 private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
257 "com.liferay.util.Http.proxy.host", "com.liferay.util.Http.proxy.port",
258 "com.liferay.util.XSSUtil.regexp.pattern"
259 };
260
261 private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
262 new String[] {
263 "amazon.license.0", "amazon.access.key.id"
264 },
265 new String[] {
266 "amazon.license.1", "amazon.access.key.id"
267 },
268 new String[] {
269 "amazon.license.2", "amazon.access.key.id"
270 },
271 new String[] {
272 "amazon.license.3", "amazon.access.key.id"
273 },
274 new String[] {
275 "cdn.host", "cdn.host.http"
276 },
277 new String[] {
278 "com.liferay.portal.servlet.filters.compression.CompressionFilter",
279 "com.liferay.portal.servlet.filters.gzip.GZipFilter"
280 },
281 new String[] {
282 "default.guest.friendly.url",
283 "default.guest.public.layout.friendly.url"
284 },
285 new String[] {
286 "default.guest.layout.column", "default.guest.public.layout.column"
287 },
288 new String[] {
289 "default.guest.layout.name", "default.guest.public.layout.name"
290 },
291 new String[] {
292 "default.guest.layout.template.id",
293 "default.guest.public.layout.template.id"
294 },
295 new String[] {
296 "default.user.layout.column", "default.user.public.layout.column"
297 },
298 new String[] {
299 "default.user.layout.name", "default.user.public.layout.name"
300 },
301 new String[] {
302 "default.user.layout.template.id",
303 "default.user.public.layout.template.id"
304 },
305 new String[] {
306 "default.user.private.layout.lar",
307 "default.user.private.layouts.lar"
308 },
309 new String[] {
310 "default.user.public.layout.lar", "default.user.public.layouts.lar"
311 },
312 new String[] {
313 "dl.hook.cmis.credentials.password",
314 "dl.store.cmis.credentials.password"
315 },
316 new String[] {
317 "dl.hook.cmis.credentials.username",
318 "dl.store.cmis.credentials.username"
319 },
320 new String[] {
321 "dl.hook.cmis.repository.url", "dl.store.cmis.repository.url"
322 },
323 new String[] {
324 "dl.hook.cmis.system.root.dir", "dl.store.cmis.system.root.dir"
325 },
326 new String[] {
327 "dl.hook.file.system.root.dir", "dl.store.file.system.root.dir"
328 },
329 new String[] {
330 "dl.hook.impl", "dl.store.impl"
331 },
332 new String[] {
333 "dl.hook.jcr.fetch.delay", "dl.store.jcr.fetch.delay"
334 },
335 new String[] {
336 "dl.hook.jcr.fetch.max.failures", "dl.store.jcr.fetch.max.failures"
337 },
338 new String[] {
339 "dl.hook.jcr.move.version.labels",
340 "dl.store.jcr.move.version.labels"
341 },
342 new String[] {
343 "dl.hook.s3.access.key", "dl.store.s3.access.key"
344 },
345 new String[] {
346 "dl.hook.s3.bucket.name", "dl.store.s3.bucket.name"
347 },
348 new String[] {
349 "dl.hook.s3.secret.key", "dl.store.s3.secret.key"
350 },
351 new String[] {
352 "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
353 "edit_configuration.jsp",
354 "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
355 "configuration.jsp"
356 },
357 new String[] {
358 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
359 "edit_configuration.jsp",
360 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
361 "configuration.jsp"
362 },
363 new String[] {
364 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
365 "edit_configuration.jsp",
366 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
367 "configuration.jsp"
368 },
369 new String[] {
370 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
371 "edit_configuration.jsp",
372 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
373 "configuration.jsp"
374 },
375 new String[] {
376 "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
377 "edit_configuration.jsp",
378 "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
379 "configuration.jsp"
380 },
381 new String[] {
382 "referer.url.domains.allowed", "redirect.url.domains.allowed"
383 },
384 new String[] {
385 "referer.url.ips.allowed", "redirect.url.ips.allowed"
386 },
387 new String[] {
388 "referer.url.security.mode", "redirect.url.security.mode"
389 },
390 new String[] {
391 "tags.asset.increment.view.counter.enabled",
392 "asset.entry.increment.view.counter.enabled"
393 }
394 };
395
396 private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
397 new String[] {
398 "com.liferay.portal.kernel.util.StringBundler.unsafe.create." +
399 "threshold",
400 "com.liferay.portal.kernel.util.StringBundler.threadlocal.buffer." +
401 "limit",
402 }
403 };
404
405 private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
406
407 }