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.util;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portlet.PortalPreferences;
20  import com.liferay.portlet.PortletPreferencesFactoryUtil;
21  
22  import javax.servlet.http.HttpServletRequest;
23  
24  /**
25   * <a href="SessionClicks.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class SessionClicks {
30  
31      public static final String CLASS_NAME = SessionClicks.class.getName();
32  
33      public static String get(
34          HttpServletRequest request, String key, String defaultValue) {
35  
36          try {
37              PortalPreferences preferences =
38                  PortletPreferencesFactoryUtil.getPortalPreferences(request);
39  
40              return preferences.getValue(CLASS_NAME, key, defaultValue);
41          }
42          catch (Exception e) {
43              _log.error(e, e);
44  
45              return null;
46          }
47      }
48  
49      public static void put(
50          HttpServletRequest request, String key, String value) {
51  
52          try {
53              PortalPreferences preferences =
54                  PortletPreferencesFactoryUtil.getPortalPreferences(request);
55  
56              preferences.setValue(CLASS_NAME, key, value);
57          }
58          catch (Exception e) {
59              _log.error(e, e);
60          }
61      }
62  
63      private static Log _log = LogFactoryUtil.getLog(SessionClicks.class);
64  
65  }