1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.portlet;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.model.Layout;
28  import com.liferay.portal.model.Portlet;
29  import com.liferay.portal.model.PortletPreferencesIds;
30  
31  import javax.portlet.PortletPreferences;
32  import javax.portlet.PortletRequest;
33  import javax.portlet.PreferencesValidator;
34  
35  import javax.servlet.http.HttpServletRequest;
36  
37  /**
38   * <a href="PortletPreferencesFactoryUtil.java.html"><b><i>View Source</i></b>
39   * </a>
40   *
41   * @author Brian Wing Shun Chan
42   *
43   */
44  public class PortletPreferencesFactoryUtil {
45  
46      public static PortletPreferences getLayoutPortletSetup(
47              Layout layout, String portletId)
48          throws SystemException {
49  
50          return getPortletPreferencesFactory().getLayoutPortletSetup(
51              layout, portletId);
52      }
53  
54      public static PortalPreferences getPortalPreferences(
55              HttpServletRequest request)
56          throws SystemException {
57  
58          return getPortletPreferencesFactory().getPortalPreferences(request);
59      }
60  
61      public static PortalPreferences getPortalPreferences(
62              PortletRequest portletRequest)
63          throws SystemException {
64  
65          return getPortletPreferencesFactory().getPortalPreferences(
66              portletRequest);
67      }
68  
69      public static PortletPreferences getPortletPreferences(
70              HttpServletRequest request, String portletId)
71          throws PortalException, SystemException {
72  
73          return getPortletPreferencesFactory().getPortletPreferences(
74              request, portletId);
75      }
76  
77      public static PortletPreferencesFactory getPortletPreferencesFactory() {
78          return _portletPreferencesFactory;
79      }
80  
81      public static PortletPreferencesIds getPortletPreferencesIds(
82              HttpServletRequest request, String portletId)
83          throws PortalException, SystemException {
84  
85          return getPortletPreferencesFactory().getPortletPreferencesIds(
86              request, portletId);
87      }
88  
89      public static PortletPreferencesIds getPortletPreferencesIds(
90              HttpServletRequest request, Layout selLayout, String portletId)
91          throws PortalException, SystemException {
92  
93          return getPortletPreferencesFactory().getPortletPreferencesIds(
94              request, selLayout, portletId);
95      }
96  
97      public static PortletPreferences getPortletSetup(
98              Layout layout, String portletId, String defaultPreferences)
99          throws SystemException {
100 
101         return getPortletPreferencesFactory().getPortletSetup(
102             layout, portletId, defaultPreferences);
103     }
104 
105     public static PortletPreferences getPortletSetup(
106             HttpServletRequest request, String portletId)
107         throws SystemException {
108 
109         return getPortletPreferencesFactory().getPortletSetup(
110             request, portletId);
111     }
112 
113     public static PortletPreferences getPortletSetup(
114             HttpServletRequest request, String portletId,
115             String defaultPreferences)
116         throws SystemException {
117 
118         return getPortletPreferencesFactory().getPortletSetup(
119             request, portletId, defaultPreferences);
120     }
121 
122     public static PortletPreferences getPortletSetup(
123             PortletRequest portletRequest)
124         throws SystemException {
125 
126         return getPortletPreferencesFactory().getPortletSetup(portletRequest);
127     }
128 
129     public static PortletPreferences getPortletSetup(
130             PortletRequest portletRequest, String portletId)
131         throws SystemException {
132 
133         return getPortletPreferencesFactory().getPortletSetup(
134             portletRequest, portletId);
135     }
136 
137     public static PortletPreferences getPreferences(
138         HttpServletRequest request) {
139 
140         return getPortletPreferencesFactory().getPreferences(request);
141     }
142 
143     public static PreferencesValidator getPreferencesValidator(
144         Portlet portlet) {
145 
146         return getPortletPreferencesFactory().getPreferencesValidator(portlet);
147     }
148 
149     public void setPortletPreferencesFactory(
150         PortletPreferencesFactory portletPreferencesFactory) {
151 
152         _portletPreferencesFactory = portletPreferencesFactory;
153     }
154 
155     private static PortletPreferencesFactory _portletPreferencesFactory;
156 
157 }