001    /**
002     * Copyright (c) 2000-2010 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.util.PropsUtil;
020    import com.liferay.util.SystemProperties;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class VerifyProperties extends VerifyProcess {
026    
027            protected void doVerify() throws Exception {
028    
029                    // system.properties
030    
031                    for (String[] keys : _MIGRATED_SYSTEM_KEYS) {
032                            String oldKey = keys[0];
033                            String newKey = keys[1];
034    
035                            verifyMigratedSystemProperty(oldKey, newKey);
036                    }
037    
038                    for (String[] keys : _RENAMED_SYSTEM_KEYS) {
039                            String oldKey = keys[0];
040                            String newKey = keys[1];
041    
042                            verifyRenamedSystemProperty(oldKey, newKey);
043                    }
044    
045                    for (String key : _OBSOLETE_SYSTEM_KEYS) {
046                            verifyObsoleteSystemProperty(key);
047                    }
048    
049                    // portal.properties
050    
051                    for (String[] keys : _RENAMED_PORTAL_KEYS) {
052                            String oldKey = keys[0];
053                            String newKey = keys[1];
054    
055                            verifyRenamedPortalProperty(oldKey, newKey);
056                    }
057    
058                    for (String key : _OBSOLETE_PORTAL_KEYS) {
059                            verifyObsoletePortalProperty(key);
060                    }
061            }
062    
063            protected void verifyMigratedSystemProperty(String oldKey, String newKey)
064                    throws Exception {
065    
066                    String value = SystemProperties.get(oldKey);
067    
068                    if (value != null) {
069                            _log.error(
070                                    "System property \"" + oldKey +
071                                            "\" was migrated to the portal property \"" + newKey +
072                                                    "\"");
073                    }
074            }
075    
076            protected void verifyRenamedPortalProperty(String oldKey, String newKey)
077                    throws Exception {
078    
079                    String value = PropsUtil.get(oldKey);
080    
081                    if (value != null) {
082                            _log.error(
083                                    "Portal property \"" + oldKey + "\" was renamed to \"" +
084                                            newKey + "\"");
085                    }
086            }
087    
088            protected void verifyRenamedSystemProperty(String oldKey, String newKey)
089                    throws Exception {
090    
091                    String value = SystemProperties.get(oldKey);
092    
093                    if (value != null) {
094                            _log.error(
095                                    "System property \"" + oldKey + "\" was renamed to \"" +
096                                            newKey + "\"");
097                    }
098            }
099    
100            protected void verifyObsoletePortalProperty(String key) throws Exception {
101                    String value = PropsUtil.get(key);
102    
103                    if (value != null) {
104                            _log.error("Portal property \"" + key + "\" is obsolete");
105                    }
106            }
107    
108            protected void verifyObsoleteSystemProperty(String key) throws Exception {
109                    String value = SystemProperties.get(key);
110    
111                    if (value != null) {
112                            _log.error("System property \"" + key + "\" is obsolete");
113                    }
114            }
115    
116            private static final String[][] _MIGRATED_SYSTEM_KEYS = new String[][] {
117                    new String[] {
118                            "com.liferay.filters.compression.CompressionFilter",
119                            "com.liferay.portal.servlet.filters.gzip.GZipFilter"
120                    },
121                    new String[] {
122                            "com.liferay.filters.doubleclick.DoubleClickFilter",
123                            "com.liferay.portal.servlet.filters.doubleclick.DoubleClickFilter"
124                    },
125                    new String[] {
126                            "com.liferay.filters.strip.StripFilter",
127                            "com.liferay.portal.servlet.filters.strip.StripFilter"
128                    },
129                    new String[] {
130                            "com.liferay.util.Http.max.connections.per.host",
131                            "com.liferay.portal.util.HttpImpl.max.connections.per.host"
132                    },
133                    new String[] {
134                            "com.liferay.util.Http.max.total.connections",
135                            "com.liferay.portal.util.HttpImpl.max.total.connections"
136                    },
137                    new String[] {
138                            "com.liferay.util.Http.proxy.auth.type",
139                            "com.liferay.portal.util.HttpImpl.proxy.auth.type"
140                    },
141                    new String[] {
142                            "com.liferay.util.Http.proxy.ntlm.domain",
143                            "com.liferay.portal.util.HttpImpl.proxy.ntlm.domain"
144                    },
145                    new String[] {
146                            "com.liferay.util.Http.proxy.ntlm.host",
147                            "com.liferay.portal.util.HttpImpl.proxy.ntlm.host"
148                    },
149                    new String[] {
150                            "com.liferay.util.Http.proxy.password",
151                            "com.liferay.portal.util.HttpImpl.proxy.password"
152                    },
153                    new String[] {
154                            "com.liferay.util.Http.proxy.username",
155                            "com.liferay.portal.util.HttpImpl.proxy.username"
156                    },
157                    new String[] {
158                            "com.liferay.util.Http.timeout",
159                            "com.liferay.portal.util.HttpImpl.timeout"
160                    },
161                    new String[] {
162                            "com.liferay.util.servlet.UploadServletRequest.max.size",
163                            "com.liferay.portal.upload.UploadServletRequestImpl.max.size"
164                    },
165                    new String[] {
166                            "com.liferay.util.servlet.UploadServletRequest.temp.dir",
167                            "com.liferay.portal.upload.UploadServletRequestImpl.temp.dir"
168                    },
169                    new String[] {
170                            "com.liferay.util.servlet.fileupload.LiferayFileItem." +
171                                    "threshold.size",
172                            "com.liferay.portal.upload.LiferayFileItem.threshold.size"
173                    },
174                    new String[] {
175                            "com.liferay.util.servlet.fileupload.LiferayInputStream." +
176                                    "threshold.size",
177                            "com.liferay.portal.upload.LiferayInputStream.threshold.size"
178                    }
179            };
180    
181            private static final String[] _OBSOLETE_PORTAL_KEYS = new String[] {
182                    "auth.max.failures.limit",
183                    "auth.simultaneous.logins",
184                    "cas.validate.url",
185                    "commons.pool.enabled",
186                    "jbi.workflow.url",
187                    "message.boards.thread.locking.enabled",
188                    "webdav.storage.class",
189                    "webdav.storage.show.edit.url",
190                    "webdav.storage.show.view.url",
191                    "webdav.storage.tokens",
192                    "xss.allow"
193            };
194    
195            private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
196                    "com.liferay.util.Http.proxy.host",
197                    "com.liferay.util.Http.proxy.port",
198                    "com.liferay.util.XSSUtil.regexp.pattern"
199            };
200    
201            private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
202                    new String[] {
203                            "amazon.license.0",
204                            "amazon.access.key.id"
205                    },
206                    new String[] {
207                            "amazon.license.1",
208                            "amazon.access.key.id"
209                    },
210                    new String[] {
211                            "amazon.license.2",
212                            "amazon.access.key.id"
213                    },
214                    new String[] {
215                            "amazon.license.3",
216                            "amazon.access.key.id"
217                    },
218                    new String[] {
219                            "cdn.host",
220                            "cdn.host.http"
221                    },
222                    new String[] {
223                            "com.liferay.portal.servlet.filters.compression.CompressionFilter",
224                            "com.liferay.portal.servlet.filters.gzip.GZipFilter"
225                    },
226                    new String[] {
227                            "default.guest.friendly.url",
228                            "default.guest.public.layout.friendly.url"
229                    },
230                    new String[] {
231                            "default.guest.layout.column",
232                            "default.guest.public.layout.column"
233                    },
234                    new String[] {
235                            "default.guest.layout.name",
236                            "default.guest.public.layout.name"
237                    },
238                    new String[] {
239                            "default.guest.layout.template.id",
240                            "default.guest.public.layout.template.id"
241                    },
242                    new String[] {
243                            "default.user.layout.column",
244                            "default.user.public.layout.column"
245                    },
246                    new String[] {
247                            "default.user.layout.name",
248                            "default.user.public.layout.name"
249                    },
250                    new String[] {
251                            "default.user.layout.template.id",
252                            "default.user.public.layout.template.id"
253                    },
254                    new String[] {
255                            "default.user.private.layout.lar",
256                            "default.user.private.layouts.lar"
257                    },
258                    new String[] {
259                            "default.user.public.layout.lar",
260                            "default.user.public.layouts.lar"
261                    },
262                    new String[] {
263                            "lucene.store.jdbc.auto.clean.up",
264                            "lucene.store.jdbc.auto.clean.up.enabled"
265                    },
266                    new String[] {
267                            "referer.url.domains.allowed",
268                            "redirect.url.domains.allowed"
269                    },
270                    new String[] {
271                            "referer.url.ips.allowed",
272                            "redirect.url.ips.allowed"
273                    },
274                    new String[] {
275                            "referer.url.security.mode",
276                            "redirect.url.security.mode"
277                    },
278                    new String[] {
279                            "tags.asset.increment.view.counter.enabled",
280                            "asset.entry.increment.view.counter.enabled"
281                    }
282            };
283    
284            private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
285            };
286    
287            private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
288    
289    }