001    /**
002     * Copyright (c) 2000-2010 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 javax.portlet.PortletPreferences;
024    import javax.portlet.PortletRequest;
025    import javax.portlet.PreferencesValidator;
026    
027    import javax.servlet.http.HttpServletRequest;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     */
032    public class PortletPreferencesFactoryUtil {
033    
034            public static PortletPreferences getLayoutPortletSetup(
035                            Layout layout, String portletId)
036                    throws SystemException {
037    
038                    return getPortletPreferencesFactory().getLayoutPortletSetup(
039                            layout, portletId);
040            }
041    
042            public static PortalPreferences getPortalPreferences(
043                            HttpServletRequest request)
044                    throws SystemException {
045    
046                    return getPortletPreferencesFactory().getPortalPreferences(request);
047            }
048    
049            public static PortalPreferences getPortalPreferences(
050                            PortletRequest portletRequest)
051                    throws SystemException {
052    
053                    return getPortletPreferencesFactory().getPortalPreferences(
054                            portletRequest);
055            }
056    
057            public static PortletPreferences getPortletPreferences(
058                            HttpServletRequest request, String portletId)
059                    throws PortalException, SystemException {
060    
061                    return getPortletPreferencesFactory().getPortletPreferences(
062                            request, portletId);
063            }
064    
065            public static PortletPreferencesFactory getPortletPreferencesFactory() {
066                    return _portletPreferencesFactory;
067            }
068    
069            public static PortletPreferencesIds getPortletPreferencesIds(
070                            HttpServletRequest request, String portletId)
071                    throws PortalException, SystemException {
072    
073                    return getPortletPreferencesFactory().getPortletPreferencesIds(
074                            request, portletId);
075            }
076    
077            public static PortletPreferencesIds getPortletPreferencesIds(
078                            HttpServletRequest request, Layout selLayout, String portletId)
079                    throws PortalException, SystemException {
080    
081                    return getPortletPreferencesFactory().getPortletPreferencesIds(
082                            request, selLayout, portletId);
083            }
084    
085            public static PortletPreferences getPortletSetup(
086                            Layout layout, String portletId, String defaultPreferences)
087                    throws SystemException {
088    
089                    return getPortletPreferencesFactory().getPortletSetup(
090                            layout, portletId, defaultPreferences);
091            }
092    
093            public static PortletPreferences getPortletSetup(
094                            HttpServletRequest request, String portletId)
095                    throws SystemException {
096    
097                    return getPortletPreferencesFactory().getPortletSetup(
098                            request, portletId);
099            }
100    
101            public static PortletPreferences getPortletSetup(
102                            HttpServletRequest request, String portletId,
103                            String defaultPreferences)
104                    throws SystemException {
105    
106                    return getPortletPreferencesFactory().getPortletSetup(
107                            request, portletId, defaultPreferences);
108            }
109    
110            public static PortletPreferences getPortletSetup(
111                            PortletRequest portletRequest)
112                    throws SystemException {
113    
114                    return getPortletPreferencesFactory().getPortletSetup(portletRequest);
115            }
116    
117            public static PortletPreferences getPortletSetup(
118                            PortletRequest portletRequest, String portletId)
119                    throws SystemException {
120    
121                    return getPortletPreferencesFactory().getPortletSetup(
122                            portletRequest, portletId);
123            }
124    
125            public static PortletPreferences getPreferences(
126                    HttpServletRequest request) {
127    
128                    return getPortletPreferencesFactory().getPreferences(request);
129            }
130    
131            public static PreferencesValidator getPreferencesValidator(
132                    Portlet portlet) {
133    
134                    return getPortletPreferencesFactory().getPreferencesValidator(portlet);
135            }
136    
137            public void setPortletPreferencesFactory(
138                    PortletPreferencesFactory portletPreferencesFactory) {
139    
140                    _portletPreferencesFactory = portletPreferencesFactory;
141            }
142    
143            private static PortletPreferencesFactory _portletPreferencesFactory;
144    
145    }