1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.verify;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.util.PropsUtil;
20  import com.liferay.util.SystemProperties;
21  
22  /**
23   * <a href="VerifyProperties.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class VerifyProperties extends VerifyProcess {
28  
29      protected void doVerify() throws Exception {
30  
31          // system.properties
32  
33          for (String[] keys : _MIGRATED_SYSTEM_KEYS) {
34              String oldKey = keys[0];
35              String newKey = keys[1];
36  
37              verifyMigratedSystemProperty(oldKey, newKey);
38          }
39  
40          for (String[] keys : _RENAMED_SYSTEM_KEYS) {
41              String oldKey = keys[0];
42              String newKey = keys[1];
43  
44              verifyRenamedSystemProperty(oldKey, newKey);
45          }
46  
47          for (String key : _OBSOLETE_SYSTEM_KEYS) {
48              verifyObsoleteSystemProperty(key);
49          }
50  
51          // portal.properties
52  
53          for (String[] keys : _RENAMED_PORTAL_KEYS) {
54              String oldKey = keys[0];
55              String newKey = keys[1];
56  
57              verifyRenamedPortalProperty(oldKey, newKey);
58          }
59  
60          for (String key : _OBSOLETE_PORTAL_KEYS) {
61              verifyObsoletePortalProperty(key);
62          }
63      }
64  
65      protected void verifyMigratedSystemProperty(String oldKey, String newKey)
66          throws Exception {
67  
68          String value = SystemProperties.get(oldKey);
69  
70          if (value != null) {
71              _log.error(
72                  "System property \"" + oldKey +
73                      "\" was migrated to the portal property \"" + newKey +
74                          "\"");
75          }
76      }
77  
78      protected void verifyRenamedPortalProperty(String oldKey, String newKey)
79          throws Exception {
80  
81          String value = PropsUtil.get(oldKey);
82  
83          if (value != null) {
84              _log.error(
85                  "Portal property \"" + oldKey + "\" was renamed to \"" +
86                      newKey + "\"");
87          }
88      }
89  
90      protected void verifyRenamedSystemProperty(String oldKey, String newKey)
91          throws Exception {
92  
93          String value = SystemProperties.get(oldKey);
94  
95          if (value != null) {
96              _log.error(
97                  "System property \"" + oldKey + "\" was renamed to \"" +
98                      newKey + "\"");
99          }
100     }
101 
102     protected void verifyObsoletePortalProperty(String key) throws Exception {
103         String value = PropsUtil.get(key);
104 
105         if (value != null) {
106             _log.error("Portal property \"" + key + "\" is obsolete");
107         }
108     }
109 
110     protected void verifyObsoleteSystemProperty(String key) throws Exception {
111         String value = SystemProperties.get(key);
112 
113         if (value != null) {
114             _log.error("System property \"" + key + "\" is obsolete");
115         }
116     }
117 
118     private static final String[][] _MIGRATED_SYSTEM_KEYS = new String[][] {
119         new String[] {
120             "com.liferay.filters.compression.CompressionFilter",
121             "com.liferay.portal.servlet.filters.gzip.GZipFilter"
122         },
123         new String[] {
124             "com.liferay.filters.doubleclick.DoubleClickFilter",
125             "com.liferay.portal.servlet.filters.doubleclick.DoubleClickFilter"
126         },
127         new String[] {
128             "com.liferay.filters.strip.StripFilter",
129             "com.liferay.portal.servlet.filters.strip.StripFilter"
130         },
131         new String[] {
132             "com.liferay.util.Http.max.connections.per.host",
133             "com.liferay.portal.util.HttpImpl.max.connections.per.host"
134         },
135         new String[] {
136             "com.liferay.util.Http.max.total.connections",
137             "com.liferay.portal.util.HttpImpl.max.total.connections"
138         },
139         new String[] {
140             "com.liferay.util.Http.proxy.auth.type",
141             "com.liferay.portal.util.HttpImpl.proxy.auth.type"
142         },
143         new String[] {
144             "com.liferay.util.Http.proxy.ntlm.domain",
145             "com.liferay.portal.util.HttpImpl.proxy.ntlm.domain"
146         },
147         new String[] {
148             "com.liferay.util.Http.proxy.ntlm.host",
149             "com.liferay.portal.util.HttpImpl.proxy.ntlm.host"
150         },
151         new String[] {
152             "com.liferay.util.Http.proxy.password",
153             "com.liferay.portal.util.HttpImpl.proxy.password"
154         },
155         new String[] {
156             "com.liferay.util.Http.proxy.username",
157             "com.liferay.portal.util.HttpImpl.proxy.username"
158         },
159         new String[] {
160             "com.liferay.util.Http.timeout",
161             "com.liferay.portal.util.HttpImpl.timeout"
162         },
163         new String[] {
164             "com.liferay.util.servlet.UploadServletRequest.max.size",
165             "com.liferay.portal.upload.UploadServletRequestImpl.max.size"
166         },
167         new String[] {
168             "com.liferay.util.servlet.UploadServletRequest.temp.dir",
169             "com.liferay.portal.upload.UploadServletRequestImpl.temp.dir"
170         },
171         new String[] {
172             "com.liferay.util.servlet.fileupload.LiferayFileItem." +
173                 "threshold.size",
174             "com.liferay.portal.upload.LiferayFileItem.threshold.size"
175         },
176         new String[] {
177             "com.liferay.util.servlet.fileupload.LiferayInputStream." +
178                 "threshold.size",
179             "com.liferay.portal.upload.LiferayInputStream.threshold.size"
180         }
181     };
182 
183     private static final String[] _OBSOLETE_PORTAL_KEYS = new String[] {
184         "auth.max.failures.limit",
185         "auth.simultaneous.logins",
186         "cas.validate.url",
187         "commons.pool.enabled",
188         "jbi.workflow.url",
189         "message.boards.thread.locking.enabled",
190         "webdav.storage.class",
191         "webdav.storage.show.edit.url",
192         "webdav.storage.show.view.url",
193         "webdav.storage.tokens",
194         "xss.allow"
195     };
196 
197     private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
198         "com.liferay.util.Http.proxy.host",
199         "com.liferay.util.Http.proxy.port",
200         "com.liferay.util.XSSUtil.regexp.pattern"
201     };
202 
203     private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
204         new String[] {
205             "amazon.license.0",
206             "amazon.access.key.id"
207         },
208         new String[] {
209             "amazon.license.1",
210             "amazon.access.key.id"
211         },
212         new String[] {
213             "amazon.license.2",
214             "amazon.access.key.id"
215         },
216         new String[] {
217             "amazon.license.3",
218             "amazon.access.key.id"
219         },
220         new String[] {
221             "cdn.host",
222             "cdn.host.http"
223         },
224         new String[] {
225             "com.liferay.portal.servlet.filters.compression.CompressionFilter",
226             "com.liferay.portal.servlet.filters.gzip.GZipFilter"
227         },
228         new String[] {
229             "default.guest.friendly.url",
230             "default.guest.public.layout.friendly.url"
231         },
232         new String[] {
233             "default.guest.layout.column",
234             "default.guest.public.layout.column"
235         },
236         new String[] {
237             "default.guest.layout.name",
238             "default.guest.public.layout.name"
239         },
240         new String[] {
241             "default.guest.layout.template.id",
242             "default.guest.public.layout.template.id"
243         },
244         new String[] {
245             "default.user.layout.column",
246             "default.user.public.layout.column"
247         },
248         new String[] {
249             "default.user.layout.name",
250             "default.user.public.layout.name"
251         },
252         new String[] {
253             "default.user.layout.template.id",
254             "default.user.public.layout.template.id"
255         },
256         new String[] {
257             "default.user.private.layout.lar",
258             "default.user.private.layouts.lar"
259         },
260         new String[] {
261             "default.user.public.layout.lar",
262             "default.user.public.layouts.lar"
263         },
264         new String[] {
265             "referer.url.domains.allowed",
266             "redirect.url.domains.allowed"
267         },
268         new String[] {
269             "referer.url.ips.allowed",
270             "redirect.url.ips.allowed"
271         },
272         new String[] {
273             "referer.url.security.mode",
274             "redirect.url.security.mode"
275         }
276     };
277 
278     private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
279     };
280 
281     private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
282 
283 }