1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.verify;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.util.PropsUtil;
28  import com.liferay.util.SystemProperties;
29  
30  /**
31   * <a href="VerifyProperties.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Brian Wing Shun Chan
34   */
35  public class VerifyProperties extends VerifyProcess {
36  
37      protected void doVerify() throws Exception {
38  
39          // system.properties
40  
41          for (String[] keys : _MIGRATED_SYSTEM_KEYS) {
42              String oldKey = keys[0];
43              String newKey = keys[1];
44  
45              verifyMigratedSystemProperty(oldKey, newKey);
46          }
47  
48          for (String[] keys : _RENAMED_SYSTEM_KEYS) {
49              String oldKey = keys[0];
50              String newKey = keys[1];
51  
52              verifyRenamedSystemProperty(oldKey, newKey);
53          }
54  
55          for (String key : _OBSOLETE_SYSTEM_KEYS) {
56              verifyObsoleteSystemProperty(key);
57          }
58  
59          // portal.properties
60  
61          for (String[] keys : _RENAMED_PORTAL_KEYS) {
62              String oldKey = keys[0];
63              String newKey = keys[1];
64  
65              verifyRenamedPortalProperty(oldKey, newKey);
66          }
67  
68          for (String key : _OBSOLETE_PORTAL_KEYS) {
69              verifyObsoletePortalProperty(key);
70          }
71      }
72  
73      protected void verifyMigratedSystemProperty(String oldKey, String newKey)
74          throws Exception {
75  
76          String value = SystemProperties.get(oldKey);
77  
78          if (value != null) {
79              _log.error(
80                  "System property \"" + oldKey +
81                      "\" was migrated to the portal property \"" + newKey +
82                          "\"");
83          }
84      }
85  
86      protected void verifyRenamedPortalProperty(String oldKey, String newKey)
87          throws Exception {
88  
89          String value = PropsUtil.get(oldKey);
90  
91          if (value != null) {
92              _log.error(
93                  "Portal property \"" + oldKey + "\" was renamed to \"" +
94                      newKey + "\"");
95          }
96      }
97  
98      protected void verifyRenamedSystemProperty(String oldKey, String newKey)
99          throws Exception {
100 
101         String value = SystemProperties.get(oldKey);
102 
103         if (value != null) {
104             _log.error(
105                 "System property \"" + oldKey + "\" was renamed to \"" +
106                     newKey + "\"");
107         }
108     }
109 
110     protected void verifyObsoletePortalProperty(String key) throws Exception {
111         String value = PropsUtil.get(key);
112 
113         if (value != null) {
114             _log.error("Portal property \"" + key + "\" is obsolete");
115         }
116     }
117 
118     protected void verifyObsoleteSystemProperty(String key) throws Exception {
119         String value = SystemProperties.get(key);
120 
121         if (value != null) {
122             _log.error("System property \"" + key + "\" is obsolete");
123         }
124     }
125 
126     private static final String[][] _MIGRATED_SYSTEM_KEYS = new String[][] {
127         new String[] {
128             "com.liferay.filters.compression.CompressionFilter",
129             "com.liferay.portal.servlet.filters.gzip.GZipFilter"
130         },
131         new String[] {
132             "com.liferay.filters.doubleclick.DoubleClickFilter",
133             "com.liferay.portal.servlet.filters.doubleclick.DoubleClickFilter"
134         },
135         new String[] {
136             "com.liferay.filters.strip.StripFilter",
137             "com.liferay.portal.servlet.filters.strip.StripFilter"
138         },
139         new String[] {
140             "com.liferay.util.Http.max.connections.per.host",
141             "com.liferay.portal.util.HttpImpl.max.connections.per.host"
142         },
143         new String[] {
144             "com.liferay.util.Http.max.total.connections",
145             "com.liferay.portal.util.HttpImpl.max.total.connections"
146         },
147         new String[] {
148             "com.liferay.util.Http.proxy.auth.type",
149             "com.liferay.portal.util.HttpImpl.proxy.auth.type"
150         },
151         new String[] {
152             "com.liferay.util.Http.proxy.ntlm.domain",
153             "com.liferay.portal.util.HttpImpl.proxy.ntlm.domain"
154         },
155         new String[] {
156             "com.liferay.util.Http.proxy.ntlm.host",
157             "com.liferay.portal.util.HttpImpl.proxy.ntlm.host"
158         },
159         new String[] {
160             "com.liferay.util.Http.proxy.password",
161             "com.liferay.portal.util.HttpImpl.proxy.password"
162         },
163         new String[] {
164             "com.liferay.util.Http.proxy.username",
165             "com.liferay.portal.util.HttpImpl.proxy.username"
166         },
167         new String[] {
168             "com.liferay.util.Http.timeout",
169             "com.liferay.portal.util.HttpImpl.timeout"
170         },
171         new String[] {
172             "com.liferay.util.servlet.UploadServletRequest.max.size",
173             "com.liferay.portal.upload.UploadServletRequestImpl.max.size"
174         },
175         new String[] {
176             "com.liferay.util.servlet.UploadServletRequest.temp.dir",
177             "com.liferay.portal.upload.UploadServletRequestImpl.temp.dir"
178         },
179         new String[] {
180             "com.liferay.util.servlet.fileupload.LiferayFileItem." +
181                 "threshold.size",
182             "com.liferay.portal.upload.LiferayFileItem.threshold.size"
183         },
184         new String[] {
185             "com.liferay.util.servlet.fileupload.LiferayInputStream." +
186                 "threshold.size",
187             "com.liferay.portal.upload.LiferayInputStream.threshold.size"
188         }
189     };
190 
191     private static final String[] _OBSOLETE_PORTAL_KEYS = new String[] {
192         "auth.simultaneous.logins",
193         "commons.pool.enabled",
194         "webdav.storage.class",
195         "webdav.storage.show.edit.url",
196         "webdav.storage.show.view.url",
197         "webdav.storage.tokens",
198         "xss.allow"
199     };
200 
201     private static final String[] _OBSOLETE_SYSTEM_KEYS = new String[] {
202         "com.liferay.util.Http.proxy.host",
203         "com.liferay.util.Http.proxy.port",
204         "com.liferay.util.XSSUtil.regexp.pattern"
205     };
206 
207     private static final String[][] _RENAMED_PORTAL_KEYS = new String[][] {
208         new String[] {
209             "amazon.license.0",
210             "amazon.access.key.id"
211         },
212         new String[] {
213             "amazon.license.1",
214             "amazon.access.key.id"
215         },
216         new String[] {
217             "amazon.license.2",
218             "amazon.access.key.id"
219         },
220         new String[] {
221             "amazon.license.3",
222             "amazon.access.key.id"
223         },
224         new String[] {
225             "cdn.host",
226             "cdn.host.http"
227         },
228         new String[] {
229             "com.liferay.portal.servlet.filters.compression.CompressionFilter",
230             "com.liferay.portal.servlet.filters.gzip.GZipFilter"
231         },
232         new String[] {
233             "default.guest.friendly.url",
234             "default.guest.public.layout.friendly.url"
235         },
236         new String[] {
237             "default.guest.layout.column",
238             "default.guest.public.layout.column"
239         },
240         new String[] {
241             "default.guest.layout.name",
242             "default.guest.public.layout.name"
243         },
244         new String[] {
245             "default.guest.layout.template.id",
246             "default.guest.public.layout.template.id"
247         },
248         new String[] {
249             "default.user.layout.column",
250             "default.user.public.layout.column"
251         },
252         new String[] {
253             "default.user.layout.name",
254             "default.user.public.layout.name"
255         },
256         new String[] {
257             "default.user.layout.template.id",
258             "default.user.public.layout.template.id"
259         },
260         new String[] {
261             "default.user.private.layout.lar",
262             "default.user.private.layouts.lar"
263         },
264         new String[] {
265             "default.user.public.layout.lar",
266             "default.user.public.layouts.lar"
267         }
268     };
269 
270     private static final String[][] _RENAMED_SYSTEM_KEYS = new String[][] {
271     };
272 
273     private static Log _log = LogFactoryUtil.getLog(VerifyProperties.class);
274 
275 }