001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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 java.util.Map;
024    
025    import javax.portlet.PortletPreferences;
026    import javax.portlet.PortletRequest;
027    import javax.portlet.PreferencesValidator;
028    
029    import javax.servlet.http.HttpServletRequest;
030    import javax.servlet.http.HttpSession;
031    
032    /**
033     * @author Brian Wing Shun Chan
034     */
035    public class PortletPreferencesFactoryUtil {
036    
037            public static PortletPreferences fromDefaultXML(String xml)
038                    throws SystemException {
039    
040                    return getPortletPreferencesFactory().fromDefaultXML(xml);
041            }
042    
043            public static PortletPreferences fromXML(
044                            long companyId, long ownerId, int ownerType, long plid,
045                            String portletId, String xml)
046                    throws SystemException {
047    
048                    return getPortletPreferencesFactory().fromXML(
049                            companyId, ownerId, ownerType, plid, portletId, xml);
050            }
051    
052            public static PortalPreferences fromXML(
053                            long companyId, long ownerId, int ownerType, String xml)
054                    throws SystemException {
055    
056                    return getPortletPreferencesFactory().fromXML(
057                            companyId, ownerId, ownerType, xml);
058            }
059    
060            public static PortletPreferences getLayoutPortletSetup(
061                            Layout layout, String portletId)
062                    throws SystemException {
063    
064                    return getPortletPreferencesFactory().getLayoutPortletSetup(
065                            layout, portletId);
066            }
067    
068            public static PortalPreferences getPortalPreferences(
069                            HttpServletRequest request)
070                    throws SystemException {
071    
072                    return getPortletPreferencesFactory().getPortalPreferences(request);
073            }
074    
075            public static PortalPreferences getPortalPreferences(
076                            HttpSession session, long companyId, long userId, boolean signedIn)
077                    throws SystemException {
078    
079                    return getPortletPreferencesFactory().getPortalPreferences(
080                            session, companyId, userId, signedIn);
081            }
082    
083            public static PortalPreferences getPortalPreferences(
084                            long companyId, long userId, boolean signedIn)
085                    throws SystemException {
086    
087                    return getPortletPreferencesFactory().getPortalPreferences(
088                            companyId, userId, signedIn);
089            }
090    
091            public static PortalPreferences getPortalPreferences(
092                            PortletRequest portletRequest)
093                    throws SystemException {
094    
095                    return getPortletPreferencesFactory().getPortalPreferences(
096                            portletRequest);
097            }
098    
099            public static PortletPreferences getPortletPreferences(
100                            HttpServletRequest request, String portletId)
101                    throws PortalException, SystemException {
102    
103                    return getPortletPreferencesFactory().getPortletPreferences(
104                            request, portletId);
105            }
106    
107            public static PortletPreferencesFactory getPortletPreferencesFactory() {
108                    return _portletPreferencesFactory;
109            }
110    
111            public static PortletPreferencesIds getPortletPreferencesIds(
112                            HttpServletRequest request, Layout selLayout, String portletId)
113                    throws PortalException, SystemException {
114    
115                    return getPortletPreferencesFactory().getPortletPreferencesIds(
116                            request, selLayout, portletId);
117            }
118    
119            public static PortletPreferencesIds getPortletPreferencesIds(
120                            HttpServletRequest request, String portletId)
121                    throws PortalException, SystemException {
122    
123                    return getPortletPreferencesFactory().getPortletPreferencesIds(
124                            request, portletId);
125            }
126    
127            public static PortletPreferencesIds getPortletPreferencesIds(
128                            long scopeGroupId, long userId, Layout layout, String portletId,
129                            boolean modeEditGuest)
130                    throws PortalException, SystemException {
131    
132                    return getPortletPreferencesFactory().getPortletPreferencesIds(
133                            scopeGroupId, userId, layout, portletId, modeEditGuest);
134            }
135    
136            public static PortletPreferences getPortletSetup(
137                            HttpServletRequest request, String portletId)
138                    throws PortalException, SystemException {
139    
140                    return getPortletPreferencesFactory().getPortletSetup(
141                            request, portletId);
142            }
143    
144            public static PortletPreferences getPortletSetup(
145                            HttpServletRequest request, String portletId,
146                            String defaultPreferences)
147                    throws PortalException, SystemException {
148    
149                    return getPortletPreferencesFactory().getPortletSetup(
150                            request, portletId, defaultPreferences);
151            }
152    
153            public static PortletPreferences getPortletSetup(
154                            Layout layout, String portletId, String defaultPreferences)
155                    throws SystemException {
156    
157                    return getPortletPreferencesFactory().getPortletSetup(
158                            layout, portletId, defaultPreferences);
159            }
160    
161            public static PortletPreferences getPortletSetup(
162                            long scopeGroupId, Layout layout, String portletId,
163                            String defaultPreferences)
164                    throws SystemException {
165    
166                    return getPortletPreferencesFactory().getPortletSetup(
167                            scopeGroupId, layout, portletId, defaultPreferences);
168            }
169    
170            public static PortletPreferences getPortletSetup(
171                            PortletRequest portletRequest)
172                    throws PortalException, SystemException {
173    
174                    return getPortletPreferencesFactory().getPortletSetup(portletRequest);
175            }
176    
177            public static PortletPreferences getPortletSetup(
178                            PortletRequest portletRequest, String portletId)
179                    throws PortalException, SystemException {
180    
181                    return getPortletPreferencesFactory().getPortletSetup(
182                            portletRequest, portletId);
183            }
184    
185            public static Map<Long, PortletPreferences> getPortletSetupMap(
186                            long companyId, long groupId, long ownerId, int ownerType,
187                            String portletId, boolean privateLayout)
188                    throws SystemException {
189    
190                    return getPortletPreferencesFactory().getPortletSetupMap(
191                            companyId, groupId, ownerId, ownerType, portletId, privateLayout);
192            }
193    
194            public static PortletPreferences getPreferences(
195                    HttpServletRequest request) {
196    
197                    return getPortletPreferencesFactory().getPreferences(request);
198            }
199    
200            public static PreferencesValidator getPreferencesValidator(
201                    Portlet portlet) {
202    
203                    return getPortletPreferencesFactory().getPreferencesValidator(portlet);
204            }
205    
206            public static PortletPreferences getStrictLayoutPortletSetup(
207                            Layout layout, String portletId)
208                    throws SystemException {
209    
210                    return getPortletPreferencesFactory().getStrictLayoutPortletSetup(
211                            layout, portletId);
212            }
213    
214            public static String toXML(PortalPreferences portalPreferences) {
215                    return getPortletPreferencesFactory().toXML(portalPreferences);
216            }
217    
218            public static String toXML(PortletPreferences portletPreferences) {
219                    return getPortletPreferencesFactory().toXML(portletPreferences);
220            }
221    
222            public void setPortletPreferencesFactory(
223                    PortletPreferencesFactory portletPreferencesFactory) {
224    
225                    _portletPreferencesFactory = portletPreferencesFactory;
226            }
227    
228            private static PortletPreferencesFactory _portletPreferencesFactory;
229    
230    }