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