1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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         "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             "referer.url.domains.allowed",
264             "redirect.url.domains.allowed"
265         },
266         new String[] {
267             "referer.url.ips.allowed",
268             "redirect.url.ips.allowed"
269         },
270         new String[] {
271             "referer.url.security.mode",
272             "redirect.url.security.mode"
273         }
274     };
275 
276     private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
277         new String[] {
278             "com.liferay.portal.kernel.util.StringBundler.unsafe.create." +
279                 "threshold",
280             "com.liferay.portal.kernel.util.StringBundler.threadlocal.buffer." +
281                 "limit",
282         }
283     };
284 
285     private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
286 
287 }