1   /**
2    * Copyright (c) 2000-2008 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.kernel.bean.PortalBeanLocatorUtil;
28  import com.liferay.portal.model.Layout;
29  import com.liferay.portal.model.Portlet;
30  import com.liferay.portal.model.PortletPreferencesIds;
31  
32  import javax.portlet.ActionRequest;
33  import javax.portlet.PortletPreferences;
34  import javax.portlet.PreferencesValidator;
35  import javax.portlet.RenderRequest;
36  
37  import javax.servlet.http.HttpServletRequest;
38  
39  /**
40   * <a href="PortletPreferencesFactoryUtil.java.html"><b><i>View Source</i></b>
41   * </a>
42   *
43   * @author Brian Wing Shun Chan
44   *
45   */
46  public class PortletPreferencesFactoryUtil {
47  
48      public static PortletPreferences getLayoutPortletSetup(
49              Layout layout, String portletId)
50          throws PortalException, SystemException {
51  
52          return getPortletPreferencesFactory().getLayoutPortletSetup(
53              layout, portletId);
54      }
55  
56      public static PortalPreferences getPortalPreferences(
57              HttpServletRequest request)
58          throws PortalException, SystemException {
59  
60          return getPortletPreferencesFactory().getPortalPreferences(request);
61      }
62  
63      public static PortalPreferences getPortalPreferences(
64              ActionRequest actionRequest)
65          throws PortalException, SystemException {
66  
67          return getPortletPreferencesFactory().getPortalPreferences(
68              actionRequest);
69      }
70  
71      public static PortalPreferences getPortalPreferences(
72              RenderRequest renderRequest)
73          throws PortalException, SystemException {
74  
75          return getPortletPreferencesFactory().getPortalPreferences(
76              renderRequest);
77      }
78  
79      public static PortletPreferences getPortletPreferences(
80              HttpServletRequest request, String portletId)
81          throws PortalException, SystemException {
82  
83          return getPortletPreferencesFactory().getPortletPreferences(
84              request, portletId);
85      }
86  
87      public static PortletPreferencesFactory getPortletPreferencesFactory() {
88          return _getUtil()._portletPreferencesFactory;
89      }
90  
91      public static PortletPreferencesIds getPortletPreferencesIds(
92              HttpServletRequest request, String portletId)
93          throws PortalException, SystemException {
94  
95          return getPortletPreferencesFactory().getPortletPreferencesIds(
96              request, portletId);
97      }
98  
99      public static PortletPreferencesIds getPortletPreferencesIds(
100             HttpServletRequest request, Layout selLayout, String portletId)
101         throws PortalException, SystemException {
102 
103         return getPortletPreferencesFactory().getPortletPreferencesIds(
104             request, selLayout, portletId);
105     }
106 
107     public static PortletPreferences getPortletSetup(
108             Layout layout, String portletId, String defaultPreferences)
109         throws PortalException, SystemException {
110 
111         return getPortletPreferencesFactory().getPortletSetup(
112             layout, portletId, defaultPreferences);
113     }
114 
115     public static PortletPreferences getPortletSetup(
116             HttpServletRequest request, String portletId)
117         throws PortalException, SystemException {
118 
119         return getPortletPreferencesFactory().getPortletSetup(
120             request, portletId);
121     }
122 
123     public static PortletPreferences getPortletSetup(
124             HttpServletRequest request, String portletId,
125             String defaultPreferences)
126         throws PortalException, SystemException {
127 
128         return getPortletPreferencesFactory().getPortletSetup(
129             request, portletId, defaultPreferences);
130     }
131 
132     public static PortletPreferences getPortletSetup(
133             ActionRequest actionRequest)
134         throws PortalException, SystemException {
135 
136         return getPortletPreferencesFactory().getPortletSetup(actionRequest);
137     }
138 
139     public static PortletPreferences getPortletSetup(
140             ActionRequest actionRequest, String portletId)
141         throws PortalException, SystemException {
142 
143         return getPortletPreferencesFactory().getPortletSetup(
144             actionRequest, portletId);
145     }
146 
147     public static PortletPreferences getPortletSetup(
148             RenderRequest renderRequest)
149         throws PortalException, SystemException {
150 
151         return getPortletPreferencesFactory().getPortletSetup(renderRequest);
152     }
153 
154     public static PortletPreferences getPortletSetup(
155             RenderRequest renderRequest, String portletId)
156         throws PortalException, SystemException {
157 
158         return getPortletPreferencesFactory().getPortletSetup(
159             renderRequest, portletId);
160     }
161 
162     public static PortletPreferences getPreferences(
163         HttpServletRequest request) {
164 
165         return getPortletPreferencesFactory().getPreferences(request);
166     }
167 
168     public static PreferencesValidator getPreferencesValidator(
169         Portlet portlet) {
170 
171         return getPortletPreferencesFactory().getPreferencesValidator(portlet);
172     }
173 
174     public void setPortletPreferencesFactory(
175         PortletPreferencesFactory portletPreferencesFactory) {
176 
177         _portletPreferencesFactory = portletPreferencesFactory;
178     }
179 
180     private static PortletPreferencesFactoryUtil _getUtil() {
181         if (_util == null) {
182             _util =
183                 (PortletPreferencesFactoryUtil)PortalBeanLocatorUtil.locate(
184                     _UTIL);
185         }
186 
187         return _util;
188     }
189 
190     private static final String _UTIL =
191         PortletPreferencesFactoryUtil.class.getName();
192 
193     private static PortletPreferencesFactoryUtil _util;
194 
195     private PortletPreferencesFactory _portletPreferencesFactory;
196 
197 }