1   /**
2    * Copyright (c) 2000-2009 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.SystemException;
26  import com.liferay.portal.kernel.annotation.BeanReference;
27  import com.liferay.portal.kernel.cache.CacheRegistry;
28  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31  import com.liferay.portal.kernel.dao.orm.FinderPath;
32  import com.liferay.portal.kernel.dao.orm.Query;
33  import com.liferay.portal.kernel.dao.orm.QueryPos;
34  import com.liferay.portal.kernel.dao.orm.QueryUtil;
35  import com.liferay.portal.kernel.dao.orm.Session;
36  import com.liferay.portal.kernel.log.Log;
37  import com.liferay.portal.kernel.log.LogFactoryUtil;
38  import com.liferay.portal.kernel.util.GetterUtil;
39  import com.liferay.portal.kernel.util.OrderByComparator;
40  import com.liferay.portal.kernel.util.StringPool;
41  import com.liferay.portal.kernel.util.StringUtil;
42  import com.liferay.portal.kernel.util.Validator;
43  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
44  import com.liferay.portal.model.ModelListener;
45  import com.liferay.portal.service.persistence.BatchSessionUtil;
46  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47  
48  import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
49  import com.liferay.portlet.documentlibrary.model.DLFileEntry;
50  import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
51  import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryModelImpl;
52  
53  import java.util.ArrayList;
54  import java.util.Collections;
55  import java.util.List;
56  
57  /**
58   * <a href="DLFileEntryPersistenceImpl.java.html"><b><i>View Source</i></b></a>
59   *
60   * @author Brian Wing Shun Chan
61   *
62   */
63  public class DLFileEntryPersistenceImpl extends BasePersistenceImpl
64      implements DLFileEntryPersistence {
65      public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryImpl.class.getName();
66      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
67          ".List";
68      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
69              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
70              "findByUuid", new String[] { String.class.getName() });
71      public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
72              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
73              "findByUuid",
74              new String[] {
75                  String.class.getName(),
76                  
77              "java.lang.Integer", "java.lang.Integer",
78                  "com.liferay.portal.kernel.util.OrderByComparator"
79              });
80      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
81              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
82              "countByUuid", new String[] { String.class.getName() });
83      public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
84              DLFileEntryModelImpl.FINDER_CACHE_ENABLED,
85              FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
86              new String[] { String.class.getName(), Long.class.getName() });
87      public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
88              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89              "countByUUID_G",
90              new String[] { String.class.getName(), Long.class.getName() });
91      public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
92              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
93              "findByGroupId", new String[] { Long.class.getName() });
94      public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
95              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96              "findByGroupId",
97              new String[] {
98                  Long.class.getName(),
99                  
100             "java.lang.Integer", "java.lang.Integer",
101                 "com.liferay.portal.kernel.util.OrderByComparator"
102             });
103     public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
104             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105             "countByGroupId", new String[] { Long.class.getName() });
106     public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
107             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108             "findByCompanyId", new String[] { Long.class.getName() });
109     public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
110             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111             "findByCompanyId",
112             new String[] {
113                 Long.class.getName(),
114                 
115             "java.lang.Integer", "java.lang.Integer",
116                 "com.liferay.portal.kernel.util.OrderByComparator"
117             });
118     public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
119             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
120             "countByCompanyId", new String[] { Long.class.getName() });
121     public static final FinderPath FINDER_PATH_FIND_BY_FOLDERID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
122             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
123             "findByFolderId", new String[] { Long.class.getName() });
124     public static final FinderPath FINDER_PATH_FIND_BY_OBC_FOLDERID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
125             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
126             "findByFolderId",
127             new String[] {
128                 Long.class.getName(),
129                 
130             "java.lang.Integer", "java.lang.Integer",
131                 "com.liferay.portal.kernel.util.OrderByComparator"
132             });
133     public static final FinderPath FINDER_PATH_COUNT_BY_FOLDERID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
134             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
135             "countByFolderId", new String[] { Long.class.getName() });
136     public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
137             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
138             "findByG_U",
139             new String[] { Long.class.getName(), Long.class.getName() });
140     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
141             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
142             "findByG_U",
143             new String[] {
144                 Long.class.getName(), Long.class.getName(),
145                 
146             "java.lang.Integer", "java.lang.Integer",
147                 "com.liferay.portal.kernel.util.OrderByComparator"
148             });
149     public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
150             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
151             "countByG_U",
152             new String[] { Long.class.getName(), Long.class.getName() });
153     public static final FinderPath FINDER_PATH_FETCH_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
154             DLFileEntryModelImpl.FINDER_CACHE_ENABLED,
155             FINDER_CLASS_NAME_ENTITY, "fetchByF_N",
156             new String[] { Long.class.getName(), String.class.getName() });
157     public static final FinderPath FINDER_PATH_COUNT_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
158             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
159             "countByF_N",
160             new String[] { Long.class.getName(), String.class.getName() });
161     public static final FinderPath FINDER_PATH_FIND_BY_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
162             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
163             "findByF_T",
164             new String[] { Long.class.getName(), String.class.getName() });
165     public static final FinderPath FINDER_PATH_FIND_BY_OBC_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
166             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
167             "findByF_T",
168             new String[] {
169                 Long.class.getName(), String.class.getName(),
170                 
171             "java.lang.Integer", "java.lang.Integer",
172                 "com.liferay.portal.kernel.util.OrderByComparator"
173             });
174     public static final FinderPath FINDER_PATH_COUNT_BY_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
175             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
176             "countByF_T",
177             new String[] { Long.class.getName(), String.class.getName() });
178     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
179             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
180             "findAll", new String[0]);
181     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
182             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
183             "countAll", new String[0]);
184 
185     public void cacheResult(DLFileEntry dlFileEntry) {
186         EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
187             DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
188 
189         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
190             new Object[] {
191                 dlFileEntry.getUuid(), new Long(dlFileEntry.getGroupId())
192             }, dlFileEntry);
193 
194         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
195             new Object[] {
196                 new Long(dlFileEntry.getFolderId()),
197                 
198             dlFileEntry.getName()
199             }, dlFileEntry);
200     }
201 
202     public void cacheResult(List<DLFileEntry> dlFileEntries) {
203         for (DLFileEntry dlFileEntry : dlFileEntries) {
204             if (EntityCacheUtil.getResult(
205                         DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
206                         DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), this) == null) {
207                 cacheResult(dlFileEntry);
208             }
209         }
210     }
211 
212     public void clearCache() {
213         CacheRegistry.clear(DLFileEntryImpl.class.getName());
214         EntityCacheUtil.clearCache(DLFileEntryImpl.class.getName());
215         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
216         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
217     }
218 
219     public DLFileEntry create(long fileEntryId) {
220         DLFileEntry dlFileEntry = new DLFileEntryImpl();
221 
222         dlFileEntry.setNew(true);
223         dlFileEntry.setPrimaryKey(fileEntryId);
224 
225         String uuid = PortalUUIDUtil.generate();
226 
227         dlFileEntry.setUuid(uuid);
228 
229         return dlFileEntry;
230     }
231 
232     public DLFileEntry remove(long fileEntryId)
233         throws NoSuchFileEntryException, SystemException {
234         Session session = null;
235 
236         try {
237             session = openSession();
238 
239             DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
240                     new Long(fileEntryId));
241 
242             if (dlFileEntry == null) {
243                 if (_log.isWarnEnabled()) {
244                     _log.warn("No DLFileEntry exists with the primary key " +
245                         fileEntryId);
246                 }
247 
248                 throw new NoSuchFileEntryException(
249                     "No DLFileEntry exists with the primary key " +
250                     fileEntryId);
251             }
252 
253             return remove(dlFileEntry);
254         }
255         catch (NoSuchFileEntryException nsee) {
256             throw nsee;
257         }
258         catch (Exception e) {
259             throw processException(e);
260         }
261         finally {
262             closeSession(session);
263         }
264     }
265 
266     public DLFileEntry remove(DLFileEntry dlFileEntry)
267         throws SystemException {
268         for (ModelListener<DLFileEntry> listener : listeners) {
269             listener.onBeforeRemove(dlFileEntry);
270         }
271 
272         dlFileEntry = removeImpl(dlFileEntry);
273 
274         for (ModelListener<DLFileEntry> listener : listeners) {
275             listener.onAfterRemove(dlFileEntry);
276         }
277 
278         return dlFileEntry;
279     }
280 
281     protected DLFileEntry removeImpl(DLFileEntry dlFileEntry)
282         throws SystemException {
283         Session session = null;
284 
285         try {
286             session = openSession();
287 
288             if (dlFileEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
289                 Object staleObject = session.get(DLFileEntryImpl.class,
290                         dlFileEntry.getPrimaryKeyObj());
291 
292                 if (staleObject != null) {
293                     session.evict(staleObject);
294                 }
295             }
296 
297             session.delete(dlFileEntry);
298 
299             session.flush();
300         }
301         catch (Exception e) {
302             throw processException(e);
303         }
304         finally {
305             closeSession(session);
306         }
307 
308         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
309 
310         DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
311 
312         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
313             new Object[] {
314                 dlFileEntryModelImpl.getOriginalUuid(),
315                 new Long(dlFileEntryModelImpl.getOriginalGroupId())
316             });
317 
318         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_N,
319             new Object[] {
320                 new Long(dlFileEntryModelImpl.getOriginalFolderId()),
321                 
322             dlFileEntryModelImpl.getOriginalName()
323             });
324 
325         EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
326             DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
327 
328         return dlFileEntry;
329     }
330 
331     /**
332      * @deprecated Use <code>update(DLFileEntry dlFileEntry, boolean merge)</code>.
333      */
334     public DLFileEntry update(DLFileEntry dlFileEntry)
335         throws SystemException {
336         if (_log.isWarnEnabled()) {
337             _log.warn(
338                 "Using the deprecated update(DLFileEntry dlFileEntry) method. Use update(DLFileEntry dlFileEntry, boolean merge) instead.");
339         }
340 
341         return update(dlFileEntry, false);
342     }
343 
344     /**
345      * Add, update, or merge, the entity. This method also calls the model
346      * listeners to trigger the proper events associated with adding, deleting,
347      * or updating an entity.
348      *
349      * @param        dlFileEntry the entity to add, update, or merge
350      * @param        merge boolean value for whether to merge the entity. The
351      *                default value is false. Setting merge to true is more
352      *                expensive and should only be true when dlFileEntry is
353      *                transient. See LEP-5473 for a detailed discussion of this
354      *                method.
355      * @return        true if the portlet can be displayed via Ajax
356      */
357     public DLFileEntry update(DLFileEntry dlFileEntry, boolean merge)
358         throws SystemException {
359         boolean isNew = dlFileEntry.isNew();
360 
361         for (ModelListener<DLFileEntry> listener : listeners) {
362             if (isNew) {
363                 listener.onBeforeCreate(dlFileEntry);
364             }
365             else {
366                 listener.onBeforeUpdate(dlFileEntry);
367             }
368         }
369 
370         dlFileEntry = updateImpl(dlFileEntry, merge);
371 
372         for (ModelListener<DLFileEntry> listener : listeners) {
373             if (isNew) {
374                 listener.onAfterCreate(dlFileEntry);
375             }
376             else {
377                 listener.onAfterUpdate(dlFileEntry);
378             }
379         }
380 
381         return dlFileEntry;
382     }
383 
384     public DLFileEntry updateImpl(
385         com.liferay.portlet.documentlibrary.model.DLFileEntry dlFileEntry,
386         boolean merge) throws SystemException {
387         boolean isNew = dlFileEntry.isNew();
388 
389         DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
390 
391         if (Validator.isNull(dlFileEntry.getUuid())) {
392             String uuid = PortalUUIDUtil.generate();
393 
394             dlFileEntry.setUuid(uuid);
395         }
396 
397         Session session = null;
398 
399         try {
400             session = openSession();
401 
402             BatchSessionUtil.update(session, dlFileEntry, merge);
403 
404             dlFileEntry.setNew(false);
405         }
406         catch (Exception e) {
407             throw processException(e);
408         }
409         finally {
410             closeSession(session);
411         }
412 
413         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
414 
415         EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
416             DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
417 
418         if (!isNew &&
419                 (!Validator.equals(dlFileEntry.getUuid(),
420                     dlFileEntryModelImpl.getOriginalUuid()) ||
421                 (dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()))) {
422             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
423                 new Object[] {
424                     dlFileEntryModelImpl.getOriginalUuid(),
425                     new Long(dlFileEntryModelImpl.getOriginalGroupId())
426                 });
427         }
428 
429         if (isNew ||
430                 (!Validator.equals(dlFileEntry.getUuid(),
431                     dlFileEntryModelImpl.getOriginalUuid()) ||
432                 (dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()))) {
433             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
434                 new Object[] {
435                     dlFileEntry.getUuid(), new Long(dlFileEntry.getGroupId())
436                 }, dlFileEntry);
437         }
438 
439         if (!isNew &&
440                 ((dlFileEntry.getFolderId() != dlFileEntryModelImpl.getOriginalFolderId()) ||
441                 !Validator.equals(dlFileEntry.getName(),
442                     dlFileEntryModelImpl.getOriginalName()))) {
443             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_N,
444                 new Object[] {
445                     new Long(dlFileEntryModelImpl.getOriginalFolderId()),
446                     
447                 dlFileEntryModelImpl.getOriginalName()
448                 });
449         }
450 
451         if (isNew ||
452                 ((dlFileEntry.getFolderId() != dlFileEntryModelImpl.getOriginalFolderId()) ||
453                 !Validator.equals(dlFileEntry.getName(),
454                     dlFileEntryModelImpl.getOriginalName()))) {
455             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
456                 new Object[] {
457                     new Long(dlFileEntry.getFolderId()),
458                     
459                 dlFileEntry.getName()
460                 }, dlFileEntry);
461         }
462 
463         return dlFileEntry;
464     }
465 
466     public DLFileEntry findByPrimaryKey(long fileEntryId)
467         throws NoSuchFileEntryException, SystemException {
468         DLFileEntry dlFileEntry = fetchByPrimaryKey(fileEntryId);
469 
470         if (dlFileEntry == null) {
471             if (_log.isWarnEnabled()) {
472                 _log.warn("No DLFileEntry exists with the primary key " +
473                     fileEntryId);
474             }
475 
476             throw new NoSuchFileEntryException(
477                 "No DLFileEntry exists with the primary key " + fileEntryId);
478         }
479 
480         return dlFileEntry;
481     }
482 
483     public DLFileEntry fetchByPrimaryKey(long fileEntryId)
484         throws SystemException {
485         DLFileEntry dlFileEntry = (DLFileEntry)EntityCacheUtil.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
486                 DLFileEntryImpl.class, fileEntryId, this);
487 
488         if (dlFileEntry == null) {
489             Session session = null;
490 
491             try {
492                 session = openSession();
493 
494                 dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
495                         new Long(fileEntryId));
496             }
497             catch (Exception e) {
498                 throw processException(e);
499             }
500             finally {
501                 if (dlFileEntry != null) {
502                     cacheResult(dlFileEntry);
503                 }
504 
505                 closeSession(session);
506             }
507         }
508 
509         return dlFileEntry;
510     }
511 
512     public List<DLFileEntry> findByUuid(String uuid) throws SystemException {
513         Object[] finderArgs = new Object[] { uuid };
514 
515         List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
516                 finderArgs, this);
517 
518         if (list == null) {
519             Session session = null;
520 
521             try {
522                 session = openSession();
523 
524                 StringBuilder query = new StringBuilder();
525 
526                 query.append(
527                     "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
528 
529                 if (uuid == null) {
530                     query.append("dlFileEntry.uuid IS NULL");
531                 }
532                 else {
533                     query.append("dlFileEntry.uuid = ?");
534                 }
535 
536                 query.append(" ");
537 
538                 query.append("ORDER BY ");
539 
540                 query.append("dlFileEntry.folderId ASC, ");
541                 query.append("dlFileEntry.name ASC");
542 
543                 Query q = session.createQuery(query.toString());
544 
545                 QueryPos qPos = QueryPos.getInstance(q);
546 
547                 if (uuid != null) {
548                     qPos.add(uuid);
549                 }
550 
551                 list = q.list();
552             }
553             catch (Exception e) {
554                 throw processException(e);
555             }
556             finally {
557                 if (list == null) {
558                     list = new ArrayList<DLFileEntry>();
559                 }
560 
561                 cacheResult(list);
562 
563                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
564                     list);
565 
566                 closeSession(session);
567             }
568         }
569 
570         return list;
571     }
572 
573     public List<DLFileEntry> findByUuid(String uuid, int start, int end)
574         throws SystemException {
575         return findByUuid(uuid, start, end, null);
576     }
577 
578     public List<DLFileEntry> findByUuid(String uuid, int start, int end,
579         OrderByComparator obc) throws SystemException {
580         Object[] finderArgs = new Object[] {
581                 uuid,
582                 
583                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
584             };
585 
586         List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
587                 finderArgs, this);
588 
589         if (list == null) {
590             Session session = null;
591 
592             try {
593                 session = openSession();
594 
595                 StringBuilder query = new StringBuilder();
596 
597                 query.append(
598                     "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
599 
600                 if (uuid == null) {
601                     query.append("dlFileEntry.uuid IS NULL");
602                 }
603                 else {
604                     query.append("dlFileEntry.uuid = ?");
605                 }
606 
607                 query.append(" ");
608 
609                 if (obc != null) {
610                     query.append("ORDER BY ");
611 
612                     String[] orderByFields = obc.getOrderByFields();
613 
614                     for (int i = 0; i < orderByFields.length; i++) {
615                         query.append("dlFileEntry.");
616                         query.append(orderByFields[i]);
617 
618                         if (obc.isAscending()) {
619                             query.append(" ASC");
620                         }
621                         else {
622                             query.append(" DESC");
623                         }
624 
625                         if ((i + 1) < orderByFields.length) {
626                             query.append(", ");
627                         }
628                     }
629                 }
630 
631                 else {
632                     query.append("ORDER BY ");
633 
634                     query.append("dlFileEntry.folderId ASC, ");
635                     query.append("dlFileEntry.name ASC");
636                 }
637 
638                 Query q = session.createQuery(query.toString());
639 
640                 QueryPos qPos = QueryPos.getInstance(q);
641 
642                 if (uuid != null) {
643                     qPos.add(uuid);
644                 }
645 
646                 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
647                         start, end);
648             }
649             catch (Exception e) {
650                 throw processException(e);
651             }
652             finally {
653                 if (list == null) {
654                     list = new ArrayList<DLFileEntry>();
655                 }
656 
657                 cacheResult(list);
658 
659                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
660                     finderArgs, list);
661 
662                 closeSession(session);
663             }
664         }
665 
666         return list;
667     }
668 
669     public DLFileEntry findByUuid_First(String uuid, OrderByComparator obc)
670         throws NoSuchFileEntryException, SystemException {
671         List<DLFileEntry> list = findByUuid(uuid, 0, 1, obc);
672 
673         if (list.isEmpty()) {
674             StringBuilder msg = new StringBuilder();
675 
676             msg.append("No DLFileEntry exists with the key {");
677 
678             msg.append("uuid=" + uuid);
679 
680             msg.append(StringPool.CLOSE_CURLY_BRACE);
681 
682             throw new NoSuchFileEntryException(msg.toString());
683         }
684         else {
685             return list.get(0);
686         }
687     }
688 
689     public DLFileEntry findByUuid_Last(String uuid, OrderByComparator obc)
690         throws NoSuchFileEntryException, SystemException {
691         int count = countByUuid(uuid);
692 
693         List<DLFileEntry> list = findByUuid(uuid, count - 1, count, obc);
694 
695         if (list.isEmpty()) {
696             StringBuilder msg = new StringBuilder();
697 
698             msg.append("No DLFileEntry exists with the key {");
699 
700             msg.append("uuid=" + uuid);
701 
702             msg.append(StringPool.CLOSE_CURLY_BRACE);
703 
704             throw new NoSuchFileEntryException(msg.toString());
705         }
706         else {
707             return list.get(0);
708         }
709     }
710 
711     public DLFileEntry[] findByUuid_PrevAndNext(long fileEntryId, String uuid,
712         OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
713         DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
714 
715         int count = countByUuid(uuid);
716 
717         Session session = null;
718 
719         try {
720             session = openSession();
721 
722             StringBuilder query = new StringBuilder();
723 
724             query.append(
725                 "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
726 
727             if (uuid == null) {
728                 query.append("dlFileEntry.uuid IS NULL");
729             }
730             else {
731                 query.append("dlFileEntry.uuid = ?");
732             }
733 
734             query.append(" ");
735 
736             if (obc != null) {
737                 query.append("ORDER BY ");
738 
739                 String[] orderByFields = obc.getOrderByFields();
740 
741                 for (int i = 0; i < orderByFields.length; i++) {
742                     query.append("dlFileEntry.");
743                     query.append(orderByFields[i]);
744 
745                     if (obc.isAscending()) {
746                         query.append(" ASC");
747                     }
748                     else {
749                         query.append(" DESC");
750                     }
751 
752                     if ((i + 1) < orderByFields.length) {
753                         query.append(", ");
754                     }
755                 }
756             }
757 
758             else {
759                 query.append("ORDER BY ");
760 
761                 query.append("dlFileEntry.folderId ASC, ");
762                 query.append("dlFileEntry.name ASC");
763             }
764 
765             Query q = session.createQuery(query.toString());
766 
767             QueryPos qPos = QueryPos.getInstance(q);
768 
769             if (uuid != null) {
770                 qPos.add(uuid);
771             }
772 
773             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
774                     dlFileEntry);
775 
776             DLFileEntry[] array = new DLFileEntryImpl[3];
777 
778             array[0] = (DLFileEntry)objArray[0];
779             array[1] = (DLFileEntry)objArray[1];
780             array[2] = (DLFileEntry)objArray[2];
781 
782             return array;
783         }
784         catch (Exception e) {
785             throw processException(e);
786         }
787         finally {
788             closeSession(session);
789         }
790     }
791 
792     public DLFileEntry findByUUID_G(String uuid, long groupId)
793         throws NoSuchFileEntryException, SystemException {
794         DLFileEntry dlFileEntry = fetchByUUID_G(uuid, groupId);
795 
796         if (dlFileEntry == null) {
797             StringBuilder msg = new StringBuilder();
798 
799             msg.append("No DLFileEntry exists with the key {");
800 
801             msg.append("uuid=" + uuid);
802 
803             msg.append(", ");
804             msg.append("groupId=" + groupId);
805 
806             msg.append(StringPool.CLOSE_CURLY_BRACE);
807 
808             if (_log.isWarnEnabled()) {
809                 _log.warn(msg.toString());
810             }
811 
812             throw new NoSuchFileEntryException(msg.toString());
813         }
814 
815         return dlFileEntry;
816     }
817 
818     public DLFileEntry fetchByUUID_G(String uuid, long groupId)
819         throws SystemException {
820         return fetchByUUID_G(uuid, groupId, true);
821     }
822 
823     public DLFileEntry fetchByUUID_G(String uuid, long groupId,
824         boolean retrieveFromCache) throws SystemException {
825         Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
826 
827         Object result = null;
828 
829         if (retrieveFromCache) {
830             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
831                     finderArgs, this);
832         }
833 
834         if (result == null) {
835             Session session = null;
836 
837             try {
838                 session = openSession();
839 
840                 StringBuilder query = new StringBuilder();
841 
842                 query.append(
843                     "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
844 
845                 if (uuid == null) {
846                     query.append("dlFileEntry.uuid IS NULL");
847                 }
848                 else {
849                     query.append("dlFileEntry.uuid = ?");
850                 }
851 
852                 query.append(" AND ");
853 
854                 query.append("dlFileEntry.groupId = ?");
855 
856                 query.append(" ");
857 
858                 query.append("ORDER BY ");
859 
860                 query.append("dlFileEntry.folderId ASC, ");
861                 query.append("dlFileEntry.name ASC");
862 
863                 Query q = session.createQuery(query.toString());
864 
865                 QueryPos qPos = QueryPos.getInstance(q);
866 
867                 if (uuid != null) {
868                     qPos.add(uuid);
869                 }
870 
871                 qPos.add(groupId);
872 
873                 List<DLFileEntry> list = q.list();
874 
875                 result = list;
876 
877                 DLFileEntry dlFileEntry = null;
878 
879                 if (list.isEmpty()) {
880                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
881                         finderArgs, list);
882                 }
883                 else {
884                     dlFileEntry = list.get(0);
885 
886                     cacheResult(dlFileEntry);
887 
888                     if ((dlFileEntry.getUuid() == null) ||
889                             !dlFileEntry.getUuid().equals(uuid) ||
890                             (dlFileEntry.getGroupId() != groupId)) {
891                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
892                             finderArgs, dlFileEntry);
893                     }
894                 }
895 
896                 return dlFileEntry;
897             }
898             catch (Exception e) {
899                 throw processException(e);
900             }
901             finally {
902                 if (result == null) {
903                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
904                         finderArgs, new ArrayList<DLFileEntry>());
905                 }
906 
907                 closeSession(session);
908             }
909         }
910         else {
911             if (result instanceof List) {
912                 return null;
913             }
914             else {
915                 return (DLFileEntry)result;
916             }
917         }
918     }
919 
920     public List<DLFileEntry> findByGroupId(long groupId)
921         throws SystemException {
922         Object[] finderArgs = new Object[] { new Long(groupId) };
923 
924         List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
925                 finderArgs, this);
926 
927         if (list == null) {
928             Session session = null;
929 
930             try {
931                 session = openSession();
932 
933                 StringBuilder query = new StringBuilder();
934 
935                 query.append(
936                     "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
937 
938                 query.append("dlFileEntry.groupId = ?");
939 
940                 query.append(" ");
941 
942                 query.append("ORDER BY ");
943 
944                 query.append("dlFileEntry.folderId ASC, ");
945                 query.append("dlFileEntry.name ASC");
946 
947                 Query q = session.createQuery(query.toString());
948 
949                 QueryPos qPos = QueryPos.getInstance(q);
950 
951                 qPos.add(groupId);
952 
953                 list = q.list();
954             }
955             catch (Exception e) {
956                 throw processException(e);
957             }
958             finally {
959                 if (list == null) {
960                     list = new ArrayList<DLFileEntry>();
961                 }
962 
963                 cacheResult(list);
964 
965                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
966                     finderArgs, list);
967 
968                 closeSession(session);
969             }
970         }
971 
972         return list;
973     }
974 
975     public List<DLFileEntry> findByGroupId(long groupId, int start, int end)
976         throws SystemException {
977         return findByGroupId(groupId, start, end, null);
978     }
979 
980     public List<DLFileEntry> findByGroupId(long groupId, int start, int end,
981         OrderByComparator obc) throws SystemException {
982         Object[] finderArgs = new Object[] {
983                 new Long(groupId),
984                 
985                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
986             };
987 
988         List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
989                 finderArgs, this);
990 
991         if (list == null) {
992             Session session = null;
993 
994             try {
995                 session = openSession();
996 
997                 StringBuilder query = new StringBuilder();
998 
999                 query.append(
1000                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1001
1002                query.append("dlFileEntry.groupId = ?");
1003
1004                query.append(" ");
1005
1006                if (obc != null) {
1007                    query.append("ORDER BY ");
1008
1009                    String[] orderByFields = obc.getOrderByFields();
1010
1011                    for (int i = 0; i < orderByFields.length; i++) {
1012                        query.append("dlFileEntry.");
1013                        query.append(orderByFields[i]);
1014
1015                        if (obc.isAscending()) {
1016                            query.append(" ASC");
1017                        }
1018                        else {
1019                            query.append(" DESC");
1020                        }
1021
1022                        if ((i + 1) < orderByFields.length) {
1023                            query.append(", ");
1024                        }
1025                    }
1026                }
1027
1028                else {
1029                    query.append("ORDER BY ");
1030
1031                    query.append("dlFileEntry.folderId ASC, ");
1032                    query.append("dlFileEntry.name ASC");
1033                }
1034
1035                Query q = session.createQuery(query.toString());
1036
1037                QueryPos qPos = QueryPos.getInstance(q);
1038
1039                qPos.add(groupId);
1040
1041                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1042                        start, end);
1043            }
1044            catch (Exception e) {
1045                throw processException(e);
1046            }
1047            finally {
1048                if (list == null) {
1049                    list = new ArrayList<DLFileEntry>();
1050                }
1051
1052                cacheResult(list);
1053
1054                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1055                    finderArgs, list);
1056
1057                closeSession(session);
1058            }
1059        }
1060
1061        return list;
1062    }
1063
1064    public DLFileEntry findByGroupId_First(long groupId, OrderByComparator obc)
1065        throws NoSuchFileEntryException, SystemException {
1066        List<DLFileEntry> list = findByGroupId(groupId, 0, 1, obc);
1067
1068        if (list.isEmpty()) {
1069            StringBuilder msg = new StringBuilder();
1070
1071            msg.append("No DLFileEntry exists with the key {");
1072
1073            msg.append("groupId=" + groupId);
1074
1075            msg.append(StringPool.CLOSE_CURLY_BRACE);
1076
1077            throw new NoSuchFileEntryException(msg.toString());
1078        }
1079        else {
1080            return list.get(0);
1081        }
1082    }
1083
1084    public DLFileEntry findByGroupId_Last(long groupId, OrderByComparator obc)
1085        throws NoSuchFileEntryException, SystemException {
1086        int count = countByGroupId(groupId);
1087
1088        List<DLFileEntry> list = findByGroupId(groupId, count - 1, count, obc);
1089
1090        if (list.isEmpty()) {
1091            StringBuilder msg = new StringBuilder();
1092
1093            msg.append("No DLFileEntry exists with the key {");
1094
1095            msg.append("groupId=" + groupId);
1096
1097            msg.append(StringPool.CLOSE_CURLY_BRACE);
1098
1099            throw new NoSuchFileEntryException(msg.toString());
1100        }
1101        else {
1102            return list.get(0);
1103        }
1104    }
1105
1106    public DLFileEntry[] findByGroupId_PrevAndNext(long fileEntryId,
1107        long groupId, OrderByComparator obc)
1108        throws NoSuchFileEntryException, SystemException {
1109        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1110
1111        int count = countByGroupId(groupId);
1112
1113        Session session = null;
1114
1115        try {
1116            session = openSession();
1117
1118            StringBuilder query = new StringBuilder();
1119
1120            query.append(
1121                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1122
1123            query.append("dlFileEntry.groupId = ?");
1124
1125            query.append(" ");
1126
1127            if (obc != null) {
1128                query.append("ORDER BY ");
1129
1130                String[] orderByFields = obc.getOrderByFields();
1131
1132                for (int i = 0; i < orderByFields.length; i++) {
1133                    query.append("dlFileEntry.");
1134                    query.append(orderByFields[i]);
1135
1136                    if (obc.isAscending()) {
1137                        query.append(" ASC");
1138                    }
1139                    else {
1140                        query.append(" DESC");
1141                    }
1142
1143                    if ((i + 1) < orderByFields.length) {
1144                        query.append(", ");
1145                    }
1146                }
1147            }
1148
1149            else {
1150                query.append("ORDER BY ");
1151
1152                query.append("dlFileEntry.folderId ASC, ");
1153                query.append("dlFileEntry.name ASC");
1154            }
1155
1156            Query q = session.createQuery(query.toString());
1157
1158            QueryPos qPos = QueryPos.getInstance(q);
1159
1160            qPos.add(groupId);
1161
1162            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1163                    dlFileEntry);
1164
1165            DLFileEntry[] array = new DLFileEntryImpl[3];
1166
1167            array[0] = (DLFileEntry)objArray[0];
1168            array[1] = (DLFileEntry)objArray[1];
1169            array[2] = (DLFileEntry)objArray[2];
1170
1171            return array;
1172        }
1173        catch (Exception e) {
1174            throw processException(e);
1175        }
1176        finally {
1177            closeSession(session);
1178        }
1179    }
1180
1181    public List<DLFileEntry> findByCompanyId(long companyId)
1182        throws SystemException {
1183        Object[] finderArgs = new Object[] { new Long(companyId) };
1184
1185        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1186                finderArgs, this);
1187
1188        if (list == null) {
1189            Session session = null;
1190
1191            try {
1192                session = openSession();
1193
1194                StringBuilder query = new StringBuilder();
1195
1196                query.append(
1197                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1198
1199                query.append("dlFileEntry.companyId = ?");
1200
1201                query.append(" ");
1202
1203                query.append("ORDER BY ");
1204
1205                query.append("dlFileEntry.folderId ASC, ");
1206                query.append("dlFileEntry.name ASC");
1207
1208                Query q = session.createQuery(query.toString());
1209
1210                QueryPos qPos = QueryPos.getInstance(q);
1211
1212                qPos.add(companyId);
1213
1214                list = q.list();
1215            }
1216            catch (Exception e) {
1217                throw processException(e);
1218            }
1219            finally {
1220                if (list == null) {
1221                    list = new ArrayList<DLFileEntry>();
1222                }
1223
1224                cacheResult(list);
1225
1226                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1227                    finderArgs, list);
1228
1229                closeSession(session);
1230            }
1231        }
1232
1233        return list;
1234    }
1235
1236    public List<DLFileEntry> findByCompanyId(long companyId, int start, int end)
1237        throws SystemException {
1238        return findByCompanyId(companyId, start, end, null);
1239    }
1240
1241    public List<DLFileEntry> findByCompanyId(long companyId, int start,
1242        int end, OrderByComparator obc) throws SystemException {
1243        Object[] finderArgs = new Object[] {
1244                new Long(companyId),
1245                
1246                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1247            };
1248
1249        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1250                finderArgs, this);
1251
1252        if (list == null) {
1253            Session session = null;
1254
1255            try {
1256                session = openSession();
1257
1258                StringBuilder query = new StringBuilder();
1259
1260                query.append(
1261                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1262
1263                query.append("dlFileEntry.companyId = ?");
1264
1265                query.append(" ");
1266
1267                if (obc != null) {
1268                    query.append("ORDER BY ");
1269
1270                    String[] orderByFields = obc.getOrderByFields();
1271
1272                    for (int i = 0; i < orderByFields.length; i++) {
1273                        query.append("dlFileEntry.");
1274                        query.append(orderByFields[i]);
1275
1276                        if (obc.isAscending()) {
1277                            query.append(" ASC");
1278                        }
1279                        else {
1280                            query.append(" DESC");
1281                        }
1282
1283                        if ((i + 1) < orderByFields.length) {
1284                            query.append(", ");
1285                        }
1286                    }
1287                }
1288
1289                else {
1290                    query.append("ORDER BY ");
1291
1292                    query.append("dlFileEntry.folderId ASC, ");
1293                    query.append("dlFileEntry.name ASC");
1294                }
1295
1296                Query q = session.createQuery(query.toString());
1297
1298                QueryPos qPos = QueryPos.getInstance(q);
1299
1300                qPos.add(companyId);
1301
1302                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1303                        start, end);
1304            }
1305            catch (Exception e) {
1306                throw processException(e);
1307            }
1308            finally {
1309                if (list == null) {
1310                    list = new ArrayList<DLFileEntry>();
1311                }
1312
1313                cacheResult(list);
1314
1315                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1316                    finderArgs, list);
1317
1318                closeSession(session);
1319            }
1320        }
1321
1322        return list;
1323    }
1324
1325    public DLFileEntry findByCompanyId_First(long companyId,
1326        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1327        List<DLFileEntry> list = findByCompanyId(companyId, 0, 1, obc);
1328
1329        if (list.isEmpty()) {
1330            StringBuilder msg = new StringBuilder();
1331
1332            msg.append("No DLFileEntry exists with the key {");
1333
1334            msg.append("companyId=" + companyId);
1335
1336            msg.append(StringPool.CLOSE_CURLY_BRACE);
1337
1338            throw new NoSuchFileEntryException(msg.toString());
1339        }
1340        else {
1341            return list.get(0);
1342        }
1343    }
1344
1345    public DLFileEntry findByCompanyId_Last(long companyId,
1346        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1347        int count = countByCompanyId(companyId);
1348
1349        List<DLFileEntry> list = findByCompanyId(companyId, count - 1, count,
1350                obc);
1351
1352        if (list.isEmpty()) {
1353            StringBuilder msg = new StringBuilder();
1354
1355            msg.append("No DLFileEntry exists with the key {");
1356
1357            msg.append("companyId=" + companyId);
1358
1359            msg.append(StringPool.CLOSE_CURLY_BRACE);
1360
1361            throw new NoSuchFileEntryException(msg.toString());
1362        }
1363        else {
1364            return list.get(0);
1365        }
1366    }
1367
1368    public DLFileEntry[] findByCompanyId_PrevAndNext(long fileEntryId,
1369        long companyId, OrderByComparator obc)
1370        throws NoSuchFileEntryException, SystemException {
1371        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1372
1373        int count = countByCompanyId(companyId);
1374
1375        Session session = null;
1376
1377        try {
1378            session = openSession();
1379
1380            StringBuilder query = new StringBuilder();
1381
1382            query.append(
1383                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1384
1385            query.append("dlFileEntry.companyId = ?");
1386
1387            query.append(" ");
1388
1389            if (obc != null) {
1390                query.append("ORDER BY ");
1391
1392                String[] orderByFields = obc.getOrderByFields();
1393
1394                for (int i = 0; i < orderByFields.length; i++) {
1395                    query.append("dlFileEntry.");
1396                    query.append(orderByFields[i]);
1397
1398                    if (obc.isAscending()) {
1399                        query.append(" ASC");
1400                    }
1401                    else {
1402                        query.append(" DESC");
1403                    }
1404
1405                    if ((i + 1) < orderByFields.length) {
1406                        query.append(", ");
1407                    }
1408                }
1409            }
1410
1411            else {
1412                query.append("ORDER BY ");
1413
1414                query.append("dlFileEntry.folderId ASC, ");
1415                query.append("dlFileEntry.name ASC");
1416            }
1417
1418            Query q = session.createQuery(query.toString());
1419
1420            QueryPos qPos = QueryPos.getInstance(q);
1421
1422            qPos.add(companyId);
1423
1424            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1425                    dlFileEntry);
1426
1427            DLFileEntry[] array = new DLFileEntryImpl[3];
1428
1429            array[0] = (DLFileEntry)objArray[0];
1430            array[1] = (DLFileEntry)objArray[1];
1431            array[2] = (DLFileEntry)objArray[2];
1432
1433            return array;
1434        }
1435        catch (Exception e) {
1436            throw processException(e);
1437        }
1438        finally {
1439            closeSession(session);
1440        }
1441    }
1442
1443    public List<DLFileEntry> findByFolderId(long folderId)
1444        throws SystemException {
1445        Object[] finderArgs = new Object[] { new Long(folderId) };
1446
1447        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FOLDERID,
1448                finderArgs, this);
1449
1450        if (list == null) {
1451            Session session = null;
1452
1453            try {
1454                session = openSession();
1455
1456                StringBuilder query = new StringBuilder();
1457
1458                query.append(
1459                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1460
1461                query.append("dlFileEntry.folderId = ?");
1462
1463                query.append(" ");
1464
1465                query.append("ORDER BY ");
1466
1467                query.append("dlFileEntry.folderId ASC, ");
1468                query.append("dlFileEntry.name ASC");
1469
1470                Query q = session.createQuery(query.toString());
1471
1472                QueryPos qPos = QueryPos.getInstance(q);
1473
1474                qPos.add(folderId);
1475
1476                list = q.list();
1477            }
1478            catch (Exception e) {
1479                throw processException(e);
1480            }
1481            finally {
1482                if (list == null) {
1483                    list = new ArrayList<DLFileEntry>();
1484                }
1485
1486                cacheResult(list);
1487
1488                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FOLDERID,
1489                    finderArgs, list);
1490
1491                closeSession(session);
1492            }
1493        }
1494
1495        return list;
1496    }
1497
1498    public List<DLFileEntry> findByFolderId(long folderId, int start, int end)
1499        throws SystemException {
1500        return findByFolderId(folderId, start, end, null);
1501    }
1502
1503    public List<DLFileEntry> findByFolderId(long folderId, int start, int end,
1504        OrderByComparator obc) throws SystemException {
1505        Object[] finderArgs = new Object[] {
1506                new Long(folderId),
1507                
1508                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1509            };
1510
1511        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
1512                finderArgs, this);
1513
1514        if (list == null) {
1515            Session session = null;
1516
1517            try {
1518                session = openSession();
1519
1520                StringBuilder query = new StringBuilder();
1521
1522                query.append(
1523                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1524
1525                query.append("dlFileEntry.folderId = ?");
1526
1527                query.append(" ");
1528
1529                if (obc != null) {
1530                    query.append("ORDER BY ");
1531
1532                    String[] orderByFields = obc.getOrderByFields();
1533
1534                    for (int i = 0; i < orderByFields.length; i++) {
1535                        query.append("dlFileEntry.");
1536                        query.append(orderByFields[i]);
1537
1538                        if (obc.isAscending()) {
1539                            query.append(" ASC");
1540                        }
1541                        else {
1542                            query.append(" DESC");
1543                        }
1544
1545                        if ((i + 1) < orderByFields.length) {
1546                            query.append(", ");
1547                        }
1548                    }
1549                }
1550
1551                else {
1552                    query.append("ORDER BY ");
1553
1554                    query.append("dlFileEntry.folderId ASC, ");
1555                    query.append("dlFileEntry.name ASC");
1556                }
1557
1558                Query q = session.createQuery(query.toString());
1559
1560                QueryPos qPos = QueryPos.getInstance(q);
1561
1562                qPos.add(folderId);
1563
1564                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1565                        start, end);
1566            }
1567            catch (Exception e) {
1568                throw processException(e);
1569            }
1570            finally {
1571                if (list == null) {
1572                    list = new ArrayList<DLFileEntry>();
1573                }
1574
1575                cacheResult(list);
1576
1577                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
1578                    finderArgs, list);
1579
1580                closeSession(session);
1581            }
1582        }
1583
1584        return list;
1585    }
1586
1587    public DLFileEntry findByFolderId_First(long folderId, OrderByComparator obc)
1588        throws NoSuchFileEntryException, SystemException {
1589        List<DLFileEntry> list = findByFolderId(folderId, 0, 1, obc);
1590
1591        if (list.isEmpty()) {
1592            StringBuilder msg = new StringBuilder();
1593
1594            msg.append("No DLFileEntry exists with the key {");
1595
1596            msg.append("folderId=" + folderId);
1597
1598            msg.append(StringPool.CLOSE_CURLY_BRACE);
1599
1600            throw new NoSuchFileEntryException(msg.toString());
1601        }
1602        else {
1603            return list.get(0);
1604        }
1605    }
1606
1607    public DLFileEntry findByFolderId_Last(long folderId, OrderByComparator obc)
1608        throws NoSuchFileEntryException, SystemException {
1609        int count = countByFolderId(folderId);
1610
1611        List<DLFileEntry> list = findByFolderId(folderId, count - 1, count, obc);
1612
1613        if (list.isEmpty()) {
1614            StringBuilder msg = new StringBuilder();
1615
1616            msg.append("No DLFileEntry exists with the key {");
1617
1618            msg.append("folderId=" + folderId);
1619
1620            msg.append(StringPool.CLOSE_CURLY_BRACE);
1621
1622            throw new NoSuchFileEntryException(msg.toString());
1623        }
1624        else {
1625            return list.get(0);
1626        }
1627    }
1628
1629    public DLFileEntry[] findByFolderId_PrevAndNext(long fileEntryId,
1630        long folderId, OrderByComparator obc)
1631        throws NoSuchFileEntryException, SystemException {
1632        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1633
1634        int count = countByFolderId(folderId);
1635
1636        Session session = null;
1637
1638        try {
1639            session = openSession();
1640
1641            StringBuilder query = new StringBuilder();
1642
1643            query.append(
1644                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1645
1646            query.append("dlFileEntry.folderId = ?");
1647
1648            query.append(" ");
1649
1650            if (obc != null) {
1651                query.append("ORDER BY ");
1652
1653                String[] orderByFields = obc.getOrderByFields();
1654
1655                for (int i = 0; i < orderByFields.length; i++) {
1656                    query.append("dlFileEntry.");
1657                    query.append(orderByFields[i]);
1658
1659                    if (obc.isAscending()) {
1660                        query.append(" ASC");
1661                    }
1662                    else {
1663                        query.append(" DESC");
1664                    }
1665
1666                    if ((i + 1) < orderByFields.length) {
1667                        query.append(", ");
1668                    }
1669                }
1670            }
1671
1672            else {
1673                query.append("ORDER BY ");
1674
1675                query.append("dlFileEntry.folderId ASC, ");
1676                query.append("dlFileEntry.name ASC");
1677            }
1678
1679            Query q = session.createQuery(query.toString());
1680
1681            QueryPos qPos = QueryPos.getInstance(q);
1682
1683            qPos.add(folderId);
1684
1685            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1686                    dlFileEntry);
1687
1688            DLFileEntry[] array = new DLFileEntryImpl[3];
1689
1690            array[0] = (DLFileEntry)objArray[0];
1691            array[1] = (DLFileEntry)objArray[1];
1692            array[2] = (DLFileEntry)objArray[2];
1693
1694            return array;
1695        }
1696        catch (Exception e) {
1697            throw processException(e);
1698        }
1699        finally {
1700            closeSession(session);
1701        }
1702    }
1703
1704    public List<DLFileEntry> findByG_U(long groupId, long userId)
1705        throws SystemException {
1706        Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1707
1708        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
1709                finderArgs, this);
1710
1711        if (list == null) {
1712            Session session = null;
1713
1714            try {
1715                session = openSession();
1716
1717                StringBuilder query = new StringBuilder();
1718
1719                query.append(
1720                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1721
1722                query.append("dlFileEntry.groupId = ?");
1723
1724                query.append(" AND ");
1725
1726                query.append("dlFileEntry.userId = ?");
1727
1728                query.append(" ");
1729
1730                query.append("ORDER BY ");
1731
1732                query.append("dlFileEntry.folderId ASC, ");
1733                query.append("dlFileEntry.name ASC");
1734
1735                Query q = session.createQuery(query.toString());
1736
1737                QueryPos qPos = QueryPos.getInstance(q);
1738
1739                qPos.add(groupId);
1740
1741                qPos.add(userId);
1742
1743                list = q.list();
1744            }
1745            catch (Exception e) {
1746                throw processException(e);
1747            }
1748            finally {
1749                if (list == null) {
1750                    list = new ArrayList<DLFileEntry>();
1751                }
1752
1753                cacheResult(list);
1754
1755                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
1756                    list);
1757
1758                closeSession(session);
1759            }
1760        }
1761
1762        return list;
1763    }
1764
1765    public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
1766        int end) throws SystemException {
1767        return findByG_U(groupId, userId, start, end, null);
1768    }
1769
1770    public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
1771        int end, OrderByComparator obc) throws SystemException {
1772        Object[] finderArgs = new Object[] {
1773                new Long(groupId), new Long(userId),
1774                
1775                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1776            };
1777
1778        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_U,
1779                finderArgs, this);
1780
1781        if (list == null) {
1782            Session session = null;
1783
1784            try {
1785                session = openSession();
1786
1787                StringBuilder query = new StringBuilder();
1788
1789                query.append(
1790                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1791
1792                query.append("dlFileEntry.groupId = ?");
1793
1794                query.append(" AND ");
1795
1796                query.append("dlFileEntry.userId = ?");
1797
1798                query.append(" ");
1799
1800                if (obc != null) {
1801                    query.append("ORDER BY ");
1802
1803                    String[] orderByFields = obc.getOrderByFields();
1804
1805                    for (int i = 0; i < orderByFields.length; i++) {
1806                        query.append("dlFileEntry.");
1807                        query.append(orderByFields[i]);
1808
1809                        if (obc.isAscending()) {
1810                            query.append(" ASC");
1811                        }
1812                        else {
1813                            query.append(" DESC");
1814                        }
1815
1816                        if ((i + 1) < orderByFields.length) {
1817                            query.append(", ");
1818                        }
1819                    }
1820                }
1821
1822                else {
1823                    query.append("ORDER BY ");
1824
1825                    query.append("dlFileEntry.folderId ASC, ");
1826                    query.append("dlFileEntry.name ASC");
1827                }
1828
1829                Query q = session.createQuery(query.toString());
1830
1831                QueryPos qPos = QueryPos.getInstance(q);
1832
1833                qPos.add(groupId);
1834
1835                qPos.add(userId);
1836
1837                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1838                        start, end);
1839            }
1840            catch (Exception e) {
1841                throw processException(e);
1842            }
1843            finally {
1844                if (list == null) {
1845                    list = new ArrayList<DLFileEntry>();
1846                }
1847
1848                cacheResult(list);
1849
1850                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_U,
1851                    finderArgs, list);
1852
1853                closeSession(session);
1854            }
1855        }
1856
1857        return list;
1858    }
1859
1860    public DLFileEntry findByG_U_First(long groupId, long userId,
1861        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1862        List<DLFileEntry> list = findByG_U(groupId, userId, 0, 1, obc);
1863
1864        if (list.isEmpty()) {
1865            StringBuilder msg = new StringBuilder();
1866
1867            msg.append("No DLFileEntry exists with the key {");
1868
1869            msg.append("groupId=" + groupId);
1870
1871            msg.append(", ");
1872            msg.append("userId=" + userId);
1873
1874            msg.append(StringPool.CLOSE_CURLY_BRACE);
1875
1876            throw new NoSuchFileEntryException(msg.toString());
1877        }
1878        else {
1879            return list.get(0);
1880        }
1881    }
1882
1883    public DLFileEntry findByG_U_Last(long groupId, long userId,
1884        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1885        int count = countByG_U(groupId, userId);
1886
1887        List<DLFileEntry> list = findByG_U(groupId, userId, count - 1, count,
1888                obc);
1889
1890        if (list.isEmpty()) {
1891            StringBuilder msg = new StringBuilder();
1892
1893            msg.append("No DLFileEntry exists with the key {");
1894
1895            msg.append("groupId=" + groupId);
1896
1897            msg.append(", ");
1898            msg.append("userId=" + userId);
1899
1900            msg.append(StringPool.CLOSE_CURLY_BRACE);
1901
1902            throw new NoSuchFileEntryException(msg.toString());
1903        }
1904        else {
1905            return list.get(0);
1906        }
1907    }
1908
1909    public DLFileEntry[] findByG_U_PrevAndNext(long fileEntryId, long groupId,
1910        long userId, OrderByComparator obc)
1911        throws NoSuchFileEntryException, SystemException {
1912        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1913
1914        int count = countByG_U(groupId, userId);
1915
1916        Session session = null;
1917
1918        try {
1919            session = openSession();
1920
1921            StringBuilder query = new StringBuilder();
1922
1923            query.append(
1924                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1925
1926            query.append("dlFileEntry.groupId = ?");
1927
1928            query.append(" AND ");
1929
1930            query.append("dlFileEntry.userId = ?");
1931
1932            query.append(" ");
1933
1934            if (obc != null) {
1935                query.append("ORDER BY ");
1936
1937                String[] orderByFields = obc.getOrderByFields();
1938
1939                for (int i = 0; i < orderByFields.length; i++) {
1940                    query.append("dlFileEntry.");
1941                    query.append(orderByFields[i]);
1942
1943                    if (obc.isAscending()) {
1944                        query.append(" ASC");
1945                    }
1946                    else {
1947                        query.append(" DESC");
1948                    }
1949
1950                    if ((i + 1) < orderByFields.length) {
1951                        query.append(", ");
1952                    }
1953                }
1954            }
1955
1956            else {
1957                query.append("ORDER BY ");
1958
1959                query.append("dlFileEntry.folderId ASC, ");
1960                query.append("dlFileEntry.name ASC");
1961            }
1962
1963            Query q = session.createQuery(query.toString());
1964
1965            QueryPos qPos = QueryPos.getInstance(q);
1966
1967            qPos.add(groupId);
1968
1969            qPos.add(userId);
1970
1971            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1972                    dlFileEntry);
1973
1974            DLFileEntry[] array = new DLFileEntryImpl[3];
1975
1976            array[0] = (DLFileEntry)objArray[0];
1977            array[1] = (DLFileEntry)objArray[1];
1978            array[2] = (DLFileEntry)objArray[2];
1979
1980            return array;
1981        }
1982        catch (Exception e) {
1983            throw processException(e);
1984        }
1985        finally {
1986            closeSession(session);
1987        }
1988    }
1989
1990    public DLFileEntry findByF_N(long folderId, String name)
1991        throws NoSuchFileEntryException, SystemException {
1992        DLFileEntry dlFileEntry = fetchByF_N(folderId, name);
1993
1994        if (dlFileEntry == null) {
1995            StringBuilder msg = new StringBuilder();
1996
1997            msg.append("No DLFileEntry exists with the key {");
1998
1999            msg.append("folderId=" + folderId);
2000
2001            msg.append(", ");
2002            msg.append("name=" + name);
2003
2004            msg.append(StringPool.CLOSE_CURLY_BRACE);
2005
2006            if (_log.isWarnEnabled()) {
2007                _log.warn(msg.toString());
2008            }
2009
2010            throw new NoSuchFileEntryException(msg.toString());
2011        }
2012
2013        return dlFileEntry;
2014    }
2015
2016    public DLFileEntry fetchByF_N(long folderId, String name)
2017        throws SystemException {
2018        return fetchByF_N(folderId, name, true);
2019    }
2020
2021    public DLFileEntry fetchByF_N(long folderId, String name,
2022        boolean retrieveFromCache) throws SystemException {
2023        Object[] finderArgs = new Object[] { new Long(folderId), name };
2024
2025        Object result = null;
2026
2027        if (retrieveFromCache) {
2028            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_F_N,
2029                    finderArgs, this);
2030        }
2031
2032        if (result == null) {
2033            Session session = null;
2034
2035            try {
2036                session = openSession();
2037
2038                StringBuilder query = new StringBuilder();
2039
2040                query.append(
2041                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
2042
2043                query.append("dlFileEntry.folderId = ?");
2044
2045                query.append(" AND ");
2046
2047                if (name == null) {
2048                    query.append("dlFileEntry.name IS NULL");
2049                }
2050                else {
2051                    query.append("dlFileEntry.name = ?");
2052                }
2053
2054                query.append(" ");
2055
2056                query.append("ORDER BY ");
2057
2058                query.append("dlFileEntry.folderId ASC, ");
2059                query.append("dlFileEntry.name ASC");
2060
2061                Query q = session.createQuery(query.toString());
2062
2063                QueryPos qPos = QueryPos.getInstance(q);
2064
2065                qPos.add(folderId);
2066
2067                if (name != null) {
2068                    qPos.add(name);
2069                }
2070
2071                List<DLFileEntry> list = q.list();
2072
2073                result = list;
2074
2075                DLFileEntry dlFileEntry = null;
2076
2077                if (list.isEmpty()) {
2078                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
2079                        finderArgs, list);
2080                }
2081                else {
2082                    dlFileEntry = list.get(0);
2083
2084                    cacheResult(dlFileEntry);
2085
2086                    if ((dlFileEntry.getFolderId() != folderId) ||
2087                            (dlFileEntry.getName() == null) ||
2088                            !dlFileEntry.getName().equals(name)) {
2089                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
2090                            finderArgs, dlFileEntry);
2091                    }
2092                }
2093
2094                return dlFileEntry;
2095            }
2096            catch (Exception e) {
2097                throw processException(e);
2098            }
2099            finally {
2100                if (result == null) {
2101                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
2102                        finderArgs, new ArrayList<DLFileEntry>());
2103                }
2104
2105                closeSession(session);
2106            }
2107        }
2108        else {
2109            if (result instanceof List) {
2110                return null;
2111            }
2112            else {
2113                return (DLFileEntry)result;
2114            }
2115        }
2116    }
2117
2118    public List<DLFileEntry> findByF_T(long folderId, String title)
2119        throws SystemException {
2120        Object[] finderArgs = new Object[] { new Long(folderId), title };
2121
2122        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_F_T,
2123                finderArgs, this);
2124
2125        if (list == null) {
2126            Session session = null;
2127
2128            try {
2129                session = openSession();
2130
2131                StringBuilder query = new StringBuilder();
2132
2133                query.append(
2134                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
2135
2136                query.append("dlFileEntry.folderId = ?");
2137
2138                query.append(" AND ");
2139
2140                if (title == null) {
2141                    query.append("dlFileEntry.title IS NULL");
2142                }
2143                else {
2144                    query.append("dlFileEntry.title = ?");
2145                }
2146
2147                query.append(" ");
2148
2149                query.append("ORDER BY ");
2150
2151                query.append("dlFileEntry.folderId ASC, ");
2152                query.append("dlFileEntry.name ASC");
2153
2154                Query q = session.createQuery(query.toString());
2155
2156                QueryPos qPos = QueryPos.getInstance(q);
2157
2158                qPos.add(folderId);
2159
2160                if (title != null) {
2161                    qPos.add(title);
2162                }
2163
2164                list = q.list();
2165            }
2166            catch (Exception e) {
2167                throw processException(e);
2168            }
2169            finally {
2170                if (list == null) {
2171                    list = new ArrayList<DLFileEntry>();
2172                }
2173
2174                cacheResult(list);
2175
2176                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_F_T, finderArgs,
2177                    list);
2178
2179                closeSession(session);
2180            }
2181        }
2182
2183        return list;
2184    }
2185
2186    public List<DLFileEntry> findByF_T(long folderId, String title, int start,
2187        int end) throws SystemException {
2188        return findByF_T(folderId, title, start, end, null);
2189    }
2190
2191    public List<DLFileEntry> findByF_T(long folderId, String title, int start,
2192        int end, OrderByComparator obc) throws SystemException {
2193        Object[] finderArgs = new Object[] {
2194                new Long(folderId),
2195                
2196                title,
2197                
2198                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2199            };
2200
2201        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_F_T,
2202                finderArgs, this);
2203
2204        if (list == null) {
2205            Session session = null;
2206
2207            try {
2208                session = openSession();
2209
2210                StringBuilder query = new StringBuilder();
2211
2212                query.append(
2213                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
2214
2215                query.append("dlFileEntry.folderId = ?");
2216
2217                query.append(" AND ");
2218
2219                if (title == null) {
2220                    query.append("dlFileEntry.title IS NULL");
2221                }
2222                else {
2223                    query.append("dlFileEntry.title = ?");
2224                }
2225
2226                query.append(" ");
2227
2228                if (obc != null) {
2229                    query.append("ORDER BY ");
2230
2231                    String[] orderByFields = obc.getOrderByFields();
2232
2233                    for (int i = 0; i < orderByFields.length; i++) {
2234                        query.append("dlFileEntry.");
2235                        query.append(orderByFields[i]);
2236
2237                        if (obc.isAscending()) {
2238                            query.append(" ASC");
2239                        }
2240                        else {
2241                            query.append(" DESC");
2242                        }
2243
2244                        if ((i + 1) < orderByFields.length) {
2245                            query.append(", ");
2246                        }
2247                    }
2248                }
2249
2250                else {
2251                    query.append("ORDER BY ");
2252
2253                    query.append("dlFileEntry.folderId ASC, ");
2254                    query.append("dlFileEntry.name ASC");
2255                }
2256
2257                Query q = session.createQuery(query.toString());
2258
2259                QueryPos qPos = QueryPos.getInstance(q);
2260
2261                qPos.add(folderId);
2262
2263                if (title != null) {
2264                    qPos.add(title);
2265                }
2266
2267                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2268                        start, end);
2269            }
2270            catch (Exception e) {
2271                throw processException(e);
2272            }
2273            finally {
2274                if (list == null) {
2275                    list = new ArrayList<DLFileEntry>();
2276                }
2277
2278                cacheResult(list);
2279
2280                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_F_T,
2281                    finderArgs, list);
2282
2283                closeSession(session);
2284            }
2285        }
2286
2287        return list;
2288    }
2289
2290    public DLFileEntry findByF_T_First(long folderId, String title,
2291        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
2292        List<DLFileEntry> list = findByF_T(folderId, title, 0, 1, obc);
2293
2294        if (list.isEmpty()) {
2295            StringBuilder msg = new StringBuilder();
2296
2297            msg.append("No DLFileEntry exists with the key {");
2298
2299            msg.append("folderId=" + folderId);
2300
2301            msg.append(", ");
2302            msg.append("title=" + title);
2303
2304            msg.append(StringPool.CLOSE_CURLY_BRACE);
2305
2306            throw new NoSuchFileEntryException(msg.toString());
2307        }
2308        else {
2309            return list.get(0);
2310        }
2311    }
2312
2313    public DLFileEntry findByF_T_Last(long folderId, String title,
2314        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
2315        int count = countByF_T(folderId, title);
2316
2317        List<DLFileEntry> list = findByF_T(folderId, title, count - 1, count,
2318                obc);
2319
2320        if (list.isEmpty()) {
2321            StringBuilder msg = new StringBuilder();
2322
2323            msg.append("No DLFileEntry exists with the key {");
2324
2325            msg.append("folderId=" + folderId);
2326
2327            msg.append(", ");
2328            msg.append("title=" + title);
2329
2330            msg.append(StringPool.CLOSE_CURLY_BRACE);
2331
2332            throw new NoSuchFileEntryException(msg.toString());
2333        }
2334        else {
2335            return list.get(0);
2336        }
2337    }
2338
2339    public DLFileEntry[] findByF_T_PrevAndNext(long fileEntryId, long folderId,
2340        String title, OrderByComparator obc)
2341        throws NoSuchFileEntryException, SystemException {
2342        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2343
2344        int count = countByF_T(folderId, title);
2345
2346        Session session = null;
2347
2348        try {
2349            session = openSession();
2350
2351            StringBuilder query = new StringBuilder();
2352
2353            query.append(
2354                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
2355
2356            query.append("dlFileEntry.folderId = ?");
2357
2358            query.append(" AND ");
2359
2360            if (title == null) {
2361                query.append("dlFileEntry.title IS NULL");
2362            }
2363            else {
2364                query.append("dlFileEntry.title = ?");
2365            }
2366
2367            query.append(" ");
2368
2369            if (obc != null) {
2370                query.append("ORDER BY ");
2371
2372                String[] orderByFields = obc.getOrderByFields();
2373
2374                for (int i = 0; i < orderByFields.length; i++) {
2375                    query.append("dlFileEntry.");
2376                    query.append(orderByFields[i]);
2377
2378                    if (obc.isAscending()) {
2379                        query.append(" ASC");
2380                    }
2381                    else {
2382                        query.append(" DESC");
2383                    }
2384
2385                    if ((i + 1) < orderByFields.length) {
2386                        query.append(", ");
2387                    }
2388                }
2389            }
2390
2391            else {
2392                query.append("ORDER BY ");
2393
2394                query.append("dlFileEntry.folderId ASC, ");
2395                query.append("dlFileEntry.name ASC");
2396            }
2397
2398            Query q = session.createQuery(query.toString());
2399
2400            QueryPos qPos = QueryPos.getInstance(q);
2401
2402            qPos.add(folderId);
2403
2404            if (title != null) {
2405                qPos.add(title);
2406            }
2407
2408            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2409                    dlFileEntry);
2410
2411            DLFileEntry[] array = new DLFileEntryImpl[3];
2412
2413            array[0] = (DLFileEntry)objArray[0];
2414            array[1] = (DLFileEntry)objArray[1];
2415            array[2] = (DLFileEntry)objArray[2];
2416
2417            return array;
2418        }
2419        catch (Exception e) {
2420            throw processException(e);
2421        }
2422        finally {
2423            closeSession(session);
2424        }
2425    }
2426
2427    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2428        throws SystemException {
2429        Session session = null;
2430
2431        try {
2432            session = openSession();
2433
2434            dynamicQuery.compile(session);
2435
2436            return dynamicQuery.list();
2437        }
2438        catch (Exception e) {
2439            throw processException(e);
2440        }
2441        finally {
2442            closeSession(session);
2443        }
2444    }
2445
2446    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2447        int start, int end) throws SystemException {
2448        Session session = null;
2449
2450        try {
2451            session = openSession();
2452
2453            dynamicQuery.setLimit(start, end);
2454
2455            dynamicQuery.compile(session);
2456
2457            return dynamicQuery.list();
2458        }
2459        catch (Exception e) {
2460            throw processException(e);
2461        }
2462        finally {
2463            closeSession(session);
2464        }
2465    }
2466
2467    public List<DLFileEntry> findAll() throws SystemException {
2468        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2469    }
2470
2471    public List<DLFileEntry> findAll(int start, int end)
2472        throws SystemException {
2473        return findAll(start, end, null);
2474    }
2475
2476    public List<DLFileEntry> findAll(int start, int end, OrderByComparator obc)
2477        throws SystemException {
2478        Object[] finderArgs = new Object[] {
2479                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2480            };
2481
2482        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2483                finderArgs, this);
2484
2485        if (list == null) {
2486            Session session = null;
2487
2488            try {
2489                session = openSession();
2490
2491                StringBuilder query = new StringBuilder();
2492
2493                query.append("SELECT dlFileEntry FROM DLFileEntry dlFileEntry ");
2494
2495                if (obc != null) {
2496                    query.append("ORDER BY ");
2497
2498                    String[] orderByFields = obc.getOrderByFields();
2499
2500                    for (int i = 0; i < orderByFields.length; i++) {
2501                        query.append("dlFileEntry.");
2502                        query.append(orderByFields[i]);
2503
2504                        if (obc.isAscending()) {
2505                            query.append(" ASC");
2506                        }
2507                        else {
2508                            query.append(" DESC");
2509                        }
2510
2511                        if ((i + 1) < orderByFields.length) {
2512                            query.append(", ");
2513                        }
2514                    }
2515                }
2516
2517                else {
2518                    query.append("ORDER BY ");
2519
2520                    query.append("dlFileEntry.folderId ASC, ");
2521                    query.append("dlFileEntry.name ASC");
2522                }
2523
2524                Query q = session.createQuery(query.toString());
2525
2526                if (obc == null) {
2527                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2528                            start, end, false);
2529
2530                    Collections.sort(list);
2531                }
2532                else {
2533                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2534                            start, end);
2535                }
2536            }
2537            catch (Exception e) {
2538                throw processException(e);
2539            }
2540            finally {
2541                if (list == null) {
2542                    list = new ArrayList<DLFileEntry>();
2543                }
2544
2545                cacheResult(list);
2546
2547                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2548
2549                closeSession(session);
2550            }
2551        }
2552
2553        return list;
2554    }
2555
2556    public void removeByUuid(String uuid) throws SystemException {
2557        for (DLFileEntry dlFileEntry : findByUuid(uuid)) {
2558            remove(dlFileEntry);
2559        }
2560    }
2561
2562    public void removeByUUID_G(String uuid, long groupId)
2563        throws NoSuchFileEntryException, SystemException {
2564        DLFileEntry dlFileEntry = findByUUID_G(uuid, groupId);
2565
2566        remove(dlFileEntry);
2567    }
2568
2569    public void removeByGroupId(long groupId) throws SystemException {
2570        for (DLFileEntry dlFileEntry : findByGroupId(groupId)) {
2571            remove(dlFileEntry);
2572        }
2573    }
2574
2575    public void removeByCompanyId(long companyId) throws SystemException {
2576        for (DLFileEntry dlFileEntry : findByCompanyId(companyId)) {
2577            remove(dlFileEntry);
2578        }
2579    }
2580
2581    public void removeByFolderId(long folderId) throws SystemException {
2582        for (DLFileEntry dlFileEntry : findByFolderId(folderId)) {
2583            remove(dlFileEntry);
2584        }
2585    }
2586
2587    public void removeByG_U(long groupId, long userId)
2588        throws SystemException {
2589        for (DLFileEntry dlFileEntry : findByG_U(groupId, userId)) {
2590            remove(dlFileEntry);
2591        }
2592    }
2593
2594    public void removeByF_N(long folderId, String name)
2595        throws NoSuchFileEntryException, SystemException {
2596        DLFileEntry dlFileEntry = findByF_N(folderId, name);
2597
2598        remove(dlFileEntry);
2599    }
2600
2601    public void removeByF_T(long folderId, String title)
2602        throws SystemException {
2603        for (DLFileEntry dlFileEntry : findByF_T(folderId, title)) {
2604            remove(dlFileEntry);
2605        }
2606    }
2607
2608    public void removeAll() throws SystemException {
2609        for (DLFileEntry dlFileEntry : findAll()) {
2610            remove(dlFileEntry);
2611        }
2612    }
2613
2614    public int countByUuid(String uuid) throws SystemException {
2615        Object[] finderArgs = new Object[] { uuid };
2616
2617        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2618                finderArgs, this);
2619
2620        if (count == null) {
2621            Session session = null;
2622
2623            try {
2624                session = openSession();
2625
2626                StringBuilder query = new StringBuilder();
2627
2628                query.append("SELECT COUNT(dlFileEntry) ");
2629                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2630
2631                if (uuid == null) {
2632                    query.append("dlFileEntry.uuid IS NULL");
2633                }
2634                else {
2635                    query.append("dlFileEntry.uuid = ?");
2636                }
2637
2638                query.append(" ");
2639
2640                Query q = session.createQuery(query.toString());
2641
2642                QueryPos qPos = QueryPos.getInstance(q);
2643
2644                if (uuid != null) {
2645                    qPos.add(uuid);
2646                }
2647
2648                count = (Long)q.uniqueResult();
2649            }
2650            catch (Exception e) {
2651                throw processException(e);
2652            }
2653            finally {
2654                if (count == null) {
2655                    count = Long.valueOf(0);
2656                }
2657
2658                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2659                    finderArgs, count);
2660
2661                closeSession(session);
2662            }
2663        }
2664
2665        return count.intValue();
2666    }
2667
2668    public int countByUUID_G(String uuid, long groupId)
2669        throws SystemException {
2670        Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2671
2672        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2673                finderArgs, this);
2674
2675        if (count == null) {
2676            Session session = null;
2677
2678            try {
2679                session = openSession();
2680
2681                StringBuilder query = new StringBuilder();
2682
2683                query.append("SELECT COUNT(dlFileEntry) ");
2684                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2685
2686                if (uuid == null) {
2687                    query.append("dlFileEntry.uuid IS NULL");
2688                }
2689                else {
2690                    query.append("dlFileEntry.uuid = ?");
2691                }
2692
2693                query.append(" AND ");
2694
2695                query.append("dlFileEntry.groupId = ?");
2696
2697                query.append(" ");
2698
2699                Query q = session.createQuery(query.toString());
2700
2701                QueryPos qPos = QueryPos.getInstance(q);
2702
2703                if (uuid != null) {
2704                    qPos.add(uuid);
2705                }
2706
2707                qPos.add(groupId);
2708
2709                count = (Long)q.uniqueResult();
2710            }
2711            catch (Exception e) {
2712                throw processException(e);
2713            }
2714            finally {
2715                if (count == null) {
2716                    count = Long.valueOf(0);
2717                }
2718
2719                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2720                    finderArgs, count);
2721
2722                closeSession(session);
2723            }
2724        }
2725
2726        return count.intValue();
2727    }
2728
2729    public int countByGroupId(long groupId) throws SystemException {
2730        Object[] finderArgs = new Object[] { new Long(groupId) };
2731
2732        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2733                finderArgs, this);
2734
2735        if (count == null) {
2736            Session session = null;
2737
2738            try {
2739                session = openSession();
2740
2741                StringBuilder query = new StringBuilder();
2742
2743                query.append("SELECT COUNT(dlFileEntry) ");
2744                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2745
2746                query.append("dlFileEntry.groupId = ?");
2747
2748                query.append(" ");
2749
2750                Query q = session.createQuery(query.toString());
2751
2752                QueryPos qPos = QueryPos.getInstance(q);
2753
2754                qPos.add(groupId);
2755
2756                count = (Long)q.uniqueResult();
2757            }
2758            catch (Exception e) {
2759                throw processException(e);
2760            }
2761            finally {
2762                if (count == null) {
2763                    count = Long.valueOf(0);
2764                }
2765
2766                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2767                    finderArgs, count);
2768
2769                closeSession(session);
2770            }
2771        }
2772
2773        return count.intValue();
2774    }
2775
2776    public int countByCompanyId(long companyId) throws SystemException {
2777        Object[] finderArgs = new Object[] { new Long(companyId) };
2778
2779        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2780                finderArgs, this);
2781
2782        if (count == null) {
2783            Session session = null;
2784
2785            try {
2786                session = openSession();
2787
2788                StringBuilder query = new StringBuilder();
2789
2790                query.append("SELECT COUNT(dlFileEntry) ");
2791                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2792
2793                query.append("dlFileEntry.companyId = ?");
2794
2795                query.append(" ");
2796
2797                Query q = session.createQuery(query.toString());
2798
2799                QueryPos qPos = QueryPos.getInstance(q);
2800
2801                qPos.add(companyId);
2802
2803                count = (Long)q.uniqueResult();
2804            }
2805            catch (Exception e) {
2806                throw processException(e);
2807            }
2808            finally {
2809                if (count == null) {
2810                    count = Long.valueOf(0);
2811                }
2812
2813                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2814                    finderArgs, count);
2815
2816                closeSession(session);
2817            }
2818        }
2819
2820        return count.intValue();
2821    }
2822
2823    public int countByFolderId(long folderId) throws SystemException {
2824        Object[] finderArgs = new Object[] { new Long(folderId) };
2825
2826        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FOLDERID,
2827                finderArgs, this);
2828
2829        if (count == null) {
2830            Session session = null;
2831
2832            try {
2833                session = openSession();
2834
2835                StringBuilder query = new StringBuilder();
2836
2837                query.append("SELECT COUNT(dlFileEntry) ");
2838                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2839
2840                query.append("dlFileEntry.folderId = ?");
2841
2842                query.append(" ");
2843
2844                Query q = session.createQuery(query.toString());
2845
2846                QueryPos qPos = QueryPos.getInstance(q);
2847
2848                qPos.add(folderId);
2849
2850                count = (Long)q.uniqueResult();
2851            }
2852            catch (Exception e) {
2853                throw processException(e);
2854            }
2855            finally {
2856                if (count == null) {
2857                    count = Long.valueOf(0);
2858                }
2859
2860                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FOLDERID,
2861                    finderArgs, count);
2862
2863                closeSession(session);
2864            }
2865        }
2866
2867        return count.intValue();
2868    }
2869
2870    public int countByG_U(long groupId, long userId) throws SystemException {
2871        Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
2872
2873        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2874                finderArgs, this);
2875
2876        if (count == null) {
2877            Session session = null;
2878
2879            try {
2880                session = openSession();
2881
2882                StringBuilder query = new StringBuilder();
2883
2884                query.append("SELECT COUNT(dlFileEntry) ");
2885                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2886
2887                query.append("dlFileEntry.groupId = ?");
2888
2889                query.append(" AND ");
2890
2891                query.append("dlFileEntry.userId = ?");
2892
2893                query.append(" ");
2894
2895                Query q = session.createQuery(query.toString());
2896
2897                QueryPos qPos = QueryPos.getInstance(q);
2898
2899                qPos.add(groupId);
2900
2901                qPos.add(userId);
2902
2903                count = (Long)q.uniqueResult();
2904            }
2905            catch (Exception e) {
2906                throw processException(e);
2907            }
2908            finally {
2909                if (count == null) {
2910                    count = Long.valueOf(0);
2911                }
2912
2913                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2914                    count);
2915
2916                closeSession(session);
2917            }
2918        }
2919
2920        return count.intValue();
2921    }
2922
2923    public int countByF_N(long folderId, String name) throws SystemException {
2924        Object[] finderArgs = new Object[] { new Long(folderId), name };
2925
2926        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_N,
2927                finderArgs, this);
2928
2929        if (count == null) {
2930            Session session = null;
2931
2932            try {
2933                session = openSession();
2934
2935                StringBuilder query = new StringBuilder();
2936
2937                query.append("SELECT COUNT(dlFileEntry) ");
2938                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2939
2940                query.append("dlFileEntry.folderId = ?");
2941
2942                query.append(" AND ");
2943
2944                if (name == null) {
2945                    query.append("dlFileEntry.name IS NULL");
2946                }
2947                else {
2948                    query.append("dlFileEntry.name = ?");
2949                }
2950
2951                query.append(" ");
2952
2953                Query q = session.createQuery(query.toString());
2954
2955                QueryPos qPos = QueryPos.getInstance(q);
2956
2957                qPos.add(folderId);
2958
2959                if (name != null) {
2960                    qPos.add(name);
2961                }
2962
2963                count = (Long)q.uniqueResult();
2964            }
2965            catch (Exception e) {
2966                throw processException(e);
2967            }
2968            finally {
2969                if (count == null) {
2970                    count = Long.valueOf(0);
2971                }
2972
2973                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_N, finderArgs,
2974                    count);
2975
2976                closeSession(session);
2977            }
2978        }
2979
2980        return count.intValue();
2981    }
2982
2983    public int countByF_T(long folderId, String title)
2984        throws SystemException {
2985        Object[] finderArgs = new Object[] { new Long(folderId), title };
2986
2987        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_T,
2988                finderArgs, this);
2989
2990        if (count == null) {
2991            Session session = null;
2992
2993            try {
2994                session = openSession();
2995
2996                StringBuilder query = new StringBuilder();
2997
2998                query.append("SELECT COUNT(dlFileEntry) ");
2999                query.append("FROM DLFileEntry dlFileEntry WHERE ");
3000
3001                query.append("dlFileEntry.folderId = ?");
3002
3003                query.append(" AND ");
3004
3005                if (title == null) {
3006                    query.append("dlFileEntry.title IS NULL");
3007                }
3008                else {
3009                    query.append("dlFileEntry.title = ?");
3010                }
3011
3012                query.append(" ");
3013
3014                Query q = session.createQuery(query.toString());
3015
3016                QueryPos qPos = QueryPos.getInstance(q);
3017
3018                qPos.add(folderId);
3019
3020                if (title != null) {
3021                    qPos.add(title);
3022                }
3023
3024                count = (Long)q.uniqueResult();
3025            }
3026            catch (Exception e) {
3027                throw processException(e);
3028            }
3029            finally {
3030                if (count == null) {
3031                    count = Long.valueOf(0);
3032                }
3033
3034                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_T, finderArgs,
3035                    count);
3036
3037                closeSession(session);
3038            }
3039        }
3040
3041        return count.intValue();
3042    }
3043
3044    public int countAll() throws SystemException {
3045        Object[] finderArgs = new Object[0];
3046
3047        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3048                finderArgs, this);
3049
3050        if (count == null) {
3051            Session session = null;
3052
3053            try {
3054                session = openSession();
3055
3056                Query q = session.createQuery(
3057                        "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry");
3058
3059                count = (Long)q.uniqueResult();
3060            }
3061            catch (Exception e) {
3062                throw processException(e);
3063            }
3064            finally {
3065                if (count == null) {
3066                    count = Long.valueOf(0);
3067                }
3068
3069                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3070                    count);
3071
3072                closeSession(session);
3073            }
3074        }
3075
3076        return count.intValue();
3077    }
3078
3079    public void afterPropertiesSet() {
3080        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3081                    com.liferay.portal.util.PropsUtil.get(
3082                        "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry")));
3083
3084        if (listenerClassNames.length > 0) {
3085            try {
3086                List<ModelListener<DLFileEntry>> listenersList = new ArrayList<ModelListener<DLFileEntry>>();
3087
3088                for (String listenerClassName : listenerClassNames) {
3089                    listenersList.add((ModelListener<DLFileEntry>)Class.forName(
3090                            listenerClassName).newInstance());
3091                }
3092
3093                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3094            }
3095            catch (Exception e) {
3096                _log.error(e);
3097            }
3098        }
3099    }
3100
3101    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence.impl")
3102    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence dlFileEntryPersistence;
3103    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence.impl")
3104    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence dlFileRankPersistence;
3105    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence.impl")
3106    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence dlFileShortcutPersistence;
3107    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence.impl")
3108    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence dlFileVersionPersistence;
3109    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence.impl")
3110    protected com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence dlFolderPersistence;
3111    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
3112    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
3113    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
3114    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
3115    @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
3116    protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
3117    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence.impl")
3118    protected com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence mbDiscussionPersistence;
3119    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence.impl")
3120    protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
3121    @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence.impl")
3122    protected com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence ratingsEntryPersistence;
3123    @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence.impl")
3124    protected com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence ratingsStatsPersistence;
3125    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence.impl")
3126    protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
3127    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
3128    protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
3129    private static Log _log = LogFactoryUtil.getLog(DLFileEntryPersistenceImpl.class);
3130}