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="EmailAddressUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class EmailAddressUtil {
40      public static com.liferay.portal.model.EmailAddress create(
41          long emailAddressId) {
42          return getPersistence().create(emailAddressId);
43      }
44  
45      public static com.liferay.portal.model.EmailAddress remove(
46          long emailAddressId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portal.NoSuchEmailAddressException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(emailAddressId));
53          }
54  
55          com.liferay.portal.model.EmailAddress emailAddress = getPersistence()
56                                                                   .remove(emailAddressId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(emailAddress);
60          }
61  
62          return emailAddress;
63      }
64  
65      public static com.liferay.portal.model.EmailAddress remove(
66          com.liferay.portal.model.EmailAddress emailAddress)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(emailAddress);
72          }
73  
74          emailAddress = getPersistence().remove(emailAddress);
75  
76          if (listener != null) {
77              listener.onAfterRemove(emailAddress);
78          }
79  
80          return emailAddress;
81      }
82  
83      public static com.liferay.portal.model.EmailAddress update(
84          com.liferay.portal.model.EmailAddress emailAddress)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = emailAddress.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(emailAddress);
92              }
93              else {
94                  listener.onBeforeUpdate(emailAddress);
95              }
96          }
97  
98          emailAddress = getPersistence().update(emailAddress);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(emailAddress);
103             }
104             else {
105                 listener.onAfterUpdate(emailAddress);
106             }
107         }
108 
109         return emailAddress;
110     }
111 
112     public static com.liferay.portal.model.EmailAddress update(
113         com.liferay.portal.model.EmailAddress emailAddress, boolean merge)
114         throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = emailAddress.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(emailAddress);
121             }
122             else {
123                 listener.onBeforeUpdate(emailAddress);
124             }
125         }
126 
127         emailAddress = getPersistence().update(emailAddress, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(emailAddress);
132             }
133             else {
134                 listener.onAfterUpdate(emailAddress);
135             }
136         }
137 
138         return emailAddress;
139     }
140 
141     public static com.liferay.portal.model.EmailAddress findByPrimaryKey(
142         long emailAddressId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portal.NoSuchEmailAddressException {
145         return getPersistence().findByPrimaryKey(emailAddressId);
146     }
147 
148     public static com.liferay.portal.model.EmailAddress fetchByPrimaryKey(
149         long emailAddressId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(emailAddressId);
151     }
152 
153     public static java.util.List findByCompanyId(long companyId)
154         throws com.liferay.portal.SystemException {
155         return getPersistence().findByCompanyId(companyId);
156     }
157 
158     public static java.util.List findByCompanyId(long companyId, int begin,
159         int end) throws com.liferay.portal.SystemException {
160         return getPersistence().findByCompanyId(companyId, begin, end);
161     }
162 
163     public static java.util.List findByCompanyId(long companyId, int begin,
164         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
165         throws com.liferay.portal.SystemException {
166         return getPersistence().findByCompanyId(companyId, begin, end, obc);
167     }
168 
169     public static com.liferay.portal.model.EmailAddress findByCompanyId_First(
170         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portal.NoSuchEmailAddressException {
173         return getPersistence().findByCompanyId_First(companyId, obc);
174     }
175 
176     public static com.liferay.portal.model.EmailAddress findByCompanyId_Last(
177         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portal.NoSuchEmailAddressException {
180         return getPersistence().findByCompanyId_Last(companyId, obc);
181     }
182 
183     public static com.liferay.portal.model.EmailAddress[] findByCompanyId_PrevAndNext(
184         long emailAddressId, long companyId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portal.NoSuchEmailAddressException {
188         return getPersistence().findByCompanyId_PrevAndNext(emailAddressId,
189             companyId, obc);
190     }
191 
192     public static java.util.List findByUserId(long userId)
193         throws com.liferay.portal.SystemException {
194         return getPersistence().findByUserId(userId);
195     }
196 
197     public static java.util.List findByUserId(long userId, int begin, int end)
198         throws com.liferay.portal.SystemException {
199         return getPersistence().findByUserId(userId, begin, end);
200     }
201 
202     public static java.util.List findByUserId(long userId, int begin, int end,
203         com.liferay.portal.kernel.util.OrderByComparator obc)
204         throws com.liferay.portal.SystemException {
205         return getPersistence().findByUserId(userId, begin, end, obc);
206     }
207 
208     public static com.liferay.portal.model.EmailAddress findByUserId_First(
209         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
210         throws com.liferay.portal.SystemException, 
211             com.liferay.portal.NoSuchEmailAddressException {
212         return getPersistence().findByUserId_First(userId, obc);
213     }
214 
215     public static com.liferay.portal.model.EmailAddress findByUserId_Last(
216         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
217         throws com.liferay.portal.SystemException, 
218             com.liferay.portal.NoSuchEmailAddressException {
219         return getPersistence().findByUserId_Last(userId, obc);
220     }
221 
222     public static com.liferay.portal.model.EmailAddress[] findByUserId_PrevAndNext(
223         long emailAddressId, long userId,
224         com.liferay.portal.kernel.util.OrderByComparator obc)
225         throws com.liferay.portal.SystemException, 
226             com.liferay.portal.NoSuchEmailAddressException {
227         return getPersistence().findByUserId_PrevAndNext(emailAddressId,
228             userId, obc);
229     }
230 
231     public static java.util.List findByC_C(long companyId, long classNameId)
232         throws com.liferay.portal.SystemException {
233         return getPersistence().findByC_C(companyId, classNameId);
234     }
235 
236     public static java.util.List findByC_C(long companyId, long classNameId,
237         int begin, int end) throws com.liferay.portal.SystemException {
238         return getPersistence().findByC_C(companyId, classNameId, begin, end);
239     }
240 
241     public static java.util.List findByC_C(long companyId, long classNameId,
242         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
243         throws com.liferay.portal.SystemException {
244         return getPersistence().findByC_C(companyId, classNameId, begin, end,
245             obc);
246     }
247 
248     public static com.liferay.portal.model.EmailAddress findByC_C_First(
249         long companyId, long classNameId,
250         com.liferay.portal.kernel.util.OrderByComparator obc)
251         throws com.liferay.portal.SystemException, 
252             com.liferay.portal.NoSuchEmailAddressException {
253         return getPersistence().findByC_C_First(companyId, classNameId, obc);
254     }
255 
256     public static com.liferay.portal.model.EmailAddress findByC_C_Last(
257         long companyId, long classNameId,
258         com.liferay.portal.kernel.util.OrderByComparator obc)
259         throws com.liferay.portal.SystemException, 
260             com.liferay.portal.NoSuchEmailAddressException {
261         return getPersistence().findByC_C_Last(companyId, classNameId, obc);
262     }
263 
264     public static com.liferay.portal.model.EmailAddress[] findByC_C_PrevAndNext(
265         long emailAddressId, long companyId, long classNameId,
266         com.liferay.portal.kernel.util.OrderByComparator obc)
267         throws com.liferay.portal.SystemException, 
268             com.liferay.portal.NoSuchEmailAddressException {
269         return getPersistence().findByC_C_PrevAndNext(emailAddressId,
270             companyId, classNameId, obc);
271     }
272 
273     public static java.util.List findByC_C_C(long companyId, long classNameId,
274         long classPK) throws com.liferay.portal.SystemException {
275         return getPersistence().findByC_C_C(companyId, classNameId, classPK);
276     }
277 
278     public static java.util.List findByC_C_C(long companyId, long classNameId,
279         long classPK, int begin, int end)
280         throws com.liferay.portal.SystemException {
281         return getPersistence().findByC_C_C(companyId, classNameId, classPK,
282             begin, end);
283     }
284 
285     public static java.util.List findByC_C_C(long companyId, long classNameId,
286         long classPK, int begin, int end,
287         com.liferay.portal.kernel.util.OrderByComparator obc)
288         throws com.liferay.portal.SystemException {
289         return getPersistence().findByC_C_C(companyId, classNameId, classPK,
290             begin, end, obc);
291     }
292 
293     public static com.liferay.portal.model.EmailAddress findByC_C_C_First(
294         long companyId, long classNameId, long classPK,
295         com.liferay.portal.kernel.util.OrderByComparator obc)
296         throws com.liferay.portal.SystemException, 
297             com.liferay.portal.NoSuchEmailAddressException {
298         return getPersistence().findByC_C_C_First(companyId, classNameId,
299             classPK, obc);
300     }
301 
302     public static com.liferay.portal.model.EmailAddress findByC_C_C_Last(
303         long companyId, long classNameId, long classPK,
304         com.liferay.portal.kernel.util.OrderByComparator obc)
305         throws com.liferay.portal.SystemException, 
306             com.liferay.portal.NoSuchEmailAddressException {
307         return getPersistence().findByC_C_C_Last(companyId, classNameId,
308             classPK, obc);
309     }
310 
311     public static com.liferay.portal.model.EmailAddress[] findByC_C_C_PrevAndNext(
312         long emailAddressId, long companyId, long classNameId, long classPK,
313         com.liferay.portal.kernel.util.OrderByComparator obc)
314         throws com.liferay.portal.SystemException, 
315             com.liferay.portal.NoSuchEmailAddressException {
316         return getPersistence().findByC_C_C_PrevAndNext(emailAddressId,
317             companyId, classNameId, classPK, obc);
318     }
319 
320     public static java.util.List findByC_C_C_P(long companyId,
321         long classNameId, long classPK, boolean primary)
322         throws com.liferay.portal.SystemException {
323         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
324             primary);
325     }
326 
327     public static java.util.List findByC_C_C_P(long companyId,
328         long classNameId, long classPK, boolean primary, int begin, int end)
329         throws com.liferay.portal.SystemException {
330         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
331             primary, begin, end);
332     }
333 
334     public static java.util.List findByC_C_C_P(long companyId,
335         long classNameId, long classPK, boolean primary, int begin, int end,
336         com.liferay.portal.kernel.util.OrderByComparator obc)
337         throws com.liferay.portal.SystemException {
338         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
339             primary, begin, end, obc);
340     }
341 
342     public static com.liferay.portal.model.EmailAddress findByC_C_C_P_First(
343         long companyId, long classNameId, long classPK, boolean primary,
344         com.liferay.portal.kernel.util.OrderByComparator obc)
345         throws com.liferay.portal.SystemException, 
346             com.liferay.portal.NoSuchEmailAddressException {
347         return getPersistence().findByC_C_C_P_First(companyId, classNameId,
348             classPK, primary, obc);
349     }
350 
351     public static com.liferay.portal.model.EmailAddress findByC_C_C_P_Last(
352         long companyId, long classNameId, long classPK, boolean primary,
353         com.liferay.portal.kernel.util.OrderByComparator obc)
354         throws com.liferay.portal.SystemException, 
355             com.liferay.portal.NoSuchEmailAddressException {
356         return getPersistence().findByC_C_C_P_Last(companyId, classNameId,
357             classPK, primary, obc);
358     }
359 
360     public static com.liferay.portal.model.EmailAddress[] findByC_C_C_P_PrevAndNext(
361         long emailAddressId, long companyId, long classNameId, long classPK,
362         boolean primary, com.liferay.portal.kernel.util.OrderByComparator obc)
363         throws com.liferay.portal.SystemException, 
364             com.liferay.portal.NoSuchEmailAddressException {
365         return getPersistence().findByC_C_C_P_PrevAndNext(emailAddressId,
366             companyId, classNameId, classPK, primary, obc);
367     }
368 
369     public static java.util.List findWithDynamicQuery(
370         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
371         throws com.liferay.portal.SystemException {
372         return getPersistence().findWithDynamicQuery(queryInitializer);
373     }
374 
375     public static java.util.List findWithDynamicQuery(
376         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
377         int begin, int end) throws com.liferay.portal.SystemException {
378         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
379             end);
380     }
381 
382     public static java.util.List findAll()
383         throws com.liferay.portal.SystemException {
384         return getPersistence().findAll();
385     }
386 
387     public static java.util.List findAll(int begin, int end)
388         throws com.liferay.portal.SystemException {
389         return getPersistence().findAll(begin, end);
390     }
391 
392     public static java.util.List findAll(int begin, int end,
393         com.liferay.portal.kernel.util.OrderByComparator obc)
394         throws com.liferay.portal.SystemException {
395         return getPersistence().findAll(begin, end, obc);
396     }
397 
398     public static void removeByCompanyId(long companyId)
399         throws com.liferay.portal.SystemException {
400         getPersistence().removeByCompanyId(companyId);
401     }
402 
403     public static void removeByUserId(long userId)
404         throws com.liferay.portal.SystemException {
405         getPersistence().removeByUserId(userId);
406     }
407 
408     public static void removeByC_C(long companyId, long classNameId)
409         throws com.liferay.portal.SystemException {
410         getPersistence().removeByC_C(companyId, classNameId);
411     }
412 
413     public static void removeByC_C_C(long companyId, long classNameId,
414         long classPK) throws com.liferay.portal.SystemException {
415         getPersistence().removeByC_C_C(companyId, classNameId, classPK);
416     }
417 
418     public static void removeByC_C_C_P(long companyId, long classNameId,
419         long classPK, boolean primary)
420         throws com.liferay.portal.SystemException {
421         getPersistence().removeByC_C_C_P(companyId, classNameId, classPK,
422             primary);
423     }
424 
425     public static void removeAll() throws com.liferay.portal.SystemException {
426         getPersistence().removeAll();
427     }
428 
429     public static int countByCompanyId(long companyId)
430         throws com.liferay.portal.SystemException {
431         return getPersistence().countByCompanyId(companyId);
432     }
433 
434     public static int countByUserId(long userId)
435         throws com.liferay.portal.SystemException {
436         return getPersistence().countByUserId(userId);
437     }
438 
439     public static int countByC_C(long companyId, long classNameId)
440         throws com.liferay.portal.SystemException {
441         return getPersistence().countByC_C(companyId, classNameId);
442     }
443 
444     public static int countByC_C_C(long companyId, long classNameId,
445         long classPK) throws com.liferay.portal.SystemException {
446         return getPersistence().countByC_C_C(companyId, classNameId, classPK);
447     }
448 
449     public static int countByC_C_C_P(long companyId, long classNameId,
450         long classPK, boolean primary)
451         throws com.liferay.portal.SystemException {
452         return getPersistence().countByC_C_C_P(companyId, classNameId, classPK,
453             primary);
454     }
455 
456     public static int countAll() throws com.liferay.portal.SystemException {
457         return getPersistence().countAll();
458     }
459 
460     public static EmailAddressPersistence getPersistence() {
461         return _getUtil()._persistence;
462     }
463 
464     public void setPersistence(EmailAddressPersistence persistence) {
465         _persistence = persistence;
466     }
467 
468     private static EmailAddressUtil _getUtil() {
469         if (_util == null) {
470             _util = (EmailAddressUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
471         }
472 
473         return _util;
474     }
475 
476     private static ModelListener _getListener() {
477         if (Validator.isNotNull(_LISTENER)) {
478             try {
479                 return (ModelListener)Class.forName(_LISTENER).newInstance();
480             }
481             catch (Exception e) {
482                 _log.error(e);
483             }
484         }
485 
486         return null;
487     }
488 
489     private static final String _UTIL = EmailAddressUtil.class.getName();
490     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
491                 "value.object.listener.com.liferay.portal.model.EmailAddress"));
492     private static Log _log = LogFactory.getLog(EmailAddressUtil.class);
493     private static EmailAddressUtil _util;
494     private EmailAddressPersistence _persistence;
495 }