001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.Layout;
020    import com.liferay.portal.model.Portlet;
021    import com.liferay.portal.model.PortletPreferencesIds;
022    
023    import javax.portlet.PortletPreferences;
024    import javax.portlet.PortletRequest;
025    import javax.portlet.PreferencesValidator;
026    
027    import javax.servlet.http.HttpServletRequest;
028    import javax.servlet.http.HttpSession;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     */
033    public class PortletPreferencesFactoryUtil {
034    
035            public static PortletPreferences fromDefaultXML(String xml)
036                    throws SystemException {
037    
038                    return getPortletPreferencesFactory().fromDefaultXML(xml);
039            }
040    
041            public static PortletPreferences fromXML(
042                            long companyId, long ownerId, int ownerType, long plid,
043                            String portletId, String xml)
044                    throws SystemException {
045    
046                    return getPortletPreferencesFactory().fromXML(
047                            companyId, ownerId, ownerType, plid, portletId, xml);
048            }
049    
050            public static PortalPreferences fromXML(
051                            long companyId, long ownerId, int ownerType, String xml)
052                    throws SystemException {
053    
054                    return getPortletPreferencesFactory().fromXML(
055                            companyId, ownerId, ownerType, xml);
056            }
057    
058            public static PortletPreferences getLayoutPortletSetup(
059                            Layout layout, String portletId)
060                    throws SystemException {
061    
062                    return getPortletPreferencesFactory().getLayoutPortletSetup(
063                            layout, portletId);
064            }
065    
066            public static PortalPreferences getPortalPreferences(
067                            HttpServletRequest request)
068                    throws SystemException {
069    
070                    return getPortletPreferencesFactory().getPortalPreferences(request);
071            }
072    
073            public static PortalPreferences getPortalPreferences(
074                            HttpSession session, long companyId, long userId, boolean signedIn)
075                    throws SystemException {
076    
077                    return getPortletPreferencesFactory().getPortalPreferences(
078                            session, companyId, userId, signedIn);
079            }
080    
081            public static PortalPreferences getPortalPreferences(
082                            long companyId, long userId, boolean signedIn)
083                    throws SystemException {
084    
085                    return getPortletPreferencesFactory().getPortalPreferences(
086                            companyId, userId, signedIn);
087            }
088    
089            public static PortalPreferences getPortalPreferences(
090                            PortletRequest portletRequest)
091                    throws SystemException {
092    
093                    return getPortletPreferencesFactory().getPortalPreferences(
094                            portletRequest);
095            }
096    
097            public static PortletPreferences getPortletPreferences(
098                            HttpServletRequest request, String portletId)
099                    throws PortalException, SystemException {
100    
101                    return getPortletPreferencesFactory().getPortletPreferences(
102                            request, portletId);
103            }
104    
105            public static PortletPreferencesFactory getPortletPreferencesFactory() {
106                    return _portletPreferencesFactory;
107            }
108    
109            public static PortletPreferencesIds getPortletPreferencesIds(
110                            HttpServletRequest request, Layout selLayout, String portletId)
111                    throws PortalException, SystemException {
112    
113                    return getPortletPreferencesFactory().getPortletPreferencesIds(
114                            request, selLayout, portletId);
115            }
116    
117            public static PortletPreferencesIds getPortletPreferencesIds(
118                            HttpServletRequest request, String portletId)
119                    throws PortalException, SystemException {
120    
121                    return getPortletPreferencesFactory().getPortletPreferencesIds(
122                            request, portletId);
123            }
124    
125            public static PortletPreferences getPortletSetup(
126                            HttpServletRequest request, String portletId)
127                    throws PortalException, SystemException {
128    
129                    return getPortletPreferencesFactory().getPortletSetup(
130                            request, portletId);
131            }
132    
133            public static PortletPreferences getPortletSetup(
134                            HttpServletRequest request, String portletId,
135                            String defaultPreferences)
136                    throws PortalException, SystemException {
137    
138                    return getPortletPreferencesFactory().getPortletSetup(
139                            request, portletId, defaultPreferences);
140            }
141    
142            public static PortletPreferences getPortletSetup(
143                            Layout layout, String portletId, String defaultPreferences)
144                    throws SystemException {
145    
146                    return getPortletPreferencesFactory().getPortletSetup(
147                            layout, portletId, defaultPreferences);
148            }
149    
150            public static PortletPreferences getPortletSetup(
151                            long scopeGroupId, Layout layout, String portletId,
152                            String defaultPreferences)
153                    throws SystemException {
154    
155                    return getPortletPreferencesFactory().getPortletSetup(
156                            scopeGroupId, layout, portletId, defaultPreferences);
157            }
158    
159            public static PortletPreferences getPortletSetup(
160                            PortletRequest portletRequest)
161                    throws PortalException, SystemException {
162    
163                    return getPortletPreferencesFactory().getPortletSetup(portletRequest);
164            }
165    
166            public static PortletPreferences getPortletSetup(
167                            PortletRequest portletRequest, String portletId)
168                    throws PortalException, SystemException {
169    
170                    return getPortletPreferencesFactory().getPortletSetup(
171                            portletRequest, portletId);
172            }
173    
174            public static PortletPreferences getPreferences(
175                    HttpServletRequest request) {
176    
177                    return getPortletPreferencesFactory().getPreferences(request);
178            }
179    
180            public static PreferencesValidator getPreferencesValidator(
181                    Portlet portlet) {
182    
183                    return getPortletPreferencesFactory().getPreferencesValidator(portlet);
184            }
185    
186            public static PortletPreferences getStrictLayoutPortletSetup(
187                            Layout layout, String portletId)
188                    throws SystemException {
189    
190                    return getPortletPreferencesFactory().getStrictLayoutPortletSetup(
191                            layout, portletId);
192            }
193    
194            public static String toXML(PortalPreferences portalPreferences) {
195                    return getPortletPreferencesFactory().toXML(portalPreferences);
196            }
197    
198            public static String toXML(PortletPreferences portletPreferences) {
199                    return getPortletPreferencesFactory().toXML(portletPreferences);
200            }
201    
202            public void setPortletPreferencesFactory(
203                    PortletPreferencesFactory portletPreferencesFactory) {
204    
205                    _portletPreferencesFactory = portletPreferencesFactory;
206            }
207    
208            private static PortletPreferencesFactory _portletPreferencesFactory;
209    
210    }