001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.bean.BeanLocatorUtil;
026: import com.liferay.portal.model.Layout;
027: import com.liferay.portal.model.Portlet;
028: import com.liferay.portal.model.PortletPreferencesIds;
029:
030: import javax.portlet.ActionRequest;
031: import javax.portlet.PortletPreferences;
032: import javax.portlet.PreferencesValidator;
033: import javax.portlet.RenderRequest;
034:
035: import javax.servlet.http.HttpServletRequest;
036:
037: /**
038: * <a href="PortletPreferencesFactoryUtil.java.html"><b><i>View Source</i></b>
039: * </a>
040: *
041: * @author Brian Wing Shun Chan
042: *
043: */
044: public class PortletPreferencesFactoryUtil {
045:
046: public static PortalPreferences getPortalPreferences(
047: HttpServletRequest req) throws PortalException,
048: SystemException {
049:
050: return getPortletPreferencesFactory().getPortalPreferences(req);
051: }
052:
053: public static PortalPreferences getPortalPreferences(
054: ActionRequest req) throws PortalException, SystemException {
055:
056: return getPortletPreferencesFactory().getPortalPreferences(req);
057: }
058:
059: public static PortalPreferences getPortalPreferences(
060: RenderRequest req) throws PortalException, SystemException {
061:
062: return getPortletPreferencesFactory().getPortalPreferences(req);
063: }
064:
065: public static PortletPreferences getPortletPreferences(
066: HttpServletRequest req, String portletId)
067: throws PortalException, SystemException {
068:
069: return getPortletPreferencesFactory().getPortletPreferences(
070: req, portletId);
071: }
072:
073: public static PortletPreferencesFactory getPortletPreferencesFactory() {
074: return _getUtil()._portletPreferencesFactory;
075: }
076:
077: public static PortletPreferencesIds getPortletPreferencesIds(
078: HttpServletRequest req, String portletId)
079: throws PortalException, SystemException {
080:
081: return getPortletPreferencesFactory().getPortletPreferencesIds(
082: req, portletId);
083: }
084:
085: public static PortletPreferencesIds getPortletPreferencesIds(
086: HttpServletRequest req, Layout selLayout, String portletId)
087: throws PortalException, SystemException {
088:
089: return getPortletPreferencesFactory().getPortletPreferencesIds(
090: req, selLayout, portletId);
091: }
092:
093: public static PortletPreferences getPortletSetup(Layout layout,
094: String portletId) throws PortalException, SystemException {
095:
096: return getPortletPreferencesFactory().getPortletSetup(layout,
097: portletId);
098: }
099:
100: public static PortletPreferences getPortletSetup(
101: HttpServletRequest req, String portletId,
102: boolean uniquePerLayout, boolean uniquePerGroup)
103: throws PortalException, SystemException {
104:
105: return getPortletPreferencesFactory().getPortletSetup(req,
106: portletId, uniquePerLayout, uniquePerGroup);
107: }
108:
109: public static PortletPreferences getPortletSetup(
110: HttpServletRequest req, String portletId,
111: boolean uniquePerLayout, boolean uniquePerGroup,
112: String defaultPreferences) throws PortalException,
113: SystemException {
114:
115: return getPortletPreferencesFactory().getPortletSetup(req,
116: portletId, uniquePerLayout, uniquePerGroup,
117: defaultPreferences);
118: }
119:
120: public static PortletPreferences getPortletSetup(Layout layout,
121: String portletId, boolean uniquePerLayout,
122: boolean uniquePerGroup, String defaultPreferences)
123: throws PortalException, SystemException {
124:
125: return getPortletPreferencesFactory().getPortletSetup(layout,
126: portletId, uniquePerLayout, uniquePerGroup,
127: defaultPreferences);
128: }
129:
130: public static PortletPreferences getPortletSetup(ActionRequest req,
131: String portletId, boolean uniquePerLayout,
132: boolean uniquePerGroup) throws PortalException,
133: SystemException {
134:
135: return getPortletPreferencesFactory().getPortletSetup(req,
136: portletId, uniquePerLayout, uniquePerGroup);
137: }
138:
139: public static PortletPreferences getPortletSetup(RenderRequest req,
140: String portletId, boolean uniquePerLayout,
141: boolean uniquePerGroup) throws PortalException,
142: SystemException {
143:
144: return getPortletPreferencesFactory().getPortletSetup(req,
145: portletId, uniquePerLayout, uniquePerGroup);
146: }
147:
148: public static PortletPreferences getPreferences(
149: HttpServletRequest req) {
150: return getPortletPreferencesFactory().getPreferences(req);
151: }
152:
153: public static PreferencesValidator getPreferencesValidator(
154: Portlet portlet) {
155:
156: return getPortletPreferencesFactory().getPreferencesValidator(
157: portlet);
158: }
159:
160: public void setPortletPreferencesFactory(
161: PortletPreferencesFactory portletPreferencesFactory) {
162:
163: _portletPreferencesFactory = portletPreferencesFactory;
164: }
165:
166: private static PortletPreferencesFactoryUtil _getUtil() {
167: if (_util == null) {
168: _util = (PortletPreferencesFactoryUtil) BeanLocatorUtil
169: .locate(_UTIL);
170: }
171:
172: return _util;
173: }
174:
175: private static final String _UTIL = PortletPreferencesFactoryUtil.class
176: .getName();
177:
178: private static PortletPreferencesFactoryUtil _util;
179:
180: private PortletPreferencesFactory _portletPreferencesFactory;
181:
182: }
|