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.portlet.documentlibrary.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="DLFileShortcutUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class DLFileShortcutUtil {
40      public static com.liferay.portlet.documentlibrary.model.DLFileShortcut create(
41          long fileShortcutId) {
42          return getPersistence().create(fileShortcutId);
43      }
44  
45      public static com.liferay.portlet.documentlibrary.model.DLFileShortcut remove(
46          long fileShortcutId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portlet.documentlibrary.NoSuchFileShortcutException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(fileShortcutId));
53          }
54  
55          com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut = getPersistence()
56                                                                                        .remove(fileShortcutId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(dlFileShortcut);
60          }
61  
62          return dlFileShortcut;
63      }
64  
65      public static com.liferay.portlet.documentlibrary.model.DLFileShortcut remove(
66          com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(dlFileShortcut);
72          }
73  
74          dlFileShortcut = getPersistence().remove(dlFileShortcut);
75  
76          if (listener != null) {
77              listener.onAfterRemove(dlFileShortcut);
78          }
79  
80          return dlFileShortcut;
81      }
82  
83      public static com.liferay.portlet.documentlibrary.model.DLFileShortcut update(
84          com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = dlFileShortcut.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(dlFileShortcut);
92              }
93              else {
94                  listener.onBeforeUpdate(dlFileShortcut);
95              }
96          }
97  
98          dlFileShortcut = getPersistence().update(dlFileShortcut);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(dlFileShortcut);
103             }
104             else {
105                 listener.onAfterUpdate(dlFileShortcut);
106             }
107         }
108 
109         return dlFileShortcut;
110     }
111 
112     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut update(
113         com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut,
114         boolean merge) throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = dlFileShortcut.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(dlFileShortcut);
121             }
122             else {
123                 listener.onBeforeUpdate(dlFileShortcut);
124             }
125         }
126 
127         dlFileShortcut = getPersistence().update(dlFileShortcut, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(dlFileShortcut);
132             }
133             else {
134                 listener.onAfterUpdate(dlFileShortcut);
135             }
136         }
137 
138         return dlFileShortcut;
139     }
140 
141     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut findByPrimaryKey(
142         long fileShortcutId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portlet.documentlibrary.NoSuchFileShortcutException {
145         return getPersistence().findByPrimaryKey(fileShortcutId);
146     }
147 
148     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut fetchByPrimaryKey(
149         long fileShortcutId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(fileShortcutId);
151     }
152 
153     public static java.util.List findByFolderId(long folderId)
154         throws com.liferay.portal.SystemException {
155         return getPersistence().findByFolderId(folderId);
156     }
157 
158     public static java.util.List findByFolderId(long folderId, int begin,
159         int end) throws com.liferay.portal.SystemException {
160         return getPersistence().findByFolderId(folderId, begin, end);
161     }
162 
163     public static java.util.List findByFolderId(long folderId, int begin,
164         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
165         throws com.liferay.portal.SystemException {
166         return getPersistence().findByFolderId(folderId, begin, end, obc);
167     }
168 
169     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut findByFolderId_First(
170         long folderId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portlet.documentlibrary.NoSuchFileShortcutException {
173         return getPersistence().findByFolderId_First(folderId, obc);
174     }
175 
176     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut findByFolderId_Last(
177         long folderId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portlet.documentlibrary.NoSuchFileShortcutException {
180         return getPersistence().findByFolderId_Last(folderId, obc);
181     }
182 
183     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut[] findByFolderId_PrevAndNext(
184         long fileShortcutId, long folderId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portlet.documentlibrary.NoSuchFileShortcutException {
188         return getPersistence().findByFolderId_PrevAndNext(fileShortcutId,
189             folderId, obc);
190     }
191 
192     public static java.util.List findByTF_TN(long toFolderId,
193         java.lang.String toName) throws com.liferay.portal.SystemException {
194         return getPersistence().findByTF_TN(toFolderId, toName);
195     }
196 
197     public static java.util.List findByTF_TN(long toFolderId,
198         java.lang.String toName, int begin, int end)
199         throws com.liferay.portal.SystemException {
200         return getPersistence().findByTF_TN(toFolderId, toName, begin, end);
201     }
202 
203     public static java.util.List findByTF_TN(long toFolderId,
204         java.lang.String toName, int begin, int end,
205         com.liferay.portal.kernel.util.OrderByComparator obc)
206         throws com.liferay.portal.SystemException {
207         return getPersistence().findByTF_TN(toFolderId, toName, begin, end, obc);
208     }
209 
210     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut findByTF_TN_First(
211         long toFolderId, java.lang.String toName,
212         com.liferay.portal.kernel.util.OrderByComparator obc)
213         throws com.liferay.portal.SystemException, 
214             com.liferay.portlet.documentlibrary.NoSuchFileShortcutException {
215         return getPersistence().findByTF_TN_First(toFolderId, toName, obc);
216     }
217 
218     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut findByTF_TN_Last(
219         long toFolderId, java.lang.String toName,
220         com.liferay.portal.kernel.util.OrderByComparator obc)
221         throws com.liferay.portal.SystemException, 
222             com.liferay.portlet.documentlibrary.NoSuchFileShortcutException {
223         return getPersistence().findByTF_TN_Last(toFolderId, toName, obc);
224     }
225 
226     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut[] findByTF_TN_PrevAndNext(
227         long fileShortcutId, long toFolderId, java.lang.String toName,
228         com.liferay.portal.kernel.util.OrderByComparator obc)
229         throws com.liferay.portal.SystemException, 
230             com.liferay.portlet.documentlibrary.NoSuchFileShortcutException {
231         return getPersistence().findByTF_TN_PrevAndNext(fileShortcutId,
232             toFolderId, toName, obc);
233     }
234 
235     public static java.util.List findWithDynamicQuery(
236         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
237         throws com.liferay.portal.SystemException {
238         return getPersistence().findWithDynamicQuery(queryInitializer);
239     }
240 
241     public static java.util.List findWithDynamicQuery(
242         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
243         int begin, int end) throws com.liferay.portal.SystemException {
244         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
245             end);
246     }
247 
248     public static java.util.List findAll()
249         throws com.liferay.portal.SystemException {
250         return getPersistence().findAll();
251     }
252 
253     public static java.util.List findAll(int begin, int end)
254         throws com.liferay.portal.SystemException {
255         return getPersistence().findAll(begin, end);
256     }
257 
258     public static java.util.List findAll(int begin, int end,
259         com.liferay.portal.kernel.util.OrderByComparator obc)
260         throws com.liferay.portal.SystemException {
261         return getPersistence().findAll(begin, end, obc);
262     }
263 
264     public static void removeByFolderId(long folderId)
265         throws com.liferay.portal.SystemException {
266         getPersistence().removeByFolderId(folderId);
267     }
268 
269     public static void removeByTF_TN(long toFolderId, java.lang.String toName)
270         throws com.liferay.portal.SystemException {
271         getPersistence().removeByTF_TN(toFolderId, toName);
272     }
273 
274     public static void removeAll() throws com.liferay.portal.SystemException {
275         getPersistence().removeAll();
276     }
277 
278     public static int countByFolderId(long folderId)
279         throws com.liferay.portal.SystemException {
280         return getPersistence().countByFolderId(folderId);
281     }
282 
283     public static int countByTF_TN(long toFolderId, java.lang.String toName)
284         throws com.liferay.portal.SystemException {
285         return getPersistence().countByTF_TN(toFolderId, toName);
286     }
287 
288     public static int countAll() throws com.liferay.portal.SystemException {
289         return getPersistence().countAll();
290     }
291 
292     public static DLFileShortcutPersistence getPersistence() {
293         return _getUtil()._persistence;
294     }
295 
296     public void setPersistence(DLFileShortcutPersistence persistence) {
297         _persistence = persistence;
298     }
299 
300     private static DLFileShortcutUtil _getUtil() {
301         if (_util == null) {
302             _util = (DLFileShortcutUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
303         }
304 
305         return _util;
306     }
307 
308     private static ModelListener _getListener() {
309         if (Validator.isNotNull(_LISTENER)) {
310             try {
311                 return (ModelListener)Class.forName(_LISTENER).newInstance();
312             }
313             catch (Exception e) {
314                 _log.error(e);
315             }
316         }
317 
318         return null;
319     }
320 
321     private static final String _UTIL = DLFileShortcutUtil.class.getName();
322     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
323                 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileShortcut"));
324     private static Log _log = LogFactory.getLog(DLFileShortcutUtil.class);
325     private static DLFileShortcutUtil _util;
326     private DLFileShortcutPersistence _persistence;
327 }