001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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.SystemProperties;
020    import com.liferay.portal.util.PropsUtil;
021    import com.liferay.portlet.documentlibrary.store.StoreFactory;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class VerifyProperties extends VerifyProcess {
027    
028            @Override
029            protected void doVerify() throws Exception {
030    
031                    // system.properties
032    
033                    for (String[] keys : _MIGRATED_SYSTEM_KEYS) {
034                            String oldKey = keys[0];
035                            String newKey = keys[1];
036    
037                            verifyMigratedSystemProperty(oldKey, newKey);
038                    }
039    
040                    for (String[] keys : _RENAMED_SYSTEM_KEYS) {
041                            String oldKey = keys[0];
042                            String newKey = keys[1];
043    
044                            verifyRenamedSystemProperty(oldKey, newKey);
045                    }
046    
047                    for (String key : _OBSOLETE_SYSTEM_KEYS) {
048                            verifyObsoleteSystemProperty(key);
049                    }
050    
051                    // portal.properties
052    
053                    for (String[] keys : _RENAMED_PORTAL_KEYS) {
054                            String oldKey = keys[0];
055                            String newKey = keys[1];
056    
057                            verifyRenamedPortalProperty(oldKey, newKey);
058                    }
059    
060                    for (String key : _OBSOLETE_PORTAL_KEYS) {
061                            verifyObsoletePortalProperty(key);
062                    }
063    
064                    StoreFactory.checkProperties();
065            }
066    
067            protected void verifyMigratedSystemProperty(String oldKey, String newKey)
068                    throws Exception {
069    
070                    String value = SystemProperties.get(oldKey);
071    
072                    if (value != null) {
073                            _log.error(
074                                    "System property \"" + oldKey +
075                                            "\" was migrated to the portal property \"" + newKey +
076                                                    "\"");
077                    }
078            }
079    
080            protected void verifyObsoletePortalProperty(String key) throws Exception {
081                    String value = PropsUtil.get(key);
082    
083                    if (value != null) {
084                            _log.error("Portal property \"" + key + "\" is obsolete");
085                    }
086            }
087    
088            protected void verifyObsoleteSystemProperty(String key) throws Exception {
089                    String value = SystemProperties.get(key);
090    
091                    if (value != null) {
092                            _log.error("System property \"" + key + "\" is obsolete");
093                    }
094            }
095    
096            protected void verifyRenamedPortalProperty(String oldKey, String newKey)
097                    throws Exception {
098    
099                    String value = PropsUtil.get(oldKey);
100    
101                    if (value != null) {
102                            _log.error(
103                                    "Portal property \"" + oldKey + "\" was renamed to \"" +
104                                            newKey + "\"");
105                    }
106            }
107    
108            protected void verifyRenamedSystemProperty(String oldKey, String newKey)
109                    throws Exception {
110    
111                    String value = SystemProperties.get(oldKey);
112    
113                    if (value != null) {
114                            _log.error(
115                                    "System property \"" + oldKey + "\" was renamed to \"" +
116                                            newKey + "\"");
117                    }
118            }
119    
120            private static final String[][] _MIGRATED_SYSTEM_KEYS = new String[][] {
121                    new String[] {
122                            "com.liferay.filters.compression.CompressionFilter",
123                            "com.liferay.portal.servlet.filters.gzip.GZipFilter"
124                    },
125                    new String[] {
126                            "com.liferay.filters.doubleclick.DoubleClickFilter",
127                            "com.liferay.portal.servlet.filters.doubleclick.DoubleClickFilter"
128                    },
129                    new String[] {
130                            "com.liferay.filters.strip.StripFilter",
131                            "com.liferay.portal.servlet.filters.strip.StripFilter"
132                    },
133                    new String[] {
134                            "com.liferay.util.Http.max.connections.per.host",
135                            "com.liferay.portal.util.HttpImpl.max.connections.per.host"
136                    },
137                    new String[] {
138                            "com.liferay.util.Http.max.total.connections",
139                            "com.liferay.portal.util.HttpImpl.max.total.connections"
140                    },
141                    new String[] {
142                            "com.liferay.util.Http.proxy.auth.type",
143                            "com.liferay.portal.util.HttpImpl.proxy.auth.type"
144                    },
145                    new String[] {
146                            "com.liferay.util.Http.proxy.ntlm.domain",
147                            "com.liferay.portal.util.HttpImpl.proxy.ntlm.domain"
148                    },
149                    new String[] {
150                            "com.liferay.util.Http.proxy.ntlm.host",
151                            "com.liferay.portal.util.HttpImpl.proxy.ntlm.host"
152                    },
153                    new String[] {
154                            "com.liferay.util.Http.proxy.password",
155                            "com.liferay.portal.util.HttpImpl.proxy.password"
156                    },
157                    new String[] {
158                            "com.liferay.util.Http.proxy.username",
159                            "com.liferay.portal.util.HttpImpl.proxy.username"
160                    },
161                    new String[] {
162                            "com.liferay.util.Http.timeout",
163                            "com.liferay.portal.util.HttpImpl.timeout"
164                    },
165                    new String[] {
166                            "com.liferay.util.format.PhoneNumberFormat",
167                            "phone.number.format.impl"
168                    },
169                    new String[] {
170                            "com.liferay.util.servlet.UploadServletRequest.max.size",
171                            "com.liferay.portal.upload.UploadServletRequestImpl.max.size"
172                    },
173                    new String[] {
174                            "com.liferay.util.servlet.UploadServletRequest.temp.dir",
175                            "com.liferay.portal.upload.UploadServletRequestImpl.temp.dir"
176                    },
177                    new String[] {
178                            "com.liferay.util.servlet.fileupload.LiferayFileItem." +
179                                    "threshold.size",
180                            "com.liferay.portal.upload.LiferayFileItem.threshold.size"
181                    },
182                    new String[] {
183                            "com.liferay.util.servlet.fileupload.LiferayInputStream." +
184                                    "threshold.size",
185                            "com.liferay.portal.upload.LiferayInputStream.threshold.size"
186                    }
187            };
188    
189            private static final String[] _OBSOLETE_PORTAL_KEYS = new String[] {
190                    "auth.max.failures.limit", "cas.validate.url", "commons.pool.enabled",
191                    "jbi.workflow.url", "lucene.analyzer",
192                    "lucene.store.jdbc.auto.clean.up",
193                    "lucene.store.jdbc.auto.clean.up.enabled",
194                    "lucene.store.jdbc.auto.clean.up.interval",
195                    "lucene.store.jdbc.dialect.db2", "lucene.store.jdbc.dialect.derby",
196                    "lucene.store.jdbc.dialect.hsqldb", "lucene.store.jdbc.dialect.jtds",
197                    "lucene.store.jdbc.dialect.microsoft",
198                    "lucene.store.jdbc.dialect.mysql", "lucene.store.jdbc.dialect.oracle",
199                    "lucene.store.jdbc.dialect.postgresql",
200                    "message.boards.thread.locking.enabled",
201                    "portal.security.manager.enable", "shard.available.names",
202                    "webdav.storage.class", "webdav.storage.show.edit.url",
203                    "webdav.storage.show.view.url", "webdav.storage.tokens", "xss.allow"
204            };
205    
206            private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
207                    "com.liferay.util.Http.proxy.host", "com.liferay.util.Http.proxy.port",
208                    "com.liferay.util.XSSUtil.regexp.pattern"
209            };
210    
211            private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
212                    new String[] {
213                            "amazon.license.0", "amazon.access.key.id"
214                    },
215                    new String[] {
216                            "amazon.license.1", "amazon.access.key.id"
217                    },
218                    new String[] {
219                            "amazon.license.2", "amazon.access.key.id"
220                    },
221                    new String[] {
222                            "amazon.license.3", "amazon.access.key.id"
223                    },
224                    new String[] {
225                            "cdn.host", "cdn.host.http"
226                    },
227                    new String[] {
228                            "com.liferay.portal.servlet.filters.compression.CompressionFilter",
229                            "com.liferay.portal.servlet.filters.gzip.GZipFilter"
230                    },
231                    new String[] {
232                            "default.guest.friendly.url",
233                            "default.guest.public.layout.friendly.url"
234                    },
235                    new String[] {
236                            "default.guest.layout.column", "default.guest.public.layout.column"
237                    },
238                    new String[] {
239                            "default.guest.layout.name", "default.guest.public.layout.name"
240                    },
241                    new String[] {
242                            "default.guest.layout.template.id",
243                            "default.guest.public.layout.template.id"
244                    },
245                    new String[] {
246                            "default.user.layout.column", "default.user.public.layout.column"
247                    },
248                    new String[] {
249                            "default.user.layout.name", "default.user.public.layout.name"
250                    },
251                    new String[] {
252                            "default.user.layout.template.id",
253                            "default.user.public.layout.template.id"
254                    },
255                    new String[] {
256                            "default.user.private.layout.lar",
257                            "default.user.private.layouts.lar"
258                    },
259                    new String[] {
260                            "default.user.public.layout.lar", "default.user.public.layouts.lar"
261                    },
262                    new String[] {
263                            "dl.hook.cmis.credentials.password",
264                            "dl.store.cmis.credentials.password"
265                    },
266                    new String[] {
267                            "dl.hook.cmis.credentials.username",
268                            "dl.store.cmis.credentials.username"
269                    },
270                    new String[] {
271                            "dl.hook.cmis.repository.url", "dl.store.cmis.repository.url"
272                    },
273                    new String[] {
274                            "dl.hook.cmis.system.root.dir", "dl.store.cmis.system.root.dir"
275                    },
276                    new String[] {
277                            "dl.hook.file.system.root.dir", "dl.store.file.system.root.dir"
278                    },
279                    new String[] {
280                            "dl.hook.impl", "dl.store.impl"
281                    },
282                    new String[] {
283                            "dl.hook.jcr.fetch.delay", "dl.store.jcr.fetch.delay"
284                    },
285                    new String[] {
286                            "dl.hook.jcr.fetch.max.failures", "dl.store.jcr.fetch.max.failures"
287                    },
288                    new String[] {
289                            "dl.hook.jcr.move.version.labels",
290                            "dl.store.jcr.move.version.labels"
291                    },
292                    new String[] {
293                            "dl.hook.s3.access.key", "dl.store.s3.access.key"
294                    },
295                    new String[] {
296                            "dl.hook.s3.bucket.name", "dl.store.s3.bucket.name"
297                    },
298                    new String[] {
299                            "dl.hook.s3.secret.key", "dl.store.s3.secret.key"
300                    },
301                    new String[] {
302                            "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
303                                    "edit_configuration.jsp",
304                            "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
305                                    "configuration.jsp"
306                    },
307                    new String[] {
308                            "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
309                                    "edit_configuration.jsp",
310                            "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
311                                    "configuration.jsp"
312                    },
313                    new String[] {
314                            "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
315                                    "edit_configuration.jsp",
316                            "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
317                                    "configuration.jsp"
318                    },
319                    new String[] {
320                            "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
321                                    "edit_configuration.jsp",
322                            "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
323                                    "configuration.jsp"
324                    },
325                    new String[] {
326                            "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
327                                    "edit_configuration.jsp",
328                            "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
329                                    "configuration.jsp"
330                    },
331                    new String[] {
332                            "referer.url.domains.allowed", "redirect.url.domains.allowed"
333                    },
334                    new String[] {
335                            "referer.url.ips.allowed", "redirect.url.ips.allowed"
336                    },
337                    new String[] {
338                            "referer.url.security.mode", "redirect.url.security.mode"
339                    },
340                    new String[] {
341                            "tags.asset.increment.view.counter.enabled",
342                            "asset.entry.increment.view.counter.enabled"
343                    }
344            };
345    
346            private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
347                    new String[] {
348                            "com.liferay.portal.kernel.util.StringBundler.unsafe.create." +
349                                    "threshold",
350                            "com.liferay.portal.kernel.util.StringBundler.threadlocal.buffer." +
351                                    "limit",
352                    }
353            };
354    
355            private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
356    
357    }