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_WITHOUT_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_WITH_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
367 else {
368 if ((repositoryModelImpl.getColumnBitmask() &
369 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
370 Object[] args = new Object[] {
371 repositoryModelImpl.getOriginalUuid()
372 };
373
374 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
375 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
376 args);
377
378 args = new Object[] { repositoryModelImpl.getUuid() };
379
380 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
381 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
382 args);
383 }
384
385 if ((repositoryModelImpl.getColumnBitmask() &
386 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
387 Object[] args = new Object[] {
388 Long.valueOf(repositoryModelImpl.getOriginalGroupId())
389 };
390
391 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
392 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
393 args);
394
395 args = new Object[] {
396 Long.valueOf(repositoryModelImpl.getGroupId())
397 };
398
399 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
400 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
401 args);
402 }
403 }
404
405 EntityCacheUtil.putResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
406 RepositoryImpl.class, repository.getPrimaryKey(), repository);
407
408 if (isNew) {
409 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
410 new Object[] {
411 repository.getUuid(), Long.valueOf(repository.getGroupId())
412 }, repository);
413 }
414 else {
415 if ((repositoryModelImpl.getColumnBitmask() &
416 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
417 Object[] args = new Object[] {
418 repositoryModelImpl.getOriginalUuid(),
419 Long.valueOf(repositoryModelImpl.getOriginalGroupId())
420 };
421
422 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
423 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
424
425 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
426 new Object[] {
427 repository.getUuid(),
428 Long.valueOf(repository.getGroupId())
429 }, repository);
430 }
431 }
432
433 return repository;
434 }
435
436 protected Repository toUnwrappedModel(Repository repository) {
437 if (repository instanceof RepositoryImpl) {
438 return repository;
439 }
440
441 RepositoryImpl repositoryImpl = new RepositoryImpl();
442
443 repositoryImpl.setNew(repository.isNew());
444 repositoryImpl.setPrimaryKey(repository.getPrimaryKey());
445
446 repositoryImpl.setUuid(repository.getUuid());
447 repositoryImpl.setRepositoryId(repository.getRepositoryId());
448 repositoryImpl.setGroupId(repository.getGroupId());
449 repositoryImpl.setCompanyId(repository.getCompanyId());
450 repositoryImpl.setUserId(repository.getUserId());
451 repositoryImpl.setUserName(repository.getUserName());
452 repositoryImpl.setCreateDate(repository.getCreateDate());
453 repositoryImpl.setModifiedDate(repository.getModifiedDate());
454 repositoryImpl.setClassNameId(repository.getClassNameId());
455 repositoryImpl.setName(repository.getName());
456 repositoryImpl.setDescription(repository.getDescription());
457 repositoryImpl.setPortletId(repository.getPortletId());
458 repositoryImpl.setTypeSettings(repository.getTypeSettings());
459 repositoryImpl.setDlFolderId(repository.getDlFolderId());
460
461 return repositoryImpl;
462 }
463
464
472 @Override
473 public Repository findByPrimaryKey(Serializable primaryKey)
474 throws NoSuchModelException, SystemException {
475 return findByPrimaryKey(((Long)primaryKey).longValue());
476 }
477
478
486 public Repository findByPrimaryKey(long repositoryId)
487 throws NoSuchRepositoryException, SystemException {
488 Repository repository = fetchByPrimaryKey(repositoryId);
489
490 if (repository == null) {
491 if (_log.isWarnEnabled()) {
492 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + repositoryId);
493 }
494
495 throw new NoSuchRepositoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
496 repositoryId);
497 }
498
499 return repository;
500 }
501
502
509 @Override
510 public Repository fetchByPrimaryKey(Serializable primaryKey)
511 throws SystemException {
512 return fetchByPrimaryKey(((Long)primaryKey).longValue());
513 }
514
515
522 public Repository fetchByPrimaryKey(long repositoryId)
523 throws SystemException {
524 Repository repository = (Repository)EntityCacheUtil.getResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
525 RepositoryImpl.class, repositoryId);
526
527 if (repository == _nullRepository) {
528 return null;
529 }
530
531 if (repository == null) {
532 Session session = null;
533
534 boolean hasException = false;
535
536 try {
537 session = openSession();
538
539 repository = (Repository)session.get(RepositoryImpl.class,
540 Long.valueOf(repositoryId));
541 }
542 catch (Exception e) {
543 hasException = true;
544
545 throw processException(e);
546 }
547 finally {
548 if (repository != null) {
549 cacheResult(repository);
550 }
551 else if (!hasException) {
552 EntityCacheUtil.putResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
553 RepositoryImpl.class, repositoryId, _nullRepository);
554 }
555
556 closeSession(session);
557 }
558 }
559
560 return repository;
561 }
562
563
570 public List<Repository> findByUuid(String uuid) throws SystemException {
571 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
572 }
573
574
587 public List<Repository> findByUuid(String uuid, int start, int end)
588 throws SystemException {
589 return findByUuid(uuid, start, end, null);
590 }
591
592
606 public List<Repository> findByUuid(String uuid, int start, int end,
607 OrderByComparator orderByComparator) throws SystemException {
608 FinderPath finderPath = null;
609 Object[] finderArgs = null;
610
611 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
612 (orderByComparator == null)) {
613 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
614 finderArgs = new Object[] { uuid };
615 }
616 else {
617 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
618 finderArgs = new Object[] { uuid, start, end, orderByComparator };
619 }
620
621 List<Repository> list = (List<Repository>)FinderCacheUtil.getResult(finderPath,
622 finderArgs, this);
623
624 if (list == null) {
625 StringBundler query = null;
626
627 if (orderByComparator != null) {
628 query = new StringBundler(3 +
629 (orderByComparator.getOrderByFields().length * 3));
630 }
631 else {
632 query = new StringBundler(2);
633 }
634
635 query.append(_SQL_SELECT_REPOSITORY_WHERE);
636
637 if (uuid == null) {
638 query.append(_FINDER_COLUMN_UUID_UUID_1);
639 }
640 else {
641 if (uuid.equals(StringPool.BLANK)) {
642 query.append(_FINDER_COLUMN_UUID_UUID_3);
643 }
644 else {
645 query.append(_FINDER_COLUMN_UUID_UUID_2);
646 }
647 }
648
649 if (orderByComparator != null) {
650 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
651 orderByComparator);
652 }
653
654 String sql = query.toString();
655
656 Session session = null;
657
658 try {
659 session = openSession();
660
661 Query q = session.createQuery(sql);
662
663 QueryPos qPos = QueryPos.getInstance(q);
664
665 if (uuid != null) {
666 qPos.add(uuid);
667 }
668
669 list = (List<Repository>)QueryUtil.list(q, getDialect(), start,
670 end);
671 }
672 catch (Exception e) {
673 throw processException(e);
674 }
675 finally {
676 if (list == null) {
677 FinderCacheUtil.removeResult(finderPath, finderArgs);
678 }
679 else {
680 cacheResult(list);
681
682 FinderCacheUtil.putResult(finderPath, finderArgs, list);
683 }
684
685 closeSession(session);
686 }
687 }
688
689 return list;
690 }
691
692
705 public Repository findByUuid_First(String uuid,
706 OrderByComparator orderByComparator)
707 throws NoSuchRepositoryException, SystemException {
708 List<Repository> list = findByUuid(uuid, 0, 1, orderByComparator);
709
710 if (list.isEmpty()) {
711 StringBundler msg = new StringBundler(4);
712
713 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
714
715 msg.append("uuid=");
716 msg.append(uuid);
717
718 msg.append(StringPool.CLOSE_CURLY_BRACE);
719
720 throw new NoSuchRepositoryException(msg.toString());
721 }
722 else {
723 return list.get(0);
724 }
725 }
726
727
740 public Repository findByUuid_Last(String uuid,
741 OrderByComparator orderByComparator)
742 throws NoSuchRepositoryException, SystemException {
743 int count = countByUuid(uuid);
744
745 List<Repository> list = findByUuid(uuid, count - 1, count,
746 orderByComparator);
747
748 if (list.isEmpty()) {
749 StringBundler msg = new StringBundler(4);
750
751 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
752
753 msg.append("uuid=");
754 msg.append(uuid);
755
756 msg.append(StringPool.CLOSE_CURLY_BRACE);
757
758 throw new NoSuchRepositoryException(msg.toString());
759 }
760 else {
761 return list.get(0);
762 }
763 }
764
765
779 public Repository[] findByUuid_PrevAndNext(long repositoryId, String uuid,
780 OrderByComparator orderByComparator)
781 throws NoSuchRepositoryException, SystemException {
782 Repository repository = findByPrimaryKey(repositoryId);
783
784 Session session = null;
785
786 try {
787 session = openSession();
788
789 Repository[] array = new RepositoryImpl[3];
790
791 array[0] = getByUuid_PrevAndNext(session, repository, uuid,
792 orderByComparator, true);
793
794 array[1] = repository;
795
796 array[2] = getByUuid_PrevAndNext(session, repository, uuid,
797 orderByComparator, false);
798
799 return array;
800 }
801 catch (Exception e) {
802 throw processException(e);
803 }
804 finally {
805 closeSession(session);
806 }
807 }
808
809 protected Repository getByUuid_PrevAndNext(Session session,
810 Repository repository, String uuid,
811 OrderByComparator orderByComparator, boolean previous) {
812 StringBundler query = null;
813
814 if (orderByComparator != null) {
815 query = new StringBundler(6 +
816 (orderByComparator.getOrderByFields().length * 6));
817 }
818 else {
819 query = new StringBundler(3);
820 }
821
822 query.append(_SQL_SELECT_REPOSITORY_WHERE);
823
824 if (uuid == null) {
825 query.append(_FINDER_COLUMN_UUID_UUID_1);
826 }
827 else {
828 if (uuid.equals(StringPool.BLANK)) {
829 query.append(_FINDER_COLUMN_UUID_UUID_3);
830 }
831 else {
832 query.append(_FINDER_COLUMN_UUID_UUID_2);
833 }
834 }
835
836 if (orderByComparator != null) {
837 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
838
839 if (orderByConditionFields.length > 0) {
840 query.append(WHERE_AND);
841 }
842
843 for (int i = 0; i < orderByConditionFields.length; i++) {
844 query.append(_ORDER_BY_ENTITY_ALIAS);
845 query.append(orderByConditionFields[i]);
846
847 if ((i + 1) < orderByConditionFields.length) {
848 if (orderByComparator.isAscending() ^ previous) {
849 query.append(WHERE_GREATER_THAN_HAS_NEXT);
850 }
851 else {
852 query.append(WHERE_LESSER_THAN_HAS_NEXT);
853 }
854 }
855 else {
856 if (orderByComparator.isAscending() ^ previous) {
857 query.append(WHERE_GREATER_THAN);
858 }
859 else {
860 query.append(WHERE_LESSER_THAN);
861 }
862 }
863 }
864
865 query.append(ORDER_BY_CLAUSE);
866
867 String[] orderByFields = orderByComparator.getOrderByFields();
868
869 for (int i = 0; i < orderByFields.length; i++) {
870 query.append(_ORDER_BY_ENTITY_ALIAS);
871 query.append(orderByFields[i]);
872
873 if ((i + 1) < orderByFields.length) {
874 if (orderByComparator.isAscending() ^ previous) {
875 query.append(ORDER_BY_ASC_HAS_NEXT);
876 }
877 else {
878 query.append(ORDER_BY_DESC_HAS_NEXT);
879 }
880 }
881 else {
882 if (orderByComparator.isAscending() ^ previous) {
883 query.append(ORDER_BY_ASC);
884 }
885 else {
886 query.append(ORDER_BY_DESC);
887 }
888 }
889 }
890 }
891
892 String sql = query.toString();
893
894 Query q = session.createQuery(sql);
895
896 q.setFirstResult(0);
897 q.setMaxResults(2);
898
899 QueryPos qPos = QueryPos.getInstance(q);
900
901 if (uuid != null) {
902 qPos.add(uuid);
903 }
904
905 if (orderByComparator != null) {
906 Object[] values = orderByComparator.getOrderByConditionValues(repository);
907
908 for (Object value : values) {
909 qPos.add(value);
910 }
911 }
912
913 List<Repository> list = q.list();
914
915 if (list.size() == 2) {
916 return list.get(1);
917 }
918 else {
919 return null;
920 }
921 }
922
923
932 public Repository findByUUID_G(String uuid, long groupId)
933 throws NoSuchRepositoryException, SystemException {
934 Repository repository = fetchByUUID_G(uuid, groupId);
935
936 if (repository == null) {
937 StringBundler msg = new StringBundler(6);
938
939 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
940
941 msg.append("uuid=");
942 msg.append(uuid);
943
944 msg.append(", groupId=");
945 msg.append(groupId);
946
947 msg.append(StringPool.CLOSE_CURLY_BRACE);
948
949 if (_log.isWarnEnabled()) {
950 _log.warn(msg.toString());
951 }
952
953 throw new NoSuchRepositoryException(msg.toString());
954 }
955
956 return repository;
957 }
958
959
967 public Repository fetchByUUID_G(String uuid, long groupId)
968 throws SystemException {
969 return fetchByUUID_G(uuid, groupId, true);
970 }
971
972
981 public Repository fetchByUUID_G(String uuid, long groupId,
982 boolean retrieveFromCache) throws SystemException {
983 Object[] finderArgs = new Object[] { uuid, groupId };
984
985 Object result = null;
986
987 if (retrieveFromCache) {
988 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
989 finderArgs, this);
990 }
991
992 if (result == null) {
993 StringBundler query = new StringBundler(3);
994
995 query.append(_SQL_SELECT_REPOSITORY_WHERE);
996
997 if (uuid == null) {
998 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
999 }
1000 else {
1001 if (uuid.equals(StringPool.BLANK)) {
1002 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1003 }
1004 else {
1005 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1006 }
1007 }
1008
1009 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1010
1011 String sql = query.toString();
1012
1013 Session session = null;
1014
1015 try {
1016 session = openSession();
1017
1018 Query q = session.createQuery(sql);
1019
1020 QueryPos qPos = QueryPos.getInstance(q);
1021
1022 if (uuid != null) {
1023 qPos.add(uuid);
1024 }
1025
1026 qPos.add(groupId);
1027
1028 List<Repository> list = q.list();
1029
1030 result = list;
1031
1032 Repository repository = null;
1033
1034 if (list.isEmpty()) {
1035 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1036 finderArgs, list);
1037 }
1038 else {
1039 repository = list.get(0);
1040
1041 cacheResult(repository);
1042
1043 if ((repository.getUuid() == null) ||
1044 !repository.getUuid().equals(uuid) ||
1045 (repository.getGroupId() != groupId)) {
1046 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1047 finderArgs, repository);
1048 }
1049 }
1050
1051 return repository;
1052 }
1053 catch (Exception e) {
1054 throw processException(e);
1055 }
1056 finally {
1057 if (result == null) {
1058 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1059 finderArgs);
1060 }
1061
1062 closeSession(session);
1063 }
1064 }
1065 else {
1066 if (result instanceof List<?>) {
1067 return null;
1068 }
1069 else {
1070 return (Repository)result;
1071 }
1072 }
1073 }
1074
1075
1082 public List<Repository> findByGroupId(long groupId)
1083 throws SystemException {
1084 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1085 }
1086
1087
1100 public List<Repository> findByGroupId(long groupId, int start, int end)
1101 throws SystemException {
1102 return findByGroupId(groupId, start, end, null);
1103 }
1104
1105
1119 public List<Repository> findByGroupId(long groupId, int start, int end,
1120 OrderByComparator orderByComparator) throws SystemException {
1121 FinderPath finderPath = null;
1122 Object[] finderArgs = null;
1123
1124 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1125 (orderByComparator == null)) {
1126 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1127 finderArgs = new Object[] { groupId };
1128 }
1129 else {
1130 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1131 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1132 }
1133
1134 List<Repository> list = (List<Repository>)FinderCacheUtil.getResult(finderPath,
1135 finderArgs, this);
1136
1137 if (list == null) {
1138 StringBundler query = null;
1139
1140 if (orderByComparator != null) {
1141 query = new StringBundler(3 +
1142 (orderByComparator.getOrderByFields().length * 3));
1143 }
1144 else {
1145 query = new StringBundler(2);
1146 }
1147
1148 query.append(_SQL_SELECT_REPOSITORY_WHERE);
1149
1150 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1151
1152 if (orderByComparator != null) {
1153 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1154 orderByComparator);
1155 }
1156
1157 String sql = query.toString();
1158
1159 Session session = null;
1160
1161 try {
1162 session = openSession();
1163
1164 Query q = session.createQuery(sql);
1165
1166 QueryPos qPos = QueryPos.getInstance(q);
1167
1168 qPos.add(groupId);
1169
1170 list = (List<Repository>)QueryUtil.list(q, getDialect(), start,
1171 end);
1172 }
1173 catch (Exception e) {
1174 throw processException(e);
1175 }
1176 finally {
1177 if (list == null) {
1178 FinderCacheUtil.removeResult(finderPath, finderArgs);
1179 }
1180 else {
1181 cacheResult(list);
1182
1183 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1184 }
1185
1186 closeSession(session);
1187 }
1188 }
1189
1190 return list;
1191 }
1192
1193
1206 public Repository findByGroupId_First(long groupId,
1207 OrderByComparator orderByComparator)
1208 throws NoSuchRepositoryException, SystemException {
1209 List<Repository> list = findByGroupId(groupId, 0, 1, orderByComparator);
1210
1211 if (list.isEmpty()) {
1212 StringBundler msg = new StringBundler(4);
1213
1214 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1215
1216 msg.append("groupId=");
1217 msg.append(groupId);
1218
1219 msg.append(StringPool.CLOSE_CURLY_BRACE);
1220
1221 throw new NoSuchRepositoryException(msg.toString());
1222 }
1223 else {
1224 return list.get(0);
1225 }
1226 }
1227
1228
1241 public Repository findByGroupId_Last(long groupId,
1242 OrderByComparator orderByComparator)
1243 throws NoSuchRepositoryException, SystemException {
1244 int count = countByGroupId(groupId);
1245
1246 List<Repository> list = findByGroupId(groupId, count - 1, count,
1247 orderByComparator);
1248
1249 if (list.isEmpty()) {
1250 StringBundler msg = new StringBundler(4);
1251
1252 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1253
1254 msg.append("groupId=");
1255 msg.append(groupId);
1256
1257 msg.append(StringPool.CLOSE_CURLY_BRACE);
1258
1259 throw new NoSuchRepositoryException(msg.toString());
1260 }
1261 else {
1262 return list.get(0);
1263 }
1264 }
1265
1266
1280 public Repository[] findByGroupId_PrevAndNext(long repositoryId,
1281 long groupId, OrderByComparator orderByComparator)
1282 throws NoSuchRepositoryException, SystemException {
1283 Repository repository = findByPrimaryKey(repositoryId);
1284
1285 Session session = null;
1286
1287 try {
1288 session = openSession();
1289
1290 Repository[] array = new RepositoryImpl[3];
1291
1292 array[0] = getByGroupId_PrevAndNext(session, repository, groupId,
1293 orderByComparator, true);
1294
1295 array[1] = repository;
1296
1297 array[2] = getByGroupId_PrevAndNext(session, repository, groupId,
1298 orderByComparator, false);
1299
1300 return array;
1301 }
1302 catch (Exception e) {
1303 throw processException(e);
1304 }
1305 finally {
1306 closeSession(session);
1307 }
1308 }
1309
1310 protected Repository getByGroupId_PrevAndNext(Session session,
1311 Repository repository, long groupId,
1312 OrderByComparator orderByComparator, boolean previous) {
1313 StringBundler query = null;
1314
1315 if (orderByComparator != null) {
1316 query = new StringBundler(6 +
1317 (orderByComparator.getOrderByFields().length * 6));
1318 }
1319 else {
1320 query = new StringBundler(3);
1321 }
1322
1323 query.append(_SQL_SELECT_REPOSITORY_WHERE);
1324
1325 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1326
1327 if (orderByComparator != null) {
1328 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1329
1330 if (orderByConditionFields.length > 0) {
1331 query.append(WHERE_AND);
1332 }
1333
1334 for (int i = 0; i < orderByConditionFields.length; i++) {
1335 query.append(_ORDER_BY_ENTITY_ALIAS);
1336 query.append(orderByConditionFields[i]);
1337
1338 if ((i + 1) < orderByConditionFields.length) {
1339 if (orderByComparator.isAscending() ^ previous) {
1340 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1341 }
1342 else {
1343 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1344 }
1345 }
1346 else {
1347 if (orderByComparator.isAscending() ^ previous) {
1348 query.append(WHERE_GREATER_THAN);
1349 }
1350 else {
1351 query.append(WHERE_LESSER_THAN);
1352 }
1353 }
1354 }
1355
1356 query.append(ORDER_BY_CLAUSE);
1357
1358 String[] orderByFields = orderByComparator.getOrderByFields();
1359
1360 for (int i = 0; i < orderByFields.length; i++) {
1361 query.append(_ORDER_BY_ENTITY_ALIAS);
1362 query.append(orderByFields[i]);
1363
1364 if ((i + 1) < orderByFields.length) {
1365 if (orderByComparator.isAscending() ^ previous) {
1366 query.append(ORDER_BY_ASC_HAS_NEXT);
1367 }
1368 else {
1369 query.append(ORDER_BY_DESC_HAS_NEXT);
1370 }
1371 }
1372 else {
1373 if (orderByComparator.isAscending() ^ previous) {
1374 query.append(ORDER_BY_ASC);
1375 }
1376 else {
1377 query.append(ORDER_BY_DESC);
1378 }
1379 }
1380 }
1381 }
1382
1383 String sql = query.toString();
1384
1385 Query q = session.createQuery(sql);
1386
1387 q.setFirstResult(0);
1388 q.setMaxResults(2);
1389
1390 QueryPos qPos = QueryPos.getInstance(q);
1391
1392 qPos.add(groupId);
1393
1394 if (orderByComparator != null) {
1395 Object[] values = orderByComparator.getOrderByConditionValues(repository);
1396
1397 for (Object value : values) {
1398 qPos.add(value);
1399 }
1400 }
1401
1402 List<Repository> list = q.list();
1403
1404 if (list.size() == 2) {
1405 return list.get(1);
1406 }
1407 else {
1408 return null;
1409 }
1410 }
1411
1412
1418 public List<Repository> findAll() throws SystemException {
1419 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1420 }
1421
1422
1434 public List<Repository> findAll(int start, int end)
1435 throws SystemException {
1436 return findAll(start, end, null);
1437 }
1438
1439
1452 public List<Repository> findAll(int start, int end,
1453 OrderByComparator orderByComparator) throws SystemException {
1454 FinderPath finderPath = null;
1455 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1456
1457 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1458 (orderByComparator == null)) {
1459 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1460 finderArgs = FINDER_ARGS_EMPTY;
1461 }
1462 else {
1463 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1464 finderArgs = new Object[] { start, end, orderByComparator };
1465 }
1466
1467 List<Repository> list = (List<Repository>)FinderCacheUtil.getResult(finderPath,
1468 finderArgs, this);
1469
1470 if (list == null) {
1471 StringBundler query = null;
1472 String sql = null;
1473
1474 if (orderByComparator != null) {
1475 query = new StringBundler(2 +
1476 (orderByComparator.getOrderByFields().length * 3));
1477
1478 query.append(_SQL_SELECT_REPOSITORY);
1479
1480 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1481 orderByComparator);
1482
1483 sql = query.toString();
1484 }
1485 else {
1486 sql = _SQL_SELECT_REPOSITORY;
1487 }
1488
1489 Session session = null;
1490
1491 try {
1492 session = openSession();
1493
1494 Query q = session.createQuery(sql);
1495
1496 if (orderByComparator == null) {
1497 list = (List<Repository>)QueryUtil.list(q, getDialect(),
1498 start, end, false);
1499
1500 Collections.sort(list);
1501 }
1502 else {
1503 list = (List<Repository>)QueryUtil.list(q, getDialect(),
1504 start, end);
1505 }
1506 }
1507 catch (Exception e) {
1508 throw processException(e);
1509 }
1510 finally {
1511 if (list == null) {
1512 FinderCacheUtil.removeResult(finderPath, finderArgs);
1513 }
1514 else {
1515 cacheResult(list);
1516
1517 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1518 }
1519
1520 closeSession(session);
1521 }
1522 }
1523
1524 return list;
1525 }
1526
1527
1533 public void removeByUuid(String uuid) throws SystemException {
1534 for (Repository repository : findByUuid(uuid)) {
1535 remove(repository);
1536 }
1537 }
1538
1539
1546 public void removeByUUID_G(String uuid, long groupId)
1547 throws NoSuchRepositoryException, SystemException {
1548 Repository repository = findByUUID_G(uuid, groupId);
1549
1550 remove(repository);
1551 }
1552
1553
1559 public void removeByGroupId(long groupId) throws SystemException {
1560 for (Repository repository : findByGroupId(groupId)) {
1561 remove(repository);
1562 }
1563 }
1564
1565
1570 public void removeAll() throws SystemException {
1571 for (Repository repository : findAll()) {
1572 remove(repository);
1573 }
1574 }
1575
1576
1583 public int countByUuid(String uuid) throws SystemException {
1584 Object[] finderArgs = new Object[] { uuid };
1585
1586 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1587 finderArgs, this);
1588
1589 if (count == null) {
1590 StringBundler query = new StringBundler(2);
1591
1592 query.append(_SQL_COUNT_REPOSITORY_WHERE);
1593
1594 if (uuid == null) {
1595 query.append(_FINDER_COLUMN_UUID_UUID_1);
1596 }
1597 else {
1598 if (uuid.equals(StringPool.BLANK)) {
1599 query.append(_FINDER_COLUMN_UUID_UUID_3);
1600 }
1601 else {
1602 query.append(_FINDER_COLUMN_UUID_UUID_2);
1603 }
1604 }
1605
1606 String sql = query.toString();
1607
1608 Session session = null;
1609
1610 try {
1611 session = openSession();
1612
1613 Query q = session.createQuery(sql);
1614
1615 QueryPos qPos = QueryPos.getInstance(q);
1616
1617 if (uuid != null) {
1618 qPos.add(uuid);
1619 }
1620
1621 count = (Long)q.uniqueResult();
1622 }
1623 catch (Exception e) {
1624 throw processException(e);
1625 }
1626 finally {
1627 if (count == null) {
1628 count = Long.valueOf(0);
1629 }
1630
1631 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1632 finderArgs, count);
1633
1634 closeSession(session);
1635 }
1636 }
1637
1638 return count.intValue();
1639 }
1640
1641
1649 public int countByUUID_G(String uuid, long groupId)
1650 throws SystemException {
1651 Object[] finderArgs = new Object[] { uuid, groupId };
1652
1653 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1654 finderArgs, this);
1655
1656 if (count == null) {
1657 StringBundler query = new StringBundler(3);
1658
1659 query.append(_SQL_COUNT_REPOSITORY_WHERE);
1660
1661 if (uuid == null) {
1662 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1663 }
1664 else {
1665 if (uuid.equals(StringPool.BLANK)) {
1666 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1667 }
1668 else {
1669 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1670 }
1671 }
1672
1673 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1674
1675 String sql = query.toString();
1676
1677 Session session = null;
1678
1679 try {
1680 session = openSession();
1681
1682 Query q = session.createQuery(sql);
1683
1684 QueryPos qPos = QueryPos.getInstance(q);
1685
1686 if (uuid != null) {
1687 qPos.add(uuid);
1688 }
1689
1690 qPos.add(groupId);
1691
1692 count = (Long)q.uniqueResult();
1693 }
1694 catch (Exception e) {
1695 throw processException(e);
1696 }
1697 finally {
1698 if (count == null) {
1699 count = Long.valueOf(0);
1700 }
1701
1702 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1703 finderArgs, count);
1704
1705 closeSession(session);
1706 }
1707 }
1708
1709 return count.intValue();
1710 }
1711
1712
1719 public int countByGroupId(long groupId) throws SystemException {
1720 Object[] finderArgs = new Object[] { groupId };
1721
1722 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1723 finderArgs, this);
1724
1725 if (count == null) {
1726 StringBundler query = new StringBundler(2);
1727
1728 query.append(_SQL_COUNT_REPOSITORY_WHERE);
1729
1730 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1731
1732 String sql = query.toString();
1733
1734 Session session = null;
1735
1736 try {
1737 session = openSession();
1738
1739 Query q = session.createQuery(sql);
1740
1741 QueryPos qPos = QueryPos.getInstance(q);
1742
1743 qPos.add(groupId);
1744
1745 count = (Long)q.uniqueResult();
1746 }
1747 catch (Exception e) {
1748 throw processException(e);
1749 }
1750 finally {
1751 if (count == null) {
1752 count = Long.valueOf(0);
1753 }
1754
1755 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1756 finderArgs, count);
1757
1758 closeSession(session);
1759 }
1760 }
1761
1762 return count.intValue();
1763 }
1764
1765
1771 public int countAll() throws SystemException {
1772 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1773 FINDER_ARGS_EMPTY, this);
1774
1775 if (count == null) {
1776 Session session = null;
1777
1778 try {
1779 session = openSession();
1780
1781 Query q = session.createQuery(_SQL_COUNT_REPOSITORY);
1782
1783 count = (Long)q.uniqueResult();
1784 }
1785 catch (Exception e) {
1786 throw processException(e);
1787 }
1788 finally {
1789 if (count == null) {
1790 count = Long.valueOf(0);
1791 }
1792
1793 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1794 FINDER_ARGS_EMPTY, count);
1795
1796 closeSession(session);
1797 }
1798 }
1799
1800 return count.intValue();
1801 }
1802
1803
1806 public void afterPropertiesSet() {
1807 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1808 com.liferay.portal.util.PropsUtil.get(
1809 "value.object.listener.com.liferay.portal.model.Repository")));
1810
1811 if (listenerClassNames.length > 0) {
1812 try {
1813 List<ModelListener<Repository>> listenersList = new ArrayList<ModelListener<Repository>>();
1814
1815 for (String listenerClassName : listenerClassNames) {
1816 listenersList.add((ModelListener<Repository>)InstanceFactory.newInstance(
1817 listenerClassName));
1818 }
1819
1820 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1821 }
1822 catch (Exception e) {
1823 _log.error(e);
1824 }
1825 }
1826 }
1827
1828 public void destroy() {
1829 EntityCacheUtil.removeCache(RepositoryImpl.class.getName());
1830 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1831 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1832 }
1833
1834 @BeanReference(type = AccountPersistence.class)
1835 protected AccountPersistence accountPersistence;
1836 @BeanReference(type = AddressPersistence.class)
1837 protected AddressPersistence addressPersistence;
1838 @BeanReference(type = BrowserTrackerPersistence.class)
1839 protected BrowserTrackerPersistence browserTrackerPersistence;
1840 @BeanReference(type = ClassNamePersistence.class)
1841 protected ClassNamePersistence classNamePersistence;
1842 @BeanReference(type = ClusterGroupPersistence.class)
1843 protected ClusterGroupPersistence clusterGroupPersistence;
1844 @BeanReference(type = CompanyPersistence.class)
1845 protected CompanyPersistence companyPersistence;
1846 @BeanReference(type = ContactPersistence.class)
1847 protected ContactPersistence contactPersistence;
1848 @BeanReference(type = CountryPersistence.class)
1849 protected CountryPersistence countryPersistence;
1850 @BeanReference(type = EmailAddressPersistence.class)
1851 protected EmailAddressPersistence emailAddressPersistence;
1852 @BeanReference(type = GroupPersistence.class)
1853 protected GroupPersistence groupPersistence;
1854 @BeanReference(type = ImagePersistence.class)
1855 protected ImagePersistence imagePersistence;
1856 @BeanReference(type = LayoutPersistence.class)
1857 protected LayoutPersistence layoutPersistence;
1858 @BeanReference(type = LayoutBranchPersistence.class)
1859 protected LayoutBranchPersistence layoutBranchPersistence;
1860 @BeanReference(type = LayoutPrototypePersistence.class)
1861 protected LayoutPrototypePersistence layoutPrototypePersistence;
1862 @BeanReference(type = LayoutRevisionPersistence.class)
1863 protected LayoutRevisionPersistence layoutRevisionPersistence;
1864 @BeanReference(type = LayoutSetPersistence.class)
1865 protected LayoutSetPersistence layoutSetPersistence;
1866 @BeanReference(type = LayoutSetBranchPersistence.class)
1867 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1868 @BeanReference(type = LayoutSetPrototypePersistence.class)
1869 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1870 @BeanReference(type = ListTypePersistence.class)
1871 protected ListTypePersistence listTypePersistence;
1872 @BeanReference(type = LockPersistence.class)
1873 protected LockPersistence lockPersistence;
1874 @BeanReference(type = MembershipRequestPersistence.class)
1875 protected MembershipRequestPersistence membershipRequestPersistence;
1876 @BeanReference(type = OrganizationPersistence.class)
1877 protected OrganizationPersistence organizationPersistence;
1878 @BeanReference(type = OrgGroupPermissionPersistence.class)
1879 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1880 @BeanReference(type = OrgGroupRolePersistence.class)
1881 protected OrgGroupRolePersistence orgGroupRolePersistence;
1882 @BeanReference(type = OrgLaborPersistence.class)
1883 protected OrgLaborPersistence orgLaborPersistence;
1884 @BeanReference(type = PasswordPolicyPersistence.class)
1885 protected PasswordPolicyPersistence passwordPolicyPersistence;
1886 @BeanReference(type = PasswordPolicyRelPersistence.class)
1887 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1888 @BeanReference(type = PasswordTrackerPersistence.class)
1889 protected PasswordTrackerPersistence passwordTrackerPersistence;
1890 @BeanReference(type = PermissionPersistence.class)
1891 protected PermissionPersistence permissionPersistence;
1892 @BeanReference(type = PhonePersistence.class)
1893 protected PhonePersistence phonePersistence;
1894 @BeanReference(type = PluginSettingPersistence.class)
1895 protected PluginSettingPersistence pluginSettingPersistence;
1896 @BeanReference(type = PortalPreferencesPersistence.class)
1897 protected PortalPreferencesPersistence portalPreferencesPersistence;
1898 @BeanReference(type = PortletPersistence.class)
1899 protected PortletPersistence portletPersistence;
1900 @BeanReference(type = PortletItemPersistence.class)
1901 protected PortletItemPersistence portletItemPersistence;
1902 @BeanReference(type = PortletPreferencesPersistence.class)
1903 protected PortletPreferencesPersistence portletPreferencesPersistence;
1904 @BeanReference(type = RegionPersistence.class)
1905 protected RegionPersistence regionPersistence;
1906 @BeanReference(type = ReleasePersistence.class)
1907 protected ReleasePersistence releasePersistence;
1908 @BeanReference(type = RepositoryPersistence.class)
1909 protected RepositoryPersistence repositoryPersistence;
1910 @BeanReference(type = RepositoryEntryPersistence.class)
1911 protected RepositoryEntryPersistence repositoryEntryPersistence;
1912 @BeanReference(type = ResourcePersistence.class)
1913 protected ResourcePersistence resourcePersistence;
1914 @BeanReference(type = ResourceActionPersistence.class)
1915 protected ResourceActionPersistence resourceActionPersistence;
1916 @BeanReference(type = ResourceBlockPersistence.class)
1917 protected ResourceBlockPersistence resourceBlockPersistence;
1918 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1919 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1920 @BeanReference(type = ResourceCodePersistence.class)
1921 protected ResourceCodePersistence resourceCodePersistence;
1922 @BeanReference(type = ResourcePermissionPersistence.class)
1923 protected ResourcePermissionPersistence resourcePermissionPersistence;
1924 @BeanReference(type = ResourceTypePermissionPersistence.class)
1925 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1926 @BeanReference(type = RolePersistence.class)
1927 protected RolePersistence rolePersistence;
1928 @BeanReference(type = ServiceComponentPersistence.class)
1929 protected ServiceComponentPersistence serviceComponentPersistence;
1930 @BeanReference(type = ShardPersistence.class)
1931 protected ShardPersistence shardPersistence;
1932 @BeanReference(type = SubscriptionPersistence.class)
1933 protected SubscriptionPersistence subscriptionPersistence;
1934 @BeanReference(type = TeamPersistence.class)
1935 protected TeamPersistence teamPersistence;
1936 @BeanReference(type = TicketPersistence.class)
1937 protected TicketPersistence ticketPersistence;
1938 @BeanReference(type = UserPersistence.class)
1939 protected UserPersistence userPersistence;
1940 @BeanReference(type = UserGroupPersistence.class)
1941 protected UserGroupPersistence userGroupPersistence;
1942 @BeanReference(type = UserGroupGroupRolePersistence.class)
1943 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1944 @BeanReference(type = UserGroupRolePersistence.class)
1945 protected UserGroupRolePersistence userGroupRolePersistence;
1946 @BeanReference(type = UserIdMapperPersistence.class)
1947 protected UserIdMapperPersistence userIdMapperPersistence;
1948 @BeanReference(type = UserNotificationEventPersistence.class)
1949 protected UserNotificationEventPersistence userNotificationEventPersistence;
1950 @BeanReference(type = UserTrackerPersistence.class)
1951 protected UserTrackerPersistence userTrackerPersistence;
1952 @BeanReference(type = UserTrackerPathPersistence.class)
1953 protected UserTrackerPathPersistence userTrackerPathPersistence;
1954 @BeanReference(type = VirtualHostPersistence.class)
1955 protected VirtualHostPersistence virtualHostPersistence;
1956 @BeanReference(type = WebDAVPropsPersistence.class)
1957 protected WebDAVPropsPersistence webDAVPropsPersistence;
1958 @BeanReference(type = WebsitePersistence.class)
1959 protected WebsitePersistence websitePersistence;
1960 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1961 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1962 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1963 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1964 @BeanReference(type = AssetEntryPersistence.class)
1965 protected AssetEntryPersistence assetEntryPersistence;
1966 @BeanReference(type = DLFileEntryPersistence.class)
1967 protected DLFileEntryPersistence dlFileEntryPersistence;
1968 @BeanReference(type = DLFileVersionPersistence.class)
1969 protected DLFileVersionPersistence dlFileVersionPersistence;
1970 @BeanReference(type = DLFolderPersistence.class)
1971 protected DLFolderPersistence dlFolderPersistence;
1972 @BeanReference(type = ExpandoValuePersistence.class)
1973 protected ExpandoValuePersistence expandoValuePersistence;
1974 private static final String _SQL_SELECT_REPOSITORY = "SELECT repository FROM Repository repository";
1975 private static final String _SQL_SELECT_REPOSITORY_WHERE = "SELECT repository FROM Repository repository WHERE ";
1976 private static final String _SQL_COUNT_REPOSITORY = "SELECT COUNT(repository) FROM Repository repository";
1977 private static final String _SQL_COUNT_REPOSITORY_WHERE = "SELECT COUNT(repository) FROM Repository repository WHERE ";
1978 private static final String _FINDER_COLUMN_UUID_UUID_1 = "repository.uuid IS NULL";
1979 private static final String _FINDER_COLUMN_UUID_UUID_2 = "repository.uuid = ?";
1980 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(repository.uuid IS NULL OR repository.uuid = ?)";
1981 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "repository.uuid IS NULL AND ";
1982 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "repository.uuid = ? AND ";
1983 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(repository.uuid IS NULL OR repository.uuid = ?) AND ";
1984 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "repository.groupId = ?";
1985 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "repository.groupId = ?";
1986 private static final String _ORDER_BY_ENTITY_ALIAS = "repository.";
1987 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Repository exists with the primary key ";
1988 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Repository exists with the key {";
1989 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1990 private static Log _log = LogFactoryUtil.getLog(RepositoryPersistenceImpl.class);
1991 private static Repository _nullRepository = new RepositoryImpl() {
1992 @Override
1993 public Object clone() {
1994 return this;
1995 }
1996
1997 @Override
1998 public CacheModel<Repository> toCacheModel() {
1999 return _nullRepositoryCacheModel;
2000 }
2001 };
2002
2003 private static CacheModel<Repository> _nullRepositoryCacheModel = new CacheModel<Repository>() {
2004 public Repository toEntityModel() {
2005 return _nullRepository;
2006 }
2007 };
2008 }