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