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