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 PortletPreferencesIds getPortletPreferencesIds(
126                            long scopeGroupId, long userId, Layout layout, String portletId,
127                            boolean modeEditGuest)
128                    throws PortalException, SystemException {
129    
130                    return getPortletPreferencesFactory().getPortletPreferencesIds(
131                            scopeGroupId, userId, layout, portletId, modeEditGuest);
132            }
133    
134            public static PortletPreferences getPortletSetup(
135                            HttpServletRequest request, String portletId)
136                    throws PortalException, SystemException {
137    
138                    return getPortletPreferencesFactory().getPortletSetup(
139                            request, portletId);
140            }
141    
142            public static PortletPreferences getPortletSetup(
143                            HttpServletRequest request, String portletId,
144                            String defaultPreferences)
145                    throws PortalException, SystemException {
146    
147                    return getPortletPreferencesFactory().getPortletSetup(
148                            request, portletId, defaultPreferences);
149            }
150    
151            public static PortletPreferences getPortletSetup(
152                            Layout layout, String portletId, String defaultPreferences)
153                    throws SystemException {
154    
155                    return getPortletPreferencesFactory().getPortletSetup(
156                            layout, portletId, defaultPreferences);
157            }
158    
159            public static PortletPreferences getPortletSetup(
160                            long scopeGroupId, Layout layout, String portletId,
161                            String defaultPreferences)
162                    throws SystemException {
163    
164                    return getPortletPreferencesFactory().getPortletSetup(
165                            scopeGroupId, layout, portletId, defaultPreferences);
166            }
167    
168            public static PortletPreferences getPortletSetup(
169                            PortletRequest portletRequest)
170                    throws PortalException, SystemException {
171    
172                    return getPortletPreferencesFactory().getPortletSetup(portletRequest);
173            }
174    
175            public static PortletPreferences getPortletSetup(
176                            PortletRequest portletRequest, String portletId)
177                    throws PortalException, SystemException {
178    
179                    return getPortletPreferencesFactory().getPortletSetup(
180                            portletRequest, portletId);
181            }
182    
183            public static PortletPreferences getPreferences(
184                    HttpServletRequest request) {
185    
186                    return getPortletPreferencesFactory().getPreferences(request);
187            }
188    
189            public static PreferencesValidator getPreferencesValidator(
190                    Portlet portlet) {
191    
192                    return getPortletPreferencesFactory().getPreferencesValidator(portlet);
193            }
194    
195            public static PortletPreferences getStrictLayoutPortletSetup(
196                            Layout layout, String portletId)
197                    throws SystemException {
198    
199                    return getPortletPreferencesFactory().getStrictLayoutPortletSetup(
200                            layout, portletId);
201            }
202    
203            public static String toXML(PortalPreferences portalPreferences) {
204                    return getPortletPreferencesFactory().toXML(portalPreferences);
205            }
206    
207            public static String toXML(PortletPreferences portletPreferences) {
208                    return getPortletPreferencesFactory().toXML(portletPreferences);
209            }
210    
211            public void setPortletPreferencesFactory(
212                    PortletPreferencesFactory portletPreferencesFactory) {
213    
214                    _portletPreferencesFactory = portletPreferencesFactory;
215            }
216    
217            private static PortletPreferencesFactory _portletPreferencesFactory;
218    
219    }