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