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.strip.StripFilter",
176 "com.liferay.portal.servlet.filters.strip.StripFilter"
177 },
178 new String[] {
179 "com.liferay.util.Http.max.connections.per.host",
180 "com.liferay.portal.util.HttpImpl.max.connections.per.host"
181 },
182 new String[] {
183 "com.liferay.util.Http.max.total.connections",
184 "com.liferay.portal.util.HttpImpl.max.total.connections"
185 },
186 new String[] {
187 "com.liferay.util.Http.proxy.auth.type",
188 "com.liferay.portal.util.HttpImpl.proxy.auth.type"
189 },
190 new String[] {
191 "com.liferay.util.Http.proxy.ntlm.domain",
192 "com.liferay.portal.util.HttpImpl.proxy.ntlm.domain"
193 },
194 new String[] {
195 "com.liferay.util.Http.proxy.ntlm.host",
196 "com.liferay.portal.util.HttpImpl.proxy.ntlm.host"
197 },
198 new String[] {
199 "com.liferay.util.Http.proxy.password",
200 "com.liferay.portal.util.HttpImpl.proxy.password"
201 },
202 new String[] {
203 "com.liferay.util.Http.proxy.username",
204 "com.liferay.portal.util.HttpImpl.proxy.username"
205 },
206 new String[] {
207 "com.liferay.util.Http.timeout",
208 "com.liferay.portal.util.HttpImpl.timeout"
209 },
210 new String[] {
211 "com.liferay.util.format.PhoneNumberFormat",
212 "phone.number.format.impl"
213 },
214 new String[] {
215 "com.liferay.util.servlet.UploadServletRequest.max.size",
216 "com.liferay.portal.upload.UploadServletRequestImpl.max.size"
217 },
218 new String[] {
219 "com.liferay.util.servlet.UploadServletRequest.temp.dir",
220 "com.liferay.portal.upload.UploadServletRequestImpl.temp.dir"
221 },
222 new String[] {
223 "com.liferay.util.servlet.fileupload.LiferayFileItem." +
224 "threshold.size",
225 "com.liferay.portal.upload.LiferayFileItem.threshold.size"
226 },
227 new String[] {
228 "com.liferay.util.servlet.fileupload.LiferayInputStream." +
229 "threshold.size",
230 "com.liferay.portal.upload.LiferayInputStream.threshold.size"
231 }
232 };
233
234 private static final String[] _OBSOLETE_PORTAL_KEYS = new String[] {
235 "auth.max.failures.limit", "cas.validate.url",
236 "cluster.executor.heartbeat.interval",
237 "com.liferay.filters.doubleclick.DoubleClickFilter",
238 "com.liferay.portal.servlet.filters.doubleclick.DoubleClickFilter",
239 "commons.pool.enabled", "jbi.workflow.url", "lucene.analyzer",
240 "lucene.store.jdbc.auto.clean.up",
241 "lucene.store.jdbc.auto.clean.up.enabled",
242 "lucene.store.jdbc.auto.clean.up.interval",
243 "lucene.store.jdbc.dialect.db2", "lucene.store.jdbc.dialect.derby",
244 "lucene.store.jdbc.dialect.hsqldb", "lucene.store.jdbc.dialect.jtds",
245 "lucene.store.jdbc.dialect.microsoft",
246 "lucene.store.jdbc.dialect.mysql", "lucene.store.jdbc.dialect.oracle",
247 "lucene.store.jdbc.dialect.postgresql",
248 "message.boards.thread.locking.enabled",
249 "portal.security.manager.enable", "scheduler.classes",
250 "shard.available.names", "webdav.storage.class",
251 "webdav.storage.show.edit.url", "webdav.storage.show.view.url",
252 "webdav.storage.tokens", "xss.allow"
253 };
254
255 private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
256 "com.liferay.util.Http.proxy.host", "com.liferay.util.Http.proxy.port",
257 "com.liferay.util.XSSUtil.regexp.pattern"
258 };
259
260 private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
261 new String[] {
262 "amazon.license.0", "amazon.access.key.id"
263 },
264 new String[] {
265 "amazon.license.1", "amazon.access.key.id"
266 },
267 new String[] {
268 "amazon.license.2", "amazon.access.key.id"
269 },
270 new String[] {
271 "amazon.license.3", "amazon.access.key.id"
272 },
273 new String[] {
274 "cdn.host", "cdn.host.http"
275 },
276 new String[] {
277 "com.liferay.portal.servlet.filters.compression.CompressionFilter",
278 "com.liferay.portal.servlet.filters.gzip.GZipFilter"
279 },
280 new String[] {
281 "default.guest.friendly.url",
282 "default.guest.public.layout.friendly.url"
283 },
284 new String[] {
285 "default.guest.layout.column", "default.guest.public.layout.column"
286 },
287 new String[] {
288 "default.guest.layout.name", "default.guest.public.layout.name"
289 },
290 new String[] {
291 "default.guest.layout.template.id",
292 "default.guest.public.layout.template.id"
293 },
294 new String[] {
295 "default.user.layout.column", "default.user.public.layout.column"
296 },
297 new String[] {
298 "default.user.layout.name", "default.user.public.layout.name"
299 },
300 new String[] {
301 "default.user.layout.template.id",
302 "default.user.public.layout.template.id"
303 },
304 new String[] {
305 "default.user.private.layout.lar",
306 "default.user.private.layouts.lar"
307 },
308 new String[] {
309 "default.user.public.layout.lar", "default.user.public.layouts.lar"
310 },
311 new String[] {
312 "dl.hook.cmis.credentials.password",
313 "dl.store.cmis.credentials.password"
314 },
315 new String[] {
316 "dl.hook.cmis.credentials.username",
317 "dl.store.cmis.credentials.username"
318 },
319 new String[] {
320 "dl.hook.cmis.repository.url", "dl.store.cmis.repository.url"
321 },
322 new String[] {
323 "dl.hook.cmis.system.root.dir", "dl.store.cmis.system.root.dir"
324 },
325 new String[] {
326 "dl.hook.file.system.root.dir", "dl.store.file.system.root.dir"
327 },
328 new String[] {
329 "dl.hook.impl", "dl.store.impl"
330 },
331 new String[] {
332 "dl.hook.jcr.fetch.delay", "dl.store.jcr.fetch.delay"
333 },
334 new String[] {
335 "dl.hook.jcr.fetch.max.failures", "dl.store.jcr.fetch.max.failures"
336 },
337 new String[] {
338 "dl.hook.jcr.move.version.labels",
339 "dl.store.jcr.move.version.labels"
340 },
341 new String[] {
342 "dl.hook.s3.access.key", "dl.store.s3.access.key"
343 },
344 new String[] {
345 "dl.hook.s3.bucket.name", "dl.store.s3.bucket.name"
346 },
347 new String[] {
348 "dl.hook.s3.secret.key", "dl.store.s3.secret.key"
349 },
350 new String[] {
351 "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
352 "edit_configuration.jsp",
353 "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
354 "configuration.jsp"
355 },
356 new String[] {
357 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
358 "edit_configuration.jsp",
359 "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
360 "configuration.jsp"
361 },
362 new String[] {
363 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
364 "edit_configuration.jsp",
365 "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
366 "configuration.jsp"
367 },
368 new String[] {
369 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
370 "edit_configuration.jsp",
371 "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
372 "configuration.jsp"
373 },
374 new String[] {
375 "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
376 "edit_configuration.jsp",
377 "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
378 "configuration.jsp"
379 },
380 new String[] {
381 "referer.url.domains.allowed", "redirect.url.domains.allowed"
382 },
383 new String[] {
384 "referer.url.ips.allowed", "redirect.url.ips.allowed"
385 },
386 new String[] {
387 "referer.url.security.mode", "redirect.url.security.mode"
388 },
389 new String[] {
390 "tags.asset.increment.view.counter.enabled",
391 "asset.entry.increment.view.counter.enabled"
392 }
393 };
394
395 private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
396 new String[] {
397 "com.liferay.portal.kernel.util.StringBundler.unsafe.create." +
398 "threshold",
399 "com.liferay.portal.kernel.util.StringBundler.threadlocal.buffer." +
400 "limit",
401 }
402 };
403
404 private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
405
406 }