1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.kernel.util.GetterUtil;
26 import com.liferay.portal.kernel.util.Validator;
27 import com.liferay.portal.model.ModelListener;
28 import com.liferay.portal.util.PropsUtil;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32
33
39 public class PortletPreferencesUtil {
40 public static com.liferay.portal.model.PortletPreferences create(
41 long portletPreferencesId) {
42 return getPersistence().create(portletPreferencesId);
43 }
44
45 public static com.liferay.portal.model.PortletPreferences remove(
46 long portletPreferencesId)
47 throws com.liferay.portal.SystemException,
48 com.liferay.portal.NoSuchPortletPreferencesException {
49 ModelListener listener = _getListener();
50
51 if (listener != null) {
52 listener.onBeforeRemove(findByPrimaryKey(portletPreferencesId));
53 }
54
55 com.liferay.portal.model.PortletPreferences portletPreferences = getPersistence()
56 .remove(portletPreferencesId);
57
58 if (listener != null) {
59 listener.onAfterRemove(portletPreferences);
60 }
61
62 return portletPreferences;
63 }
64
65 public static com.liferay.portal.model.PortletPreferences remove(
66 com.liferay.portal.model.PortletPreferences portletPreferences)
67 throws com.liferay.portal.SystemException {
68 ModelListener listener = _getListener();
69
70 if (listener != null) {
71 listener.onBeforeRemove(portletPreferences);
72 }
73
74 portletPreferences = getPersistence().remove(portletPreferences);
75
76 if (listener != null) {
77 listener.onAfterRemove(portletPreferences);
78 }
79
80 return portletPreferences;
81 }
82
83 public static com.liferay.portal.model.PortletPreferences update(
84 com.liferay.portal.model.PortletPreferences portletPreferences)
85 throws com.liferay.portal.SystemException {
86 ModelListener listener = _getListener();
87 boolean isNew = portletPreferences.isNew();
88
89 if (listener != null) {
90 if (isNew) {
91 listener.onBeforeCreate(portletPreferences);
92 }
93 else {
94 listener.onBeforeUpdate(portletPreferences);
95 }
96 }
97
98 portletPreferences = getPersistence().update(portletPreferences);
99
100 if (listener != null) {
101 if (isNew) {
102 listener.onAfterCreate(portletPreferences);
103 }
104 else {
105 listener.onAfterUpdate(portletPreferences);
106 }
107 }
108
109 return portletPreferences;
110 }
111
112 public static com.liferay.portal.model.PortletPreferences update(
113 com.liferay.portal.model.PortletPreferences portletPreferences,
114 boolean merge) throws com.liferay.portal.SystemException {
115 ModelListener listener = _getListener();
116 boolean isNew = portletPreferences.isNew();
117
118 if (listener != null) {
119 if (isNew) {
120 listener.onBeforeCreate(portletPreferences);
121 }
122 else {
123 listener.onBeforeUpdate(portletPreferences);
124 }
125 }
126
127 portletPreferences = getPersistence().update(portletPreferences, merge);
128
129 if (listener != null) {
130 if (isNew) {
131 listener.onAfterCreate(portletPreferences);
132 }
133 else {
134 listener.onAfterUpdate(portletPreferences);
135 }
136 }
137
138 return portletPreferences;
139 }
140
141 public static com.liferay.portal.model.PortletPreferences findByPrimaryKey(
142 long portletPreferencesId)
143 throws com.liferay.portal.SystemException,
144 com.liferay.portal.NoSuchPortletPreferencesException {
145 return getPersistence().findByPrimaryKey(portletPreferencesId);
146 }
147
148 public static com.liferay.portal.model.PortletPreferences fetchByPrimaryKey(
149 long portletPreferencesId) throws com.liferay.portal.SystemException {
150 return getPersistence().fetchByPrimaryKey(portletPreferencesId);
151 }
152
153 public static java.util.List findByPlid(long plid)
154 throws com.liferay.portal.SystemException {
155 return getPersistence().findByPlid(plid);
156 }
157
158 public static java.util.List findByPlid(long plid, int begin, int end)
159 throws com.liferay.portal.SystemException {
160 return getPersistence().findByPlid(plid, begin, end);
161 }
162
163 public static java.util.List findByPlid(long plid, int begin, int end,
164 com.liferay.portal.kernel.util.OrderByComparator obc)
165 throws com.liferay.portal.SystemException {
166 return getPersistence().findByPlid(plid, begin, end, obc);
167 }
168
169 public static com.liferay.portal.model.PortletPreferences findByPlid_First(
170 long plid, com.liferay.portal.kernel.util.OrderByComparator obc)
171 throws com.liferay.portal.SystemException,
172 com.liferay.portal.NoSuchPortletPreferencesException {
173 return getPersistence().findByPlid_First(plid, obc);
174 }
175
176 public static com.liferay.portal.model.PortletPreferences findByPlid_Last(
177 long plid, com.liferay.portal.kernel.util.OrderByComparator obc)
178 throws com.liferay.portal.SystemException,
179 com.liferay.portal.NoSuchPortletPreferencesException {
180 return getPersistence().findByPlid_Last(plid, obc);
181 }
182
183 public static com.liferay.portal.model.PortletPreferences[] findByPlid_PrevAndNext(
184 long portletPreferencesId, long plid,
185 com.liferay.portal.kernel.util.OrderByComparator obc)
186 throws com.liferay.portal.SystemException,
187 com.liferay.portal.NoSuchPortletPreferencesException {
188 return getPersistence().findByPlid_PrevAndNext(portletPreferencesId,
189 plid, obc);
190 }
191
192 public static java.util.List findByO_O_P(long ownerId, int ownerType,
193 long plid) throws com.liferay.portal.SystemException {
194 return getPersistence().findByO_O_P(ownerId, ownerType, plid);
195 }
196
197 public static java.util.List findByO_O_P(long ownerId, int ownerType,
198 long plid, int begin, int end)
199 throws com.liferay.portal.SystemException {
200 return getPersistence().findByO_O_P(ownerId, ownerType, plid, begin, end);
201 }
202
203 public static java.util.List findByO_O_P(long ownerId, int ownerType,
204 long plid, int begin, int end,
205 com.liferay.portal.kernel.util.OrderByComparator obc)
206 throws com.liferay.portal.SystemException {
207 return getPersistence().findByO_O_P(ownerId, ownerType, plid, begin,
208 end, obc);
209 }
210
211 public static com.liferay.portal.model.PortletPreferences findByO_O_P_First(
212 long ownerId, int ownerType, long plid,
213 com.liferay.portal.kernel.util.OrderByComparator obc)
214 throws com.liferay.portal.SystemException,
215 com.liferay.portal.NoSuchPortletPreferencesException {
216 return getPersistence().findByO_O_P_First(ownerId, ownerType, plid, obc);
217 }
218
219 public static com.liferay.portal.model.PortletPreferences findByO_O_P_Last(
220 long ownerId, int ownerType, long plid,
221 com.liferay.portal.kernel.util.OrderByComparator obc)
222 throws com.liferay.portal.SystemException,
223 com.liferay.portal.NoSuchPortletPreferencesException {
224 return getPersistence().findByO_O_P_Last(ownerId, ownerType, plid, obc);
225 }
226
227 public static com.liferay.portal.model.PortletPreferences[] findByO_O_P_PrevAndNext(
228 long portletPreferencesId, long ownerId, int ownerType, long plid,
229 com.liferay.portal.kernel.util.OrderByComparator obc)
230 throws com.liferay.portal.SystemException,
231 com.liferay.portal.NoSuchPortletPreferencesException {
232 return getPersistence().findByO_O_P_PrevAndNext(portletPreferencesId,
233 ownerId, ownerType, plid, obc);
234 }
235
236 public static com.liferay.portal.model.PortletPreferences findByO_O_P_P(
237 long ownerId, int ownerType, long plid, java.lang.String portletId)
238 throws com.liferay.portal.SystemException,
239 com.liferay.portal.NoSuchPortletPreferencesException {
240 return getPersistence().findByO_O_P_P(ownerId, ownerType, plid,
241 portletId);
242 }
243
244 public static com.liferay.portal.model.PortletPreferences fetchByO_O_P_P(
245 long ownerId, int ownerType, long plid, java.lang.String portletId)
246 throws com.liferay.portal.SystemException {
247 return getPersistence().fetchByO_O_P_P(ownerId, ownerType, plid,
248 portletId);
249 }
250
251 public static java.util.List findWithDynamicQuery(
252 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
253 throws com.liferay.portal.SystemException {
254 return getPersistence().findWithDynamicQuery(queryInitializer);
255 }
256
257 public static java.util.List findWithDynamicQuery(
258 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
259 int begin, int end) throws com.liferay.portal.SystemException {
260 return getPersistence().findWithDynamicQuery(queryInitializer, begin,
261 end);
262 }
263
264 public static java.util.List findAll()
265 throws com.liferay.portal.SystemException {
266 return getPersistence().findAll();
267 }
268
269 public static java.util.List findAll(int begin, int end)
270 throws com.liferay.portal.SystemException {
271 return getPersistence().findAll(begin, end);
272 }
273
274 public static java.util.List findAll(int begin, int end,
275 com.liferay.portal.kernel.util.OrderByComparator obc)
276 throws com.liferay.portal.SystemException {
277 return getPersistence().findAll(begin, end, obc);
278 }
279
280 public static void removeByPlid(long plid)
281 throws com.liferay.portal.SystemException {
282 getPersistence().removeByPlid(plid);
283 }
284
285 public static void removeByO_O_P(long ownerId, int ownerType, long plid)
286 throws com.liferay.portal.SystemException {
287 getPersistence().removeByO_O_P(ownerId, ownerType, plid);
288 }
289
290 public static void removeByO_O_P_P(long ownerId, int ownerType, long plid,
291 java.lang.String portletId)
292 throws com.liferay.portal.SystemException,
293 com.liferay.portal.NoSuchPortletPreferencesException {
294 getPersistence().removeByO_O_P_P(ownerId, ownerType, plid, portletId);
295 }
296
297 public static void removeAll() throws com.liferay.portal.SystemException {
298 getPersistence().removeAll();
299 }
300
301 public static int countByPlid(long plid)
302 throws com.liferay.portal.SystemException {
303 return getPersistence().countByPlid(plid);
304 }
305
306 public static int countByO_O_P(long ownerId, int ownerType, long plid)
307 throws com.liferay.portal.SystemException {
308 return getPersistence().countByO_O_P(ownerId, ownerType, plid);
309 }
310
311 public static int countByO_O_P_P(long ownerId, int ownerType, long plid,
312 java.lang.String portletId) throws com.liferay.portal.SystemException {
313 return getPersistence().countByO_O_P_P(ownerId, ownerType, plid,
314 portletId);
315 }
316
317 public static int countAll() throws com.liferay.portal.SystemException {
318 return getPersistence().countAll();
319 }
320
321 public static PortletPreferencesPersistence getPersistence() {
322 return _getUtil()._persistence;
323 }
324
325 public void setPersistence(PortletPreferencesPersistence persistence) {
326 _persistence = persistence;
327 }
328
329 private static PortletPreferencesUtil _getUtil() {
330 if (_util == null) {
331 _util = (PortletPreferencesUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
332 }
333
334 return _util;
335 }
336
337 private static ModelListener _getListener() {
338 if (Validator.isNotNull(_LISTENER)) {
339 try {
340 return (ModelListener)Class.forName(_LISTENER).newInstance();
341 }
342 catch (Exception e) {
343 _log.error(e);
344 }
345 }
346
347 return null;
348 }
349
350 private static final String _UTIL = PortletPreferencesUtil.class.getName();
351 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
352 "value.object.listener.com.liferay.portal.model.PortletPreferences"));
353 private static Log _log = LogFactory.getLog(PortletPreferencesUtil.class);
354 private static PortletPreferencesUtil _util;
355 private PortletPreferencesPersistence _persistence;
356 }