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="PasswordPolicyRelUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class PasswordPolicyRelUtil {
40      public static com.liferay.portal.model.PasswordPolicyRel create(
41          long passwordPolicyRelId) {
42          return getPersistence().create(passwordPolicyRelId);
43      }
44  
45      public static com.liferay.portal.model.PasswordPolicyRel remove(
46          long passwordPolicyRelId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portal.NoSuchPasswordPolicyRelException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(passwordPolicyRelId));
53          }
54  
55          com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel = getPersistence()
56                                                                             .remove(passwordPolicyRelId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(passwordPolicyRel);
60          }
61  
62          return passwordPolicyRel;
63      }
64  
65      public static com.liferay.portal.model.PasswordPolicyRel remove(
66          com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(passwordPolicyRel);
72          }
73  
74          passwordPolicyRel = getPersistence().remove(passwordPolicyRel);
75  
76          if (listener != null) {
77              listener.onAfterRemove(passwordPolicyRel);
78          }
79  
80          return passwordPolicyRel;
81      }
82  
83      public static com.liferay.portal.model.PasswordPolicyRel update(
84          com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = passwordPolicyRel.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(passwordPolicyRel);
92              }
93              else {
94                  listener.onBeforeUpdate(passwordPolicyRel);
95              }
96          }
97  
98          passwordPolicyRel = getPersistence().update(passwordPolicyRel);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(passwordPolicyRel);
103             }
104             else {
105                 listener.onAfterUpdate(passwordPolicyRel);
106             }
107         }
108 
109         return passwordPolicyRel;
110     }
111 
112     public static com.liferay.portal.model.PasswordPolicyRel update(
113         com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel,
114         boolean merge) throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = passwordPolicyRel.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(passwordPolicyRel);
121             }
122             else {
123                 listener.onBeforeUpdate(passwordPolicyRel);
124             }
125         }
126 
127         passwordPolicyRel = getPersistence().update(passwordPolicyRel, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(passwordPolicyRel);
132             }
133             else {
134                 listener.onAfterUpdate(passwordPolicyRel);
135             }
136         }
137 
138         return passwordPolicyRel;
139     }
140 
141     public static com.liferay.portal.model.PasswordPolicyRel findByPrimaryKey(
142         long passwordPolicyRelId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portal.NoSuchPasswordPolicyRelException {
145         return getPersistence().findByPrimaryKey(passwordPolicyRelId);
146     }
147 
148     public static com.liferay.portal.model.PasswordPolicyRel fetchByPrimaryKey(
149         long passwordPolicyRelId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(passwordPolicyRelId);
151     }
152 
153     public static com.liferay.portal.model.PasswordPolicyRel findByC_C(
154         long classNameId, long classPK)
155         throws com.liferay.portal.SystemException, 
156             com.liferay.portal.NoSuchPasswordPolicyRelException {
157         return getPersistence().findByC_C(classNameId, classPK);
158     }
159 
160     public static com.liferay.portal.model.PasswordPolicyRel fetchByC_C(
161         long classNameId, long classPK)
162         throws com.liferay.portal.SystemException {
163         return getPersistence().fetchByC_C(classNameId, classPK);
164     }
165 
166     public static com.liferay.portal.model.PasswordPolicyRel findByP_C_C(
167         long passwordPolicyId, long classNameId, long classPK)
168         throws com.liferay.portal.SystemException, 
169             com.liferay.portal.NoSuchPasswordPolicyRelException {
170         return getPersistence().findByP_C_C(passwordPolicyId, classNameId,
171             classPK);
172     }
173 
174     public static com.liferay.portal.model.PasswordPolicyRel fetchByP_C_C(
175         long passwordPolicyId, long classNameId, long classPK)
176         throws com.liferay.portal.SystemException {
177         return getPersistence().fetchByP_C_C(passwordPolicyId, classNameId,
178             classPK);
179     }
180 
181     public static java.util.List findWithDynamicQuery(
182         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
183         throws com.liferay.portal.SystemException {
184         return getPersistence().findWithDynamicQuery(queryInitializer);
185     }
186 
187     public static java.util.List findWithDynamicQuery(
188         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
189         int begin, int end) throws com.liferay.portal.SystemException {
190         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
191             end);
192     }
193 
194     public static java.util.List findAll()
195         throws com.liferay.portal.SystemException {
196         return getPersistence().findAll();
197     }
198 
199     public static java.util.List findAll(int begin, int end)
200         throws com.liferay.portal.SystemException {
201         return getPersistence().findAll(begin, end);
202     }
203 
204     public static java.util.List findAll(int begin, int end,
205         com.liferay.portal.kernel.util.OrderByComparator obc)
206         throws com.liferay.portal.SystemException {
207         return getPersistence().findAll(begin, end, obc);
208     }
209 
210     public static void removeByC_C(long classNameId, long classPK)
211         throws com.liferay.portal.SystemException, 
212             com.liferay.portal.NoSuchPasswordPolicyRelException {
213         getPersistence().removeByC_C(classNameId, classPK);
214     }
215 
216     public static void removeByP_C_C(long passwordPolicyId, long classNameId,
217         long classPK)
218         throws com.liferay.portal.SystemException, 
219             com.liferay.portal.NoSuchPasswordPolicyRelException {
220         getPersistence().removeByP_C_C(passwordPolicyId, classNameId, classPK);
221     }
222 
223     public static void removeAll() throws com.liferay.portal.SystemException {
224         getPersistence().removeAll();
225     }
226 
227     public static int countByC_C(long classNameId, long classPK)
228         throws com.liferay.portal.SystemException {
229         return getPersistence().countByC_C(classNameId, classPK);
230     }
231 
232     public static int countByP_C_C(long passwordPolicyId, long classNameId,
233         long classPK) throws com.liferay.portal.SystemException {
234         return getPersistence().countByP_C_C(passwordPolicyId, classNameId,
235             classPK);
236     }
237 
238     public static int countAll() throws com.liferay.portal.SystemException {
239         return getPersistence().countAll();
240     }
241 
242     public static PasswordPolicyRelPersistence getPersistence() {
243         return _getUtil()._persistence;
244     }
245 
246     public void setPersistence(PasswordPolicyRelPersistence persistence) {
247         _persistence = persistence;
248     }
249 
250     private static PasswordPolicyRelUtil _getUtil() {
251         if (_util == null) {
252             _util = (PasswordPolicyRelUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
253         }
254 
255         return _util;
256     }
257 
258     private static ModelListener _getListener() {
259         if (Validator.isNotNull(_LISTENER)) {
260             try {
261                 return (ModelListener)Class.forName(_LISTENER).newInstance();
262             }
263             catch (Exception e) {
264                 _log.error(e);
265             }
266         }
267 
268         return null;
269     }
270 
271     private static final String _UTIL = PasswordPolicyRelUtil.class.getName();
272     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
273                 "value.object.listener.com.liferay.portal.model.PasswordPolicyRel"));
274     private static Log _log = LogFactory.getLog(PasswordPolicyRelUtil.class);
275     private static PasswordPolicyRelUtil _util;
276     private PasswordPolicyRelPersistence _persistence;
277 }