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.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  public class PortletPreferencesFactoryUtil {
44  
45      public static PortletPreferences getLayoutPortletSetup(
46              Layout layout, String portletId)
47          throws SystemException {
48  
49          return getPortletPreferencesFactory().getLayoutPortletSetup(
50              layout, portletId);
51      }
52  
53      public static PortalPreferences getPortalPreferences(
54              HttpServletRequest request)
55          throws SystemException {
56  
57          return getPortletPreferencesFactory().getPortalPreferences(request);
58      }
59  
60      public static PortalPreferences getPortalPreferences(
61              PortletRequest portletRequest)
62          throws SystemException {
63  
64          return getPortletPreferencesFactory().getPortalPreferences(
65              portletRequest);
66      }
67  
68      public static PortletPreferences getPortletPreferences(
69              HttpServletRequest request, String portletId)
70          throws PortalException, SystemException {
71  
72          return getPortletPreferencesFactory().getPortletPreferences(
73              request, portletId);
74      }
75  
76      public static PortletPreferencesFactory getPortletPreferencesFactory() {
77          return _portletPreferencesFactory;
78      }
79  
80      public static PortletPreferencesIds getPortletPreferencesIds(
81              HttpServletRequest request, String portletId)
82          throws PortalException, SystemException {
83  
84          return getPortletPreferencesFactory().getPortletPreferencesIds(
85              request, portletId);
86      }
87  
88      public static PortletPreferencesIds getPortletPreferencesIds(
89              HttpServletRequest request, Layout selLayout, String portletId)
90          throws PortalException, SystemException {
91  
92          return getPortletPreferencesFactory().getPortletPreferencesIds(
93              request, selLayout, portletId);
94      }
95  
96      public static PortletPreferences getPortletSetup(
97              Layout layout, String portletId, String defaultPreferences)
98          throws SystemException {
99  
100         return getPortletPreferencesFactory().getPortletSetup(
101             layout, portletId, defaultPreferences);
102     }
103 
104     public static PortletPreferences getPortletSetup(
105             HttpServletRequest request, String portletId)
106         throws SystemException {
107 
108         return getPortletPreferencesFactory().getPortletSetup(
109             request, portletId);
110     }
111 
112     public static PortletPreferences getPortletSetup(
113             HttpServletRequest request, String portletId,
114             String defaultPreferences)
115         throws SystemException {
116 
117         return getPortletPreferencesFactory().getPortletSetup(
118             request, portletId, defaultPreferences);
119     }
120 
121     public static PortletPreferences getPortletSetup(
122             PortletRequest portletRequest)
123         throws SystemException {
124 
125         return getPortletPreferencesFactory().getPortletSetup(portletRequest);
126     }
127 
128     public static PortletPreferences getPortletSetup(
129             PortletRequest portletRequest, String portletId)
130         throws SystemException {
131 
132         return getPortletPreferencesFactory().getPortletSetup(
133             portletRequest, portletId);
134     }
135 
136     public static PortletPreferences getPreferences(
137         HttpServletRequest request) {
138 
139         return getPortletPreferencesFactory().getPreferences(request);
140     }
141 
142     public static PreferencesValidator getPreferencesValidator(
143         Portlet portlet) {
144 
145         return getPortletPreferencesFactory().getPreferencesValidator(portlet);
146     }
147 
148     public void setPortletPreferencesFactory(
149         PortletPreferencesFactory portletPreferencesFactory) {
150 
151         _portletPreferencesFactory = portletPreferencesFactory;
152     }
153 
154     private static PortletPreferencesFactory _portletPreferencesFactory;
155 
156 }