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