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