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         "xss.allow"
188     };
189 
190     private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
191         "com.liferay.util.Http.proxy.host",
192         "com.liferay.util.Http.proxy.port",
193         "com.liferay.util.XSSUtil.regexp.pattern"
194     };
195 
196     private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
197         new String[] {
198             "amazon.license.0",
199             "amazon.access.key.id"
200         },
201         new String[] {
202             "amazon.license.1",
203             "amazon.access.key.id"
204         },
205         new String[] {
206             "amazon.license.2",
207             "amazon.access.key.id"
208         },
209         new String[] {
210             "amazon.license.3",
211             "amazon.access.key.id"
212         },
213         new String[] {
214             "cdn.host",
215             "cdn.host.http"
216         },
217         new String[] {
218             "com.liferay.portal.servlet.filters.compression.CompressionFilter",
219             "com.liferay.portal.servlet.filters.gzip.GZipFilter"
220         },
221         new String[] {
222             "default.guest.friendly.url",
223             "default.guest.public.layout.friendly.url"
224         },
225         new String[] {
226             "default.guest.layout.column",
227             "default.guest.public.layout.column"
228         },
229         new String[] {
230             "default.guest.layout.name",
231             "default.guest.public.layout.name"
232         },
233         new String[] {
234             "default.guest.layout.template.id",
235             "default.guest.public.layout.template.id"
236         },
237         new String[] {
238             "default.user.layout.column",
239             "default.user.public.layout.column"
240         },
241         new String[] {
242             "default.user.layout.name",
243             "default.user.public.layout.name"
244         },
245         new String[] {
246             "default.user.layout.template.id",
247             "default.user.public.layout.template.id"
248         },
249         new String[] {
250             "default.user.private.layout.lar",
251             "default.user.private.layouts.lar"
252         },
253         new String[] {
254             "default.user.public.layout.lar",
255             "default.user.public.layouts.lar"
256         }
257     };
258 
259     private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
260     };
261 
262     private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
263 
264 }