001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchPermissionException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.model.CacheModel;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.model.Permission;
047 import com.liferay.portal.model.impl.PermissionImpl;
048 import com.liferay.portal.model.impl.PermissionModelImpl;
049 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.List;
056 import java.util.Set;
057
058
070 public class PermissionPersistenceImpl extends BasePersistenceImpl<Permission>
071 implements PermissionPersistence {
072
077 public static final String FINDER_CLASS_NAME_ENTITY = PermissionImpl.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_RESOURCEID =
083 new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
084 PermissionModelImpl.FINDER_CACHE_ENABLED, PermissionImpl.class,
085 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByResourceId",
086 new String[] {
087 Long.class.getName(),
088
089 "java.lang.Integer", "java.lang.Integer",
090 "com.liferay.portal.kernel.util.OrderByComparator"
091 });
092 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEID =
093 new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
094 PermissionModelImpl.FINDER_CACHE_ENABLED, PermissionImpl.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourceId",
096 new String[] { Long.class.getName() },
097 PermissionModelImpl.RESOURCEID_COLUMN_BITMASK);
098 public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEID = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
099 PermissionModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByResourceId",
101 new String[] { Long.class.getName() });
102 public static final FinderPath FINDER_PATH_FETCH_BY_A_R = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
103 PermissionModelImpl.FINDER_CACHE_ENABLED, PermissionImpl.class,
104 FINDER_CLASS_NAME_ENTITY, "fetchByA_R",
105 new String[] { String.class.getName(), Long.class.getName() },
106 PermissionModelImpl.ACTIONID_COLUMN_BITMASK |
107 PermissionModelImpl.RESOURCEID_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
109 PermissionModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA_R",
111 new String[] { String.class.getName(), Long.class.getName() });
112 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
113 PermissionModelImpl.FINDER_CACHE_ENABLED, PermissionImpl.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
115 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
116 PermissionModelImpl.FINDER_CACHE_ENABLED, PermissionImpl.class,
117 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
118 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
119 PermissionModelImpl.FINDER_CACHE_ENABLED, Long.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
121
122
127 public void cacheResult(Permission permission) {
128 EntityCacheUtil.putResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
129 PermissionImpl.class, permission.getPrimaryKey(), permission);
130
131 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
132 new Object[] {
133 permission.getActionId(),
134 Long.valueOf(permission.getResourceId())
135 }, permission);
136
137 permission.resetOriginalValues();
138 }
139
140
145 public void cacheResult(List<Permission> permissions) {
146 for (Permission permission : permissions) {
147 if (EntityCacheUtil.getResult(
148 PermissionModelImpl.ENTITY_CACHE_ENABLED,
149 PermissionImpl.class, permission.getPrimaryKey()) == null) {
150 cacheResult(permission);
151 }
152 else {
153 permission.resetOriginalValues();
154 }
155 }
156 }
157
158
165 @Override
166 public void clearCache() {
167 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
168 CacheRegistryUtil.clear(PermissionImpl.class.getName());
169 }
170
171 EntityCacheUtil.clearCache(PermissionImpl.class.getName());
172
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
174 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
175 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
176 }
177
178
185 @Override
186 public void clearCache(Permission permission) {
187 EntityCacheUtil.removeResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
188 PermissionImpl.class, permission.getPrimaryKey());
189
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
191 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
192
193 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R,
194 new Object[] {
195 permission.getActionId(),
196 Long.valueOf(permission.getResourceId())
197 });
198 }
199
200
206 public Permission create(long permissionId) {
207 Permission permission = new PermissionImpl();
208
209 permission.setNew(true);
210 permission.setPrimaryKey(permissionId);
211
212 return permission;
213 }
214
215
223 @Override
224 public Permission remove(Serializable primaryKey)
225 throws NoSuchModelException, SystemException {
226 return remove(((Long)primaryKey).longValue());
227 }
228
229
237 public Permission remove(long permissionId)
238 throws NoSuchPermissionException, SystemException {
239 Session session = null;
240
241 try {
242 session = openSession();
243
244 Permission permission = (Permission)session.get(PermissionImpl.class,
245 Long.valueOf(permissionId));
246
247 if (permission == null) {
248 if (_log.isWarnEnabled()) {
249 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + permissionId);
250 }
251
252 throw new NoSuchPermissionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
253 permissionId);
254 }
255
256 return permissionPersistence.remove(permission);
257 }
258 catch (NoSuchPermissionException nsee) {
259 throw nsee;
260 }
261 catch (Exception e) {
262 throw processException(e);
263 }
264 finally {
265 closeSession(session);
266 }
267 }
268
269
276 @Override
277 public Permission remove(Permission permission) throws SystemException {
278 return super.remove(permission);
279 }
280
281 @Override
282 protected Permission removeImpl(Permission permission)
283 throws SystemException {
284 permission = toUnwrappedModel(permission);
285
286 try {
287 clearGroups.clear(permission.getPrimaryKey());
288 }
289 catch (Exception e) {
290 throw processException(e);
291 }
292 finally {
293 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
294 }
295
296 try {
297 clearRoles.clear(permission.getPrimaryKey());
298 }
299 catch (Exception e) {
300 throw processException(e);
301 }
302 finally {
303 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
304 }
305
306 try {
307 clearUsers.clear(permission.getPrimaryKey());
308 }
309 catch (Exception e) {
310 throw processException(e);
311 }
312 finally {
313 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
314 }
315
316 Session session = null;
317
318 try {
319 session = openSession();
320
321 BatchSessionUtil.delete(session, permission);
322 }
323 catch (Exception e) {
324 throw processException(e);
325 }
326 finally {
327 closeSession(session);
328 }
329
330 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
331 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
332
333 PermissionModelImpl permissionModelImpl = (PermissionModelImpl)permission;
334
335 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R,
336 new Object[] {
337 permissionModelImpl.getActionId(),
338 Long.valueOf(permissionModelImpl.getResourceId())
339 });
340
341 EntityCacheUtil.removeResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
342 PermissionImpl.class, permission.getPrimaryKey());
343
344 return permission;
345 }
346
347 @Override
348 public Permission updateImpl(
349 com.liferay.portal.model.Permission permission, boolean merge)
350 throws SystemException {
351 permission = toUnwrappedModel(permission);
352
353 boolean isNew = permission.isNew();
354
355 PermissionModelImpl permissionModelImpl = (PermissionModelImpl)permission;
356
357 Session session = null;
358
359 try {
360 session = openSession();
361
362 BatchSessionUtil.update(session, permission, merge);
363
364 permission.setNew(false);
365 }
366 catch (Exception e) {
367 throw processException(e);
368 }
369 finally {
370 closeSession(session);
371 }
372
373 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
374
375 if (isNew || !PermissionModelImpl.COLUMN_BITMASK_ENABLED) {
376 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
377 }
378
379 else {
380 if ((permissionModelImpl.getColumnBitmask() &
381 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEID.getColumnBitmask()) != 0) {
382 Object[] args = new Object[] {
383 Long.valueOf(permissionModelImpl.getOriginalResourceId())
384 };
385
386 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEID,
387 args);
388 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEID,
389 args);
390
391 args = new Object[] {
392 Long.valueOf(permissionModelImpl.getResourceId())
393 };
394
395 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEID,
396 args);
397 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEID,
398 args);
399 }
400 }
401
402 EntityCacheUtil.putResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
403 PermissionImpl.class, permission.getPrimaryKey(), permission);
404
405 if (isNew) {
406 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
407 new Object[] {
408 permission.getActionId(),
409 Long.valueOf(permission.getResourceId())
410 }, permission);
411 }
412 else {
413 if ((permissionModelImpl.getColumnBitmask() &
414 FINDER_PATH_FETCH_BY_A_R.getColumnBitmask()) != 0) {
415 Object[] args = new Object[] {
416 permissionModelImpl.getOriginalActionId(),
417 Long.valueOf(permissionModelImpl.getOriginalResourceId())
418 };
419
420 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
421 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R, args);
422
423 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
424 new Object[] {
425 permission.getActionId(),
426 Long.valueOf(permission.getResourceId())
427 }, permission);
428 }
429 }
430
431 return permission;
432 }
433
434 protected Permission toUnwrappedModel(Permission permission) {
435 if (permission instanceof PermissionImpl) {
436 return permission;
437 }
438
439 PermissionImpl permissionImpl = new PermissionImpl();
440
441 permissionImpl.setNew(permission.isNew());
442 permissionImpl.setPrimaryKey(permission.getPrimaryKey());
443
444 permissionImpl.setPermissionId(permission.getPermissionId());
445 permissionImpl.setCompanyId(permission.getCompanyId());
446 permissionImpl.setActionId(permission.getActionId());
447 permissionImpl.setResourceId(permission.getResourceId());
448
449 return permissionImpl;
450 }
451
452
460 @Override
461 public Permission findByPrimaryKey(Serializable primaryKey)
462 throws NoSuchModelException, SystemException {
463 return findByPrimaryKey(((Long)primaryKey).longValue());
464 }
465
466
474 public Permission findByPrimaryKey(long permissionId)
475 throws NoSuchPermissionException, SystemException {
476 Permission permission = fetchByPrimaryKey(permissionId);
477
478 if (permission == null) {
479 if (_log.isWarnEnabled()) {
480 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + permissionId);
481 }
482
483 throw new NoSuchPermissionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
484 permissionId);
485 }
486
487 return permission;
488 }
489
490
497 @Override
498 public Permission fetchByPrimaryKey(Serializable primaryKey)
499 throws SystemException {
500 return fetchByPrimaryKey(((Long)primaryKey).longValue());
501 }
502
503
510 public Permission fetchByPrimaryKey(long permissionId)
511 throws SystemException {
512 Permission permission = (Permission)EntityCacheUtil.getResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
513 PermissionImpl.class, permissionId);
514
515 if (permission == _nullPermission) {
516 return null;
517 }
518
519 if (permission == null) {
520 Session session = null;
521
522 boolean hasException = false;
523
524 try {
525 session = openSession();
526
527 permission = (Permission)session.get(PermissionImpl.class,
528 Long.valueOf(permissionId));
529 }
530 catch (Exception e) {
531 hasException = true;
532
533 throw processException(e);
534 }
535 finally {
536 if (permission != null) {
537 cacheResult(permission);
538 }
539 else if (!hasException) {
540 EntityCacheUtil.putResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
541 PermissionImpl.class, permissionId, _nullPermission);
542 }
543
544 closeSession(session);
545 }
546 }
547
548 return permission;
549 }
550
551
558 public List<Permission> findByResourceId(long resourceId)
559 throws SystemException {
560 return findByResourceId(resourceId, QueryUtil.ALL_POS,
561 QueryUtil.ALL_POS, null);
562 }
563
564
577 public List<Permission> findByResourceId(long resourceId, int start, int end)
578 throws SystemException {
579 return findByResourceId(resourceId, start, end, null);
580 }
581
582
596 public List<Permission> findByResourceId(long resourceId, int start,
597 int end, OrderByComparator orderByComparator) throws SystemException {
598 FinderPath finderPath = null;
599 Object[] finderArgs = null;
600
601 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
602 (orderByComparator == null)) {
603 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEID;
604 finderArgs = new Object[] { resourceId };
605 }
606 else {
607 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEID;
608 finderArgs = new Object[] { resourceId, start, end, orderByComparator };
609 }
610
611 List<Permission> list = (List<Permission>)FinderCacheUtil.getResult(finderPath,
612 finderArgs, this);
613
614 if (list == null) {
615 StringBundler query = null;
616
617 if (orderByComparator != null) {
618 query = new StringBundler(3 +
619 (orderByComparator.getOrderByFields().length * 3));
620 }
621 else {
622 query = new StringBundler(2);
623 }
624
625 query.append(_SQL_SELECT_PERMISSION_WHERE);
626
627 query.append(_FINDER_COLUMN_RESOURCEID_RESOURCEID_2);
628
629 if (orderByComparator != null) {
630 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
631 orderByComparator);
632 }
633
634 String sql = query.toString();
635
636 Session session = null;
637
638 try {
639 session = openSession();
640
641 Query q = session.createQuery(sql);
642
643 QueryPos qPos = QueryPos.getInstance(q);
644
645 qPos.add(resourceId);
646
647 list = (List<Permission>)QueryUtil.list(q, getDialect(), start,
648 end);
649 }
650 catch (Exception e) {
651 throw processException(e);
652 }
653 finally {
654 if (list == null) {
655 FinderCacheUtil.removeResult(finderPath, finderArgs);
656 }
657 else {
658 cacheResult(list);
659
660 FinderCacheUtil.putResult(finderPath, finderArgs, list);
661 }
662
663 closeSession(session);
664 }
665 }
666
667 return list;
668 }
669
670
683 public Permission findByResourceId_First(long resourceId,
684 OrderByComparator orderByComparator)
685 throws NoSuchPermissionException, SystemException {
686 List<Permission> list = findByResourceId(resourceId, 0, 1,
687 orderByComparator);
688
689 if (list.isEmpty()) {
690 StringBundler msg = new StringBundler(4);
691
692 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
693
694 msg.append("resourceId=");
695 msg.append(resourceId);
696
697 msg.append(StringPool.CLOSE_CURLY_BRACE);
698
699 throw new NoSuchPermissionException(msg.toString());
700 }
701 else {
702 return list.get(0);
703 }
704 }
705
706
719 public Permission findByResourceId_Last(long resourceId,
720 OrderByComparator orderByComparator)
721 throws NoSuchPermissionException, SystemException {
722 int count = countByResourceId(resourceId);
723
724 List<Permission> list = findByResourceId(resourceId, count - 1, count,
725 orderByComparator);
726
727 if (list.isEmpty()) {
728 StringBundler msg = new StringBundler(4);
729
730 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
731
732 msg.append("resourceId=");
733 msg.append(resourceId);
734
735 msg.append(StringPool.CLOSE_CURLY_BRACE);
736
737 throw new NoSuchPermissionException(msg.toString());
738 }
739 else {
740 return list.get(0);
741 }
742 }
743
744
758 public Permission[] findByResourceId_PrevAndNext(long permissionId,
759 long resourceId, OrderByComparator orderByComparator)
760 throws NoSuchPermissionException, SystemException {
761 Permission permission = findByPrimaryKey(permissionId);
762
763 Session session = null;
764
765 try {
766 session = openSession();
767
768 Permission[] array = new PermissionImpl[3];
769
770 array[0] = getByResourceId_PrevAndNext(session, permission,
771 resourceId, orderByComparator, true);
772
773 array[1] = permission;
774
775 array[2] = getByResourceId_PrevAndNext(session, permission,
776 resourceId, orderByComparator, false);
777
778 return array;
779 }
780 catch (Exception e) {
781 throw processException(e);
782 }
783 finally {
784 closeSession(session);
785 }
786 }
787
788 protected Permission getByResourceId_PrevAndNext(Session session,
789 Permission permission, long resourceId,
790 OrderByComparator orderByComparator, boolean previous) {
791 StringBundler query = null;
792
793 if (orderByComparator != null) {
794 query = new StringBundler(6 +
795 (orderByComparator.getOrderByFields().length * 6));
796 }
797 else {
798 query = new StringBundler(3);
799 }
800
801 query.append(_SQL_SELECT_PERMISSION_WHERE);
802
803 query.append(_FINDER_COLUMN_RESOURCEID_RESOURCEID_2);
804
805 if (orderByComparator != null) {
806 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
807
808 if (orderByConditionFields.length > 0) {
809 query.append(WHERE_AND);
810 }
811
812 for (int i = 0; i < orderByConditionFields.length; i++) {
813 query.append(_ORDER_BY_ENTITY_ALIAS);
814 query.append(orderByConditionFields[i]);
815
816 if ((i + 1) < orderByConditionFields.length) {
817 if (orderByComparator.isAscending() ^ previous) {
818 query.append(WHERE_GREATER_THAN_HAS_NEXT);
819 }
820 else {
821 query.append(WHERE_LESSER_THAN_HAS_NEXT);
822 }
823 }
824 else {
825 if (orderByComparator.isAscending() ^ previous) {
826 query.append(WHERE_GREATER_THAN);
827 }
828 else {
829 query.append(WHERE_LESSER_THAN);
830 }
831 }
832 }
833
834 query.append(ORDER_BY_CLAUSE);
835
836 String[] orderByFields = orderByComparator.getOrderByFields();
837
838 for (int i = 0; i < orderByFields.length; i++) {
839 query.append(_ORDER_BY_ENTITY_ALIAS);
840 query.append(orderByFields[i]);
841
842 if ((i + 1) < orderByFields.length) {
843 if (orderByComparator.isAscending() ^ previous) {
844 query.append(ORDER_BY_ASC_HAS_NEXT);
845 }
846 else {
847 query.append(ORDER_BY_DESC_HAS_NEXT);
848 }
849 }
850 else {
851 if (orderByComparator.isAscending() ^ previous) {
852 query.append(ORDER_BY_ASC);
853 }
854 else {
855 query.append(ORDER_BY_DESC);
856 }
857 }
858 }
859 }
860
861 String sql = query.toString();
862
863 Query q = session.createQuery(sql);
864
865 q.setFirstResult(0);
866 q.setMaxResults(2);
867
868 QueryPos qPos = QueryPos.getInstance(q);
869
870 qPos.add(resourceId);
871
872 if (orderByComparator != null) {
873 Object[] values = orderByComparator.getOrderByConditionValues(permission);
874
875 for (Object value : values) {
876 qPos.add(value);
877 }
878 }
879
880 List<Permission> list = q.list();
881
882 if (list.size() == 2) {
883 return list.get(1);
884 }
885 else {
886 return null;
887 }
888 }
889
890
899 public Permission findByA_R(String actionId, long resourceId)
900 throws NoSuchPermissionException, SystemException {
901 Permission permission = fetchByA_R(actionId, resourceId);
902
903 if (permission == null) {
904 StringBundler msg = new StringBundler(6);
905
906 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
907
908 msg.append("actionId=");
909 msg.append(actionId);
910
911 msg.append(", resourceId=");
912 msg.append(resourceId);
913
914 msg.append(StringPool.CLOSE_CURLY_BRACE);
915
916 if (_log.isWarnEnabled()) {
917 _log.warn(msg.toString());
918 }
919
920 throw new NoSuchPermissionException(msg.toString());
921 }
922
923 return permission;
924 }
925
926
934 public Permission fetchByA_R(String actionId, long resourceId)
935 throws SystemException {
936 return fetchByA_R(actionId, resourceId, true);
937 }
938
939
948 public Permission fetchByA_R(String actionId, long resourceId,
949 boolean retrieveFromCache) throws SystemException {
950 Object[] finderArgs = new Object[] { actionId, resourceId };
951
952 Object result = null;
953
954 if (retrieveFromCache) {
955 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_A_R,
956 finderArgs, this);
957 }
958
959 if (result == null) {
960 StringBundler query = new StringBundler(3);
961
962 query.append(_SQL_SELECT_PERMISSION_WHERE);
963
964 if (actionId == null) {
965 query.append(_FINDER_COLUMN_A_R_ACTIONID_1);
966 }
967 else {
968 if (actionId.equals(StringPool.BLANK)) {
969 query.append(_FINDER_COLUMN_A_R_ACTIONID_3);
970 }
971 else {
972 query.append(_FINDER_COLUMN_A_R_ACTIONID_2);
973 }
974 }
975
976 query.append(_FINDER_COLUMN_A_R_RESOURCEID_2);
977
978 String sql = query.toString();
979
980 Session session = null;
981
982 try {
983 session = openSession();
984
985 Query q = session.createQuery(sql);
986
987 QueryPos qPos = QueryPos.getInstance(q);
988
989 if (actionId != null) {
990 qPos.add(actionId);
991 }
992
993 qPos.add(resourceId);
994
995 List<Permission> list = q.list();
996
997 result = list;
998
999 Permission permission = null;
1000
1001 if (list.isEmpty()) {
1002 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
1003 finderArgs, list);
1004 }
1005 else {
1006 permission = list.get(0);
1007
1008 cacheResult(permission);
1009
1010 if ((permission.getActionId() == null) ||
1011 !permission.getActionId().equals(actionId) ||
1012 (permission.getResourceId() != resourceId)) {
1013 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
1014 finderArgs, permission);
1015 }
1016 }
1017
1018 return permission;
1019 }
1020 catch (Exception e) {
1021 throw processException(e);
1022 }
1023 finally {
1024 if (result == null) {
1025 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R,
1026 finderArgs);
1027 }
1028
1029 closeSession(session);
1030 }
1031 }
1032 else {
1033 if (result instanceof List<?>) {
1034 return null;
1035 }
1036 else {
1037 return (Permission)result;
1038 }
1039 }
1040 }
1041
1042
1048 public List<Permission> findAll() throws SystemException {
1049 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1050 }
1051
1052
1064 public List<Permission> findAll(int start, int end)
1065 throws SystemException {
1066 return findAll(start, end, null);
1067 }
1068
1069
1082 public List<Permission> findAll(int start, int end,
1083 OrderByComparator orderByComparator) throws SystemException {
1084 FinderPath finderPath = null;
1085 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1086
1087 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1088 (orderByComparator == null)) {
1089 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1090 finderArgs = FINDER_ARGS_EMPTY;
1091 }
1092 else {
1093 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1094 finderArgs = new Object[] { start, end, orderByComparator };
1095 }
1096
1097 List<Permission> list = (List<Permission>)FinderCacheUtil.getResult(finderPath,
1098 finderArgs, this);
1099
1100 if (list == null) {
1101 StringBundler query = null;
1102 String sql = null;
1103
1104 if (orderByComparator != null) {
1105 query = new StringBundler(2 +
1106 (orderByComparator.getOrderByFields().length * 3));
1107
1108 query.append(_SQL_SELECT_PERMISSION);
1109
1110 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1111 orderByComparator);
1112
1113 sql = query.toString();
1114 }
1115 else {
1116 sql = _SQL_SELECT_PERMISSION;
1117 }
1118
1119 Session session = null;
1120
1121 try {
1122 session = openSession();
1123
1124 Query q = session.createQuery(sql);
1125
1126 if (orderByComparator == null) {
1127 list = (List<Permission>)QueryUtil.list(q, getDialect(),
1128 start, end, false);
1129
1130 Collections.sort(list);
1131 }
1132 else {
1133 list = (List<Permission>)QueryUtil.list(q, getDialect(),
1134 start, end);
1135 }
1136 }
1137 catch (Exception e) {
1138 throw processException(e);
1139 }
1140 finally {
1141 if (list == null) {
1142 FinderCacheUtil.removeResult(finderPath, finderArgs);
1143 }
1144 else {
1145 cacheResult(list);
1146
1147 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1148 }
1149
1150 closeSession(session);
1151 }
1152 }
1153
1154 return list;
1155 }
1156
1157
1163 public void removeByResourceId(long resourceId) throws SystemException {
1164 for (Permission permission : findByResourceId(resourceId)) {
1165 permissionPersistence.remove(permission);
1166 }
1167 }
1168
1169
1176 public void removeByA_R(String actionId, long resourceId)
1177 throws NoSuchPermissionException, SystemException {
1178 Permission permission = findByA_R(actionId, resourceId);
1179
1180 permissionPersistence.remove(permission);
1181 }
1182
1183
1188 public void removeAll() throws SystemException {
1189 for (Permission permission : findAll()) {
1190 permissionPersistence.remove(permission);
1191 }
1192 }
1193
1194
1201 public int countByResourceId(long resourceId) throws SystemException {
1202 Object[] finderArgs = new Object[] { resourceId };
1203
1204 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEID,
1205 finderArgs, this);
1206
1207 if (count == null) {
1208 StringBundler query = new StringBundler(2);
1209
1210 query.append(_SQL_COUNT_PERMISSION_WHERE);
1211
1212 query.append(_FINDER_COLUMN_RESOURCEID_RESOURCEID_2);
1213
1214 String sql = query.toString();
1215
1216 Session session = null;
1217
1218 try {
1219 session = openSession();
1220
1221 Query q = session.createQuery(sql);
1222
1223 QueryPos qPos = QueryPos.getInstance(q);
1224
1225 qPos.add(resourceId);
1226
1227 count = (Long)q.uniqueResult();
1228 }
1229 catch (Exception e) {
1230 throw processException(e);
1231 }
1232 finally {
1233 if (count == null) {
1234 count = Long.valueOf(0);
1235 }
1236
1237 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEID,
1238 finderArgs, count);
1239
1240 closeSession(session);
1241 }
1242 }
1243
1244 return count.intValue();
1245 }
1246
1247
1255 public int countByA_R(String actionId, long resourceId)
1256 throws SystemException {
1257 Object[] finderArgs = new Object[] { actionId, resourceId };
1258
1259 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
1260 finderArgs, this);
1261
1262 if (count == null) {
1263 StringBundler query = new StringBundler(3);
1264
1265 query.append(_SQL_COUNT_PERMISSION_WHERE);
1266
1267 if (actionId == null) {
1268 query.append(_FINDER_COLUMN_A_R_ACTIONID_1);
1269 }
1270 else {
1271 if (actionId.equals(StringPool.BLANK)) {
1272 query.append(_FINDER_COLUMN_A_R_ACTIONID_3);
1273 }
1274 else {
1275 query.append(_FINDER_COLUMN_A_R_ACTIONID_2);
1276 }
1277 }
1278
1279 query.append(_FINDER_COLUMN_A_R_RESOURCEID_2);
1280
1281 String sql = query.toString();
1282
1283 Session session = null;
1284
1285 try {
1286 session = openSession();
1287
1288 Query q = session.createQuery(sql);
1289
1290 QueryPos qPos = QueryPos.getInstance(q);
1291
1292 if (actionId != null) {
1293 qPos.add(actionId);
1294 }
1295
1296 qPos.add(resourceId);
1297
1298 count = (Long)q.uniqueResult();
1299 }
1300 catch (Exception e) {
1301 throw processException(e);
1302 }
1303 finally {
1304 if (count == null) {
1305 count = Long.valueOf(0);
1306 }
1307
1308 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
1309 count);
1310
1311 closeSession(session);
1312 }
1313 }
1314
1315 return count.intValue();
1316 }
1317
1318
1324 public int countAll() throws SystemException {
1325 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1326 FINDER_ARGS_EMPTY, this);
1327
1328 if (count == null) {
1329 Session session = null;
1330
1331 try {
1332 session = openSession();
1333
1334 Query q = session.createQuery(_SQL_COUNT_PERMISSION);
1335
1336 count = (Long)q.uniqueResult();
1337 }
1338 catch (Exception e) {
1339 throw processException(e);
1340 }
1341 finally {
1342 if (count == null) {
1343 count = Long.valueOf(0);
1344 }
1345
1346 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1347 FINDER_ARGS_EMPTY, count);
1348
1349 closeSession(session);
1350 }
1351 }
1352
1353 return count.intValue();
1354 }
1355
1356
1363 public List<com.liferay.portal.model.Group> getGroups(long pk)
1364 throws SystemException {
1365 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1366 }
1367
1368
1381 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1382 int end) throws SystemException {
1383 return getGroups(pk, start, end, null);
1384 }
1385
1386 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1387 PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1388 com.liferay.portal.model.impl.GroupImpl.class,
1389 PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
1390 "getGroups",
1391 new String[] {
1392 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1393 "com.liferay.portal.kernel.util.OrderByComparator"
1394 });
1395
1396
1410 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1411 int end, OrderByComparator orderByComparator) throws SystemException {
1412 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
1413
1414 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
1415 finderArgs, this);
1416
1417 if (list == null) {
1418 Session session = null;
1419
1420 try {
1421 session = openSession();
1422
1423 String sql = null;
1424
1425 if (orderByComparator != null) {
1426 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
1427 .concat(orderByComparator.getOrderBy());
1428 }
1429 else {
1430 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
1431 }
1432
1433 SQLQuery q = session.createSQLQuery(sql);
1434
1435 q.addEntity("Group_",
1436 com.liferay.portal.model.impl.GroupImpl.class);
1437
1438 QueryPos qPos = QueryPos.getInstance(q);
1439
1440 qPos.add(pk);
1441
1442 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
1443 getDialect(), start, end);
1444 }
1445 catch (Exception e) {
1446 throw processException(e);
1447 }
1448 finally {
1449 if (list == null) {
1450 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
1451 finderArgs);
1452 }
1453 else {
1454 groupPersistence.cacheResult(list);
1455
1456 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
1457 finderArgs, list);
1458 }
1459
1460 closeSession(session);
1461 }
1462 }
1463
1464 return list;
1465 }
1466
1467 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1468 PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1469 Long.class,
1470 PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
1471 "getGroupsSize", new String[] { Long.class.getName() });
1472
1473
1480 public int getGroupsSize(long pk) throws SystemException {
1481 Object[] finderArgs = new Object[] { pk };
1482
1483 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
1484 finderArgs, this);
1485
1486 if (count == null) {
1487 Session session = null;
1488
1489 try {
1490 session = openSession();
1491
1492 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
1493
1494 q.addScalar(COUNT_COLUMN_NAME,
1495 com.liferay.portal.kernel.dao.orm.Type.LONG);
1496
1497 QueryPos qPos = QueryPos.getInstance(q);
1498
1499 qPos.add(pk);
1500
1501 count = (Long)q.uniqueResult();
1502 }
1503 catch (Exception e) {
1504 throw processException(e);
1505 }
1506 finally {
1507 if (count == null) {
1508 count = Long.valueOf(0);
1509 }
1510
1511 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
1512 finderArgs, count);
1513
1514 closeSession(session);
1515 }
1516 }
1517
1518 return count.intValue();
1519 }
1520
1521 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1522 PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1523 Boolean.class,
1524 PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
1525 "containsGroup",
1526 new String[] { Long.class.getName(), Long.class.getName() });
1527
1528
1536 public boolean containsGroup(long pk, long groupPK)
1537 throws SystemException {
1538 Object[] finderArgs = new Object[] { pk, groupPK };
1539
1540 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
1541 finderArgs, this);
1542
1543 if (value == null) {
1544 try {
1545 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
1546 }
1547 catch (Exception e) {
1548 throw processException(e);
1549 }
1550 finally {
1551 if (value == null) {
1552 value = Boolean.FALSE;
1553 }
1554
1555 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
1556 finderArgs, value);
1557 }
1558 }
1559
1560 return value.booleanValue();
1561 }
1562
1563
1570 public boolean containsGroups(long pk) throws SystemException {
1571 if (getGroupsSize(pk) > 0) {
1572 return true;
1573 }
1574 else {
1575 return false;
1576 }
1577 }
1578
1579
1586 public void addGroup(long pk, long groupPK) throws SystemException {
1587 try {
1588 addGroup.add(pk, groupPK);
1589 }
1590 catch (Exception e) {
1591 throw processException(e);
1592 }
1593 finally {
1594 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1595 }
1596 }
1597
1598
1605 public void addGroup(long pk, com.liferay.portal.model.Group group)
1606 throws SystemException {
1607 try {
1608 addGroup.add(pk, group.getPrimaryKey());
1609 }
1610 catch (Exception e) {
1611 throw processException(e);
1612 }
1613 finally {
1614 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1615 }
1616 }
1617
1618
1625 public void addGroups(long pk, long[] groupPKs) throws SystemException {
1626 try {
1627 for (long groupPK : groupPKs) {
1628 addGroup.add(pk, groupPK);
1629 }
1630 }
1631 catch (Exception e) {
1632 throw processException(e);
1633 }
1634 finally {
1635 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1636 }
1637 }
1638
1639
1646 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
1647 throws SystemException {
1648 try {
1649 for (com.liferay.portal.model.Group group : groups) {
1650 addGroup.add(pk, group.getPrimaryKey());
1651 }
1652 }
1653 catch (Exception e) {
1654 throw processException(e);
1655 }
1656 finally {
1657 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1658 }
1659 }
1660
1661
1667 public void clearGroups(long pk) throws SystemException {
1668 try {
1669 clearGroups.clear(pk);
1670 }
1671 catch (Exception e) {
1672 throw processException(e);
1673 }
1674 finally {
1675 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1676 }
1677 }
1678
1679
1686 public void removeGroup(long pk, long groupPK) throws SystemException {
1687 try {
1688 removeGroup.remove(pk, groupPK);
1689 }
1690 catch (Exception e) {
1691 throw processException(e);
1692 }
1693 finally {
1694 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1695 }
1696 }
1697
1698
1705 public void removeGroup(long pk, com.liferay.portal.model.Group group)
1706 throws SystemException {
1707 try {
1708 removeGroup.remove(pk, group.getPrimaryKey());
1709 }
1710 catch (Exception e) {
1711 throw processException(e);
1712 }
1713 finally {
1714 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1715 }
1716 }
1717
1718
1725 public void removeGroups(long pk, long[] groupPKs)
1726 throws SystemException {
1727 try {
1728 for (long groupPK : groupPKs) {
1729 removeGroup.remove(pk, groupPK);
1730 }
1731 }
1732 catch (Exception e) {
1733 throw processException(e);
1734 }
1735 finally {
1736 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1737 }
1738 }
1739
1740
1747 public void removeGroups(long pk,
1748 List<com.liferay.portal.model.Group> groups) throws SystemException {
1749 try {
1750 for (com.liferay.portal.model.Group group : groups) {
1751 removeGroup.remove(pk, group.getPrimaryKey());
1752 }
1753 }
1754 catch (Exception e) {
1755 throw processException(e);
1756 }
1757 finally {
1758 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1759 }
1760 }
1761
1762
1769 public void setGroups(long pk, long[] groupPKs) throws SystemException {
1770 try {
1771 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
1772
1773 List<com.liferay.portal.model.Group> groups = getGroups(pk);
1774
1775 for (com.liferay.portal.model.Group group : groups) {
1776 if (!groupPKSet.remove(group.getPrimaryKey())) {
1777 removeGroup.remove(pk, group.getPrimaryKey());
1778 }
1779 }
1780
1781 for (Long groupPK : groupPKSet) {
1782 addGroup.add(pk, groupPK);
1783 }
1784 }
1785 catch (Exception e) {
1786 throw processException(e);
1787 }
1788 finally {
1789 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1790 }
1791 }
1792
1793
1800 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
1801 throws SystemException {
1802 try {
1803 long[] groupPKs = new long[groups.size()];
1804
1805 for (int i = 0; i < groups.size(); i++) {
1806 com.liferay.portal.model.Group group = groups.get(i);
1807
1808 groupPKs[i] = group.getPrimaryKey();
1809 }
1810
1811 setGroups(pk, groupPKs);
1812 }
1813 catch (Exception e) {
1814 throw processException(e);
1815 }
1816 finally {
1817 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1818 }
1819 }
1820
1821
1828 public List<com.liferay.portal.model.Role> getRoles(long pk)
1829 throws SystemException {
1830 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1831 }
1832
1833
1846 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
1847 int end) throws SystemException {
1848 return getRoles(pk, start, end, null);
1849 }
1850
1851 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1852 PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1853 com.liferay.portal.model.impl.RoleImpl.class,
1854 PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
1855 "getRoles",
1856 new String[] {
1857 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1858 "com.liferay.portal.kernel.util.OrderByComparator"
1859 });
1860
1861
1875 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
1876 int end, OrderByComparator orderByComparator) throws SystemException {
1877 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
1878
1879 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
1880 finderArgs, this);
1881
1882 if (list == null) {
1883 Session session = null;
1884
1885 try {
1886 session = openSession();
1887
1888 String sql = null;
1889
1890 if (orderByComparator != null) {
1891 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
1892 .concat(orderByComparator.getOrderBy());
1893 }
1894 else {
1895 sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
1896 }
1897
1898 SQLQuery q = session.createSQLQuery(sql);
1899
1900 q.addEntity("Role_",
1901 com.liferay.portal.model.impl.RoleImpl.class);
1902
1903 QueryPos qPos = QueryPos.getInstance(q);
1904
1905 qPos.add(pk);
1906
1907 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
1908 getDialect(), start, end);
1909 }
1910 catch (Exception e) {
1911 throw processException(e);
1912 }
1913 finally {
1914 if (list == null) {
1915 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES,
1916 finderArgs);
1917 }
1918 else {
1919 rolePersistence.cacheResult(list);
1920
1921 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES,
1922 finderArgs, list);
1923 }
1924
1925 closeSession(session);
1926 }
1927 }
1928
1929 return list;
1930 }
1931
1932 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1933 PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1934 Long.class,
1935 PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
1936 "getRolesSize", new String[] { Long.class.getName() });
1937
1938
1945 public int getRolesSize(long pk) throws SystemException {
1946 Object[] finderArgs = new Object[] { pk };
1947
1948 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
1949 finderArgs, this);
1950
1951 if (count == null) {
1952 Session session = null;
1953
1954 try {
1955 session = openSession();
1956
1957 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
1958
1959 q.addScalar(COUNT_COLUMN_NAME,
1960 com.liferay.portal.kernel.dao.orm.Type.LONG);
1961
1962 QueryPos qPos = QueryPos.getInstance(q);
1963
1964 qPos.add(pk);
1965
1966 count = (Long)q.uniqueResult();
1967 }
1968 catch (Exception e) {
1969 throw processException(e);
1970 }
1971 finally {
1972 if (count == null) {
1973 count = Long.valueOf(0);
1974 }
1975
1976 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
1977 finderArgs, count);
1978
1979 closeSession(session);
1980 }
1981 }
1982
1983 return count.intValue();
1984 }
1985
1986 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1987 PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1988 Boolean.class,
1989 PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
1990 "containsRole",
1991 new String[] { Long.class.getName(), Long.class.getName() });
1992
1993
2001 public boolean containsRole(long pk, long rolePK) throws SystemException {
2002 Object[] finderArgs = new Object[] { pk, rolePK };
2003
2004 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
2005 finderArgs, this);
2006
2007 if (value == null) {
2008 try {
2009 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
2010 }
2011 catch (Exception e) {
2012 throw processException(e);
2013 }
2014 finally {
2015 if (value == null) {
2016 value = Boolean.FALSE;
2017 }
2018
2019 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
2020 finderArgs, value);
2021 }
2022 }
2023
2024 return value.booleanValue();
2025 }
2026
2027
2034 public boolean containsRoles(long pk) throws SystemException {
2035 if (getRolesSize(pk) > 0) {
2036 return true;
2037 }
2038 else {
2039 return false;
2040 }
2041 }
2042
2043
2050 public void addRole(long pk, long rolePK) throws SystemException {
2051 try {
2052 addRole.add(pk, rolePK);
2053 }
2054 catch (Exception e) {
2055 throw processException(e);
2056 }
2057 finally {
2058 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2059 }
2060 }
2061
2062
2069 public void addRole(long pk, com.liferay.portal.model.Role role)
2070 throws SystemException {
2071 try {
2072 addRole.add(pk, role.getPrimaryKey());
2073 }
2074 catch (Exception e) {
2075 throw processException(e);
2076 }
2077 finally {
2078 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2079 }
2080 }
2081
2082
2089 public void addRoles(long pk, long[] rolePKs) throws SystemException {
2090 try {
2091 for (long rolePK : rolePKs) {
2092 addRole.add(pk, rolePK);
2093 }
2094 }
2095 catch (Exception e) {
2096 throw processException(e);
2097 }
2098 finally {
2099 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2100 }
2101 }
2102
2103
2110 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
2111 throws SystemException {
2112 try {
2113 for (com.liferay.portal.model.Role role : roles) {
2114 addRole.add(pk, role.getPrimaryKey());
2115 }
2116 }
2117 catch (Exception e) {
2118 throw processException(e);
2119 }
2120 finally {
2121 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2122 }
2123 }
2124
2125
2131 public void clearRoles(long pk) throws SystemException {
2132 try {
2133 clearRoles.clear(pk);
2134 }
2135 catch (Exception e) {
2136 throw processException(e);
2137 }
2138 finally {
2139 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2140 }
2141 }
2142
2143
2150 public void removeRole(long pk, long rolePK) throws SystemException {
2151 try {
2152 removeRole.remove(pk, rolePK);
2153 }
2154 catch (Exception e) {
2155 throw processException(e);
2156 }
2157 finally {
2158 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2159 }
2160 }
2161
2162
2169 public void removeRole(long pk, com.liferay.portal.model.Role role)
2170 throws SystemException {
2171 try {
2172 removeRole.remove(pk, role.getPrimaryKey());
2173 }
2174 catch (Exception e) {
2175 throw processException(e);
2176 }
2177 finally {
2178 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2179 }
2180 }
2181
2182
2189 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
2190 try {
2191 for (long rolePK : rolePKs) {
2192 removeRole.remove(pk, rolePK);
2193 }
2194 }
2195 catch (Exception e) {
2196 throw processException(e);
2197 }
2198 finally {
2199 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2200 }
2201 }
2202
2203
2210 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
2211 throws SystemException {
2212 try {
2213 for (com.liferay.portal.model.Role role : roles) {
2214 removeRole.remove(pk, role.getPrimaryKey());
2215 }
2216 }
2217 catch (Exception e) {
2218 throw processException(e);
2219 }
2220 finally {
2221 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2222 }
2223 }
2224
2225
2232 public void setRoles(long pk, long[] rolePKs) throws SystemException {
2233 try {
2234 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
2235
2236 List<com.liferay.portal.model.Role> roles = getRoles(pk);
2237
2238 for (com.liferay.portal.model.Role role : roles) {
2239 if (!rolePKSet.remove(role.getPrimaryKey())) {
2240 removeRole.remove(pk, role.getPrimaryKey());
2241 }
2242 }
2243
2244 for (Long rolePK : rolePKSet) {
2245 addRole.add(pk, rolePK);
2246 }
2247 }
2248 catch (Exception e) {
2249 throw processException(e);
2250 }
2251 finally {
2252 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2253 }
2254 }
2255
2256
2263 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
2264 throws SystemException {
2265 try {
2266 long[] rolePKs = new long[roles.size()];
2267
2268 for (int i = 0; i < roles.size(); i++) {
2269 com.liferay.portal.model.Role role = roles.get(i);
2270
2271 rolePKs[i] = role.getPrimaryKey();
2272 }
2273
2274 setRoles(pk, rolePKs);
2275 }
2276 catch (Exception e) {
2277 throw processException(e);
2278 }
2279 finally {
2280 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2281 }
2282 }
2283
2284
2291 public List<com.liferay.portal.model.User> getUsers(long pk)
2292 throws SystemException {
2293 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2294 }
2295
2296
2309 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2310 int end) throws SystemException {
2311 return getUsers(pk, start, end, null);
2312 }
2313
2314 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2315 PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
2316 com.liferay.portal.model.impl.UserImpl.class,
2317 PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
2318 "getUsers",
2319 new String[] {
2320 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2321 "com.liferay.portal.kernel.util.OrderByComparator"
2322 });
2323
2324
2338 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2339 int end, OrderByComparator orderByComparator) throws SystemException {
2340 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2341
2342 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
2343 finderArgs, this);
2344
2345 if (list == null) {
2346 Session session = null;
2347
2348 try {
2349 session = openSession();
2350
2351 String sql = null;
2352
2353 if (orderByComparator != null) {
2354 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
2355 .concat(orderByComparator.getOrderBy());
2356 }
2357 else {
2358 sql = _SQL_GETUSERS;
2359 }
2360
2361 SQLQuery q = session.createSQLQuery(sql);
2362
2363 q.addEntity("User_",
2364 com.liferay.portal.model.impl.UserImpl.class);
2365
2366 QueryPos qPos = QueryPos.getInstance(q);
2367
2368 qPos.add(pk);
2369
2370 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
2371 getDialect(), start, end);
2372 }
2373 catch (Exception e) {
2374 throw processException(e);
2375 }
2376 finally {
2377 if (list == null) {
2378 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
2379 finderArgs);
2380 }
2381 else {
2382 userPersistence.cacheResult(list);
2383
2384 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
2385 finderArgs, list);
2386 }
2387
2388 closeSession(session);
2389 }
2390 }
2391
2392 return list;
2393 }
2394
2395 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2396 PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
2397 Long.class,
2398 PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
2399 "getUsersSize", new String[] { Long.class.getName() });
2400
2401
2408 public int getUsersSize(long pk) throws SystemException {
2409 Object[] finderArgs = new Object[] { pk };
2410
2411 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
2412 finderArgs, this);
2413
2414 if (count == null) {
2415 Session session = null;
2416
2417 try {
2418 session = openSession();
2419
2420 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
2421
2422 q.addScalar(COUNT_COLUMN_NAME,
2423 com.liferay.portal.kernel.dao.orm.Type.LONG);
2424
2425 QueryPos qPos = QueryPos.getInstance(q);
2426
2427 qPos.add(pk);
2428
2429 count = (Long)q.uniqueResult();
2430 }
2431 catch (Exception e) {
2432 throw processException(e);
2433 }
2434 finally {
2435 if (count == null) {
2436 count = Long.valueOf(0);
2437 }
2438
2439 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
2440 finderArgs, count);
2441
2442 closeSession(session);
2443 }
2444 }
2445
2446 return count.intValue();
2447 }
2448
2449 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2450 PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
2451 Boolean.class,
2452 PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
2453 "containsUser",
2454 new String[] { Long.class.getName(), Long.class.getName() });
2455
2456
2464 public boolean containsUser(long pk, long userPK) throws SystemException {
2465 Object[] finderArgs = new Object[] { pk, userPK };
2466
2467 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
2468 finderArgs, this);
2469
2470 if (value == null) {
2471 try {
2472 value = Boolean.valueOf(containsUser.contains(pk, userPK));
2473 }
2474 catch (Exception e) {
2475 throw processException(e);
2476 }
2477 finally {
2478 if (value == null) {
2479 value = Boolean.FALSE;
2480 }
2481
2482 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
2483 finderArgs, value);
2484 }
2485 }
2486
2487 return value.booleanValue();
2488 }
2489
2490
2497 public boolean containsUsers(long pk) throws SystemException {
2498 if (getUsersSize(pk) > 0) {
2499 return true;
2500 }
2501 else {
2502 return false;
2503 }
2504 }
2505
2506
2513 public void addUser(long pk, long userPK) throws SystemException {
2514 try {
2515 addUser.add(pk, userPK);
2516 }
2517 catch (Exception e) {
2518 throw processException(e);
2519 }
2520 finally {
2521 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2522 }
2523 }
2524
2525
2532 public void addUser(long pk, com.liferay.portal.model.User user)
2533 throws SystemException {
2534 try {
2535 addUser.add(pk, user.getPrimaryKey());
2536 }
2537 catch (Exception e) {
2538 throw processException(e);
2539 }
2540 finally {
2541 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2542 }
2543 }
2544
2545
2552 public void addUsers(long pk, long[] userPKs) throws SystemException {
2553 try {
2554 for (long userPK : userPKs) {
2555 addUser.add(pk, userPK);
2556 }
2557 }
2558 catch (Exception e) {
2559 throw processException(e);
2560 }
2561 finally {
2562 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2563 }
2564 }
2565
2566
2573 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
2574 throws SystemException {
2575 try {
2576 for (com.liferay.portal.model.User user : users) {
2577 addUser.add(pk, user.getPrimaryKey());
2578 }
2579 }
2580 catch (Exception e) {
2581 throw processException(e);
2582 }
2583 finally {
2584 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2585 }
2586 }
2587
2588
2594 public void clearUsers(long pk) throws SystemException {
2595 try {
2596 clearUsers.clear(pk);
2597 }
2598 catch (Exception e) {
2599 throw processException(e);
2600 }
2601 finally {
2602 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2603 }
2604 }
2605
2606
2613 public void removeUser(long pk, long userPK) throws SystemException {
2614 try {
2615 removeUser.remove(pk, userPK);
2616 }
2617 catch (Exception e) {
2618 throw processException(e);
2619 }
2620 finally {
2621 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2622 }
2623 }
2624
2625
2632 public void removeUser(long pk, com.liferay.portal.model.User user)
2633 throws SystemException {
2634 try {
2635 removeUser.remove(pk, user.getPrimaryKey());
2636 }
2637 catch (Exception e) {
2638 throw processException(e);
2639 }
2640 finally {
2641 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2642 }
2643 }
2644
2645
2652 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2653 try {
2654 for (long userPK : userPKs) {
2655 removeUser.remove(pk, userPK);
2656 }
2657 }
2658 catch (Exception e) {
2659 throw processException(e);
2660 }
2661 finally {
2662 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2663 }
2664 }
2665
2666
2673 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2674 throws SystemException {
2675 try {
2676 for (com.liferay.portal.model.User user : users) {
2677 removeUser.remove(pk, user.getPrimaryKey());
2678 }
2679 }
2680 catch (Exception e) {
2681 throw processException(e);
2682 }
2683 finally {
2684 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2685 }
2686 }
2687
2688
2695 public void setUsers(long pk, long[] userPKs) throws SystemException {
2696 try {
2697 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2698
2699 List<com.liferay.portal.model.User> users = getUsers(pk);
2700
2701 for (com.liferay.portal.model.User user : users) {
2702 if (!userPKSet.remove(user.getPrimaryKey())) {
2703 removeUser.remove(pk, user.getPrimaryKey());
2704 }
2705 }
2706
2707 for (Long userPK : userPKSet) {
2708 addUser.add(pk, userPK);
2709 }
2710 }
2711 catch (Exception e) {
2712 throw processException(e);
2713 }
2714 finally {
2715 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2716 }
2717 }
2718
2719
2726 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2727 throws SystemException {
2728 try {
2729 long[] userPKs = new long[users.size()];
2730
2731 for (int i = 0; i < users.size(); i++) {
2732 com.liferay.portal.model.User user = users.get(i);
2733
2734 userPKs[i] = user.getPrimaryKey();
2735 }
2736
2737 setUsers(pk, userPKs);
2738 }
2739 catch (Exception e) {
2740 throw processException(e);
2741 }
2742 finally {
2743 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2744 }
2745 }
2746
2747
2750 public void afterPropertiesSet() {
2751 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2752 com.liferay.portal.util.PropsUtil.get(
2753 "value.object.listener.com.liferay.portal.model.Permission")));
2754
2755 if (listenerClassNames.length > 0) {
2756 try {
2757 List<ModelListener<Permission>> listenersList = new ArrayList<ModelListener<Permission>>();
2758
2759 for (String listenerClassName : listenerClassNames) {
2760 listenersList.add((ModelListener<Permission>)InstanceFactory.newInstance(
2761 listenerClassName));
2762 }
2763
2764 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2765 }
2766 catch (Exception e) {
2767 _log.error(e);
2768 }
2769 }
2770
2771 containsGroup = new ContainsGroup(this);
2772
2773 addGroup = new AddGroup(this);
2774 clearGroups = new ClearGroups(this);
2775 removeGroup = new RemoveGroup(this);
2776
2777 containsRole = new ContainsRole(this);
2778
2779 addRole = new AddRole(this);
2780 clearRoles = new ClearRoles(this);
2781 removeRole = new RemoveRole(this);
2782
2783 containsUser = new ContainsUser(this);
2784
2785 addUser = new AddUser(this);
2786 clearUsers = new ClearUsers(this);
2787 removeUser = new RemoveUser(this);
2788 }
2789
2790 public void destroy() {
2791 EntityCacheUtil.removeCache(PermissionImpl.class.getName());
2792 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2793 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2794 }
2795
2796 @BeanReference(type = AccountPersistence.class)
2797 protected AccountPersistence accountPersistence;
2798 @BeanReference(type = AddressPersistence.class)
2799 protected AddressPersistence addressPersistence;
2800 @BeanReference(type = BrowserTrackerPersistence.class)
2801 protected BrowserTrackerPersistence browserTrackerPersistence;
2802 @BeanReference(type = ClassNamePersistence.class)
2803 protected ClassNamePersistence classNamePersistence;
2804 @BeanReference(type = ClusterGroupPersistence.class)
2805 protected ClusterGroupPersistence clusterGroupPersistence;
2806 @BeanReference(type = CompanyPersistence.class)
2807 protected CompanyPersistence companyPersistence;
2808 @BeanReference(type = ContactPersistence.class)
2809 protected ContactPersistence contactPersistence;
2810 @BeanReference(type = CountryPersistence.class)
2811 protected CountryPersistence countryPersistence;
2812 @BeanReference(type = EmailAddressPersistence.class)
2813 protected EmailAddressPersistence emailAddressPersistence;
2814 @BeanReference(type = GroupPersistence.class)
2815 protected GroupPersistence groupPersistence;
2816 @BeanReference(type = ImagePersistence.class)
2817 protected ImagePersistence imagePersistence;
2818 @BeanReference(type = LayoutPersistence.class)
2819 protected LayoutPersistence layoutPersistence;
2820 @BeanReference(type = LayoutBranchPersistence.class)
2821 protected LayoutBranchPersistence layoutBranchPersistence;
2822 @BeanReference(type = LayoutPrototypePersistence.class)
2823 protected LayoutPrototypePersistence layoutPrototypePersistence;
2824 @BeanReference(type = LayoutRevisionPersistence.class)
2825 protected LayoutRevisionPersistence layoutRevisionPersistence;
2826 @BeanReference(type = LayoutSetPersistence.class)
2827 protected LayoutSetPersistence layoutSetPersistence;
2828 @BeanReference(type = LayoutSetBranchPersistence.class)
2829 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2830 @BeanReference(type = LayoutSetPrototypePersistence.class)
2831 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2832 @BeanReference(type = ListTypePersistence.class)
2833 protected ListTypePersistence listTypePersistence;
2834 @BeanReference(type = LockPersistence.class)
2835 protected LockPersistence lockPersistence;
2836 @BeanReference(type = MembershipRequestPersistence.class)
2837 protected MembershipRequestPersistence membershipRequestPersistence;
2838 @BeanReference(type = OrganizationPersistence.class)
2839 protected OrganizationPersistence organizationPersistence;
2840 @BeanReference(type = OrgGroupPermissionPersistence.class)
2841 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2842 @BeanReference(type = OrgGroupRolePersistence.class)
2843 protected OrgGroupRolePersistence orgGroupRolePersistence;
2844 @BeanReference(type = OrgLaborPersistence.class)
2845 protected OrgLaborPersistence orgLaborPersistence;
2846 @BeanReference(type = PasswordPolicyPersistence.class)
2847 protected PasswordPolicyPersistence passwordPolicyPersistence;
2848 @BeanReference(type = PasswordPolicyRelPersistence.class)
2849 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2850 @BeanReference(type = PasswordTrackerPersistence.class)
2851 protected PasswordTrackerPersistence passwordTrackerPersistence;
2852 @BeanReference(type = PermissionPersistence.class)
2853 protected PermissionPersistence permissionPersistence;
2854 @BeanReference(type = PhonePersistence.class)
2855 protected PhonePersistence phonePersistence;
2856 @BeanReference(type = PluginSettingPersistence.class)
2857 protected PluginSettingPersistence pluginSettingPersistence;
2858 @BeanReference(type = PortalPreferencesPersistence.class)
2859 protected PortalPreferencesPersistence portalPreferencesPersistence;
2860 @BeanReference(type = PortletPersistence.class)
2861 protected PortletPersistence portletPersistence;
2862 @BeanReference(type = PortletItemPersistence.class)
2863 protected PortletItemPersistence portletItemPersistence;
2864 @BeanReference(type = PortletPreferencesPersistence.class)
2865 protected PortletPreferencesPersistence portletPreferencesPersistence;
2866 @BeanReference(type = RegionPersistence.class)
2867 protected RegionPersistence regionPersistence;
2868 @BeanReference(type = ReleasePersistence.class)
2869 protected ReleasePersistence releasePersistence;
2870 @BeanReference(type = RepositoryPersistence.class)
2871 protected RepositoryPersistence repositoryPersistence;
2872 @BeanReference(type = RepositoryEntryPersistence.class)
2873 protected RepositoryEntryPersistence repositoryEntryPersistence;
2874 @BeanReference(type = ResourcePersistence.class)
2875 protected ResourcePersistence resourcePersistence;
2876 @BeanReference(type = ResourceActionPersistence.class)
2877 protected ResourceActionPersistence resourceActionPersistence;
2878 @BeanReference(type = ResourceBlockPersistence.class)
2879 protected ResourceBlockPersistence resourceBlockPersistence;
2880 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2881 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2882 @BeanReference(type = ResourceCodePersistence.class)
2883 protected ResourceCodePersistence resourceCodePersistence;
2884 @BeanReference(type = ResourcePermissionPersistence.class)
2885 protected ResourcePermissionPersistence resourcePermissionPersistence;
2886 @BeanReference(type = ResourceTypePermissionPersistence.class)
2887 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2888 @BeanReference(type = RolePersistence.class)
2889 protected RolePersistence rolePersistence;
2890 @BeanReference(type = ServiceComponentPersistence.class)
2891 protected ServiceComponentPersistence serviceComponentPersistence;
2892 @BeanReference(type = ShardPersistence.class)
2893 protected ShardPersistence shardPersistence;
2894 @BeanReference(type = SubscriptionPersistence.class)
2895 protected SubscriptionPersistence subscriptionPersistence;
2896 @BeanReference(type = TeamPersistence.class)
2897 protected TeamPersistence teamPersistence;
2898 @BeanReference(type = TicketPersistence.class)
2899 protected TicketPersistence ticketPersistence;
2900 @BeanReference(type = UserPersistence.class)
2901 protected UserPersistence userPersistence;
2902 @BeanReference(type = UserGroupPersistence.class)
2903 protected UserGroupPersistence userGroupPersistence;
2904 @BeanReference(type = UserGroupGroupRolePersistence.class)
2905 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2906 @BeanReference(type = UserGroupRolePersistence.class)
2907 protected UserGroupRolePersistence userGroupRolePersistence;
2908 @BeanReference(type = UserIdMapperPersistence.class)
2909 protected UserIdMapperPersistence userIdMapperPersistence;
2910 @BeanReference(type = UserNotificationEventPersistence.class)
2911 protected UserNotificationEventPersistence userNotificationEventPersistence;
2912 @BeanReference(type = UserTrackerPersistence.class)
2913 protected UserTrackerPersistence userTrackerPersistence;
2914 @BeanReference(type = UserTrackerPathPersistence.class)
2915 protected UserTrackerPathPersistence userTrackerPathPersistence;
2916 @BeanReference(type = VirtualHostPersistence.class)
2917 protected VirtualHostPersistence virtualHostPersistence;
2918 @BeanReference(type = WebDAVPropsPersistence.class)
2919 protected WebDAVPropsPersistence webDAVPropsPersistence;
2920 @BeanReference(type = WebsitePersistence.class)
2921 protected WebsitePersistence websitePersistence;
2922 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2923 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2924 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2925 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2926 protected ContainsGroup containsGroup;
2927 protected AddGroup addGroup;
2928 protected ClearGroups clearGroups;
2929 protected RemoveGroup removeGroup;
2930 protected ContainsRole containsRole;
2931 protected AddRole addRole;
2932 protected ClearRoles clearRoles;
2933 protected RemoveRole removeRole;
2934 protected ContainsUser containsUser;
2935 protected AddUser addUser;
2936 protected ClearUsers clearUsers;
2937 protected RemoveUser removeUser;
2938
2939 protected class ContainsGroup {
2940 protected ContainsGroup(PermissionPersistenceImpl persistenceImpl) {
2941 super();
2942
2943 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2944 _SQL_CONTAINSGROUP,
2945 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2946 RowMapper.COUNT);
2947 }
2948
2949 protected boolean contains(long permissionId, long groupId) {
2950 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2951 new Long(permissionId), new Long(groupId)
2952 });
2953
2954 if (results.size() > 0) {
2955 Integer count = results.get(0);
2956
2957 if (count.intValue() > 0) {
2958 return true;
2959 }
2960 }
2961
2962 return false;
2963 }
2964
2965 private MappingSqlQuery<Integer> _mappingSqlQuery;
2966 }
2967
2968 protected class AddGroup {
2969 protected AddGroup(PermissionPersistenceImpl persistenceImpl) {
2970 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2971 "INSERT INTO Groups_Permissions (permissionId, groupId) VALUES (?, ?)",
2972 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2973 _persistenceImpl = persistenceImpl;
2974 }
2975
2976 protected void add(long permissionId, long groupId)
2977 throws SystemException {
2978 if (!_persistenceImpl.containsGroup.contains(permissionId, groupId)) {
2979 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2980
2981 for (ModelListener<Permission> listener : listeners) {
2982 listener.onBeforeAddAssociation(permissionId,
2983 com.liferay.portal.model.Group.class.getName(), groupId);
2984 }
2985
2986 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2987 listener.onBeforeAddAssociation(groupId,
2988 Permission.class.getName(), permissionId);
2989 }
2990
2991 _sqlUpdate.update(new Object[] {
2992 new Long(permissionId), new Long(groupId)
2993 });
2994
2995 for (ModelListener<Permission> listener : listeners) {
2996 listener.onAfterAddAssociation(permissionId,
2997 com.liferay.portal.model.Group.class.getName(), groupId);
2998 }
2999
3000 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3001 listener.onAfterAddAssociation(groupId,
3002 Permission.class.getName(), permissionId);
3003 }
3004 }
3005 }
3006
3007 private SqlUpdate _sqlUpdate;
3008 private PermissionPersistenceImpl _persistenceImpl;
3009 }
3010
3011 protected class ClearGroups {
3012 protected ClearGroups(PermissionPersistenceImpl persistenceImpl) {
3013 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3014 "DELETE FROM Groups_Permissions WHERE permissionId = ?",
3015 new int[] { java.sql.Types.BIGINT });
3016 }
3017
3018 protected void clear(long permissionId) throws SystemException {
3019 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
3020
3021 List<com.liferay.portal.model.Group> groups = null;
3022
3023 if ((listeners.length > 0) || (groupListeners.length > 0)) {
3024 groups = getGroups(permissionId);
3025
3026 for (com.liferay.portal.model.Group group : groups) {
3027 for (ModelListener<Permission> listener : listeners) {
3028 listener.onBeforeRemoveAssociation(permissionId,
3029 com.liferay.portal.model.Group.class.getName(),
3030 group.getPrimaryKey());
3031 }
3032
3033 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3034 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
3035 Permission.class.getName(), permissionId);
3036 }
3037 }
3038 }
3039
3040 _sqlUpdate.update(new Object[] { new Long(permissionId) });
3041
3042 if ((listeners.length > 0) || (groupListeners.length > 0)) {
3043 for (com.liferay.portal.model.Group group : groups) {
3044 for (ModelListener<Permission> listener : listeners) {
3045 listener.onAfterRemoveAssociation(permissionId,
3046 com.liferay.portal.model.Group.class.getName(),
3047 group.getPrimaryKey());
3048 }
3049
3050 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3051 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
3052 Permission.class.getName(), permissionId);
3053 }
3054 }
3055 }
3056 }
3057
3058 private SqlUpdate _sqlUpdate;
3059 }
3060
3061 protected class RemoveGroup {
3062 protected RemoveGroup(PermissionPersistenceImpl persistenceImpl) {
3063 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3064 "DELETE FROM Groups_Permissions WHERE permissionId = ? AND groupId = ?",
3065 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3066 _persistenceImpl = persistenceImpl;
3067 }
3068
3069 protected void remove(long permissionId, long groupId)
3070 throws SystemException {
3071 if (_persistenceImpl.containsGroup.contains(permissionId, groupId)) {
3072 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
3073
3074 for (ModelListener<Permission> listener : listeners) {
3075 listener.onBeforeRemoveAssociation(permissionId,
3076 com.liferay.portal.model.Group.class.getName(), groupId);
3077 }
3078
3079 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3080 listener.onBeforeRemoveAssociation(groupId,
3081 Permission.class.getName(), permissionId);
3082 }
3083
3084 _sqlUpdate.update(new Object[] {
3085 new Long(permissionId), new Long(groupId)
3086 });
3087
3088 for (ModelListener<Permission> listener : listeners) {
3089 listener.onAfterRemoveAssociation(permissionId,
3090 com.liferay.portal.model.Group.class.getName(), groupId);
3091 }
3092
3093 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3094 listener.onAfterRemoveAssociation(groupId,
3095 Permission.class.getName(), permissionId);
3096 }
3097 }
3098 }
3099
3100 private SqlUpdate _sqlUpdate;
3101 private PermissionPersistenceImpl _persistenceImpl;
3102 }
3103
3104 protected class ContainsRole {
3105 protected ContainsRole(PermissionPersistenceImpl persistenceImpl) {
3106 super();
3107
3108 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3109 _SQL_CONTAINSROLE,
3110 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3111 RowMapper.COUNT);
3112 }
3113
3114 protected boolean contains(long permissionId, long roleId) {
3115 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3116 new Long(permissionId), new Long(roleId)
3117 });
3118
3119 if (results.size() > 0) {
3120 Integer count = results.get(0);
3121
3122 if (count.intValue() > 0) {
3123 return true;
3124 }
3125 }
3126
3127 return false;
3128 }
3129
3130 private MappingSqlQuery<Integer> _mappingSqlQuery;
3131 }
3132
3133 protected class AddRole {
3134 protected AddRole(PermissionPersistenceImpl persistenceImpl) {
3135 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3136 "INSERT INTO Roles_Permissions (permissionId, roleId) VALUES (?, ?)",
3137 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3138 _persistenceImpl = persistenceImpl;
3139 }
3140
3141 protected void add(long permissionId, long roleId)
3142 throws SystemException {
3143 if (!_persistenceImpl.containsRole.contains(permissionId, roleId)) {
3144 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
3145
3146 for (ModelListener<Permission> listener : listeners) {
3147 listener.onBeforeAddAssociation(permissionId,
3148 com.liferay.portal.model.Role.class.getName(), roleId);
3149 }
3150
3151 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3152 listener.onBeforeAddAssociation(roleId,
3153 Permission.class.getName(), permissionId);
3154 }
3155
3156 _sqlUpdate.update(new Object[] {
3157 new Long(permissionId), new Long(roleId)
3158 });
3159
3160 for (ModelListener<Permission> listener : listeners) {
3161 listener.onAfterAddAssociation(permissionId,
3162 com.liferay.portal.model.Role.class.getName(), roleId);
3163 }
3164
3165 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3166 listener.onAfterAddAssociation(roleId,
3167 Permission.class.getName(), permissionId);
3168 }
3169 }
3170 }
3171
3172 private SqlUpdate _sqlUpdate;
3173 private PermissionPersistenceImpl _persistenceImpl;
3174 }
3175
3176 protected class ClearRoles {
3177 protected ClearRoles(PermissionPersistenceImpl persistenceImpl) {
3178 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3179 "DELETE FROM Roles_Permissions WHERE permissionId = ?",
3180 new int[] { java.sql.Types.BIGINT });
3181 }
3182
3183 protected void clear(long permissionId) throws SystemException {
3184 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
3185
3186 List<com.liferay.portal.model.Role> roles = null;
3187
3188 if ((listeners.length > 0) || (roleListeners.length > 0)) {
3189 roles = getRoles(permissionId);
3190
3191 for (com.liferay.portal.model.Role role : roles) {
3192 for (ModelListener<Permission> listener : listeners) {
3193 listener.onBeforeRemoveAssociation(permissionId,
3194 com.liferay.portal.model.Role.class.getName(),
3195 role.getPrimaryKey());
3196 }
3197
3198 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3199 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
3200 Permission.class.getName(), permissionId);
3201 }
3202 }
3203 }
3204
3205 _sqlUpdate.update(new Object[] { new Long(permissionId) });
3206
3207 if ((listeners.length > 0) || (roleListeners.length > 0)) {
3208 for (com.liferay.portal.model.Role role : roles) {
3209 for (ModelListener<Permission> listener : listeners) {
3210 listener.onAfterRemoveAssociation(permissionId,
3211 com.liferay.portal.model.Role.class.getName(),
3212 role.getPrimaryKey());
3213 }
3214
3215 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3216 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
3217 Permission.class.getName(), permissionId);
3218 }
3219 }
3220 }
3221 }
3222
3223 private SqlUpdate _sqlUpdate;
3224 }
3225
3226 protected class RemoveRole {
3227 protected RemoveRole(PermissionPersistenceImpl persistenceImpl) {
3228 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3229 "DELETE FROM Roles_Permissions WHERE permissionId = ? AND roleId = ?",
3230 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3231 _persistenceImpl = persistenceImpl;
3232 }
3233
3234 protected void remove(long permissionId, long roleId)
3235 throws SystemException {
3236 if (_persistenceImpl.containsRole.contains(permissionId, roleId)) {
3237 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
3238
3239 for (ModelListener<Permission> listener : listeners) {
3240 listener.onBeforeRemoveAssociation(permissionId,
3241 com.liferay.portal.model.Role.class.getName(), roleId);
3242 }
3243
3244 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3245 listener.onBeforeRemoveAssociation(roleId,
3246 Permission.class.getName(), permissionId);
3247 }
3248
3249 _sqlUpdate.update(new Object[] {
3250 new Long(permissionId), new Long(roleId)
3251 });
3252
3253 for (ModelListener<Permission> listener : listeners) {
3254 listener.onAfterRemoveAssociation(permissionId,
3255 com.liferay.portal.model.Role.class.getName(), roleId);
3256 }
3257
3258 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3259 listener.onAfterRemoveAssociation(roleId,
3260 Permission.class.getName(), permissionId);
3261 }
3262 }
3263 }
3264
3265 private SqlUpdate _sqlUpdate;
3266 private PermissionPersistenceImpl _persistenceImpl;
3267 }
3268
3269 protected class ContainsUser {
3270 protected ContainsUser(PermissionPersistenceImpl persistenceImpl) {
3271 super();
3272
3273 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3274 _SQL_CONTAINSUSER,
3275 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3276 RowMapper.COUNT);
3277 }
3278
3279 protected boolean contains(long permissionId, long userId) {
3280 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3281 new Long(permissionId), new Long(userId)
3282 });
3283
3284 if (results.size() > 0) {
3285 Integer count = results.get(0);
3286
3287 if (count.intValue() > 0) {
3288 return true;
3289 }
3290 }
3291
3292 return false;
3293 }
3294
3295 private MappingSqlQuery<Integer> _mappingSqlQuery;
3296 }
3297
3298 protected class AddUser {
3299 protected AddUser(PermissionPersistenceImpl persistenceImpl) {
3300 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3301 "INSERT INTO Users_Permissions (permissionId, userId) VALUES (?, ?)",
3302 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3303 _persistenceImpl = persistenceImpl;
3304 }
3305
3306 protected void add(long permissionId, long userId)
3307 throws SystemException {
3308 if (!_persistenceImpl.containsUser.contains(permissionId, userId)) {
3309 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3310
3311 for (ModelListener<Permission> listener : listeners) {
3312 listener.onBeforeAddAssociation(permissionId,
3313 com.liferay.portal.model.User.class.getName(), userId);
3314 }
3315
3316 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3317 listener.onBeforeAddAssociation(userId,
3318 Permission.class.getName(), permissionId);
3319 }
3320
3321 _sqlUpdate.update(new Object[] {
3322 new Long(permissionId), new Long(userId)
3323 });
3324
3325 for (ModelListener<Permission> listener : listeners) {
3326 listener.onAfterAddAssociation(permissionId,
3327 com.liferay.portal.model.User.class.getName(), userId);
3328 }
3329
3330 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3331 listener.onAfterAddAssociation(userId,
3332 Permission.class.getName(), permissionId);
3333 }
3334 }
3335 }
3336
3337 private SqlUpdate _sqlUpdate;
3338 private PermissionPersistenceImpl _persistenceImpl;
3339 }
3340
3341 protected class ClearUsers {
3342 protected ClearUsers(PermissionPersistenceImpl persistenceImpl) {
3343 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3344 "DELETE FROM Users_Permissions WHERE permissionId = ?",
3345 new int[] { java.sql.Types.BIGINT });
3346 }
3347
3348 protected void clear(long permissionId) throws SystemException {
3349 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3350
3351 List<com.liferay.portal.model.User> users = null;
3352
3353 if ((listeners.length > 0) || (userListeners.length > 0)) {
3354 users = getUsers(permissionId);
3355
3356 for (com.liferay.portal.model.User user : users) {
3357 for (ModelListener<Permission> listener : listeners) {
3358 listener.onBeforeRemoveAssociation(permissionId,
3359 com.liferay.portal.model.User.class.getName(),
3360 user.getPrimaryKey());
3361 }
3362
3363 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3364 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
3365 Permission.class.getName(), permissionId);
3366 }
3367 }
3368 }
3369
3370 _sqlUpdate.update(new Object[] { new Long(permissionId) });
3371
3372 if ((listeners.length > 0) || (userListeners.length > 0)) {
3373 for (com.liferay.portal.model.User user : users) {
3374 for (ModelListener<Permission> listener : listeners) {
3375 listener.onAfterRemoveAssociation(permissionId,
3376 com.liferay.portal.model.User.class.getName(),
3377 user.getPrimaryKey());
3378 }
3379
3380 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3381 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
3382 Permission.class.getName(), permissionId);
3383 }
3384 }
3385 }
3386 }
3387
3388 private SqlUpdate _sqlUpdate;
3389 }
3390
3391 protected class RemoveUser {
3392 protected RemoveUser(PermissionPersistenceImpl persistenceImpl) {
3393 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3394 "DELETE FROM Users_Permissions WHERE permissionId = ? AND userId = ?",
3395 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3396 _persistenceImpl = persistenceImpl;
3397 }
3398
3399 protected void remove(long permissionId, long userId)
3400 throws SystemException {
3401 if (_persistenceImpl.containsUser.contains(permissionId, userId)) {
3402 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3403
3404 for (ModelListener<Permission> listener : listeners) {
3405 listener.onBeforeRemoveAssociation(permissionId,
3406 com.liferay.portal.model.User.class.getName(), userId);
3407 }
3408
3409 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3410 listener.onBeforeRemoveAssociation(userId,
3411 Permission.class.getName(), permissionId);
3412 }
3413
3414 _sqlUpdate.update(new Object[] {
3415 new Long(permissionId), new Long(userId)
3416 });
3417
3418 for (ModelListener<Permission> listener : listeners) {
3419 listener.onAfterRemoveAssociation(permissionId,
3420 com.liferay.portal.model.User.class.getName(), userId);
3421 }
3422
3423 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3424 listener.onAfterRemoveAssociation(userId,
3425 Permission.class.getName(), permissionId);
3426 }
3427 }
3428 }
3429
3430 private SqlUpdate _sqlUpdate;
3431 private PermissionPersistenceImpl _persistenceImpl;
3432 }
3433
3434 private static final String _SQL_SELECT_PERMISSION = "SELECT permission FROM Permission permission";
3435 private static final String _SQL_SELECT_PERMISSION_WHERE = "SELECT permission FROM Permission permission WHERE ";
3436 private static final String _SQL_COUNT_PERMISSION = "SELECT COUNT(permission) FROM Permission permission";
3437 private static final String _SQL_COUNT_PERMISSION_WHERE = "SELECT COUNT(permission) FROM Permission permission WHERE ";
3438 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Permissions ON (Groups_Permissions.groupId = Group_.groupId) WHERE (Groups_Permissions.permissionId = ?)";
3439 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE permissionId = ?";
3440 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE permissionId = ? AND groupId = ?";
3441 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Roles_Permissions ON (Roles_Permissions.roleId = Role_.roleId) WHERE (Roles_Permissions.permissionId = ?)";
3442 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE permissionId = ?";
3443 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE permissionId = ? AND roleId = ?";
3444 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Permissions ON (Users_Permissions.userId = User_.userId) WHERE (Users_Permissions.permissionId = ?)";
3445 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE permissionId = ?";
3446 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE permissionId = ? AND userId = ?";
3447 private static final String _FINDER_COLUMN_RESOURCEID_RESOURCEID_2 = "permission.resourceId = ?";
3448 private static final String _FINDER_COLUMN_A_R_ACTIONID_1 = "permission.actionId IS NULL AND ";
3449 private static final String _FINDER_COLUMN_A_R_ACTIONID_2 = "permission.actionId = ? AND ";
3450 private static final String _FINDER_COLUMN_A_R_ACTIONID_3 = "(permission.actionId IS NULL OR permission.actionId = ?) AND ";
3451 private static final String _FINDER_COLUMN_A_R_RESOURCEID_2 = "permission.resourceId = ?";
3452 private static final String _ORDER_BY_ENTITY_ALIAS = "permission.";
3453 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Permission exists with the primary key ";
3454 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Permission exists with the key {";
3455 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3456 private static Log _log = LogFactoryUtil.getLog(PermissionPersistenceImpl.class);
3457 private static Permission _nullPermission = new PermissionImpl() {
3458 @Override
3459 public Object clone() {
3460 return this;
3461 }
3462
3463 @Override
3464 public CacheModel<Permission> toCacheModel() {
3465 return _nullPermissionCacheModel;
3466 }
3467 };
3468
3469 private static CacheModel<Permission> _nullPermissionCacheModel = new CacheModel<Permission>() {
3470 public Permission toEntityModel() {
3471 return _nullPermission;
3472 }
3473 };
3474 }