1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.documentlibrary.service.persistence;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.annotation.BeanReference;
27  import com.liferay.portal.kernel.cache.CacheRegistry;
28  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31  import com.liferay.portal.kernel.dao.orm.FinderPath;
32  import com.liferay.portal.kernel.dao.orm.Query;
33  import com.liferay.portal.kernel.dao.orm.QueryPos;
34  import com.liferay.portal.kernel.dao.orm.QueryUtil;
35  import com.liferay.portal.kernel.dao.orm.Session;
36  import com.liferay.portal.kernel.log.Log;
37  import com.liferay.portal.kernel.log.LogFactoryUtil;
38  import com.liferay.portal.kernel.util.GetterUtil;
39  import com.liferay.portal.kernel.util.OrderByComparator;
40  import com.liferay.portal.kernel.util.StringPool;
41  import com.liferay.portal.kernel.util.StringUtil;
42  import com.liferay.portal.kernel.util.Validator;
43  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
44  import com.liferay.portal.model.ModelListener;
45  import com.liferay.portal.service.persistence.BatchSessionUtil;
46  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47  
48  import com.liferay.portlet.documentlibrary.NoSuchFileShortcutException;
49  import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
50  import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutImpl;
51  import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutModelImpl;
52  
53  import java.util.ArrayList;
54  import java.util.Collections;
55  import java.util.List;
56  
57  /**
58   * <a href="DLFileShortcutPersistenceImpl.java.html"><b><i>View Source</i></b></a>
59   *
60   * <p>
61   * ServiceBuilder generated this class. Modifications in this class will be
62   * overwritten the next time is generated.
63   * </p>
64   *
65   * @author    Brian Wing Shun Chan
66   * @see       DLFileShortcutPersistence
67   * @see       DLFileShortcutUtil
68   * @generated
69   */
70  public class DLFileShortcutPersistenceImpl extends BasePersistenceImpl
71      implements DLFileShortcutPersistence {
72      public static final String FINDER_CLASS_NAME_ENTITY = DLFileShortcutImpl.class.getName();
73      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74          ".List";
75      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
76              DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
77              FINDER_CLASS_NAME_LIST, "findByUuid",
78              new String[] { String.class.getName() });
79      public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
80              DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
81              FINDER_CLASS_NAME_LIST, "findByUuid",
82              new String[] {
83                  String.class.getName(),
84                  
85              "java.lang.Integer", "java.lang.Integer",
86                  "com.liferay.portal.kernel.util.OrderByComparator"
87              });
88      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
89              DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
90              FINDER_CLASS_NAME_LIST, "countByUuid",
91              new String[] { String.class.getName() });
92      public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
93              DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
94              FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
95              new String[] { String.class.getName(), Long.class.getName() });
96      public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
97              DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
98              FINDER_CLASS_NAME_LIST, "countByUUID_G",
99              new String[] { String.class.getName(), Long.class.getName() });
100     public static final FinderPath FINDER_PATH_FIND_BY_FOLDERID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
101             DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
102             FINDER_CLASS_NAME_LIST, "findByFolderId",
103             new String[] { Long.class.getName() });
104     public static final FinderPath FINDER_PATH_FIND_BY_OBC_FOLDERID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
105             DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
106             FINDER_CLASS_NAME_LIST, "findByFolderId",
107             new String[] {
108                 Long.class.getName(),
109                 
110             "java.lang.Integer", "java.lang.Integer",
111                 "com.liferay.portal.kernel.util.OrderByComparator"
112             });
113     public static final FinderPath FINDER_PATH_COUNT_BY_FOLDERID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
114             DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
115             FINDER_CLASS_NAME_LIST, "countByFolderId",
116             new String[] { Long.class.getName() });
117     public static final FinderPath FINDER_PATH_FIND_BY_TF_TN = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
118             DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
119             FINDER_CLASS_NAME_LIST, "findByTF_TN",
120             new String[] { Long.class.getName(), String.class.getName() });
121     public static final FinderPath FINDER_PATH_FIND_BY_OBC_TF_TN = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
122             DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
123             FINDER_CLASS_NAME_LIST, "findByTF_TN",
124             new String[] {
125                 Long.class.getName(), String.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_TF_TN = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
131             DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
132             FINDER_CLASS_NAME_LIST, "countByTF_TN",
133             new String[] { Long.class.getName(), String.class.getName() });
134     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
135             DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
136             FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
137     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
138             DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
139             FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
140 
141     public void cacheResult(DLFileShortcut dlFileShortcut) {
142         EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
143             DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
144             dlFileShortcut);
145 
146         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
147             new Object[] {
148                 dlFileShortcut.getUuid(), new Long(dlFileShortcut.getGroupId())
149             }, dlFileShortcut);
150     }
151 
152     public void cacheResult(List<DLFileShortcut> dlFileShortcuts) {
153         for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
154             if (EntityCacheUtil.getResult(
155                         DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
156                         DLFileShortcutImpl.class,
157                         dlFileShortcut.getPrimaryKey(), this) == null) {
158                 cacheResult(dlFileShortcut);
159             }
160         }
161     }
162 
163     public void clearCache() {
164         CacheRegistry.clear(DLFileShortcutImpl.class.getName());
165         EntityCacheUtil.clearCache(DLFileShortcutImpl.class.getName());
166         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
167         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
168     }
169 
170     public DLFileShortcut create(long fileShortcutId) {
171         DLFileShortcut dlFileShortcut = new DLFileShortcutImpl();
172 
173         dlFileShortcut.setNew(true);
174         dlFileShortcut.setPrimaryKey(fileShortcutId);
175 
176         String uuid = PortalUUIDUtil.generate();
177 
178         dlFileShortcut.setUuid(uuid);
179 
180         return dlFileShortcut;
181     }
182 
183     public DLFileShortcut remove(long fileShortcutId)
184         throws NoSuchFileShortcutException, SystemException {
185         Session session = null;
186 
187         try {
188             session = openSession();
189 
190             DLFileShortcut dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
191                     new Long(fileShortcutId));
192 
193             if (dlFileShortcut == null) {
194                 if (_log.isWarnEnabled()) {
195                     _log.warn("No DLFileShortcut exists with the primary key " +
196                         fileShortcutId);
197                 }
198 
199                 throw new NoSuchFileShortcutException(
200                     "No DLFileShortcut exists with the primary key " +
201                     fileShortcutId);
202             }
203 
204             return remove(dlFileShortcut);
205         }
206         catch (NoSuchFileShortcutException nsee) {
207             throw nsee;
208         }
209         catch (Exception e) {
210             throw processException(e);
211         }
212         finally {
213             closeSession(session);
214         }
215     }
216 
217     public DLFileShortcut remove(DLFileShortcut dlFileShortcut)
218         throws SystemException {
219         for (ModelListener<DLFileShortcut> listener : listeners) {
220             listener.onBeforeRemove(dlFileShortcut);
221         }
222 
223         dlFileShortcut = removeImpl(dlFileShortcut);
224 
225         for (ModelListener<DLFileShortcut> listener : listeners) {
226             listener.onAfterRemove(dlFileShortcut);
227         }
228 
229         return dlFileShortcut;
230     }
231 
232     protected DLFileShortcut removeImpl(DLFileShortcut dlFileShortcut)
233         throws SystemException {
234         Session session = null;
235 
236         try {
237             session = openSession();
238 
239             if (dlFileShortcut.isCachedModel() || BatchSessionUtil.isEnabled()) {
240                 Object staleObject = session.get(DLFileShortcutImpl.class,
241                         dlFileShortcut.getPrimaryKeyObj());
242 
243                 if (staleObject != null) {
244                     session.evict(staleObject);
245                 }
246             }
247 
248             session.delete(dlFileShortcut);
249 
250             session.flush();
251         }
252         catch (Exception e) {
253             throw processException(e);
254         }
255         finally {
256             closeSession(session);
257         }
258 
259         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
260 
261         DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
262 
263         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
264             new Object[] {
265                 dlFileShortcutModelImpl.getOriginalUuid(),
266                 new Long(dlFileShortcutModelImpl.getOriginalGroupId())
267             });
268 
269         EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
270             DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
271 
272         return dlFileShortcut;
273     }
274 
275     /**
276      * @deprecated Use {@link #update(DLFileShortcut, boolean merge)}.
277      */
278     public DLFileShortcut update(DLFileShortcut dlFileShortcut)
279         throws SystemException {
280         if (_log.isWarnEnabled()) {
281             _log.warn(
282                 "Using the deprecated update(DLFileShortcut dlFileShortcut) method. Use update(DLFileShortcut dlFileShortcut, boolean merge) instead.");
283         }
284 
285         return update(dlFileShortcut, false);
286     }
287 
288     /**
289      * Add, update, or merge, the entity. This method also calls the model
290      * listeners to trigger the proper events associated with adding, deleting,
291      * or updating an entity.
292      *
293      * @param  dlFileShortcut the entity to add, update, or merge
294      * @param  merge boolean value for whether to merge the entity. The default
295      *         value is false. Setting merge to true is more expensive and
296      *         should only be true when dlFileShortcut is transient. See
297      *         LEP-5473 for a detailed discussion of this method.
298      * @return the entity that was added, updated, or merged
299      */
300     public DLFileShortcut update(DLFileShortcut dlFileShortcut, boolean merge)
301         throws SystemException {
302         boolean isNew = dlFileShortcut.isNew();
303 
304         for (ModelListener<DLFileShortcut> listener : listeners) {
305             if (isNew) {
306                 listener.onBeforeCreate(dlFileShortcut);
307             }
308             else {
309                 listener.onBeforeUpdate(dlFileShortcut);
310             }
311         }
312 
313         dlFileShortcut = updateImpl(dlFileShortcut, merge);
314 
315         for (ModelListener<DLFileShortcut> listener : listeners) {
316             if (isNew) {
317                 listener.onAfterCreate(dlFileShortcut);
318             }
319             else {
320                 listener.onAfterUpdate(dlFileShortcut);
321             }
322         }
323 
324         return dlFileShortcut;
325     }
326 
327     public DLFileShortcut updateImpl(
328         com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut,
329         boolean merge) throws SystemException {
330         boolean isNew = dlFileShortcut.isNew();
331 
332         DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
333 
334         if (Validator.isNull(dlFileShortcut.getUuid())) {
335             String uuid = PortalUUIDUtil.generate();
336 
337             dlFileShortcut.setUuid(uuid);
338         }
339 
340         Session session = null;
341 
342         try {
343             session = openSession();
344 
345             BatchSessionUtil.update(session, dlFileShortcut, merge);
346 
347             dlFileShortcut.setNew(false);
348         }
349         catch (Exception e) {
350             throw processException(e);
351         }
352         finally {
353             closeSession(session);
354         }
355 
356         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
357 
358         EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
359             DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
360             dlFileShortcut);
361 
362         if (!isNew &&
363                 (!Validator.equals(dlFileShortcut.getUuid(),
364                     dlFileShortcutModelImpl.getOriginalUuid()) ||
365                 (dlFileShortcut.getGroupId() != dlFileShortcutModelImpl.getOriginalGroupId()))) {
366             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
367                 new Object[] {
368                     dlFileShortcutModelImpl.getOriginalUuid(),
369                     new Long(dlFileShortcutModelImpl.getOriginalGroupId())
370                 });
371         }
372 
373         if (isNew ||
374                 (!Validator.equals(dlFileShortcut.getUuid(),
375                     dlFileShortcutModelImpl.getOriginalUuid()) ||
376                 (dlFileShortcut.getGroupId() != dlFileShortcutModelImpl.getOriginalGroupId()))) {
377             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
378                 new Object[] {
379                     dlFileShortcut.getUuid(),
380                     new Long(dlFileShortcut.getGroupId())
381                 }, dlFileShortcut);
382         }
383 
384         return dlFileShortcut;
385     }
386 
387     public DLFileShortcut findByPrimaryKey(long fileShortcutId)
388         throws NoSuchFileShortcutException, SystemException {
389         DLFileShortcut dlFileShortcut = fetchByPrimaryKey(fileShortcutId);
390 
391         if (dlFileShortcut == null) {
392             if (_log.isWarnEnabled()) {
393                 _log.warn("No DLFileShortcut exists with the primary key " +
394                     fileShortcutId);
395             }
396 
397             throw new NoSuchFileShortcutException(
398                 "No DLFileShortcut exists with the primary key " +
399                 fileShortcutId);
400         }
401 
402         return dlFileShortcut;
403     }
404 
405     public DLFileShortcut fetchByPrimaryKey(long fileShortcutId)
406         throws SystemException {
407         DLFileShortcut dlFileShortcut = (DLFileShortcut)EntityCacheUtil.getResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
408                 DLFileShortcutImpl.class, fileShortcutId, this);
409 
410         if (dlFileShortcut == null) {
411             Session session = null;
412 
413             try {
414                 session = openSession();
415 
416                 dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
417                         new Long(fileShortcutId));
418             }
419             catch (Exception e) {
420                 throw processException(e);
421             }
422             finally {
423                 if (dlFileShortcut != null) {
424                     cacheResult(dlFileShortcut);
425                 }
426 
427                 closeSession(session);
428             }
429         }
430 
431         return dlFileShortcut;
432     }
433 
434     public List<DLFileShortcut> findByUuid(String uuid)
435         throws SystemException {
436         Object[] finderArgs = new Object[] { uuid };
437 
438         List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
439                 finderArgs, this);
440 
441         if (list == null) {
442             Session session = null;
443 
444             try {
445                 session = openSession();
446 
447                 StringBuilder query = new StringBuilder();
448 
449                 query.append(
450                     "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
451 
452                 if (uuid == null) {
453                     query.append("dlFileShortcut.uuid IS NULL");
454                 }
455                 else {
456                     query.append("dlFileShortcut.uuid = ?");
457                 }
458 
459                 query.append(" ");
460 
461                 Query q = session.createQuery(query.toString());
462 
463                 QueryPos qPos = QueryPos.getInstance(q);
464 
465                 if (uuid != null) {
466                     qPos.add(uuid);
467                 }
468 
469                 list = q.list();
470             }
471             catch (Exception e) {
472                 throw processException(e);
473             }
474             finally {
475                 if (list == null) {
476                     list = new ArrayList<DLFileShortcut>();
477                 }
478 
479                 cacheResult(list);
480 
481                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
482                     list);
483 
484                 closeSession(session);
485             }
486         }
487 
488         return list;
489     }
490 
491     public List<DLFileShortcut> findByUuid(String uuid, int start, int end)
492         throws SystemException {
493         return findByUuid(uuid, start, end, null);
494     }
495 
496     public List<DLFileShortcut> findByUuid(String uuid, int start, int end,
497         OrderByComparator obc) throws SystemException {
498         Object[] finderArgs = new Object[] {
499                 uuid,
500                 
501                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
502             };
503 
504         List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
505                 finderArgs, this);
506 
507         if (list == null) {
508             Session session = null;
509 
510             try {
511                 session = openSession();
512 
513                 StringBuilder query = new StringBuilder();
514 
515                 query.append(
516                     "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
517 
518                 if (uuid == null) {
519                     query.append("dlFileShortcut.uuid IS NULL");
520                 }
521                 else {
522                     query.append("dlFileShortcut.uuid = ?");
523                 }
524 
525                 query.append(" ");
526 
527                 if (obc != null) {
528                     query.append("ORDER BY ");
529 
530                     String[] orderByFields = obc.getOrderByFields();
531 
532                     for (int i = 0; i < orderByFields.length; i++) {
533                         query.append("dlFileShortcut.");
534                         query.append(orderByFields[i]);
535 
536                         if (obc.isAscending()) {
537                             query.append(" ASC");
538                         }
539                         else {
540                             query.append(" DESC");
541                         }
542 
543                         if ((i + 1) < orderByFields.length) {
544                             query.append(", ");
545                         }
546                     }
547                 }
548 
549                 Query q = session.createQuery(query.toString());
550 
551                 QueryPos qPos = QueryPos.getInstance(q);
552 
553                 if (uuid != null) {
554                     qPos.add(uuid);
555                 }
556 
557                 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
558                         start, end);
559             }
560             catch (Exception e) {
561                 throw processException(e);
562             }
563             finally {
564                 if (list == null) {
565                     list = new ArrayList<DLFileShortcut>();
566                 }
567 
568                 cacheResult(list);
569 
570                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
571                     finderArgs, list);
572 
573                 closeSession(session);
574             }
575         }
576 
577         return list;
578     }
579 
580     public DLFileShortcut findByUuid_First(String uuid, OrderByComparator obc)
581         throws NoSuchFileShortcutException, SystemException {
582         List<DLFileShortcut> list = findByUuid(uuid, 0, 1, obc);
583 
584         if (list.isEmpty()) {
585             StringBuilder msg = new StringBuilder();
586 
587             msg.append("No DLFileShortcut exists with the key {");
588 
589             msg.append("uuid=" + uuid);
590 
591             msg.append(StringPool.CLOSE_CURLY_BRACE);
592 
593             throw new NoSuchFileShortcutException(msg.toString());
594         }
595         else {
596             return list.get(0);
597         }
598     }
599 
600     public DLFileShortcut findByUuid_Last(String uuid, OrderByComparator obc)
601         throws NoSuchFileShortcutException, SystemException {
602         int count = countByUuid(uuid);
603 
604         List<DLFileShortcut> list = findByUuid(uuid, count - 1, count, obc);
605 
606         if (list.isEmpty()) {
607             StringBuilder msg = new StringBuilder();
608 
609             msg.append("No DLFileShortcut exists with the key {");
610 
611             msg.append("uuid=" + uuid);
612 
613             msg.append(StringPool.CLOSE_CURLY_BRACE);
614 
615             throw new NoSuchFileShortcutException(msg.toString());
616         }
617         else {
618             return list.get(0);
619         }
620     }
621 
622     public DLFileShortcut[] findByUuid_PrevAndNext(long fileShortcutId,
623         String uuid, OrderByComparator obc)
624         throws NoSuchFileShortcutException, SystemException {
625         DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
626 
627         int count = countByUuid(uuid);
628 
629         Session session = null;
630 
631         try {
632             session = openSession();
633 
634             StringBuilder query = new StringBuilder();
635 
636             query.append(
637                 "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
638 
639             if (uuid == null) {
640                 query.append("dlFileShortcut.uuid IS NULL");
641             }
642             else {
643                 query.append("dlFileShortcut.uuid = ?");
644             }
645 
646             query.append(" ");
647 
648             if (obc != null) {
649                 query.append("ORDER BY ");
650 
651                 String[] orderByFields = obc.getOrderByFields();
652 
653                 for (int i = 0; i < orderByFields.length; i++) {
654                     query.append("dlFileShortcut.");
655                     query.append(orderByFields[i]);
656 
657                     if (obc.isAscending()) {
658                         query.append(" ASC");
659                     }
660                     else {
661                         query.append(" DESC");
662                     }
663 
664                     if ((i + 1) < orderByFields.length) {
665                         query.append(", ");
666                     }
667                 }
668             }
669 
670             Query q = session.createQuery(query.toString());
671 
672             QueryPos qPos = QueryPos.getInstance(q);
673 
674             if (uuid != null) {
675                 qPos.add(uuid);
676             }
677 
678             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
679                     dlFileShortcut);
680 
681             DLFileShortcut[] array = new DLFileShortcutImpl[3];
682 
683             array[0] = (DLFileShortcut)objArray[0];
684             array[1] = (DLFileShortcut)objArray[1];
685             array[2] = (DLFileShortcut)objArray[2];
686 
687             return array;
688         }
689         catch (Exception e) {
690             throw processException(e);
691         }
692         finally {
693             closeSession(session);
694         }
695     }
696 
697     public DLFileShortcut findByUUID_G(String uuid, long groupId)
698         throws NoSuchFileShortcutException, SystemException {
699         DLFileShortcut dlFileShortcut = fetchByUUID_G(uuid, groupId);
700 
701         if (dlFileShortcut == null) {
702             StringBuilder msg = new StringBuilder();
703 
704             msg.append("No DLFileShortcut exists with the key {");
705 
706             msg.append("uuid=" + uuid);
707 
708             msg.append(", ");
709             msg.append("groupId=" + groupId);
710 
711             msg.append(StringPool.CLOSE_CURLY_BRACE);
712 
713             if (_log.isWarnEnabled()) {
714                 _log.warn(msg.toString());
715             }
716 
717             throw new NoSuchFileShortcutException(msg.toString());
718         }
719 
720         return dlFileShortcut;
721     }
722 
723     public DLFileShortcut fetchByUUID_G(String uuid, long groupId)
724         throws SystemException {
725         return fetchByUUID_G(uuid, groupId, true);
726     }
727 
728     public DLFileShortcut fetchByUUID_G(String uuid, long groupId,
729         boolean retrieveFromCache) throws SystemException {
730         Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
731 
732         Object result = null;
733 
734         if (retrieveFromCache) {
735             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
736                     finderArgs, this);
737         }
738 
739         if (result == null) {
740             Session session = null;
741 
742             try {
743                 session = openSession();
744 
745                 StringBuilder query = new StringBuilder();
746 
747                 query.append(
748                     "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
749 
750                 if (uuid == null) {
751                     query.append("dlFileShortcut.uuid IS NULL");
752                 }
753                 else {
754                     query.append("dlFileShortcut.uuid = ?");
755                 }
756 
757                 query.append(" AND ");
758 
759                 query.append("dlFileShortcut.groupId = ?");
760 
761                 query.append(" ");
762 
763                 Query q = session.createQuery(query.toString());
764 
765                 QueryPos qPos = QueryPos.getInstance(q);
766 
767                 if (uuid != null) {
768                     qPos.add(uuid);
769                 }
770 
771                 qPos.add(groupId);
772 
773                 List<DLFileShortcut> list = q.list();
774 
775                 result = list;
776 
777                 DLFileShortcut dlFileShortcut = null;
778 
779                 if (list.isEmpty()) {
780                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
781                         finderArgs, list);
782                 }
783                 else {
784                     dlFileShortcut = list.get(0);
785 
786                     cacheResult(dlFileShortcut);
787 
788                     if ((dlFileShortcut.getUuid() == null) ||
789                             !dlFileShortcut.getUuid().equals(uuid) ||
790                             (dlFileShortcut.getGroupId() != groupId)) {
791                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
792                             finderArgs, dlFileShortcut);
793                     }
794                 }
795 
796                 return dlFileShortcut;
797             }
798             catch (Exception e) {
799                 throw processException(e);
800             }
801             finally {
802                 if (result == null) {
803                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
804                         finderArgs, new ArrayList<DLFileShortcut>());
805                 }
806 
807                 closeSession(session);
808             }
809         }
810         else {
811             if (result instanceof List<?>) {
812                 return null;
813             }
814             else {
815                 return (DLFileShortcut)result;
816             }
817         }
818     }
819 
820     public List<DLFileShortcut> findByFolderId(long folderId)
821         throws SystemException {
822         Object[] finderArgs = new Object[] { new Long(folderId) };
823 
824         List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FOLDERID,
825                 finderArgs, this);
826 
827         if (list == null) {
828             Session session = null;
829 
830             try {
831                 session = openSession();
832 
833                 StringBuilder query = new StringBuilder();
834 
835                 query.append(
836                     "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
837 
838                 query.append("dlFileShortcut.folderId = ?");
839 
840                 query.append(" ");
841 
842                 Query q = session.createQuery(query.toString());
843 
844                 QueryPos qPos = QueryPos.getInstance(q);
845 
846                 qPos.add(folderId);
847 
848                 list = q.list();
849             }
850             catch (Exception e) {
851                 throw processException(e);
852             }
853             finally {
854                 if (list == null) {
855                     list = new ArrayList<DLFileShortcut>();
856                 }
857 
858                 cacheResult(list);
859 
860                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FOLDERID,
861                     finderArgs, list);
862 
863                 closeSession(session);
864             }
865         }
866 
867         return list;
868     }
869 
870     public List<DLFileShortcut> findByFolderId(long folderId, int start, int end)
871         throws SystemException {
872         return findByFolderId(folderId, start, end, null);
873     }
874 
875     public List<DLFileShortcut> findByFolderId(long folderId, int start,
876         int end, OrderByComparator obc) throws SystemException {
877         Object[] finderArgs = new Object[] {
878                 new Long(folderId),
879                 
880                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
881             };
882 
883         List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
884                 finderArgs, this);
885 
886         if (list == null) {
887             Session session = null;
888 
889             try {
890                 session = openSession();
891 
892                 StringBuilder query = new StringBuilder();
893 
894                 query.append(
895                     "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
896 
897                 query.append("dlFileShortcut.folderId = ?");
898 
899                 query.append(" ");
900 
901                 if (obc != null) {
902                     query.append("ORDER BY ");
903 
904                     String[] orderByFields = obc.getOrderByFields();
905 
906                     for (int i = 0; i < orderByFields.length; i++) {
907                         query.append("dlFileShortcut.");
908                         query.append(orderByFields[i]);
909 
910                         if (obc.isAscending()) {
911                             query.append(" ASC");
912                         }
913                         else {
914                             query.append(" DESC");
915                         }
916 
917                         if ((i + 1) < orderByFields.length) {
918                             query.append(", ");
919                         }
920                     }
921                 }
922 
923                 Query q = session.createQuery(query.toString());
924 
925                 QueryPos qPos = QueryPos.getInstance(q);
926 
927                 qPos.add(folderId);
928 
929                 list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
930                         start, end);
931             }
932             catch (Exception e) {
933                 throw processException(e);
934             }
935             finally {
936                 if (list == null) {
937                     list = new ArrayList<DLFileShortcut>();
938                 }
939 
940                 cacheResult(list);
941 
942                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
943                     finderArgs, list);
944 
945                 closeSession(session);
946             }
947         }
948 
949         return list;
950     }
951 
952     public DLFileShortcut findByFolderId_First(long folderId,
953         OrderByComparator obc)
954         throws NoSuchFileShortcutException, SystemException {
955         List<DLFileShortcut> list = findByFolderId(folderId, 0, 1, obc);
956 
957         if (list.isEmpty()) {
958             StringBuilder msg = new StringBuilder();
959 
960             msg.append("No DLFileShortcut exists with the key {");
961 
962             msg.append("folderId=" + folderId);
963 
964             msg.append(StringPool.CLOSE_CURLY_BRACE);
965 
966             throw new NoSuchFileShortcutException(msg.toString());
967         }
968         else {
969             return list.get(0);
970         }
971     }
972 
973     public DLFileShortcut findByFolderId_Last(long folderId,
974         OrderByComparator obc)
975         throws NoSuchFileShortcutException, SystemException {
976         int count = countByFolderId(folderId);
977 
978         List<DLFileShortcut> list = findByFolderId(folderId, count - 1, count,
979                 obc);
980 
981         if (list.isEmpty()) {
982             StringBuilder msg = new StringBuilder();
983 
984             msg.append("No DLFileShortcut exists with the key {");
985 
986             msg.append("folderId=" + folderId);
987 
988             msg.append(StringPool.CLOSE_CURLY_BRACE);
989 
990             throw new NoSuchFileShortcutException(msg.toString());
991         }
992         else {
993             return list.get(0);
994         }
995     }
996 
997     public DLFileShortcut[] findByFolderId_PrevAndNext(long fileShortcutId,
998         long folderId, OrderByComparator obc)
999         throws NoSuchFileShortcutException, SystemException {
1000        DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1001
1002        int count = countByFolderId(folderId);
1003
1004        Session session = null;
1005
1006        try {
1007            session = openSession();
1008
1009            StringBuilder query = new StringBuilder();
1010
1011            query.append(
1012                "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
1013
1014            query.append("dlFileShortcut.folderId = ?");
1015
1016            query.append(" ");
1017
1018            if (obc != null) {
1019                query.append("ORDER BY ");
1020
1021                String[] orderByFields = obc.getOrderByFields();
1022
1023                for (int i = 0; i < orderByFields.length; i++) {
1024                    query.append("dlFileShortcut.");
1025                    query.append(orderByFields[i]);
1026
1027                    if (obc.isAscending()) {
1028                        query.append(" ASC");
1029                    }
1030                    else {
1031                        query.append(" DESC");
1032                    }
1033
1034                    if ((i + 1) < orderByFields.length) {
1035                        query.append(", ");
1036                    }
1037                }
1038            }
1039
1040            Query q = session.createQuery(query.toString());
1041
1042            QueryPos qPos = QueryPos.getInstance(q);
1043
1044            qPos.add(folderId);
1045
1046            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1047                    dlFileShortcut);
1048
1049            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1050
1051            array[0] = (DLFileShortcut)objArray[0];
1052            array[1] = (DLFileShortcut)objArray[1];
1053            array[2] = (DLFileShortcut)objArray[2];
1054
1055            return array;
1056        }
1057        catch (Exception e) {
1058            throw processException(e);
1059        }
1060        finally {
1061            closeSession(session);
1062        }
1063    }
1064
1065    public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName)
1066        throws SystemException {
1067        Object[] finderArgs = new Object[] { new Long(toFolderId), toName };
1068
1069        List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_TF_TN,
1070                finderArgs, this);
1071
1072        if (list == null) {
1073            Session session = null;
1074
1075            try {
1076                session = openSession();
1077
1078                StringBuilder query = new StringBuilder();
1079
1080                query.append(
1081                    "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
1082
1083                query.append("dlFileShortcut.toFolderId = ?");
1084
1085                query.append(" AND ");
1086
1087                if (toName == null) {
1088                    query.append("dlFileShortcut.toName IS NULL");
1089                }
1090                else {
1091                    query.append("dlFileShortcut.toName = ?");
1092                }
1093
1094                query.append(" ");
1095
1096                Query q = session.createQuery(query.toString());
1097
1098                QueryPos qPos = QueryPos.getInstance(q);
1099
1100                qPos.add(toFolderId);
1101
1102                if (toName != null) {
1103                    qPos.add(toName);
1104                }
1105
1106                list = q.list();
1107            }
1108            catch (Exception e) {
1109                throw processException(e);
1110            }
1111            finally {
1112                if (list == null) {
1113                    list = new ArrayList<DLFileShortcut>();
1114                }
1115
1116                cacheResult(list);
1117
1118                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_TF_TN,
1119                    finderArgs, list);
1120
1121                closeSession(session);
1122            }
1123        }
1124
1125        return list;
1126    }
1127
1128    public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName,
1129        int start, int end) throws SystemException {
1130        return findByTF_TN(toFolderId, toName, start, end, null);
1131    }
1132
1133    public List<DLFileShortcut> findByTF_TN(long toFolderId, String toName,
1134        int start, int end, OrderByComparator obc) throws SystemException {
1135        Object[] finderArgs = new Object[] {
1136                new Long(toFolderId),
1137                
1138                toName,
1139                
1140                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1141            };
1142
1143        List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_TF_TN,
1144                finderArgs, this);
1145
1146        if (list == null) {
1147            Session session = null;
1148
1149            try {
1150                session = openSession();
1151
1152                StringBuilder query = new StringBuilder();
1153
1154                query.append(
1155                    "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
1156
1157                query.append("dlFileShortcut.toFolderId = ?");
1158
1159                query.append(" AND ");
1160
1161                if (toName == null) {
1162                    query.append("dlFileShortcut.toName IS NULL");
1163                }
1164                else {
1165                    query.append("dlFileShortcut.toName = ?");
1166                }
1167
1168                query.append(" ");
1169
1170                if (obc != null) {
1171                    query.append("ORDER BY ");
1172
1173                    String[] orderByFields = obc.getOrderByFields();
1174
1175                    for (int i = 0; i < orderByFields.length; i++) {
1176                        query.append("dlFileShortcut.");
1177                        query.append(orderByFields[i]);
1178
1179                        if (obc.isAscending()) {
1180                            query.append(" ASC");
1181                        }
1182                        else {
1183                            query.append(" DESC");
1184                        }
1185
1186                        if ((i + 1) < orderByFields.length) {
1187                            query.append(", ");
1188                        }
1189                    }
1190                }
1191
1192                Query q = session.createQuery(query.toString());
1193
1194                QueryPos qPos = QueryPos.getInstance(q);
1195
1196                qPos.add(toFolderId);
1197
1198                if (toName != null) {
1199                    qPos.add(toName);
1200                }
1201
1202                list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
1203                        start, end);
1204            }
1205            catch (Exception e) {
1206                throw processException(e);
1207            }
1208            finally {
1209                if (list == null) {
1210                    list = new ArrayList<DLFileShortcut>();
1211                }
1212
1213                cacheResult(list);
1214
1215                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_TF_TN,
1216                    finderArgs, list);
1217
1218                closeSession(session);
1219            }
1220        }
1221
1222        return list;
1223    }
1224
1225    public DLFileShortcut findByTF_TN_First(long toFolderId, String toName,
1226        OrderByComparator obc)
1227        throws NoSuchFileShortcutException, SystemException {
1228        List<DLFileShortcut> list = findByTF_TN(toFolderId, toName, 0, 1, obc);
1229
1230        if (list.isEmpty()) {
1231            StringBuilder msg = new StringBuilder();
1232
1233            msg.append("No DLFileShortcut exists with the key {");
1234
1235            msg.append("toFolderId=" + toFolderId);
1236
1237            msg.append(", ");
1238            msg.append("toName=" + toName);
1239
1240            msg.append(StringPool.CLOSE_CURLY_BRACE);
1241
1242            throw new NoSuchFileShortcutException(msg.toString());
1243        }
1244        else {
1245            return list.get(0);
1246        }
1247    }
1248
1249    public DLFileShortcut findByTF_TN_Last(long toFolderId, String toName,
1250        OrderByComparator obc)
1251        throws NoSuchFileShortcutException, SystemException {
1252        int count = countByTF_TN(toFolderId, toName);
1253
1254        List<DLFileShortcut> list = findByTF_TN(toFolderId, toName, count - 1,
1255                count, obc);
1256
1257        if (list.isEmpty()) {
1258            StringBuilder msg = new StringBuilder();
1259
1260            msg.append("No DLFileShortcut exists with the key {");
1261
1262            msg.append("toFolderId=" + toFolderId);
1263
1264            msg.append(", ");
1265            msg.append("toName=" + toName);
1266
1267            msg.append(StringPool.CLOSE_CURLY_BRACE);
1268
1269            throw new NoSuchFileShortcutException(msg.toString());
1270        }
1271        else {
1272            return list.get(0);
1273        }
1274    }
1275
1276    public DLFileShortcut[] findByTF_TN_PrevAndNext(long fileShortcutId,
1277        long toFolderId, String toName, OrderByComparator obc)
1278        throws NoSuchFileShortcutException, SystemException {
1279        DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1280
1281        int count = countByTF_TN(toFolderId, toName);
1282
1283        Session session = null;
1284
1285        try {
1286            session = openSession();
1287
1288            StringBuilder query = new StringBuilder();
1289
1290            query.append(
1291                "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ");
1292
1293            query.append("dlFileShortcut.toFolderId = ?");
1294
1295            query.append(" AND ");
1296
1297            if (toName == null) {
1298                query.append("dlFileShortcut.toName IS NULL");
1299            }
1300            else {
1301                query.append("dlFileShortcut.toName = ?");
1302            }
1303
1304            query.append(" ");
1305
1306            if (obc != null) {
1307                query.append("ORDER BY ");
1308
1309                String[] orderByFields = obc.getOrderByFields();
1310
1311                for (int i = 0; i < orderByFields.length; i++) {
1312                    query.append("dlFileShortcut.");
1313                    query.append(orderByFields[i]);
1314
1315                    if (obc.isAscending()) {
1316                        query.append(" ASC");
1317                    }
1318                    else {
1319                        query.append(" DESC");
1320                    }
1321
1322                    if ((i + 1) < orderByFields.length) {
1323                        query.append(", ");
1324                    }
1325                }
1326            }
1327
1328            Query q = session.createQuery(query.toString());
1329
1330            QueryPos qPos = QueryPos.getInstance(q);
1331
1332            qPos.add(toFolderId);
1333
1334            if (toName != null) {
1335                qPos.add(toName);
1336            }
1337
1338            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1339                    dlFileShortcut);
1340
1341            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1342
1343            array[0] = (DLFileShortcut)objArray[0];
1344            array[1] = (DLFileShortcut)objArray[1];
1345            array[2] = (DLFileShortcut)objArray[2];
1346
1347            return array;
1348        }
1349        catch (Exception e) {
1350            throw processException(e);
1351        }
1352        finally {
1353            closeSession(session);
1354        }
1355    }
1356
1357    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1358        throws SystemException {
1359        Session session = null;
1360
1361        try {
1362            session = openSession();
1363
1364            dynamicQuery.compile(session);
1365
1366            return dynamicQuery.list();
1367        }
1368        catch (Exception e) {
1369            throw processException(e);
1370        }
1371        finally {
1372            closeSession(session);
1373        }
1374    }
1375
1376    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1377        int start, int end) throws SystemException {
1378        Session session = null;
1379
1380        try {
1381            session = openSession();
1382
1383            dynamicQuery.setLimit(start, end);
1384
1385            dynamicQuery.compile(session);
1386
1387            return dynamicQuery.list();
1388        }
1389        catch (Exception e) {
1390            throw processException(e);
1391        }
1392        finally {
1393            closeSession(session);
1394        }
1395    }
1396
1397    public List<DLFileShortcut> findAll() throws SystemException {
1398        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1399    }
1400
1401    public List<DLFileShortcut> findAll(int start, int end)
1402        throws SystemException {
1403        return findAll(start, end, null);
1404    }
1405
1406    public List<DLFileShortcut> findAll(int start, int end,
1407        OrderByComparator obc) throws SystemException {
1408        Object[] finderArgs = new Object[] {
1409                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1410            };
1411
1412        List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1413                finderArgs, this);
1414
1415        if (list == null) {
1416            Session session = null;
1417
1418            try {
1419                session = openSession();
1420
1421                StringBuilder query = new StringBuilder();
1422
1423                query.append(
1424                    "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut ");
1425
1426                if (obc != null) {
1427                    query.append("ORDER BY ");
1428
1429                    String[] orderByFields = obc.getOrderByFields();
1430
1431                    for (int i = 0; i < orderByFields.length; i++) {
1432                        query.append("dlFileShortcut.");
1433                        query.append(orderByFields[i]);
1434
1435                        if (obc.isAscending()) {
1436                            query.append(" ASC");
1437                        }
1438                        else {
1439                            query.append(" DESC");
1440                        }
1441
1442                        if ((i + 1) < orderByFields.length) {
1443                            query.append(", ");
1444                        }
1445                    }
1446                }
1447
1448                Query q = session.createQuery(query.toString());
1449
1450                if (obc == null) {
1451                    list = (List<DLFileShortcut>)QueryUtil.list(q,
1452                            getDialect(), start, end, false);
1453
1454                    Collections.sort(list);
1455                }
1456                else {
1457                    list = (List<DLFileShortcut>)QueryUtil.list(q,
1458                            getDialect(), start, end);
1459                }
1460            }
1461            catch (Exception e) {
1462                throw processException(e);
1463            }
1464            finally {
1465                if (list == null) {
1466                    list = new ArrayList<DLFileShortcut>();
1467                }
1468
1469                cacheResult(list);
1470
1471                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1472
1473                closeSession(session);
1474            }
1475        }
1476
1477        return list;
1478    }
1479
1480    public void removeByUuid(String uuid) throws SystemException {
1481        for (DLFileShortcut dlFileShortcut : findByUuid(uuid)) {
1482            remove(dlFileShortcut);
1483        }
1484    }
1485
1486    public void removeByUUID_G(String uuid, long groupId)
1487        throws NoSuchFileShortcutException, SystemException {
1488        DLFileShortcut dlFileShortcut = findByUUID_G(uuid, groupId);
1489
1490        remove(dlFileShortcut);
1491    }
1492
1493    public void removeByFolderId(long folderId) throws SystemException {
1494        for (DLFileShortcut dlFileShortcut : findByFolderId(folderId)) {
1495            remove(dlFileShortcut);
1496        }
1497    }
1498
1499    public void removeByTF_TN(long toFolderId, String toName)
1500        throws SystemException {
1501        for (DLFileShortcut dlFileShortcut : findByTF_TN(toFolderId, toName)) {
1502            remove(dlFileShortcut);
1503        }
1504    }
1505
1506    public void removeAll() throws SystemException {
1507        for (DLFileShortcut dlFileShortcut : findAll()) {
1508            remove(dlFileShortcut);
1509        }
1510    }
1511
1512    public int countByUuid(String uuid) throws SystemException {
1513        Object[] finderArgs = new Object[] { uuid };
1514
1515        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1516                finderArgs, this);
1517
1518        if (count == null) {
1519            Session session = null;
1520
1521            try {
1522                session = openSession();
1523
1524                StringBuilder query = new StringBuilder();
1525
1526                query.append("SELECT COUNT(dlFileShortcut) ");
1527                query.append("FROM DLFileShortcut dlFileShortcut WHERE ");
1528
1529                if (uuid == null) {
1530                    query.append("dlFileShortcut.uuid IS NULL");
1531                }
1532                else {
1533                    query.append("dlFileShortcut.uuid = ?");
1534                }
1535
1536                query.append(" ");
1537
1538                Query q = session.createQuery(query.toString());
1539
1540                QueryPos qPos = QueryPos.getInstance(q);
1541
1542                if (uuid != null) {
1543                    qPos.add(uuid);
1544                }
1545
1546                count = (Long)q.uniqueResult();
1547            }
1548            catch (Exception e) {
1549                throw processException(e);
1550            }
1551            finally {
1552                if (count == null) {
1553                    count = Long.valueOf(0);
1554                }
1555
1556                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1557                    finderArgs, count);
1558
1559                closeSession(session);
1560            }
1561        }
1562
1563        return count.intValue();
1564    }
1565
1566    public int countByUUID_G(String uuid, long groupId)
1567        throws SystemException {
1568        Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1569
1570        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1571                finderArgs, this);
1572
1573        if (count == null) {
1574            Session session = null;
1575
1576            try {
1577                session = openSession();
1578
1579                StringBuilder query = new StringBuilder();
1580
1581                query.append("SELECT COUNT(dlFileShortcut) ");
1582                query.append("FROM DLFileShortcut dlFileShortcut WHERE ");
1583
1584                if (uuid == null) {
1585                    query.append("dlFileShortcut.uuid IS NULL");
1586                }
1587                else {
1588                    query.append("dlFileShortcut.uuid = ?");
1589                }
1590
1591                query.append(" AND ");
1592
1593                query.append("dlFileShortcut.groupId = ?");
1594
1595                query.append(" ");
1596
1597                Query q = session.createQuery(query.toString());
1598
1599                QueryPos qPos = QueryPos.getInstance(q);
1600
1601                if (uuid != null) {
1602                    qPos.add(uuid);
1603                }
1604
1605                qPos.add(groupId);
1606
1607                count = (Long)q.uniqueResult();
1608            }
1609            catch (Exception e) {
1610                throw processException(e);
1611            }
1612            finally {
1613                if (count == null) {
1614                    count = Long.valueOf(0);
1615                }
1616
1617                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1618                    finderArgs, count);
1619
1620                closeSession(session);
1621            }
1622        }
1623
1624        return count.intValue();
1625    }
1626
1627    public int countByFolderId(long folderId) throws SystemException {
1628        Object[] finderArgs = new Object[] { new Long(folderId) };
1629
1630        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FOLDERID,
1631                finderArgs, this);
1632
1633        if (count == null) {
1634            Session session = null;
1635
1636            try {
1637                session = openSession();
1638
1639                StringBuilder query = new StringBuilder();
1640
1641                query.append("SELECT COUNT(dlFileShortcut) ");
1642                query.append("FROM DLFileShortcut dlFileShortcut WHERE ");
1643
1644                query.append("dlFileShortcut.folderId = ?");
1645
1646                query.append(" ");
1647
1648                Query q = session.createQuery(query.toString());
1649
1650                QueryPos qPos = QueryPos.getInstance(q);
1651
1652                qPos.add(folderId);
1653
1654                count = (Long)q.uniqueResult();
1655            }
1656            catch (Exception e) {
1657                throw processException(e);
1658            }
1659            finally {
1660                if (count == null) {
1661                    count = Long.valueOf(0);
1662                }
1663
1664                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FOLDERID,
1665                    finderArgs, count);
1666
1667                closeSession(session);
1668            }
1669        }
1670
1671        return count.intValue();
1672    }
1673
1674    public int countByTF_TN(long toFolderId, String toName)
1675        throws SystemException {
1676        Object[] finderArgs = new Object[] { new Long(toFolderId), toName };
1677
1678        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TF_TN,
1679                finderArgs, this);
1680
1681        if (count == null) {
1682            Session session = null;
1683
1684            try {
1685                session = openSession();
1686
1687                StringBuilder query = new StringBuilder();
1688
1689                query.append("SELECT COUNT(dlFileShortcut) ");
1690                query.append("FROM DLFileShortcut dlFileShortcut WHERE ");
1691
1692                query.append("dlFileShortcut.toFolderId = ?");
1693
1694                query.append(" AND ");
1695
1696                if (toName == null) {
1697                    query.append("dlFileShortcut.toName IS NULL");
1698                }
1699                else {
1700                    query.append("dlFileShortcut.toName = ?");
1701                }
1702
1703                query.append(" ");
1704
1705                Query q = session.createQuery(query.toString());
1706
1707                QueryPos qPos = QueryPos.getInstance(q);
1708
1709                qPos.add(toFolderId);
1710
1711                if (toName != null) {
1712                    qPos.add(toName);
1713                }
1714
1715                count = (Long)q.uniqueResult();
1716            }
1717            catch (Exception e) {
1718                throw processException(e);
1719            }
1720            finally {
1721                if (count == null) {
1722                    count = Long.valueOf(0);
1723                }
1724
1725                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TF_TN,
1726                    finderArgs, count);
1727
1728                closeSession(session);
1729            }
1730        }
1731
1732        return count.intValue();
1733    }
1734
1735    public int countAll() throws SystemException {
1736        Object[] finderArgs = new Object[0];
1737
1738        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1739                finderArgs, this);
1740
1741        if (count == null) {
1742            Session session = null;
1743
1744            try {
1745                session = openSession();
1746
1747                Query q = session.createQuery(
1748                        "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut");
1749
1750                count = (Long)q.uniqueResult();
1751            }
1752            catch (Exception e) {
1753                throw processException(e);
1754            }
1755            finally {
1756                if (count == null) {
1757                    count = Long.valueOf(0);
1758                }
1759
1760                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1761                    count);
1762
1763                closeSession(session);
1764            }
1765        }
1766
1767        return count.intValue();
1768    }
1769
1770    public void afterPropertiesSet() {
1771        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1772                    com.liferay.portal.util.PropsUtil.get(
1773                        "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileShortcut")));
1774
1775        if (listenerClassNames.length > 0) {
1776            try {
1777                List<ModelListener<DLFileShortcut>> listenersList = new ArrayList<ModelListener<DLFileShortcut>>();
1778
1779                for (String listenerClassName : listenerClassNames) {
1780                    listenersList.add((ModelListener<DLFileShortcut>)Class.forName(
1781                            listenerClassName).newInstance());
1782                }
1783
1784                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1785            }
1786            catch (Exception e) {
1787                _log.error(e);
1788            }
1789        }
1790    }
1791
1792    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence.impl")
1793    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence dlFileEntryPersistence;
1794    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence.impl")
1795    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence dlFileRankPersistence;
1796    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence.impl")
1797    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence dlFileShortcutPersistence;
1798    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence.impl")
1799    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence dlFileVersionPersistence;
1800    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence.impl")
1801    protected com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence dlFolderPersistence;
1802    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1803    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1804    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1805    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1806    private static Log _log = LogFactoryUtil.getLog(DLFileShortcutPersistenceImpl.class);
1807}