1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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  /**
34   * <a href="WebsiteUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class WebsiteUtil {
40      public static com.liferay.portal.model.Website create(long websiteId) {
41          return getPersistence().create(websiteId);
42      }
43  
44      public static com.liferay.portal.model.Website remove(long websiteId)
45          throws com.liferay.portal.SystemException, 
46              com.liferay.portal.NoSuchWebsiteException {
47          ModelListener listener = _getListener();
48  
49          if (listener != null) {
50              listener.onBeforeRemove(findByPrimaryKey(websiteId));
51          }
52  
53          com.liferay.portal.model.Website website = getPersistence().remove(websiteId);
54  
55          if (listener != null) {
56              listener.onAfterRemove(website);
57          }
58  
59          return website;
60      }
61  
62      public static com.liferay.portal.model.Website remove(
63          com.liferay.portal.model.Website website)
64          throws com.liferay.portal.SystemException {
65          ModelListener listener = _getListener();
66  
67          if (listener != null) {
68              listener.onBeforeRemove(website);
69          }
70  
71          website = getPersistence().remove(website);
72  
73          if (listener != null) {
74              listener.onAfterRemove(website);
75          }
76  
77          return website;
78      }
79  
80      public static com.liferay.portal.model.Website update(
81          com.liferay.portal.model.Website website)
82          throws com.liferay.portal.SystemException {
83          ModelListener listener = _getListener();
84          boolean isNew = website.isNew();
85  
86          if (listener != null) {
87              if (isNew) {
88                  listener.onBeforeCreate(website);
89              }
90              else {
91                  listener.onBeforeUpdate(website);
92              }
93          }
94  
95          website = getPersistence().update(website);
96  
97          if (listener != null) {
98              if (isNew) {
99                  listener.onAfterCreate(website);
100             }
101             else {
102                 listener.onAfterUpdate(website);
103             }
104         }
105 
106         return website;
107     }
108 
109     public static com.liferay.portal.model.Website update(
110         com.liferay.portal.model.Website website, boolean merge)
111         throws com.liferay.portal.SystemException {
112         ModelListener listener = _getListener();
113         boolean isNew = website.isNew();
114 
115         if (listener != null) {
116             if (isNew) {
117                 listener.onBeforeCreate(website);
118             }
119             else {
120                 listener.onBeforeUpdate(website);
121             }
122         }
123 
124         website = getPersistence().update(website, merge);
125 
126         if (listener != null) {
127             if (isNew) {
128                 listener.onAfterCreate(website);
129             }
130             else {
131                 listener.onAfterUpdate(website);
132             }
133         }
134 
135         return website;
136     }
137 
138     public static com.liferay.portal.model.Website findByPrimaryKey(
139         long websiteId)
140         throws com.liferay.portal.SystemException, 
141             com.liferay.portal.NoSuchWebsiteException {
142         return getPersistence().findByPrimaryKey(websiteId);
143     }
144 
145     public static com.liferay.portal.model.Website fetchByPrimaryKey(
146         long websiteId) throws com.liferay.portal.SystemException {
147         return getPersistence().fetchByPrimaryKey(websiteId);
148     }
149 
150     public static java.util.List findByCompanyId(long companyId)
151         throws com.liferay.portal.SystemException {
152         return getPersistence().findByCompanyId(companyId);
153     }
154 
155     public static java.util.List findByCompanyId(long companyId, int begin,
156         int end) throws com.liferay.portal.SystemException {
157         return getPersistence().findByCompanyId(companyId, begin, end);
158     }
159 
160     public static java.util.List findByCompanyId(long companyId, int begin,
161         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
162         throws com.liferay.portal.SystemException {
163         return getPersistence().findByCompanyId(companyId, begin, end, obc);
164     }
165 
166     public static com.liferay.portal.model.Website findByCompanyId_First(
167         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
168         throws com.liferay.portal.SystemException, 
169             com.liferay.portal.NoSuchWebsiteException {
170         return getPersistence().findByCompanyId_First(companyId, obc);
171     }
172 
173     public static com.liferay.portal.model.Website findByCompanyId_Last(
174         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
175         throws com.liferay.portal.SystemException, 
176             com.liferay.portal.NoSuchWebsiteException {
177         return getPersistence().findByCompanyId_Last(companyId, obc);
178     }
179 
180     public static com.liferay.portal.model.Website[] findByCompanyId_PrevAndNext(
181         long websiteId, long companyId,
182         com.liferay.portal.kernel.util.OrderByComparator obc)
183         throws com.liferay.portal.SystemException, 
184             com.liferay.portal.NoSuchWebsiteException {
185         return getPersistence().findByCompanyId_PrevAndNext(websiteId,
186             companyId, obc);
187     }
188 
189     public static java.util.List findByUserId(long userId)
190         throws com.liferay.portal.SystemException {
191         return getPersistence().findByUserId(userId);
192     }
193 
194     public static java.util.List findByUserId(long userId, int begin, int end)
195         throws com.liferay.portal.SystemException {
196         return getPersistence().findByUserId(userId, begin, end);
197     }
198 
199     public static java.util.List findByUserId(long userId, int begin, int end,
200         com.liferay.portal.kernel.util.OrderByComparator obc)
201         throws com.liferay.portal.SystemException {
202         return getPersistence().findByUserId(userId, begin, end, obc);
203     }
204 
205     public static com.liferay.portal.model.Website findByUserId_First(
206         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
207         throws com.liferay.portal.SystemException, 
208             com.liferay.portal.NoSuchWebsiteException {
209         return getPersistence().findByUserId_First(userId, obc);
210     }
211 
212     public static com.liferay.portal.model.Website findByUserId_Last(
213         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
214         throws com.liferay.portal.SystemException, 
215             com.liferay.portal.NoSuchWebsiteException {
216         return getPersistence().findByUserId_Last(userId, obc);
217     }
218 
219     public static com.liferay.portal.model.Website[] findByUserId_PrevAndNext(
220         long websiteId, long userId,
221         com.liferay.portal.kernel.util.OrderByComparator obc)
222         throws com.liferay.portal.SystemException, 
223             com.liferay.portal.NoSuchWebsiteException {
224         return getPersistence().findByUserId_PrevAndNext(websiteId, userId, obc);
225     }
226 
227     public static java.util.List findByC_C(long companyId, long classNameId)
228         throws com.liferay.portal.SystemException {
229         return getPersistence().findByC_C(companyId, classNameId);
230     }
231 
232     public static java.util.List findByC_C(long companyId, long classNameId,
233         int begin, int end) throws com.liferay.portal.SystemException {
234         return getPersistence().findByC_C(companyId, classNameId, begin, end);
235     }
236 
237     public static java.util.List findByC_C(long companyId, long classNameId,
238         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
239         throws com.liferay.portal.SystemException {
240         return getPersistence().findByC_C(companyId, classNameId, begin, end,
241             obc);
242     }
243 
244     public static com.liferay.portal.model.Website findByC_C_First(
245         long companyId, long classNameId,
246         com.liferay.portal.kernel.util.OrderByComparator obc)
247         throws com.liferay.portal.SystemException, 
248             com.liferay.portal.NoSuchWebsiteException {
249         return getPersistence().findByC_C_First(companyId, classNameId, obc);
250     }
251 
252     public static com.liferay.portal.model.Website findByC_C_Last(
253         long companyId, long classNameId,
254         com.liferay.portal.kernel.util.OrderByComparator obc)
255         throws com.liferay.portal.SystemException, 
256             com.liferay.portal.NoSuchWebsiteException {
257         return getPersistence().findByC_C_Last(companyId, classNameId, obc);
258     }
259 
260     public static com.liferay.portal.model.Website[] findByC_C_PrevAndNext(
261         long websiteId, long companyId, long classNameId,
262         com.liferay.portal.kernel.util.OrderByComparator obc)
263         throws com.liferay.portal.SystemException, 
264             com.liferay.portal.NoSuchWebsiteException {
265         return getPersistence().findByC_C_PrevAndNext(websiteId, companyId,
266             classNameId, obc);
267     }
268 
269     public static java.util.List findByC_C_C(long companyId, long classNameId,
270         long classPK) throws com.liferay.portal.SystemException {
271         return getPersistence().findByC_C_C(companyId, classNameId, classPK);
272     }
273 
274     public static java.util.List findByC_C_C(long companyId, long classNameId,
275         long classPK, int begin, int end)
276         throws com.liferay.portal.SystemException {
277         return getPersistence().findByC_C_C(companyId, classNameId, classPK,
278             begin, end);
279     }
280 
281     public static java.util.List findByC_C_C(long companyId, long classNameId,
282         long classPK, int begin, int end,
283         com.liferay.portal.kernel.util.OrderByComparator obc)
284         throws com.liferay.portal.SystemException {
285         return getPersistence().findByC_C_C(companyId, classNameId, classPK,
286             begin, end, obc);
287     }
288 
289     public static com.liferay.portal.model.Website findByC_C_C_First(
290         long companyId, long classNameId, long classPK,
291         com.liferay.portal.kernel.util.OrderByComparator obc)
292         throws com.liferay.portal.SystemException, 
293             com.liferay.portal.NoSuchWebsiteException {
294         return getPersistence().findByC_C_C_First(companyId, classNameId,
295             classPK, obc);
296     }
297 
298     public static com.liferay.portal.model.Website findByC_C_C_Last(
299         long companyId, long classNameId, long classPK,
300         com.liferay.portal.kernel.util.OrderByComparator obc)
301         throws com.liferay.portal.SystemException, 
302             com.liferay.portal.NoSuchWebsiteException {
303         return getPersistence().findByC_C_C_Last(companyId, classNameId,
304             classPK, obc);
305     }
306 
307     public static com.liferay.portal.model.Website[] findByC_C_C_PrevAndNext(
308         long websiteId, long companyId, long classNameId, long classPK,
309         com.liferay.portal.kernel.util.OrderByComparator obc)
310         throws com.liferay.portal.SystemException, 
311             com.liferay.portal.NoSuchWebsiteException {
312         return getPersistence().findByC_C_C_PrevAndNext(websiteId, companyId,
313             classNameId, classPK, obc);
314     }
315 
316     public static java.util.List findByC_C_C_P(long companyId,
317         long classNameId, long classPK, boolean primary)
318         throws com.liferay.portal.SystemException {
319         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
320             primary);
321     }
322 
323     public static java.util.List findByC_C_C_P(long companyId,
324         long classNameId, long classPK, boolean primary, int begin, int end)
325         throws com.liferay.portal.SystemException {
326         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
327             primary, begin, end);
328     }
329 
330     public static java.util.List findByC_C_C_P(long companyId,
331         long classNameId, long classPK, boolean primary, int begin, int end,
332         com.liferay.portal.kernel.util.OrderByComparator obc)
333         throws com.liferay.portal.SystemException {
334         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
335             primary, begin, end, obc);
336     }
337 
338     public static com.liferay.portal.model.Website findByC_C_C_P_First(
339         long companyId, long classNameId, long classPK, boolean primary,
340         com.liferay.portal.kernel.util.OrderByComparator obc)
341         throws com.liferay.portal.SystemException, 
342             com.liferay.portal.NoSuchWebsiteException {
343         return getPersistence().findByC_C_C_P_First(companyId, classNameId,
344             classPK, primary, obc);
345     }
346 
347     public static com.liferay.portal.model.Website findByC_C_C_P_Last(
348         long companyId, long classNameId, long classPK, boolean primary,
349         com.liferay.portal.kernel.util.OrderByComparator obc)
350         throws com.liferay.portal.SystemException, 
351             com.liferay.portal.NoSuchWebsiteException {
352         return getPersistence().findByC_C_C_P_Last(companyId, classNameId,
353             classPK, primary, obc);
354     }
355 
356     public static com.liferay.portal.model.Website[] findByC_C_C_P_PrevAndNext(
357         long websiteId, long companyId, long classNameId, long classPK,
358         boolean primary, com.liferay.portal.kernel.util.OrderByComparator obc)
359         throws com.liferay.portal.SystemException, 
360             com.liferay.portal.NoSuchWebsiteException {
361         return getPersistence().findByC_C_C_P_PrevAndNext(websiteId, companyId,
362             classNameId, classPK, primary, obc);
363     }
364 
365     public static java.util.List findWithDynamicQuery(
366         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
367         throws com.liferay.portal.SystemException {
368         return getPersistence().findWithDynamicQuery(queryInitializer);
369     }
370 
371     public static java.util.List findWithDynamicQuery(
372         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
373         int begin, int end) throws com.liferay.portal.SystemException {
374         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
375             end);
376     }
377 
378     public static java.util.List findAll()
379         throws com.liferay.portal.SystemException {
380         return getPersistence().findAll();
381     }
382 
383     public static java.util.List findAll(int begin, int end)
384         throws com.liferay.portal.SystemException {
385         return getPersistence().findAll(begin, end);
386     }
387 
388     public static java.util.List findAll(int begin, int end,
389         com.liferay.portal.kernel.util.OrderByComparator obc)
390         throws com.liferay.portal.SystemException {
391         return getPersistence().findAll(begin, end, obc);
392     }
393 
394     public static void removeByCompanyId(long companyId)
395         throws com.liferay.portal.SystemException {
396         getPersistence().removeByCompanyId(companyId);
397     }
398 
399     public static void removeByUserId(long userId)
400         throws com.liferay.portal.SystemException {
401         getPersistence().removeByUserId(userId);
402     }
403 
404     public static void removeByC_C(long companyId, long classNameId)
405         throws com.liferay.portal.SystemException {
406         getPersistence().removeByC_C(companyId, classNameId);
407     }
408 
409     public static void removeByC_C_C(long companyId, long classNameId,
410         long classPK) throws com.liferay.portal.SystemException {
411         getPersistence().removeByC_C_C(companyId, classNameId, classPK);
412     }
413 
414     public static void removeByC_C_C_P(long companyId, long classNameId,
415         long classPK, boolean primary)
416         throws com.liferay.portal.SystemException {
417         getPersistence().removeByC_C_C_P(companyId, classNameId, classPK,
418             primary);
419     }
420 
421     public static void removeAll() throws com.liferay.portal.SystemException {
422         getPersistence().removeAll();
423     }
424 
425     public static int countByCompanyId(long companyId)
426         throws com.liferay.portal.SystemException {
427         return getPersistence().countByCompanyId(companyId);
428     }
429 
430     public static int countByUserId(long userId)
431         throws com.liferay.portal.SystemException {
432         return getPersistence().countByUserId(userId);
433     }
434 
435     public static int countByC_C(long companyId, long classNameId)
436         throws com.liferay.portal.SystemException {
437         return getPersistence().countByC_C(companyId, classNameId);
438     }
439 
440     public static int countByC_C_C(long companyId, long classNameId,
441         long classPK) throws com.liferay.portal.SystemException {
442         return getPersistence().countByC_C_C(companyId, classNameId, classPK);
443     }
444 
445     public static int countByC_C_C_P(long companyId, long classNameId,
446         long classPK, boolean primary)
447         throws com.liferay.portal.SystemException {
448         return getPersistence().countByC_C_C_P(companyId, classNameId, classPK,
449             primary);
450     }
451 
452     public static int countAll() throws com.liferay.portal.SystemException {
453         return getPersistence().countAll();
454     }
455 
456     public static WebsitePersistence getPersistence() {
457         return _getUtil()._persistence;
458     }
459 
460     public void setPersistence(WebsitePersistence persistence) {
461         _persistence = persistence;
462     }
463 
464     private static WebsiteUtil _getUtil() {
465         if (_util == null) {
466             _util = (WebsiteUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
467         }
468 
469         return _util;
470     }
471 
472     private static ModelListener _getListener() {
473         if (Validator.isNotNull(_LISTENER)) {
474             try {
475                 return (ModelListener)Class.forName(_LISTENER).newInstance();
476             }
477             catch (Exception e) {
478                 _log.error(e);
479             }
480         }
481 
482         return null;
483     }
484 
485     private static final String _UTIL = WebsiteUtil.class.getName();
486     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
487                 "value.object.listener.com.liferay.portal.model.Website"));
488     private static Log _log = LogFactory.getLog(WebsiteUtil.class);
489     private static WebsiteUtil _util;
490     private WebsitePersistence _persistence;
491 }