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