001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchRepositoryException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.model.Repository;
042 import com.liferay.portal.model.impl.RepositoryImpl;
043 import com.liferay.portal.model.impl.RepositoryModelImpl;
044 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045
046 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
047 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
048 import com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence;
049 import com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence;
050 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057
058
070 public class RepositoryPersistenceImpl extends BasePersistenceImpl<Repository>
071 implements RepositoryPersistence {
072
077 public static final String FINDER_CLASS_NAME_ENTITY = RepositoryImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List1";
080 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List2";
082 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
083 RepositoryModelImpl.FINDER_CACHE_ENABLED, RepositoryImpl.class,
084 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
085 new String[] {
086 String.class.getName(),
087
088 "java.lang.Integer", "java.lang.Integer",
089 "com.liferay.portal.kernel.util.OrderByComparator"
090 });
091 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
092 RepositoryModelImpl.FINDER_CACHE_ENABLED, RepositoryImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
094 new String[] { String.class.getName() },
095 RepositoryModelImpl.UUID_COLUMN_BITMASK);
096 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
097 RepositoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
099 new String[] { String.class.getName() });
100 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
101 RepositoryModelImpl.FINDER_CACHE_ENABLED, RepositoryImpl.class,
102 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
103 new String[] { String.class.getName(), Long.class.getName() },
104 RepositoryModelImpl.UUID_COLUMN_BITMASK |
105 RepositoryModelImpl.GROUPID_COLUMN_BITMASK);
106 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
107 RepositoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
109 new String[] { String.class.getName(), Long.class.getName() });
110 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
111 RepositoryModelImpl.FINDER_CACHE_ENABLED, RepositoryImpl.class,
112 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
113 new String[] {
114 Long.class.getName(),
115
116 "java.lang.Integer", "java.lang.Integer",
117 "com.liferay.portal.kernel.util.OrderByComparator"
118 });
119 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
120 new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
121 RepositoryModelImpl.FINDER_CACHE_ENABLED, RepositoryImpl.class,
122 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
123 new String[] { Long.class.getName() },
124 RepositoryModelImpl.GROUPID_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
126 RepositoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
128 new String[] { Long.class.getName() });
129 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
130 RepositoryModelImpl.FINDER_CACHE_ENABLED, RepositoryImpl.class,
131 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
132 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
133 RepositoryModelImpl.FINDER_CACHE_ENABLED, RepositoryImpl.class,
134 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
135 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
136 RepositoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
138
139
144 public void cacheResult(Repository repository) {
145 EntityCacheUtil.putResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
146 RepositoryImpl.class, repository.getPrimaryKey(), repository);
147
148 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
149 new Object[] {
150 repository.getUuid(), Long.valueOf(repository.getGroupId())
151 }, repository);
152
153 repository.resetOriginalValues();
154 }
155
156
161 public void cacheResult(List<Repository> repositories) {
162 for (Repository repository : repositories) {
163 if (EntityCacheUtil.getResult(
164 RepositoryModelImpl.ENTITY_CACHE_ENABLED,
165 RepositoryImpl.class, repository.getPrimaryKey()) == null) {
166 cacheResult(repository);
167 }
168 else {
169 repository.resetOriginalValues();
170 }
171 }
172 }
173
174
181 @Override
182 public void clearCache() {
183 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
184 CacheRegistryUtil.clear(RepositoryImpl.class.getName());
185 }
186
187 EntityCacheUtil.clearCache(RepositoryImpl.class.getName());
188
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
191 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
192 }
193
194
201 @Override
202 public void clearCache(Repository repository) {
203 EntityCacheUtil.removeResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
204 RepositoryImpl.class, repository.getPrimaryKey());
205
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
207 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
208
209 clearUniqueFindersCache(repository);
210 }
211
212 @Override
213 public void clearCache(List<Repository> repositories) {
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
215 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
216
217 for (Repository repository : repositories) {
218 EntityCacheUtil.removeResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
219 RepositoryImpl.class, repository.getPrimaryKey());
220
221 clearUniqueFindersCache(repository);
222 }
223 }
224
225 protected void clearUniqueFindersCache(Repository repository) {
226 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
227 new Object[] {
228 repository.getUuid(), Long.valueOf(repository.getGroupId())
229 });
230 }
231
232
238 public Repository create(long repositoryId) {
239 Repository repository = new RepositoryImpl();
240
241 repository.setNew(true);
242 repository.setPrimaryKey(repositoryId);
243
244 String uuid = PortalUUIDUtil.generate();
245
246 repository.setUuid(uuid);
247
248 return repository;
249 }
250
251
259 public Repository remove(long repositoryId)
260 throws NoSuchRepositoryException, SystemException {
261 return remove(Long.valueOf(repositoryId));
262 }
263
264
272 @Override
273 public Repository remove(Serializable primaryKey)
274 throws NoSuchRepositoryException, SystemException {
275 Session session = null;
276
277 try {
278 session = openSession();
279
280 Repository repository = (Repository)session.get(RepositoryImpl.class,
281 primaryKey);
282
283 if (repository == null) {
284 if (_log.isWarnEnabled()) {
285 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
286 }
287
288 throw new NoSuchRepositoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
289 primaryKey);
290 }
291
292 return remove(repository);
293 }
294 catch (NoSuchRepositoryException nsee) {
295 throw nsee;
296 }
297 catch (Exception e) {
298 throw processException(e);
299 }
300 finally {
301 closeSession(session);
302 }
303 }
304
305 @Override
306 protected Repository removeImpl(Repository repository)
307 throws SystemException {
308 repository = toUnwrappedModel(repository);
309
310 Session session = null;
311
312 try {
313 session = openSession();
314
315 BatchSessionUtil.delete(session, repository);
316 }
317 catch (Exception e) {
318 throw processException(e);
319 }
320 finally {
321 closeSession(session);
322 }
323
324 clearCache(repository);
325
326 return repository;
327 }
328
329 @Override
330 public Repository updateImpl(
331 com.liferay.portal.model.Repository repository, boolean merge)
332 throws SystemException {
333 repository = toUnwrappedModel(repository);
334
335 boolean isNew = repository.isNew();
336
337 RepositoryModelImpl repositoryModelImpl = (RepositoryModelImpl)repository;
338
339 if (Validator.isNull(repository.getUuid())) {
340 String uuid = PortalUUIDUtil.generate();
341
342 repository.setUuid(uuid);
343 }
344
345 Session session = null;
346
347 try {
348 session = openSession();
349
350 BatchSessionUtil.update(session, repository, merge);
351
352 repository.setNew(false);
353 }
354 catch (Exception e) {
355 throw processException(e);
356 }
357 finally {
358 closeSession(session);
359 }
360
361 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
362
363 if (isNew || !RepositoryModelImpl.COLUMN_BITMASK_ENABLED) {
364 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
365 }
366 else {
367 if ((repositoryModelImpl.getColumnBitmask() &
368 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
369 Object[] args = new Object[] {
370 repositoryModelImpl.getOriginalUuid()
371 };
372
373 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
374 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
375 args);
376
377 args = new Object[] { repositoryModelImpl.getUuid() };
378
379 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
380 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
381 args);
382 }
383
384 if ((repositoryModelImpl.getColumnBitmask() &
385 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
386 Object[] args = new Object[] {
387 Long.valueOf(repositoryModelImpl.getOriginalGroupId())
388 };
389
390 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
391 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
392 args);
393
394 args = new Object[] {
395 Long.valueOf(repositoryModelImpl.getGroupId())
396 };
397
398 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
399 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
400 args);
401 }
402 }
403
404 EntityCacheUtil.putResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
405 RepositoryImpl.class, repository.getPrimaryKey(), repository);
406
407 if (isNew) {
408 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
409 new Object[] {
410 repository.getUuid(), Long.valueOf(repository.getGroupId())
411 }, repository);
412 }
413 else {
414 if ((repositoryModelImpl.getColumnBitmask() &
415 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
416 Object[] args = new Object[] {
417 repositoryModelImpl.getOriginalUuid(),
418 Long.valueOf(repositoryModelImpl.getOriginalGroupId())
419 };
420
421 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
422 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
423
424 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
425 new Object[] {
426 repository.getUuid(),
427 Long.valueOf(repository.getGroupId())
428 }, repository);
429 }
430 }
431
432 return repository;
433 }
434
435 protected Repository toUnwrappedModel(Repository repository) {
436 if (repository instanceof RepositoryImpl) {
437 return repository;
438 }
439
440 RepositoryImpl repositoryImpl = new RepositoryImpl();
441
442 repositoryImpl.setNew(repository.isNew());
443 repositoryImpl.setPrimaryKey(repository.getPrimaryKey());
444
445 repositoryImpl.setUuid(repository.getUuid());
446 repositoryImpl.setRepositoryId(repository.getRepositoryId());
447 repositoryImpl.setGroupId(repository.getGroupId());
448 repositoryImpl.setCompanyId(repository.getCompanyId());
449 repositoryImpl.setUserId(repository.getUserId());
450 repositoryImpl.setUserName(repository.getUserName());
451 repositoryImpl.setCreateDate(repository.getCreateDate());
452 repositoryImpl.setModifiedDate(repository.getModifiedDate());
453 repositoryImpl.setClassNameId(repository.getClassNameId());
454 repositoryImpl.setName(repository.getName());
455 repositoryImpl.setDescription(repository.getDescription());
456 repositoryImpl.setPortletId(repository.getPortletId());
457 repositoryImpl.setTypeSettings(repository.getTypeSettings());
458 repositoryImpl.setDlFolderId(repository.getDlFolderId());
459
460 return repositoryImpl;
461 }
462
463
471 @Override
472 public Repository findByPrimaryKey(Serializable primaryKey)
473 throws NoSuchModelException, SystemException {
474 return findByPrimaryKey(((Long)primaryKey).longValue());
475 }
476
477
485 public Repository findByPrimaryKey(long repositoryId)
486 throws NoSuchRepositoryException, SystemException {
487 Repository repository = fetchByPrimaryKey(repositoryId);
488
489 if (repository == null) {
490 if (_log.isWarnEnabled()) {
491 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + repositoryId);
492 }
493
494 throw new NoSuchRepositoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
495 repositoryId);
496 }
497
498 return repository;
499 }
500
501
508 @Override
509 public Repository fetchByPrimaryKey(Serializable primaryKey)
510 throws SystemException {
511 return fetchByPrimaryKey(((Long)primaryKey).longValue());
512 }
513
514
521 public Repository fetchByPrimaryKey(long repositoryId)
522 throws SystemException {
523 Repository repository = (Repository)EntityCacheUtil.getResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
524 RepositoryImpl.class, repositoryId);
525
526 if (repository == _nullRepository) {
527 return null;
528 }
529
530 if (repository == null) {
531 Session session = null;
532
533 boolean hasException = false;
534
535 try {
536 session = openSession();
537
538 repository = (Repository)session.get(RepositoryImpl.class,
539 Long.valueOf(repositoryId));
540 }
541 catch (Exception e) {
542 hasException = true;
543
544 throw processException(e);
545 }
546 finally {
547 if (repository != null) {
548 cacheResult(repository);
549 }
550 else if (!hasException) {
551 EntityCacheUtil.putResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
552 RepositoryImpl.class, repositoryId, _nullRepository);
553 }
554
555 closeSession(session);
556 }
557 }
558
559 return repository;
560 }
561
562
569 public List<Repository> findByUuid(String uuid) throws SystemException {
570 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
571 }
572
573
586 public List<Repository> findByUuid(String uuid, int start, int end)
587 throws SystemException {
588 return findByUuid(uuid, start, end, null);
589 }
590
591
605 public List<Repository> findByUuid(String uuid, int start, int end,
606 OrderByComparator orderByComparator) throws SystemException {
607 FinderPath finderPath = null;
608 Object[] finderArgs = null;
609
610 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
611 (orderByComparator == null)) {
612 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
613 finderArgs = new Object[] { uuid };
614 }
615 else {
616 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
617 finderArgs = new Object[] { uuid, start, end, orderByComparator };
618 }
619
620 List<Repository> list = (List<Repository>)FinderCacheUtil.getResult(finderPath,
621 finderArgs, this);
622
623 if ((list != null) && !list.isEmpty()) {
624 for (Repository repository : list) {
625 if (!Validator.equals(uuid, repository.getUuid())) {
626 list = null;
627
628 break;
629 }
630 }
631 }
632
633 if (list == null) {
634 StringBundler query = null;
635
636 if (orderByComparator != null) {
637 query = new StringBundler(3 +
638 (orderByComparator.getOrderByFields().length * 3));
639 }
640 else {
641 query = new StringBundler(2);
642 }
643
644 query.append(_SQL_SELECT_REPOSITORY_WHERE);
645
646 if (uuid == null) {
647 query.append(_FINDER_COLUMN_UUID_UUID_1);
648 }
649 else {
650 if (uuid.equals(StringPool.BLANK)) {
651 query.append(_FINDER_COLUMN_UUID_UUID_3);
652 }
653 else {
654 query.append(_FINDER_COLUMN_UUID_UUID_2);
655 }
656 }
657
658 if (orderByComparator != null) {
659 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
660 orderByComparator);
661 }
662
663 String sql = query.toString();
664
665 Session session = null;
666
667 try {
668 session = openSession();
669
670 Query q = session.createQuery(sql);
671
672 QueryPos qPos = QueryPos.getInstance(q);
673
674 if (uuid != null) {
675 qPos.add(uuid);
676 }
677
678 list = (List<Repository>)QueryUtil.list(q, getDialect(), start,
679 end);
680 }
681 catch (Exception e) {
682 throw processException(e);
683 }
684 finally {
685 if (list == null) {
686 FinderCacheUtil.removeResult(finderPath, finderArgs);
687 }
688 else {
689 cacheResult(list);
690
691 FinderCacheUtil.putResult(finderPath, finderArgs, list);
692 }
693
694 closeSession(session);
695 }
696 }
697
698 return list;
699 }
700
701
714 public Repository findByUuid_First(String uuid,
715 OrderByComparator orderByComparator)
716 throws NoSuchRepositoryException, SystemException {
717 List<Repository> list = findByUuid(uuid, 0, 1, orderByComparator);
718
719 if (list.isEmpty()) {
720 StringBundler msg = new StringBundler(4);
721
722 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
723
724 msg.append("uuid=");
725 msg.append(uuid);
726
727 msg.append(StringPool.CLOSE_CURLY_BRACE);
728
729 throw new NoSuchRepositoryException(msg.toString());
730 }
731 else {
732 return list.get(0);
733 }
734 }
735
736
749 public Repository findByUuid_Last(String uuid,
750 OrderByComparator orderByComparator)
751 throws NoSuchRepositoryException, SystemException {
752 int count = countByUuid(uuid);
753
754 List<Repository> list = findByUuid(uuid, count - 1, count,
755 orderByComparator);
756
757 if (list.isEmpty()) {
758 StringBundler msg = new StringBundler(4);
759
760 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
761
762 msg.append("uuid=");
763 msg.append(uuid);
764
765 msg.append(StringPool.CLOSE_CURLY_BRACE);
766
767 throw new NoSuchRepositoryException(msg.toString());
768 }
769 else {
770 return list.get(0);
771 }
772 }
773
774
788 public Repository[] findByUuid_PrevAndNext(long repositoryId, String uuid,
789 OrderByComparator orderByComparator)
790 throws NoSuchRepositoryException, SystemException {
791 Repository repository = findByPrimaryKey(repositoryId);
792
793 Session session = null;
794
795 try {
796 session = openSession();
797
798 Repository[] array = new RepositoryImpl[3];
799
800 array[0] = getByUuid_PrevAndNext(session, repository, uuid,
801 orderByComparator, true);
802
803 array[1] = repository;
804
805 array[2] = getByUuid_PrevAndNext(session, repository, uuid,
806 orderByComparator, false);
807
808 return array;
809 }
810 catch (Exception e) {
811 throw processException(e);
812 }
813 finally {
814 closeSession(session);
815 }
816 }
817
818 protected Repository getByUuid_PrevAndNext(Session session,
819 Repository repository, String uuid,
820 OrderByComparator orderByComparator, boolean previous) {
821 StringBundler query = null;
822
823 if (orderByComparator != null) {
824 query = new StringBundler(6 +
825 (orderByComparator.getOrderByFields().length * 6));
826 }
827 else {
828 query = new StringBundler(3);
829 }
830
831 query.append(_SQL_SELECT_REPOSITORY_WHERE);
832
833 if (uuid == null) {
834 query.append(_FINDER_COLUMN_UUID_UUID_1);
835 }
836 else {
837 if (uuid.equals(StringPool.BLANK)) {
838 query.append(_FINDER_COLUMN_UUID_UUID_3);
839 }
840 else {
841 query.append(_FINDER_COLUMN_UUID_UUID_2);
842 }
843 }
844
845 if (orderByComparator != null) {
846 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
847
848 if (orderByConditionFields.length > 0) {
849 query.append(WHERE_AND);
850 }
851
852 for (int i = 0; i < orderByConditionFields.length; i++) {
853 query.append(_ORDER_BY_ENTITY_ALIAS);
854 query.append(orderByConditionFields[i]);
855
856 if ((i + 1) < orderByConditionFields.length) {
857 if (orderByComparator.isAscending() ^ previous) {
858 query.append(WHERE_GREATER_THAN_HAS_NEXT);
859 }
860 else {
861 query.append(WHERE_LESSER_THAN_HAS_NEXT);
862 }
863 }
864 else {
865 if (orderByComparator.isAscending() ^ previous) {
866 query.append(WHERE_GREATER_THAN);
867 }
868 else {
869 query.append(WHERE_LESSER_THAN);
870 }
871 }
872 }
873
874 query.append(ORDER_BY_CLAUSE);
875
876 String[] orderByFields = orderByComparator.getOrderByFields();
877
878 for (int i = 0; i < orderByFields.length; i++) {
879 query.append(_ORDER_BY_ENTITY_ALIAS);
880 query.append(orderByFields[i]);
881
882 if ((i + 1) < orderByFields.length) {
883 if (orderByComparator.isAscending() ^ previous) {
884 query.append(ORDER_BY_ASC_HAS_NEXT);
885 }
886 else {
887 query.append(ORDER_BY_DESC_HAS_NEXT);
888 }
889 }
890 else {
891 if (orderByComparator.isAscending() ^ previous) {
892 query.append(ORDER_BY_ASC);
893 }
894 else {
895 query.append(ORDER_BY_DESC);
896 }
897 }
898 }
899 }
900
901 String sql = query.toString();
902
903 Query q = session.createQuery(sql);
904
905 q.setFirstResult(0);
906 q.setMaxResults(2);
907
908 QueryPos qPos = QueryPos.getInstance(q);
909
910 if (uuid != null) {
911 qPos.add(uuid);
912 }
913
914 if (orderByComparator != null) {
915 Object[] values = orderByComparator.getOrderByConditionValues(repository);
916
917 for (Object value : values) {
918 qPos.add(value);
919 }
920 }
921
922 List<Repository> list = q.list();
923
924 if (list.size() == 2) {
925 return list.get(1);
926 }
927 else {
928 return null;
929 }
930 }
931
932
941 public Repository findByUUID_G(String uuid, long groupId)
942 throws NoSuchRepositoryException, SystemException {
943 Repository repository = fetchByUUID_G(uuid, groupId);
944
945 if (repository == null) {
946 StringBundler msg = new StringBundler(6);
947
948 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
949
950 msg.append("uuid=");
951 msg.append(uuid);
952
953 msg.append(", groupId=");
954 msg.append(groupId);
955
956 msg.append(StringPool.CLOSE_CURLY_BRACE);
957
958 if (_log.isWarnEnabled()) {
959 _log.warn(msg.toString());
960 }
961
962 throw new NoSuchRepositoryException(msg.toString());
963 }
964
965 return repository;
966 }
967
968
976 public Repository fetchByUUID_G(String uuid, long groupId)
977 throws SystemException {
978 return fetchByUUID_G(uuid, groupId, true);
979 }
980
981
990 public Repository fetchByUUID_G(String uuid, long groupId,
991 boolean retrieveFromCache) throws SystemException {
992 Object[] finderArgs = new Object[] { uuid, groupId };
993
994 Object result = null;
995
996 if (retrieveFromCache) {
997 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
998 finderArgs, this);
999 }
1000
1001 if (result instanceof Repository) {
1002 Repository repository = (Repository)result;
1003
1004 if (!Validator.equals(uuid, repository.getUuid()) ||
1005 (groupId != repository.getGroupId())) {
1006 result = null;
1007 }
1008 }
1009
1010 if (result == null) {
1011 StringBundler query = new StringBundler(3);
1012
1013 query.append(_SQL_SELECT_REPOSITORY_WHERE);
1014
1015 if (uuid == null) {
1016 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1017 }
1018 else {
1019 if (uuid.equals(StringPool.BLANK)) {
1020 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1021 }
1022 else {
1023 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1024 }
1025 }
1026
1027 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1028
1029 String sql = query.toString();
1030
1031 Session session = null;
1032
1033 try {
1034 session = openSession();
1035
1036 Query q = session.createQuery(sql);
1037
1038 QueryPos qPos = QueryPos.getInstance(q);
1039
1040 if (uuid != null) {
1041 qPos.add(uuid);
1042 }
1043
1044 qPos.add(groupId);
1045
1046 List<Repository> list = q.list();
1047
1048 result = list;
1049
1050 Repository repository = null;
1051
1052 if (list.isEmpty()) {
1053 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1054 finderArgs, list);
1055 }
1056 else {
1057 repository = list.get(0);
1058
1059 cacheResult(repository);
1060
1061 if ((repository.getUuid() == null) ||
1062 !repository.getUuid().equals(uuid) ||
1063 (repository.getGroupId() != groupId)) {
1064 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1065 finderArgs, repository);
1066 }
1067 }
1068
1069 return repository;
1070 }
1071 catch (Exception e) {
1072 throw processException(e);
1073 }
1074 finally {
1075 if (result == null) {
1076 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1077 finderArgs);
1078 }
1079
1080 closeSession(session);
1081 }
1082 }
1083 else {
1084 if (result instanceof List<?>) {
1085 return null;
1086 }
1087 else {
1088 return (Repository)result;
1089 }
1090 }
1091 }
1092
1093
1100 public List<Repository> findByGroupId(long groupId)
1101 throws SystemException {
1102 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1103 }
1104
1105
1118 public List<Repository> findByGroupId(long groupId, int start, int end)
1119 throws SystemException {
1120 return findByGroupId(groupId, start, end, null);
1121 }
1122
1123
1137 public List<Repository> findByGroupId(long groupId, int start, int end,
1138 OrderByComparator orderByComparator) throws SystemException {
1139 FinderPath finderPath = null;
1140 Object[] finderArgs = null;
1141
1142 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1143 (orderByComparator == null)) {
1144 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1145 finderArgs = new Object[] { groupId };
1146 }
1147 else {
1148 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1149 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1150 }
1151
1152 List<Repository> list = (List<Repository>)FinderCacheUtil.getResult(finderPath,
1153 finderArgs, this);
1154
1155 if ((list != null) && !list.isEmpty()) {
1156 for (Repository repository : list) {
1157 if ((groupId != repository.getGroupId())) {
1158 list = null;
1159
1160 break;
1161 }
1162 }
1163 }
1164
1165 if (list == null) {
1166 StringBundler query = null;
1167
1168 if (orderByComparator != null) {
1169 query = new StringBundler(3 +
1170 (orderByComparator.getOrderByFields().length * 3));
1171 }
1172 else {
1173 query = new StringBundler(2);
1174 }
1175
1176 query.append(_SQL_SELECT_REPOSITORY_WHERE);
1177
1178 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1179
1180 if (orderByComparator != null) {
1181 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1182 orderByComparator);
1183 }
1184
1185 String sql = query.toString();
1186
1187 Session session = null;
1188
1189 try {
1190 session = openSession();
1191
1192 Query q = session.createQuery(sql);
1193
1194 QueryPos qPos = QueryPos.getInstance(q);
1195
1196 qPos.add(groupId);
1197
1198 list = (List<Repository>)QueryUtil.list(q, getDialect(), start,
1199 end);
1200 }
1201 catch (Exception e) {
1202 throw processException(e);
1203 }
1204 finally {
1205 if (list == null) {
1206 FinderCacheUtil.removeResult(finderPath, finderArgs);
1207 }
1208 else {
1209 cacheResult(list);
1210
1211 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1212 }
1213
1214 closeSession(session);
1215 }
1216 }
1217
1218 return list;
1219 }
1220
1221
1234 public Repository findByGroupId_First(long groupId,
1235 OrderByComparator orderByComparator)
1236 throws NoSuchRepositoryException, SystemException {
1237 List<Repository> list = findByGroupId(groupId, 0, 1, orderByComparator);
1238
1239 if (list.isEmpty()) {
1240 StringBundler msg = new StringBundler(4);
1241
1242 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1243
1244 msg.append("groupId=");
1245 msg.append(groupId);
1246
1247 msg.append(StringPool.CLOSE_CURLY_BRACE);
1248
1249 throw new NoSuchRepositoryException(msg.toString());
1250 }
1251 else {
1252 return list.get(0);
1253 }
1254 }
1255
1256
1269 public Repository findByGroupId_Last(long groupId,
1270 OrderByComparator orderByComparator)
1271 throws NoSuchRepositoryException, SystemException {
1272 int count = countByGroupId(groupId);
1273
1274 List<Repository> list = findByGroupId(groupId, count - 1, count,
1275 orderByComparator);
1276
1277 if (list.isEmpty()) {
1278 StringBundler msg = new StringBundler(4);
1279
1280 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1281
1282 msg.append("groupId=");
1283 msg.append(groupId);
1284
1285 msg.append(StringPool.CLOSE_CURLY_BRACE);
1286
1287 throw new NoSuchRepositoryException(msg.toString());
1288 }
1289 else {
1290 return list.get(0);
1291 }
1292 }
1293
1294
1308 public Repository[] findByGroupId_PrevAndNext(long repositoryId,
1309 long groupId, OrderByComparator orderByComparator)
1310 throws NoSuchRepositoryException, SystemException {
1311 Repository repository = findByPrimaryKey(repositoryId);
1312
1313 Session session = null;
1314
1315 try {
1316 session = openSession();
1317
1318 Repository[] array = new RepositoryImpl[3];
1319
1320 array[0] = getByGroupId_PrevAndNext(session, repository, groupId,
1321 orderByComparator, true);
1322
1323 array[1] = repository;
1324
1325 array[2] = getByGroupId_PrevAndNext(session, repository, groupId,
1326 orderByComparator, false);
1327
1328 return array;
1329 }
1330 catch (Exception e) {
1331 throw processException(e);
1332 }
1333 finally {
1334 closeSession(session);
1335 }
1336 }
1337
1338 protected Repository getByGroupId_PrevAndNext(Session session,
1339 Repository repository, long groupId,
1340 OrderByComparator orderByComparator, boolean previous) {
1341 StringBundler query = null;
1342
1343 if (orderByComparator != null) {
1344 query = new StringBundler(6 +
1345 (orderByComparator.getOrderByFields().length * 6));
1346 }
1347 else {
1348 query = new StringBundler(3);
1349 }
1350
1351 query.append(_SQL_SELECT_REPOSITORY_WHERE);
1352
1353 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1354
1355 if (orderByComparator != null) {
1356 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1357
1358 if (orderByConditionFields.length > 0) {
1359 query.append(WHERE_AND);
1360 }
1361
1362 for (int i = 0; i < orderByConditionFields.length; i++) {
1363 query.append(_ORDER_BY_ENTITY_ALIAS);
1364 query.append(orderByConditionFields[i]);
1365
1366 if ((i + 1) < orderByConditionFields.length) {
1367 if (orderByComparator.isAscending() ^ previous) {
1368 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1369 }
1370 else {
1371 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1372 }
1373 }
1374 else {
1375 if (orderByComparator.isAscending() ^ previous) {
1376 query.append(WHERE_GREATER_THAN);
1377 }
1378 else {
1379 query.append(WHERE_LESSER_THAN);
1380 }
1381 }
1382 }
1383
1384 query.append(ORDER_BY_CLAUSE);
1385
1386 String[] orderByFields = orderByComparator.getOrderByFields();
1387
1388 for (int i = 0; i < orderByFields.length; i++) {
1389 query.append(_ORDER_BY_ENTITY_ALIAS);
1390 query.append(orderByFields[i]);
1391
1392 if ((i + 1) < orderByFields.length) {
1393 if (orderByComparator.isAscending() ^ previous) {
1394 query.append(ORDER_BY_ASC_HAS_NEXT);
1395 }
1396 else {
1397 query.append(ORDER_BY_DESC_HAS_NEXT);
1398 }
1399 }
1400 else {
1401 if (orderByComparator.isAscending() ^ previous) {
1402 query.append(ORDER_BY_ASC);
1403 }
1404 else {
1405 query.append(ORDER_BY_DESC);
1406 }
1407 }
1408 }
1409 }
1410
1411 String sql = query.toString();
1412
1413 Query q = session.createQuery(sql);
1414
1415 q.setFirstResult(0);
1416 q.setMaxResults(2);
1417
1418 QueryPos qPos = QueryPos.getInstance(q);
1419
1420 qPos.add(groupId);
1421
1422 if (orderByComparator != null) {
1423 Object[] values = orderByComparator.getOrderByConditionValues(repository);
1424
1425 for (Object value : values) {
1426 qPos.add(value);
1427 }
1428 }
1429
1430 List<Repository> list = q.list();
1431
1432 if (list.size() == 2) {
1433 return list.get(1);
1434 }
1435 else {
1436 return null;
1437 }
1438 }
1439
1440
1446 public List<Repository> findAll() throws SystemException {
1447 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1448 }
1449
1450
1462 public List<Repository> findAll(int start, int end)
1463 throws SystemException {
1464 return findAll(start, end, null);
1465 }
1466
1467
1480 public List<Repository> findAll(int start, int end,
1481 OrderByComparator orderByComparator) throws SystemException {
1482 FinderPath finderPath = null;
1483 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1484
1485 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1486 (orderByComparator == null)) {
1487 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1488 finderArgs = FINDER_ARGS_EMPTY;
1489 }
1490 else {
1491 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1492 finderArgs = new Object[] { start, end, orderByComparator };
1493 }
1494
1495 List<Repository> list = (List<Repository>)FinderCacheUtil.getResult(finderPath,
1496 finderArgs, this);
1497
1498 if (list == null) {
1499 StringBundler query = null;
1500 String sql = null;
1501
1502 if (orderByComparator != null) {
1503 query = new StringBundler(2 +
1504 (orderByComparator.getOrderByFields().length * 3));
1505
1506 query.append(_SQL_SELECT_REPOSITORY);
1507
1508 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1509 orderByComparator);
1510
1511 sql = query.toString();
1512 }
1513 else {
1514 sql = _SQL_SELECT_REPOSITORY;
1515 }
1516
1517 Session session = null;
1518
1519 try {
1520 session = openSession();
1521
1522 Query q = session.createQuery(sql);
1523
1524 if (orderByComparator == null) {
1525 list = (List<Repository>)QueryUtil.list(q, getDialect(),
1526 start, end, false);
1527
1528 Collections.sort(list);
1529 }
1530 else {
1531 list = (List<Repository>)QueryUtil.list(q, getDialect(),
1532 start, end);
1533 }
1534 }
1535 catch (Exception e) {
1536 throw processException(e);
1537 }
1538 finally {
1539 if (list == null) {
1540 FinderCacheUtil.removeResult(finderPath, finderArgs);
1541 }
1542 else {
1543 cacheResult(list);
1544
1545 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1546 }
1547
1548 closeSession(session);
1549 }
1550 }
1551
1552 return list;
1553 }
1554
1555
1561 public void removeByUuid(String uuid) throws SystemException {
1562 for (Repository repository : findByUuid(uuid)) {
1563 remove(repository);
1564 }
1565 }
1566
1567
1574 public void removeByUUID_G(String uuid, long groupId)
1575 throws NoSuchRepositoryException, SystemException {
1576 Repository repository = findByUUID_G(uuid, groupId);
1577
1578 remove(repository);
1579 }
1580
1581
1587 public void removeByGroupId(long groupId) throws SystemException {
1588 for (Repository repository : findByGroupId(groupId)) {
1589 remove(repository);
1590 }
1591 }
1592
1593
1598 public void removeAll() throws SystemException {
1599 for (Repository repository : findAll()) {
1600 remove(repository);
1601 }
1602 }
1603
1604
1611 public int countByUuid(String uuid) throws SystemException {
1612 Object[] finderArgs = new Object[] { uuid };
1613
1614 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1615 finderArgs, this);
1616
1617 if (count == null) {
1618 StringBundler query = new StringBundler(2);
1619
1620 query.append(_SQL_COUNT_REPOSITORY_WHERE);
1621
1622 if (uuid == null) {
1623 query.append(_FINDER_COLUMN_UUID_UUID_1);
1624 }
1625 else {
1626 if (uuid.equals(StringPool.BLANK)) {
1627 query.append(_FINDER_COLUMN_UUID_UUID_3);
1628 }
1629 else {
1630 query.append(_FINDER_COLUMN_UUID_UUID_2);
1631 }
1632 }
1633
1634 String sql = query.toString();
1635
1636 Session session = null;
1637
1638 try {
1639 session = openSession();
1640
1641 Query q = session.createQuery(sql);
1642
1643 QueryPos qPos = QueryPos.getInstance(q);
1644
1645 if (uuid != null) {
1646 qPos.add(uuid);
1647 }
1648
1649 count = (Long)q.uniqueResult();
1650 }
1651 catch (Exception e) {
1652 throw processException(e);
1653 }
1654 finally {
1655 if (count == null) {
1656 count = Long.valueOf(0);
1657 }
1658
1659 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1660 finderArgs, count);
1661
1662 closeSession(session);
1663 }
1664 }
1665
1666 return count.intValue();
1667 }
1668
1669
1677 public int countByUUID_G(String uuid, long groupId)
1678 throws SystemException {
1679 Object[] finderArgs = new Object[] { uuid, groupId };
1680
1681 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1682 finderArgs, this);
1683
1684 if (count == null) {
1685 StringBundler query = new StringBundler(3);
1686
1687 query.append(_SQL_COUNT_REPOSITORY_WHERE);
1688
1689 if (uuid == null) {
1690 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1691 }
1692 else {
1693 if (uuid.equals(StringPool.BLANK)) {
1694 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1695 }
1696 else {
1697 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1698 }
1699 }
1700
1701 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1702
1703 String sql = query.toString();
1704
1705 Session session = null;
1706
1707 try {
1708 session = openSession();
1709
1710 Query q = session.createQuery(sql);
1711
1712 QueryPos qPos = QueryPos.getInstance(q);
1713
1714 if (uuid != null) {
1715 qPos.add(uuid);
1716 }
1717
1718 qPos.add(groupId);
1719
1720 count = (Long)q.uniqueResult();
1721 }
1722 catch (Exception e) {
1723 throw processException(e);
1724 }
1725 finally {
1726 if (count == null) {
1727 count = Long.valueOf(0);
1728 }
1729
1730 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1731 finderArgs, count);
1732
1733 closeSession(session);
1734 }
1735 }
1736
1737 return count.intValue();
1738 }
1739
1740
1747 public int countByGroupId(long groupId) throws SystemException {
1748 Object[] finderArgs = new Object[] { groupId };
1749
1750 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1751 finderArgs, this);
1752
1753 if (count == null) {
1754 StringBundler query = new StringBundler(2);
1755
1756 query.append(_SQL_COUNT_REPOSITORY_WHERE);
1757
1758 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1759
1760 String sql = query.toString();
1761
1762 Session session = null;
1763
1764 try {
1765 session = openSession();
1766
1767 Query q = session.createQuery(sql);
1768
1769 QueryPos qPos = QueryPos.getInstance(q);
1770
1771 qPos.add(groupId);
1772
1773 count = (Long)q.uniqueResult();
1774 }
1775 catch (Exception e) {
1776 throw processException(e);
1777 }
1778 finally {
1779 if (count == null) {
1780 count = Long.valueOf(0);
1781 }
1782
1783 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1784 finderArgs, count);
1785
1786 closeSession(session);
1787 }
1788 }
1789
1790 return count.intValue();
1791 }
1792
1793
1799 public int countAll() throws SystemException {
1800 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1801 FINDER_ARGS_EMPTY, this);
1802
1803 if (count == null) {
1804 Session session = null;
1805
1806 try {
1807 session = openSession();
1808
1809 Query q = session.createQuery(_SQL_COUNT_REPOSITORY);
1810
1811 count = (Long)q.uniqueResult();
1812 }
1813 catch (Exception e) {
1814 throw processException(e);
1815 }
1816 finally {
1817 if (count == null) {
1818 count = Long.valueOf(0);
1819 }
1820
1821 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1822 FINDER_ARGS_EMPTY, count);
1823
1824 closeSession(session);
1825 }
1826 }
1827
1828 return count.intValue();
1829 }
1830
1831
1834 public void afterPropertiesSet() {
1835 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1836 com.liferay.portal.util.PropsUtil.get(
1837 "value.object.listener.com.liferay.portal.model.Repository")));
1838
1839 if (listenerClassNames.length > 0) {
1840 try {
1841 List<ModelListener<Repository>> listenersList = new ArrayList<ModelListener<Repository>>();
1842
1843 for (String listenerClassName : listenerClassNames) {
1844 listenersList.add((ModelListener<Repository>)InstanceFactory.newInstance(
1845 listenerClassName));
1846 }
1847
1848 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1849 }
1850 catch (Exception e) {
1851 _log.error(e);
1852 }
1853 }
1854 }
1855
1856 public void destroy() {
1857 EntityCacheUtil.removeCache(RepositoryImpl.class.getName());
1858 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1859 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1860 }
1861
1862 @BeanReference(type = AccountPersistence.class)
1863 protected AccountPersistence accountPersistence;
1864 @BeanReference(type = AddressPersistence.class)
1865 protected AddressPersistence addressPersistence;
1866 @BeanReference(type = BrowserTrackerPersistence.class)
1867 protected BrowserTrackerPersistence browserTrackerPersistence;
1868 @BeanReference(type = ClassNamePersistence.class)
1869 protected ClassNamePersistence classNamePersistence;
1870 @BeanReference(type = ClusterGroupPersistence.class)
1871 protected ClusterGroupPersistence clusterGroupPersistence;
1872 @BeanReference(type = CompanyPersistence.class)
1873 protected CompanyPersistence companyPersistence;
1874 @BeanReference(type = ContactPersistence.class)
1875 protected ContactPersistence contactPersistence;
1876 @BeanReference(type = CountryPersistence.class)
1877 protected CountryPersistence countryPersistence;
1878 @BeanReference(type = EmailAddressPersistence.class)
1879 protected EmailAddressPersistence emailAddressPersistence;
1880 @BeanReference(type = GroupPersistence.class)
1881 protected GroupPersistence groupPersistence;
1882 @BeanReference(type = ImagePersistence.class)
1883 protected ImagePersistence imagePersistence;
1884 @BeanReference(type = LayoutPersistence.class)
1885 protected LayoutPersistence layoutPersistence;
1886 @BeanReference(type = LayoutBranchPersistence.class)
1887 protected LayoutBranchPersistence layoutBranchPersistence;
1888 @BeanReference(type = LayoutPrototypePersistence.class)
1889 protected LayoutPrototypePersistence layoutPrototypePersistence;
1890 @BeanReference(type = LayoutRevisionPersistence.class)
1891 protected LayoutRevisionPersistence layoutRevisionPersistence;
1892 @BeanReference(type = LayoutSetPersistence.class)
1893 protected LayoutSetPersistence layoutSetPersistence;
1894 @BeanReference(type = LayoutSetBranchPersistence.class)
1895 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1896 @BeanReference(type = LayoutSetPrototypePersistence.class)
1897 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1898 @BeanReference(type = ListTypePersistence.class)
1899 protected ListTypePersistence listTypePersistence;
1900 @BeanReference(type = LockPersistence.class)
1901 protected LockPersistence lockPersistence;
1902 @BeanReference(type = MembershipRequestPersistence.class)
1903 protected MembershipRequestPersistence membershipRequestPersistence;
1904 @BeanReference(type = OrganizationPersistence.class)
1905 protected OrganizationPersistence organizationPersistence;
1906 @BeanReference(type = OrgGroupPermissionPersistence.class)
1907 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1908 @BeanReference(type = OrgGroupRolePersistence.class)
1909 protected OrgGroupRolePersistence orgGroupRolePersistence;
1910 @BeanReference(type = OrgLaborPersistence.class)
1911 protected OrgLaborPersistence orgLaborPersistence;
1912 @BeanReference(type = PasswordPolicyPersistence.class)
1913 protected PasswordPolicyPersistence passwordPolicyPersistence;
1914 @BeanReference(type = PasswordPolicyRelPersistence.class)
1915 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1916 @BeanReference(type = PasswordTrackerPersistence.class)
1917 protected PasswordTrackerPersistence passwordTrackerPersistence;
1918 @BeanReference(type = PermissionPersistence.class)
1919 protected PermissionPersistence permissionPersistence;
1920 @BeanReference(type = PhonePersistence.class)
1921 protected PhonePersistence phonePersistence;
1922 @BeanReference(type = PluginSettingPersistence.class)
1923 protected PluginSettingPersistence pluginSettingPersistence;
1924 @BeanReference(type = PortalPreferencesPersistence.class)
1925 protected PortalPreferencesPersistence portalPreferencesPersistence;
1926 @BeanReference(type = PortletPersistence.class)
1927 protected PortletPersistence portletPersistence;
1928 @BeanReference(type = PortletItemPersistence.class)
1929 protected PortletItemPersistence portletItemPersistence;
1930 @BeanReference(type = PortletPreferencesPersistence.class)
1931 protected PortletPreferencesPersistence portletPreferencesPersistence;
1932 @BeanReference(type = RegionPersistence.class)
1933 protected RegionPersistence regionPersistence;
1934 @BeanReference(type = ReleasePersistence.class)
1935 protected ReleasePersistence releasePersistence;
1936 @BeanReference(type = RepositoryPersistence.class)
1937 protected RepositoryPersistence repositoryPersistence;
1938 @BeanReference(type = RepositoryEntryPersistence.class)
1939 protected RepositoryEntryPersistence repositoryEntryPersistence;
1940 @BeanReference(type = ResourcePersistence.class)
1941 protected ResourcePersistence resourcePersistence;
1942 @BeanReference(type = ResourceActionPersistence.class)
1943 protected ResourceActionPersistence resourceActionPersistence;
1944 @BeanReference(type = ResourceBlockPersistence.class)
1945 protected ResourceBlockPersistence resourceBlockPersistence;
1946 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1947 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1948 @BeanReference(type = ResourceCodePersistence.class)
1949 protected ResourceCodePersistence resourceCodePersistence;
1950 @BeanReference(type = ResourcePermissionPersistence.class)
1951 protected ResourcePermissionPersistence resourcePermissionPersistence;
1952 @BeanReference(type = ResourceTypePermissionPersistence.class)
1953 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1954 @BeanReference(type = RolePersistence.class)
1955 protected RolePersistence rolePersistence;
1956 @BeanReference(type = ServiceComponentPersistence.class)
1957 protected ServiceComponentPersistence serviceComponentPersistence;
1958 @BeanReference(type = ShardPersistence.class)
1959 protected ShardPersistence shardPersistence;
1960 @BeanReference(type = SubscriptionPersistence.class)
1961 protected SubscriptionPersistence subscriptionPersistence;
1962 @BeanReference(type = TeamPersistence.class)
1963 protected TeamPersistence teamPersistence;
1964 @BeanReference(type = TicketPersistence.class)
1965 protected TicketPersistence ticketPersistence;
1966 @BeanReference(type = UserPersistence.class)
1967 protected UserPersistence userPersistence;
1968 @BeanReference(type = UserGroupPersistence.class)
1969 protected UserGroupPersistence userGroupPersistence;
1970 @BeanReference(type = UserGroupGroupRolePersistence.class)
1971 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1972 @BeanReference(type = UserGroupRolePersistence.class)
1973 protected UserGroupRolePersistence userGroupRolePersistence;
1974 @BeanReference(type = UserIdMapperPersistence.class)
1975 protected UserIdMapperPersistence userIdMapperPersistence;
1976 @BeanReference(type = UserNotificationEventPersistence.class)
1977 protected UserNotificationEventPersistence userNotificationEventPersistence;
1978 @BeanReference(type = UserTrackerPersistence.class)
1979 protected UserTrackerPersistence userTrackerPersistence;
1980 @BeanReference(type = UserTrackerPathPersistence.class)
1981 protected UserTrackerPathPersistence userTrackerPathPersistence;
1982 @BeanReference(type = VirtualHostPersistence.class)
1983 protected VirtualHostPersistence virtualHostPersistence;
1984 @BeanReference(type = WebDAVPropsPersistence.class)
1985 protected WebDAVPropsPersistence webDAVPropsPersistence;
1986 @BeanReference(type = WebsitePersistence.class)
1987 protected WebsitePersistence websitePersistence;
1988 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1989 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1990 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1991 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1992 @BeanReference(type = AssetEntryPersistence.class)
1993 protected AssetEntryPersistence assetEntryPersistence;
1994 @BeanReference(type = DLFileEntryPersistence.class)
1995 protected DLFileEntryPersistence dlFileEntryPersistence;
1996 @BeanReference(type = DLFileVersionPersistence.class)
1997 protected DLFileVersionPersistence dlFileVersionPersistence;
1998 @BeanReference(type = DLFolderPersistence.class)
1999 protected DLFolderPersistence dlFolderPersistence;
2000 @BeanReference(type = ExpandoValuePersistence.class)
2001 protected ExpandoValuePersistence expandoValuePersistence;
2002 private static final String _SQL_SELECT_REPOSITORY = "SELECT repository FROM Repository repository";
2003 private static final String _SQL_SELECT_REPOSITORY_WHERE = "SELECT repository FROM Repository repository WHERE ";
2004 private static final String _SQL_COUNT_REPOSITORY = "SELECT COUNT(repository) FROM Repository repository";
2005 private static final String _SQL_COUNT_REPOSITORY_WHERE = "SELECT COUNT(repository) FROM Repository repository WHERE ";
2006 private static final String _FINDER_COLUMN_UUID_UUID_1 = "repository.uuid IS NULL";
2007 private static final String _FINDER_COLUMN_UUID_UUID_2 = "repository.uuid = ?";
2008 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(repository.uuid IS NULL OR repository.uuid = ?)";
2009 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "repository.uuid IS NULL AND ";
2010 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "repository.uuid = ? AND ";
2011 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(repository.uuid IS NULL OR repository.uuid = ?) AND ";
2012 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "repository.groupId = ?";
2013 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "repository.groupId = ?";
2014 private static final String _ORDER_BY_ENTITY_ALIAS = "repository.";
2015 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Repository exists with the primary key ";
2016 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Repository exists with the key {";
2017 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2018 private static Log _log = LogFactoryUtil.getLog(RepositoryPersistenceImpl.class);
2019 private static Repository _nullRepository = new RepositoryImpl() {
2020 @Override
2021 public Object clone() {
2022 return this;
2023 }
2024
2025 @Override
2026 public CacheModel<Repository> toCacheModel() {
2027 return _nullRepositoryCacheModel;
2028 }
2029 };
2030
2031 private static CacheModel<Repository> _nullRepositoryCacheModel = new CacheModel<Repository>() {
2032 public Repository toEntityModel() {
2033 return _nullRepository;
2034 }
2035 };
2036 }