001    /**
002     * Copyright (c) 2000-2011 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 verifyRenamedPortalProperty(String oldKey, String newKey)
081                    throws Exception {
082    
083                    String value = PropsUtil.get(oldKey);
084    
085                    if (value != null) {
086                            _log.error(
087                                    "Portal property \"" + oldKey + "\" was renamed to \"" +
088                                            newKey + "\"");
089                    }
090            }
091    
092            protected void verifyRenamedSystemProperty(String oldKey, String newKey)
093                    throws Exception {
094    
095                    String value = SystemProperties.get(oldKey);
096    
097                    if (value != null) {
098                            _log.error(
099                                    "System property \"" + oldKey + "\" was renamed to \"" +
100                                            newKey + "\"");
101                    }
102            }
103    
104            protected void verifyObsoletePortalProperty(String key) throws Exception {
105                    String value = PropsUtil.get(key);
106    
107                    if (value != null) {
108                            _log.error("Portal property \"" + key + "\" is obsolete");
109                    }
110            }
111    
112            protected void verifyObsoleteSystemProperty(String key) throws Exception {
113                    String value = SystemProperties.get(key);
114    
115                    if (value != null) {
116                            _log.error("System property \"" + key + "\" is obsolete");
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.servlet.UploadServletRequest.max.size",
167                            "com.liferay.portal.upload.UploadServletRequestImpl.max.size"
168                    },
169                    new String[] {
170                            "com.liferay.util.servlet.UploadServletRequest.temp.dir",
171                            "com.liferay.portal.upload.UploadServletRequestImpl.temp.dir"
172                    },
173                    new String[] {
174                            "com.liferay.util.servlet.fileupload.LiferayFileItem." +
175                                    "threshold.size",
176                            "com.liferay.portal.upload.LiferayFileItem.threshold.size"
177                    },
178                    new String[] {
179                            "com.liferay.util.servlet.fileupload.LiferayInputStream." +
180                                    "threshold.size",
181                            "com.liferay.portal.upload.LiferayInputStream.threshold.size"
182                    }
183            };
184    
185            private static final String[] _OBSOLETE_PORTAL_KEYS = new String[] {
186                    "auth.max.failures.limit",
187                    "cas.validate.url",
188                    "commons.pool.enabled",
189                    "jbi.workflow.url",
190                    "lucene.analyzer",
191                    "message.boards.thread.locking.enabled",
192                    "portal.security.manager.enable",
193                    "shard.available.names",
194                    "webdav.storage.class",
195                    "webdav.storage.show.edit.url",
196                    "webdav.storage.show.view.url",
197                    "webdav.storage.tokens",
198                    "xss.allow"
199            };
200    
201            private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
202                    "com.liferay.util.Http.proxy.host",
203                    "com.liferay.util.Http.proxy.port",
204                    "com.liferay.util.XSSUtil.regexp.pattern"
205            };
206    
207            private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
208                    new String[] {
209                            "amazon.license.0",
210                            "amazon.access.key.id"
211                    },
212                    new String[] {
213                            "amazon.license.1",
214                            "amazon.access.key.id"
215                    },
216                    new String[] {
217                            "amazon.license.2",
218                            "amazon.access.key.id"
219                    },
220                    new String[] {
221                            "amazon.license.3",
222                            "amazon.access.key.id"
223                    },
224                    new String[] {
225                            "cdn.host",
226                            "cdn.host.http"
227                    },
228                    new String[] {
229                            "com.liferay.portal.servlet.filters.compression.CompressionFilter",
230                            "com.liferay.portal.servlet.filters.gzip.GZipFilter"
231                    },
232                    new String[] {
233                            "default.guest.friendly.url",
234                            "default.guest.public.layout.friendly.url"
235                    },
236                    new String[] {
237                            "default.guest.layout.column",
238                            "default.guest.public.layout.column"
239                    },
240                    new String[] {
241                            "default.guest.layout.name",
242                            "default.guest.public.layout.name"
243                    },
244                    new String[] {
245                            "default.guest.layout.template.id",
246                            "default.guest.public.layout.template.id"
247                    },
248                    new String[] {
249                            "default.user.layout.column",
250                            "default.user.public.layout.column"
251                    },
252                    new String[] {
253                            "default.user.layout.name",
254                            "default.user.public.layout.name"
255                    },
256                    new String[] {
257                            "default.user.layout.template.id",
258                            "default.user.public.layout.template.id"
259                    },
260                    new String[] {
261                            "default.user.private.layout.lar",
262                            "default.user.private.layouts.lar"
263                    },
264                    new String[] {
265                            "default.user.public.layout.lar",
266                            "default.user.public.layouts.lar"
267                    },
268                    new String[] {
269                            "dl.hook.cmis.credentials.password",
270                            "dl.store.cmis.credentials.password"
271                    },
272                    new String[] {
273                            "dl.hook.cmis.credentials.username",
274                            "dl.store.cmis.credentials.username"
275                    },
276                    new String[] {
277                            "dl.hook.cmis.repository.url",
278                            "dl.store.cmis.repository.url"
279                    },
280                    new String[] {
281                            "dl.hook.cmis.system.root.dir",
282                            "dl.store.cmis.system.root.dir"
283                    },
284                    new String[] {
285                            "dl.hook.file.system.root.dir",
286                            "dl.store.file.system.root.dir"
287                    },
288                    new String[] {
289                            "dl.hook.impl",
290                            "dl.store.impl"
291                    },
292                    new String[] {
293                            "dl.hook.jcr.fetch.delay",
294                            "dl.store.jcr.fetch.delay"
295                    },
296                    new String[] {
297                            "dl.hook.jcr.fetch.max.failures",
298                            "dl.store.jcr.fetch.max.failures"
299                    },
300                    new String[] {
301                            "dl.hook.jcr.move.version.labels",
302                            "dl.store.jcr.move.version.labels"
303                    },
304                    new String[] {
305                            "dl.hook.s3.access.key",
306                            "dl.store.s3.access.key"
307                    },
308                    new String[] {
309                            "dl.hook.s3.bucket.name",
310                            "dl.store.s3.bucket.name"
311                    },
312                    new String[] {
313                            "dl.hook.s3.secret.key",
314                            "dl.store.s3.secret.key"
315                    },
316                    new String[] {
317                            "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
318                                    "edit_configuration.jsp",
319                            "editor.wysiwyg.portal-web.docroot.html.portlet.calendar." +
320                                    "configuration.jsp"
321                    },
322                    new String[] {
323                            "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
324                                    "edit_configuration.jsp",
325                            "editor.wysiwyg.portal-web.docroot.html.portlet.invitation." +
326                                    "configuration.jsp"
327                    },
328                    new String[] {
329                            "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
330                                    "edit_configuration.jsp",
331                            "editor.wysiwyg.portal-web.docroot.html.portlet.journal." +
332                                    "configuration.jsp"
333                    },
334                    new String[] {
335                            "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
336                                    "edit_configuration.jsp",
337                            "editor.wysiwyg.portal-web.docroot.html.portlet.message_boards." +
338                                    "configuration.jsp"
339                    },
340                    new String[] {
341                            "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
342                                    "edit_configuration.jsp",
343                            "editor.wysiwyg.portal-web.docroot.html.portlet.shopping." +
344                                    "configuration.jsp"
345                    },
346                    new String[] {
347                            "lucene.store.jdbc.auto.clean.up",
348                            "lucene.store.jdbc.auto.clean.up.enabled"
349                    },
350                    new String[] {
351                            "referer.url.domains.allowed",
352                            "redirect.url.domains.allowed"
353                    },
354                    new String[] {
355                            "referer.url.ips.allowed",
356                            "redirect.url.ips.allowed"
357                    },
358                    new String[] {
359                            "referer.url.security.mode",
360                            "redirect.url.security.mode"
361                    },
362                    new String[] {
363                            "tags.asset.increment.view.counter.enabled",
364                            "asset.entry.increment.view.counter.enabled"
365                    }
366            };
367    
368            private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
369                    new String[] {
370                            "com.liferay.portal.kernel.util.StringBundler.unsafe.create." +
371                                    "threshold",
372                            "com.liferay.portal.kernel.util.StringBundler.threadlocal.buffer." +
373                                    "limit",
374                    }
375            };
376    
377            private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
378    
379    }