001    /**
002     * Copyright (c) 2000-2013 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.exception.SystemException;
021    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
022    import com.liferay.portal.model.Layout;
023    import com.liferay.portal.model.Portlet;
024    import com.liferay.portal.model.PortletPreferencesIds;
025    import com.liferay.portal.theme.ThemeDisplay;
026    
027    import java.util.Map;
028    
029    import javax.portlet.PortletPreferences;
030    import javax.portlet.PortletRequest;
031    import javax.portlet.PreferencesValidator;
032    
033    import javax.servlet.http.HttpServletRequest;
034    import javax.servlet.http.HttpSession;
035    
036    /**
037     * @author Brian Wing Shun Chan
038     */
039    @ProviderType
040    public class PortletPreferencesFactoryUtil {
041    
042            public static void checkControlPanelPortletPreferences(
043                            ThemeDisplay themeDisplay, Portlet portlet)
044                    throws PortalException, SystemException {
045    
046                    getPortletPreferencesFactory().checkControlPanelPortletPreferences(
047                            themeDisplay, portlet);
048            }
049    
050            public static PortletPreferences fromDefaultXML(String xml)
051                    throws SystemException {
052    
053                    return getPortletPreferencesFactory().fromDefaultXML(xml);
054            }
055    
056            public static PortalPreferences fromXML(
057                            long ownerId, int ownerType, String xml)
058                    throws SystemException {
059    
060                    return getPortletPreferencesFactory().fromXML(ownerId, ownerType, xml);
061            }
062    
063            public static PortletPreferences fromXML(
064                            long companyId, long ownerId, int ownerType, long plid,
065                            String portletId, String xml)
066                    throws SystemException {
067    
068                    return getPortletPreferencesFactory().fromXML(
069                            companyId, ownerId, ownerType, plid, portletId, xml);
070            }
071    
072            /**
073             * @deprecated As of 6.2.0, replaced by {@link #fromXML(long, int, String)}
074             */
075            public static PortalPreferences fromXML(
076                            long companyId, long ownerId, int ownerType, String xml)
077                    throws SystemException {
078    
079                    return getPortletPreferencesFactory().fromXML(
080                            companyId, ownerId, ownerType, xml);
081            }
082    
083            public static PortletPreferences getLayoutPortletSetup(
084                            Layout layout, String portletId)
085                    throws SystemException {
086    
087                    return getPortletPreferencesFactory().getLayoutPortletSetup(
088                            layout, portletId);
089            }
090    
091            public static PortletPreferences getLayoutPortletSetup(
092                            Layout layout, String portletId, String defaultPreferences)
093                    throws SystemException {
094    
095                    return getPortletPreferencesFactory().getLayoutPortletSetup(
096                            layout, portletId, defaultPreferences);
097            }
098    
099            public static PortalPreferences getPortalPreferences(
100                            HttpServletRequest request)
101                    throws SystemException {
102    
103                    return getPortletPreferencesFactory().getPortalPreferences(request);
104            }
105    
106            public static PortalPreferences getPortalPreferences(
107                            HttpSession session, long userId, boolean signedIn)
108                    throws SystemException {
109    
110                    return getPortletPreferencesFactory().getPortalPreferences(
111                            session, userId, signedIn);
112            }
113    
114            /**
115             * @deprecated As of 6.2.0, replaced by {@link
116             *             #getPortalPreferences(HttpSession, long, boolean)}
117             */
118            public static PortalPreferences getPortalPreferences(
119                            HttpSession session, long companyId, long userId, boolean signedIn)
120                    throws SystemException {
121    
122                    return getPortletPreferencesFactory().getPortalPreferences(
123                            session, companyId, userId, signedIn);
124            }
125    
126            public static PortalPreferences getPortalPreferences(
127                            long userId, boolean signedIn)
128                    throws SystemException {
129    
130                    return getPortletPreferencesFactory().getPortalPreferences(
131                            userId, signedIn);
132            }
133    
134            /**
135             * @deprecated As of 6.2.0, replaced by {@link #getPortalPreferences(long,
136             *             boolean)}
137             */
138            public static PortalPreferences getPortalPreferences(
139                            long companyId, long userId, boolean signedIn)
140                    throws SystemException {
141    
142                    return getPortletPreferencesFactory().getPortalPreferences(
143                            companyId, userId, signedIn);
144            }
145    
146            public static PortalPreferences getPortalPreferences(
147                            PortletRequest portletRequest)
148                    throws SystemException {
149    
150                    return getPortletPreferencesFactory().getPortalPreferences(
151                            portletRequest);
152            }
153    
154            public static PortletPreferences getPortletPreferences(
155                            HttpServletRequest request, String portletId)
156                    throws PortalException, SystemException {
157    
158                    return getPortletPreferencesFactory().getPortletPreferences(
159                            request, portletId);
160            }
161    
162            public static PortletPreferencesFactory getPortletPreferencesFactory() {
163                    PortalRuntimePermission.checkGetBeanProperty(
164                            PortletPreferencesFactoryUtil.class);
165    
166                    return _portletPreferencesFactory;
167            }
168    
169            public static PortletPreferencesIds getPortletPreferencesIds(
170                            HttpServletRequest request, Layout selLayout, String portletId)
171                    throws PortalException, SystemException {
172    
173                    return getPortletPreferencesFactory().getPortletPreferencesIds(
174                            request, selLayout, portletId);
175            }
176    
177            public static PortletPreferencesIds getPortletPreferencesIds(
178                            HttpServletRequest request, String portletId)
179                    throws PortalException, SystemException {
180    
181                    return getPortletPreferencesFactory().getPortletPreferencesIds(
182                            request, portletId);
183            }
184    
185            public static PortletPreferencesIds getPortletPreferencesIds(
186                            long scopeGroupId, long userId, Layout layout, String portletId,
187                            boolean modeEditGuest)
188                    throws PortalException, SystemException {
189    
190                    return getPortletPreferencesFactory().getPortletPreferencesIds(
191                            scopeGroupId, userId, layout, portletId, modeEditGuest);
192            }
193    
194            public static PortletPreferences getPortletSetup(
195                            HttpServletRequest request, String portletId)
196                    throws PortalException, SystemException {
197    
198                    return getPortletPreferencesFactory().getPortletSetup(
199                            request, portletId);
200            }
201    
202            public static PortletPreferences getPortletSetup(
203                            HttpServletRequest request, String portletId,
204                            String defaultPreferences)
205                    throws PortalException, SystemException {
206    
207                    return getPortletPreferencesFactory().getPortletSetup(
208                            request, portletId, defaultPreferences);
209            }
210    
211            public static PortletPreferences getPortletSetup(
212                            Layout layout, String portletId, String defaultPreferences)
213                    throws SystemException {
214    
215                    return getPortletPreferencesFactory().getPortletSetup(
216                            layout, portletId, defaultPreferences);
217            }
218    
219            public static PortletPreferences getPortletSetup(
220                            long scopeGroupId, Layout layout, String portletId,
221                            String defaultPreferences)
222                    throws SystemException {
223    
224                    return getPortletPreferencesFactory().getPortletSetup(
225                            scopeGroupId, layout, portletId, defaultPreferences);
226            }
227    
228            public static PortletPreferences getPortletSetup(
229                            PortletRequest portletRequest)
230                    throws PortalException, SystemException {
231    
232                    return getPortletPreferencesFactory().getPortletSetup(portletRequest);
233            }
234    
235            public static PortletPreferences getPortletSetup(
236                            PortletRequest portletRequest, String portletId)
237                    throws PortalException, SystemException {
238    
239                    return getPortletPreferencesFactory().getPortletSetup(
240                            portletRequest, portletId);
241            }
242    
243            public static Map<Long, PortletPreferences> getPortletSetupMap(
244                            long companyId, long groupId, long ownerId, int ownerType,
245                            String portletId, boolean privateLayout)
246                    throws SystemException {
247    
248                    return getPortletPreferencesFactory().getPortletSetupMap(
249                            companyId, groupId, ownerId, ownerType, portletId, privateLayout);
250            }
251    
252            public static PortletPreferences getPreferences(
253                    HttpServletRequest request) {
254    
255                    return getPortletPreferencesFactory().getPreferences(request);
256            }
257    
258            public static PreferencesValidator getPreferencesValidator(
259                    Portlet portlet) {
260    
261                    return getPortletPreferencesFactory().getPreferencesValidator(portlet);
262            }
263    
264            public static PortletPreferences getStrictLayoutPortletSetup(
265                            Layout layout, String portletId)
266                    throws SystemException {
267    
268                    return getPortletPreferencesFactory().getStrictLayoutPortletSetup(
269                            layout, portletId);
270            }
271    
272            public static PortletPreferences getStrictPortletSetup(
273                            Layout layout, String portletId)
274                    throws SystemException {
275    
276                    return getPortletPreferencesFactory().getStrictPortletSetup(
277                            layout, portletId);
278            }
279    
280            public static PortletPreferences strictFromXML(
281                            long companyId, long ownerId, int ownerType, long plid,
282                            String portletId, String xml)
283                    throws SystemException {
284    
285                    return getPortletPreferencesFactory().strictFromXML(
286                            companyId, ownerId, ownerType, plid, portletId, xml);
287            }
288    
289            public static String toXML(PortalPreferences portalPreferences) {
290                    return getPortletPreferencesFactory().toXML(portalPreferences);
291            }
292    
293            public static String toXML(PortletPreferences portletPreferences) {
294                    return getPortletPreferencesFactory().toXML(portletPreferences);
295            }
296    
297            public void setPortletPreferencesFactory(
298                    PortletPreferencesFactory portletPreferencesFactory) {
299    
300                    PortalRuntimePermission.checkSetBeanProperty(getClass());
301    
302                    _portletPreferencesFactory = portletPreferencesFactory;
303            }
304    
305            private static PortletPreferencesFactory _portletPreferencesFactory;
306    
307    }