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.annotation.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.kernel.util.Validator;
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
074 public class PermissionPersistenceImpl extends BasePersistenceImpl<Permission>
075 implements PermissionPersistence {
076 public static final String FINDER_CLASS_NAME_ENTITY = PermissionImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
078 ".List";
079 public static final FinderPath FINDER_PATH_FIND_BY_RESOURCEID = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
080 PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
081 "findByResourceId",
082 new String[] {
083 Long.class.getName(),
084
085 "java.lang.Integer", "java.lang.Integer",
086 "com.liferay.portal.kernel.util.OrderByComparator"
087 });
088 public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEID = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
089 PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
090 "countByResourceId", new String[] { Long.class.getName() });
091 public static final FinderPath FINDER_PATH_FETCH_BY_A_R = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
092 PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
093 "fetchByA_R",
094 new String[] { String.class.getName(), Long.class.getName() });
095 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
096 PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
097 "countByA_R",
098 new String[] { String.class.getName(), Long.class.getName() });
099 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
100 PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "findAll", new String[0]);
102 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
103 PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104 "countAll", new String[0]);
105
106
111 public void cacheResult(Permission permission) {
112 EntityCacheUtil.putResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
113 PermissionImpl.class, permission.getPrimaryKey(), permission);
114
115 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
116 new Object[] {
117 permission.getActionId(), new Long(permission.getResourceId())
118 }, permission);
119 }
120
121
126 public void cacheResult(List<Permission> permissions) {
127 for (Permission permission : permissions) {
128 if (EntityCacheUtil.getResult(
129 PermissionModelImpl.ENTITY_CACHE_ENABLED,
130 PermissionImpl.class, permission.getPrimaryKey(), this) == null) {
131 cacheResult(permission);
132 }
133 }
134 }
135
136
143 public void clearCache() {
144 CacheRegistryUtil.clear(PermissionImpl.class.getName());
145 EntityCacheUtil.clearCache(PermissionImpl.class.getName());
146 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
147 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
148 }
149
150
157 public void clearCache(Permission permission) {
158 EntityCacheUtil.removeResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
159 PermissionImpl.class, permission.getPrimaryKey());
160
161 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R,
162 new Object[] {
163 permission.getActionId(), new Long(permission.getResourceId())
164 });
165 }
166
167
173 public Permission create(long permissionId) {
174 Permission permission = new PermissionImpl();
175
176 permission.setNew(true);
177 permission.setPrimaryKey(permissionId);
178
179 return permission;
180 }
181
182
190 public Permission remove(Serializable primaryKey)
191 throws NoSuchModelException, SystemException {
192 return remove(((Long)primaryKey).longValue());
193 }
194
195
203 public Permission remove(long permissionId)
204 throws NoSuchPermissionException, SystemException {
205 Session session = null;
206
207 try {
208 session = openSession();
209
210 Permission permission = (Permission)session.get(PermissionImpl.class,
211 new Long(permissionId));
212
213 if (permission == null) {
214 if (_log.isWarnEnabled()) {
215 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + permissionId);
216 }
217
218 throw new NoSuchPermissionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
219 permissionId);
220 }
221
222 return remove(permission);
223 }
224 catch (NoSuchPermissionException nsee) {
225 throw nsee;
226 }
227 catch (Exception e) {
228 throw processException(e);
229 }
230 finally {
231 closeSession(session);
232 }
233 }
234
235 protected Permission removeImpl(Permission permission)
236 throws SystemException {
237 permission = toUnwrappedModel(permission);
238
239 try {
240 clearGroups.clear(permission.getPrimaryKey());
241 }
242 catch (Exception e) {
243 throw processException(e);
244 }
245 finally {
246 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
247 }
248
249 try {
250 clearRoles.clear(permission.getPrimaryKey());
251 }
252 catch (Exception e) {
253 throw processException(e);
254 }
255 finally {
256 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
257 }
258
259 try {
260 clearUsers.clear(permission.getPrimaryKey());
261 }
262 catch (Exception e) {
263 throw processException(e);
264 }
265 finally {
266 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
267 }
268
269 Session session = null;
270
271 try {
272 session = openSession();
273
274 if (permission.isCachedModel() || BatchSessionUtil.isEnabled()) {
275 Object staleObject = session.get(PermissionImpl.class,
276 permission.getPrimaryKeyObj());
277
278 if (staleObject != null) {
279 session.evict(staleObject);
280 }
281 }
282
283 session.delete(permission);
284
285 session.flush();
286 }
287 catch (Exception e) {
288 throw processException(e);
289 }
290 finally {
291 closeSession(session);
292 }
293
294 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
295
296 PermissionModelImpl permissionModelImpl = (PermissionModelImpl)permission;
297
298 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R,
299 new Object[] {
300 permissionModelImpl.getOriginalActionId(),
301 new Long(permissionModelImpl.getOriginalResourceId())
302 });
303
304 EntityCacheUtil.removeResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
305 PermissionImpl.class, permission.getPrimaryKey());
306
307 return permission;
308 }
309
310 public Permission updateImpl(
311 com.liferay.portal.model.Permission permission, boolean merge)
312 throws SystemException {
313 permission = toUnwrappedModel(permission);
314
315 boolean isNew = permission.isNew();
316
317 PermissionModelImpl permissionModelImpl = (PermissionModelImpl)permission;
318
319 Session session = null;
320
321 try {
322 session = openSession();
323
324 BatchSessionUtil.update(session, permission, merge);
325
326 permission.setNew(false);
327 }
328 catch (Exception e) {
329 throw processException(e);
330 }
331 finally {
332 closeSession(session);
333 }
334
335 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
336
337 EntityCacheUtil.putResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
338 PermissionImpl.class, permission.getPrimaryKey(), permission);
339
340 if (!isNew &&
341 (!Validator.equals(permission.getActionId(),
342 permissionModelImpl.getOriginalActionId()) ||
343 (permission.getResourceId() != permissionModelImpl.getOriginalResourceId()))) {
344 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R,
345 new Object[] {
346 permissionModelImpl.getOriginalActionId(),
347 new Long(permissionModelImpl.getOriginalResourceId())
348 });
349 }
350
351 if (isNew ||
352 (!Validator.equals(permission.getActionId(),
353 permissionModelImpl.getOriginalActionId()) ||
354 (permission.getResourceId() != permissionModelImpl.getOriginalResourceId()))) {
355 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
356 new Object[] {
357 permission.getActionId(),
358 new Long(permission.getResourceId())
359 }, permission);
360 }
361
362 return permission;
363 }
364
365 protected Permission toUnwrappedModel(Permission permission) {
366 if (permission instanceof PermissionImpl) {
367 return permission;
368 }
369
370 PermissionImpl permissionImpl = new PermissionImpl();
371
372 permissionImpl.setNew(permission.isNew());
373 permissionImpl.setPrimaryKey(permission.getPrimaryKey());
374
375 permissionImpl.setPermissionId(permission.getPermissionId());
376 permissionImpl.setCompanyId(permission.getCompanyId());
377 permissionImpl.setActionId(permission.getActionId());
378 permissionImpl.setResourceId(permission.getResourceId());
379
380 return permissionImpl;
381 }
382
383
391 public Permission findByPrimaryKey(Serializable primaryKey)
392 throws NoSuchModelException, SystemException {
393 return findByPrimaryKey(((Long)primaryKey).longValue());
394 }
395
396
404 public Permission findByPrimaryKey(long permissionId)
405 throws NoSuchPermissionException, SystemException {
406 Permission permission = fetchByPrimaryKey(permissionId);
407
408 if (permission == null) {
409 if (_log.isWarnEnabled()) {
410 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + permissionId);
411 }
412
413 throw new NoSuchPermissionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
414 permissionId);
415 }
416
417 return permission;
418 }
419
420
427 public Permission fetchByPrimaryKey(Serializable primaryKey)
428 throws SystemException {
429 return fetchByPrimaryKey(((Long)primaryKey).longValue());
430 }
431
432
439 public Permission fetchByPrimaryKey(long permissionId)
440 throws SystemException {
441 Permission permission = (Permission)EntityCacheUtil.getResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
442 PermissionImpl.class, permissionId, this);
443
444 if (permission == null) {
445 Session session = null;
446
447 try {
448 session = openSession();
449
450 permission = (Permission)session.get(PermissionImpl.class,
451 new Long(permissionId));
452 }
453 catch (Exception e) {
454 throw processException(e);
455 }
456 finally {
457 if (permission != null) {
458 cacheResult(permission);
459 }
460
461 closeSession(session);
462 }
463 }
464
465 return permission;
466 }
467
468
475 public List<Permission> findByResourceId(long resourceId)
476 throws SystemException {
477 return findByResourceId(resourceId, QueryUtil.ALL_POS,
478 QueryUtil.ALL_POS, null);
479 }
480
481
494 public List<Permission> findByResourceId(long resourceId, int start, int end)
495 throws SystemException {
496 return findByResourceId(resourceId, start, end, null);
497 }
498
499
513 public List<Permission> findByResourceId(long resourceId, int start,
514 int end, OrderByComparator orderByComparator) throws SystemException {
515 Object[] finderArgs = new Object[] {
516 resourceId,
517
518 String.valueOf(start), String.valueOf(end),
519 String.valueOf(orderByComparator)
520 };
521
522 List<Permission> list = (List<Permission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_RESOURCEID,
523 finderArgs, this);
524
525 if (list == null) {
526 Session session = null;
527
528 try {
529 session = openSession();
530
531 StringBundler query = null;
532
533 if (orderByComparator != null) {
534 query = new StringBundler(3 +
535 (orderByComparator.getOrderByFields().length * 3));
536 }
537 else {
538 query = new StringBundler(2);
539 }
540
541 query.append(_SQL_SELECT_PERMISSION_WHERE);
542
543 query.append(_FINDER_COLUMN_RESOURCEID_RESOURCEID_2);
544
545 if (orderByComparator != null) {
546 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
547 orderByComparator);
548 }
549
550 String sql = query.toString();
551
552 Query q = session.createQuery(sql);
553
554 QueryPos qPos = QueryPos.getInstance(q);
555
556 qPos.add(resourceId);
557
558 list = (List<Permission>)QueryUtil.list(q, getDialect(), start,
559 end);
560 }
561 catch (Exception e) {
562 throw processException(e);
563 }
564 finally {
565 if (list == null) {
566 list = new ArrayList<Permission>();
567 }
568
569 cacheResult(list);
570
571 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_RESOURCEID,
572 finderArgs, list);
573
574 closeSession(session);
575 }
576 }
577
578 return list;
579 }
580
581
594 public Permission findByResourceId_First(long resourceId,
595 OrderByComparator orderByComparator)
596 throws NoSuchPermissionException, SystemException {
597 List<Permission> list = findByResourceId(resourceId, 0, 1,
598 orderByComparator);
599
600 if (list.isEmpty()) {
601 StringBundler msg = new StringBundler(4);
602
603 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
604
605 msg.append("resourceId=");
606 msg.append(resourceId);
607
608 msg.append(StringPool.CLOSE_CURLY_BRACE);
609
610 throw new NoSuchPermissionException(msg.toString());
611 }
612 else {
613 return list.get(0);
614 }
615 }
616
617
630 public Permission findByResourceId_Last(long resourceId,
631 OrderByComparator orderByComparator)
632 throws NoSuchPermissionException, SystemException {
633 int count = countByResourceId(resourceId);
634
635 List<Permission> list = findByResourceId(resourceId, count - 1, count,
636 orderByComparator);
637
638 if (list.isEmpty()) {
639 StringBundler msg = new StringBundler(4);
640
641 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
642
643 msg.append("resourceId=");
644 msg.append(resourceId);
645
646 msg.append(StringPool.CLOSE_CURLY_BRACE);
647
648 throw new NoSuchPermissionException(msg.toString());
649 }
650 else {
651 return list.get(0);
652 }
653 }
654
655
669 public Permission[] findByResourceId_PrevAndNext(long permissionId,
670 long resourceId, OrderByComparator orderByComparator)
671 throws NoSuchPermissionException, SystemException {
672 Permission permission = findByPrimaryKey(permissionId);
673
674 Session session = null;
675
676 try {
677 session = openSession();
678
679 Permission[] array = new PermissionImpl[3];
680
681 array[0] = getByResourceId_PrevAndNext(session, permission,
682 resourceId, orderByComparator, true);
683
684 array[1] = permission;
685
686 array[2] = getByResourceId_PrevAndNext(session, permission,
687 resourceId, orderByComparator, false);
688
689 return array;
690 }
691 catch (Exception e) {
692 throw processException(e);
693 }
694 finally {
695 closeSession(session);
696 }
697 }
698
699 protected Permission getByResourceId_PrevAndNext(Session session,
700 Permission permission, long resourceId,
701 OrderByComparator orderByComparator, boolean previous) {
702 StringBundler query = null;
703
704 if (orderByComparator != null) {
705 query = new StringBundler(6 +
706 (orderByComparator.getOrderByFields().length * 6));
707 }
708 else {
709 query = new StringBundler(3);
710 }
711
712 query.append(_SQL_SELECT_PERMISSION_WHERE);
713
714 query.append(_FINDER_COLUMN_RESOURCEID_RESOURCEID_2);
715
716 if (orderByComparator != null) {
717 String[] orderByFields = orderByComparator.getOrderByFields();
718
719 if (orderByFields.length > 0) {
720 query.append(WHERE_AND);
721 }
722
723 for (int i = 0; i < orderByFields.length; i++) {
724 query.append(_ORDER_BY_ENTITY_ALIAS);
725 query.append(orderByFields[i]);
726
727 if ((i + 1) < orderByFields.length) {
728 if (orderByComparator.isAscending() ^ previous) {
729 query.append(WHERE_GREATER_THAN_HAS_NEXT);
730 }
731 else {
732 query.append(WHERE_LESSER_THAN_HAS_NEXT);
733 }
734 }
735 else {
736 if (orderByComparator.isAscending() ^ previous) {
737 query.append(WHERE_GREATER_THAN);
738 }
739 else {
740 query.append(WHERE_LESSER_THAN);
741 }
742 }
743 }
744
745 query.append(ORDER_BY_CLAUSE);
746
747 for (int i = 0; i < orderByFields.length; i++) {
748 query.append(_ORDER_BY_ENTITY_ALIAS);
749 query.append(orderByFields[i]);
750
751 if ((i + 1) < orderByFields.length) {
752 if (orderByComparator.isAscending() ^ previous) {
753 query.append(ORDER_BY_ASC_HAS_NEXT);
754 }
755 else {
756 query.append(ORDER_BY_DESC_HAS_NEXT);
757 }
758 }
759 else {
760 if (orderByComparator.isAscending() ^ previous) {
761 query.append(ORDER_BY_ASC);
762 }
763 else {
764 query.append(ORDER_BY_DESC);
765 }
766 }
767 }
768 }
769
770 String sql = query.toString();
771
772 Query q = session.createQuery(sql);
773
774 q.setFirstResult(0);
775 q.setMaxResults(2);
776
777 QueryPos qPos = QueryPos.getInstance(q);
778
779 qPos.add(resourceId);
780
781 if (orderByComparator != null) {
782 Object[] values = orderByComparator.getOrderByValues(permission);
783
784 for (Object value : values) {
785 qPos.add(value);
786 }
787 }
788
789 List<Permission> list = q.list();
790
791 if (list.size() == 2) {
792 return list.get(1);
793 }
794 else {
795 return null;
796 }
797 }
798
799
808 public Permission findByA_R(String actionId, long resourceId)
809 throws NoSuchPermissionException, SystemException {
810 Permission permission = fetchByA_R(actionId, resourceId);
811
812 if (permission == null) {
813 StringBundler msg = new StringBundler(6);
814
815 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
816
817 msg.append("actionId=");
818 msg.append(actionId);
819
820 msg.append(", resourceId=");
821 msg.append(resourceId);
822
823 msg.append(StringPool.CLOSE_CURLY_BRACE);
824
825 if (_log.isWarnEnabled()) {
826 _log.warn(msg.toString());
827 }
828
829 throw new NoSuchPermissionException(msg.toString());
830 }
831
832 return permission;
833 }
834
835
843 public Permission fetchByA_R(String actionId, long resourceId)
844 throws SystemException {
845 return fetchByA_R(actionId, resourceId, true);
846 }
847
848
856 public Permission fetchByA_R(String actionId, long resourceId,
857 boolean retrieveFromCache) throws SystemException {
858 Object[] finderArgs = new Object[] { actionId, resourceId };
859
860 Object result = null;
861
862 if (retrieveFromCache) {
863 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_A_R,
864 finderArgs, this);
865 }
866
867 if (result == null) {
868 Session session = null;
869
870 try {
871 session = openSession();
872
873 StringBundler query = new StringBundler(3);
874
875 query.append(_SQL_SELECT_PERMISSION_WHERE);
876
877 if (actionId == null) {
878 query.append(_FINDER_COLUMN_A_R_ACTIONID_1);
879 }
880 else {
881 if (actionId.equals(StringPool.BLANK)) {
882 query.append(_FINDER_COLUMN_A_R_ACTIONID_3);
883 }
884 else {
885 query.append(_FINDER_COLUMN_A_R_ACTIONID_2);
886 }
887 }
888
889 query.append(_FINDER_COLUMN_A_R_RESOURCEID_2);
890
891 String sql = query.toString();
892
893 Query q = session.createQuery(sql);
894
895 QueryPos qPos = QueryPos.getInstance(q);
896
897 if (actionId != null) {
898 qPos.add(actionId);
899 }
900
901 qPos.add(resourceId);
902
903 List<Permission> list = q.list();
904
905 result = list;
906
907 Permission permission = null;
908
909 if (list.isEmpty()) {
910 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
911 finderArgs, list);
912 }
913 else {
914 permission = list.get(0);
915
916 cacheResult(permission);
917
918 if ((permission.getActionId() == null) ||
919 !permission.getActionId().equals(actionId) ||
920 (permission.getResourceId() != resourceId)) {
921 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
922 finderArgs, permission);
923 }
924 }
925
926 return permission;
927 }
928 catch (Exception e) {
929 throw processException(e);
930 }
931 finally {
932 if (result == null) {
933 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
934 finderArgs, new ArrayList<Permission>());
935 }
936
937 closeSession(session);
938 }
939 }
940 else {
941 if (result instanceof List<?>) {
942 return null;
943 }
944 else {
945 return (Permission)result;
946 }
947 }
948 }
949
950
956 public List<Permission> findAll() throws SystemException {
957 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
958 }
959
960
972 public List<Permission> findAll(int start, int end)
973 throws SystemException {
974 return findAll(start, end, null);
975 }
976
977
990 public List<Permission> findAll(int start, int end,
991 OrderByComparator orderByComparator) throws SystemException {
992 Object[] finderArgs = new Object[] {
993 String.valueOf(start), String.valueOf(end),
994 String.valueOf(orderByComparator)
995 };
996
997 List<Permission> list = (List<Permission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
998 finderArgs, this);
999
1000 if (list == null) {
1001 Session session = null;
1002
1003 try {
1004 session = openSession();
1005
1006 StringBundler query = null;
1007 String sql = null;
1008
1009 if (orderByComparator != null) {
1010 query = new StringBundler(2 +
1011 (orderByComparator.getOrderByFields().length * 3));
1012
1013 query.append(_SQL_SELECT_PERMISSION);
1014
1015 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1016 orderByComparator);
1017
1018 sql = query.toString();
1019 }
1020 else {
1021 sql = _SQL_SELECT_PERMISSION;
1022 }
1023
1024 Query q = session.createQuery(sql);
1025
1026 if (orderByComparator == null) {
1027 list = (List<Permission>)QueryUtil.list(q, getDialect(),
1028 start, end, false);
1029
1030 Collections.sort(list);
1031 }
1032 else {
1033 list = (List<Permission>)QueryUtil.list(q, getDialect(),
1034 start, end);
1035 }
1036 }
1037 catch (Exception e) {
1038 throw processException(e);
1039 }
1040 finally {
1041 if (list == null) {
1042 list = new ArrayList<Permission>();
1043 }
1044
1045 cacheResult(list);
1046
1047 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1048
1049 closeSession(session);
1050 }
1051 }
1052
1053 return list;
1054 }
1055
1056
1062 public void removeByResourceId(long resourceId) throws SystemException {
1063 for (Permission permission : findByResourceId(resourceId)) {
1064 remove(permission);
1065 }
1066 }
1067
1068
1075 public void removeByA_R(String actionId, long resourceId)
1076 throws NoSuchPermissionException, SystemException {
1077 Permission permission = findByA_R(actionId, resourceId);
1078
1079 remove(permission);
1080 }
1081
1082
1087 public void removeAll() throws SystemException {
1088 for (Permission permission : findAll()) {
1089 remove(permission);
1090 }
1091 }
1092
1093
1100 public int countByResourceId(long resourceId) throws SystemException {
1101 Object[] finderArgs = new Object[] { resourceId };
1102
1103 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEID,
1104 finderArgs, this);
1105
1106 if (count == null) {
1107 Session session = null;
1108
1109 try {
1110 session = openSession();
1111
1112 StringBundler query = new StringBundler(2);
1113
1114 query.append(_SQL_COUNT_PERMISSION_WHERE);
1115
1116 query.append(_FINDER_COLUMN_RESOURCEID_RESOURCEID_2);
1117
1118 String sql = query.toString();
1119
1120 Query q = session.createQuery(sql);
1121
1122 QueryPos qPos = QueryPos.getInstance(q);
1123
1124 qPos.add(resourceId);
1125
1126 count = (Long)q.uniqueResult();
1127 }
1128 catch (Exception e) {
1129 throw processException(e);
1130 }
1131 finally {
1132 if (count == null) {
1133 count = Long.valueOf(0);
1134 }
1135
1136 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEID,
1137 finderArgs, count);
1138
1139 closeSession(session);
1140 }
1141 }
1142
1143 return count.intValue();
1144 }
1145
1146
1154 public int countByA_R(String actionId, long resourceId)
1155 throws SystemException {
1156 Object[] finderArgs = new Object[] { actionId, resourceId };
1157
1158 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
1159 finderArgs, this);
1160
1161 if (count == null) {
1162 Session session = null;
1163
1164 try {
1165 session = openSession();
1166
1167 StringBundler query = new StringBundler(3);
1168
1169 query.append(_SQL_COUNT_PERMISSION_WHERE);
1170
1171 if (actionId == null) {
1172 query.append(_FINDER_COLUMN_A_R_ACTIONID_1);
1173 }
1174 else {
1175 if (actionId.equals(StringPool.BLANK)) {
1176 query.append(_FINDER_COLUMN_A_R_ACTIONID_3);
1177 }
1178 else {
1179 query.append(_FINDER_COLUMN_A_R_ACTIONID_2);
1180 }
1181 }
1182
1183 query.append(_FINDER_COLUMN_A_R_RESOURCEID_2);
1184
1185 String sql = query.toString();
1186
1187 Query q = session.createQuery(sql);
1188
1189 QueryPos qPos = QueryPos.getInstance(q);
1190
1191 if (actionId != null) {
1192 qPos.add(actionId);
1193 }
1194
1195 qPos.add(resourceId);
1196
1197 count = (Long)q.uniqueResult();
1198 }
1199 catch (Exception e) {
1200 throw processException(e);
1201 }
1202 finally {
1203 if (count == null) {
1204 count = Long.valueOf(0);
1205 }
1206
1207 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
1208 count);
1209
1210 closeSession(session);
1211 }
1212 }
1213
1214 return count.intValue();
1215 }
1216
1217
1223 public int countAll() throws SystemException {
1224 Object[] finderArgs = new Object[0];
1225
1226 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1227 finderArgs, this);
1228
1229 if (count == null) {
1230 Session session = null;
1231
1232 try {
1233 session = openSession();
1234
1235 Query q = session.createQuery(_SQL_COUNT_PERMISSION);
1236
1237 count = (Long)q.uniqueResult();
1238 }
1239 catch (Exception e) {
1240 throw processException(e);
1241 }
1242 finally {
1243 if (count == null) {
1244 count = Long.valueOf(0);
1245 }
1246
1247 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1248 count);
1249
1250 closeSession(session);
1251 }
1252 }
1253
1254 return count.intValue();
1255 }
1256
1257
1264 public List<com.liferay.portal.model.Group> getGroups(long pk)
1265 throws SystemException {
1266 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1267 }
1268
1269
1282 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1283 int end) throws SystemException {
1284 return getGroups(pk, start, end, null);
1285 }
1286
1287 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1288 PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1289 PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
1290 "getGroups",
1291 new String[] {
1292 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1293 "com.liferay.portal.kernel.util.OrderByComparator"
1294 });
1295
1296
1310 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1311 int end, OrderByComparator orderByComparator) throws SystemException {
1312 Object[] finderArgs = new Object[] {
1313 pk, String.valueOf(start), String.valueOf(end),
1314 String.valueOf(orderByComparator)
1315 };
1316
1317 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
1318 finderArgs, this);
1319
1320 if (list == null) {
1321 Session session = null;
1322
1323 try {
1324 session = openSession();
1325
1326 String sql = null;
1327
1328 if (orderByComparator != null) {
1329 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
1330 .concat(orderByComparator.getOrderBy());
1331 }
1332 else {
1333 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
1334 }
1335
1336 SQLQuery q = session.createSQLQuery(sql);
1337
1338 q.addEntity("Group_",
1339 com.liferay.portal.model.impl.GroupImpl.class);
1340
1341 QueryPos qPos = QueryPos.getInstance(q);
1342
1343 qPos.add(pk);
1344
1345 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
1346 getDialect(), start, end);
1347 }
1348 catch (Exception e) {
1349 throw processException(e);
1350 }
1351 finally {
1352 if (list == null) {
1353 list = new ArrayList<com.liferay.portal.model.Group>();
1354 }
1355
1356 groupPersistence.cacheResult(list);
1357
1358 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
1359 list);
1360
1361 closeSession(session);
1362 }
1363 }
1364
1365 return list;
1366 }
1367
1368 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1369 PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1370 PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
1371 "getGroupsSize", new String[] { Long.class.getName() });
1372
1373
1380 public int getGroupsSize(long pk) throws SystemException {
1381 Object[] finderArgs = new Object[] { pk };
1382
1383 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
1384 finderArgs, this);
1385
1386 if (count == null) {
1387 Session session = null;
1388
1389 try {
1390 session = openSession();
1391
1392 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
1393
1394 q.addScalar(COUNT_COLUMN_NAME,
1395 com.liferay.portal.kernel.dao.orm.Type.LONG);
1396
1397 QueryPos qPos = QueryPos.getInstance(q);
1398
1399 qPos.add(pk);
1400
1401 count = (Long)q.uniqueResult();
1402 }
1403 catch (Exception e) {
1404 throw processException(e);
1405 }
1406 finally {
1407 if (count == null) {
1408 count = Long.valueOf(0);
1409 }
1410
1411 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
1412 finderArgs, count);
1413
1414 closeSession(session);
1415 }
1416 }
1417
1418 return count.intValue();
1419 }
1420
1421 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1422 PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1423 PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
1424 "containsGroup",
1425 new String[] { Long.class.getName(), Long.class.getName() });
1426
1427
1435 public boolean containsGroup(long pk, long groupPK)
1436 throws SystemException {
1437 Object[] finderArgs = new Object[] { pk, groupPK };
1438
1439 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
1440 finderArgs, this);
1441
1442 if (value == null) {
1443 try {
1444 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
1445 }
1446 catch (Exception e) {
1447 throw processException(e);
1448 }
1449 finally {
1450 if (value == null) {
1451 value = Boolean.FALSE;
1452 }
1453
1454 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
1455 finderArgs, value);
1456 }
1457 }
1458
1459 return value.booleanValue();
1460 }
1461
1462
1469 public boolean containsGroups(long pk) throws SystemException {
1470 if (getGroupsSize(pk) > 0) {
1471 return true;
1472 }
1473 else {
1474 return false;
1475 }
1476 }
1477
1478
1485 public void addGroup(long pk, long groupPK) throws SystemException {
1486 try {
1487 addGroup.add(pk, groupPK);
1488 }
1489 catch (Exception e) {
1490 throw processException(e);
1491 }
1492 finally {
1493 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1494 }
1495 }
1496
1497
1504 public void addGroup(long pk, com.liferay.portal.model.Group group)
1505 throws SystemException {
1506 try {
1507 addGroup.add(pk, group.getPrimaryKey());
1508 }
1509 catch (Exception e) {
1510 throw processException(e);
1511 }
1512 finally {
1513 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1514 }
1515 }
1516
1517
1524 public void addGroups(long pk, long[] groupPKs) throws SystemException {
1525 try {
1526 for (long groupPK : groupPKs) {
1527 addGroup.add(pk, groupPK);
1528 }
1529 }
1530 catch (Exception e) {
1531 throw processException(e);
1532 }
1533 finally {
1534 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1535 }
1536 }
1537
1538
1545 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
1546 throws SystemException {
1547 try {
1548 for (com.liferay.portal.model.Group group : groups) {
1549 addGroup.add(pk, group.getPrimaryKey());
1550 }
1551 }
1552 catch (Exception e) {
1553 throw processException(e);
1554 }
1555 finally {
1556 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1557 }
1558 }
1559
1560
1566 public void clearGroups(long pk) throws SystemException {
1567 try {
1568 clearGroups.clear(pk);
1569 }
1570 catch (Exception e) {
1571 throw processException(e);
1572 }
1573 finally {
1574 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1575 }
1576 }
1577
1578
1585 public void removeGroup(long pk, long groupPK) throws SystemException {
1586 try {
1587 removeGroup.remove(pk, groupPK);
1588 }
1589 catch (Exception e) {
1590 throw processException(e);
1591 }
1592 finally {
1593 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1594 }
1595 }
1596
1597
1604 public void removeGroup(long pk, com.liferay.portal.model.Group group)
1605 throws SystemException {
1606 try {
1607 removeGroup.remove(pk, group.getPrimaryKey());
1608 }
1609 catch (Exception e) {
1610 throw processException(e);
1611 }
1612 finally {
1613 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1614 }
1615 }
1616
1617
1624 public void removeGroups(long pk, long[] groupPKs)
1625 throws SystemException {
1626 try {
1627 for (long groupPK : groupPKs) {
1628 removeGroup.remove(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 removeGroups(long pk,
1647 List<com.liferay.portal.model.Group> groups) throws SystemException {
1648 try {
1649 for (com.liferay.portal.model.Group group : groups) {
1650 removeGroup.remove(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
1668 public void setGroups(long pk, long[] groupPKs) throws SystemException {
1669 try {
1670 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
1671
1672 List<com.liferay.portal.model.Group> groups = getGroups(pk);
1673
1674 for (com.liferay.portal.model.Group group : groups) {
1675 if (!groupPKSet.remove(group.getPrimaryKey())) {
1676 removeGroup.remove(pk, group.getPrimaryKey());
1677 }
1678 }
1679
1680 for (Long groupPK : groupPKSet) {
1681 addGroup.add(pk, groupPK);
1682 }
1683 }
1684 catch (Exception e) {
1685 throw processException(e);
1686 }
1687 finally {
1688 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1689 }
1690 }
1691
1692
1699 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
1700 throws SystemException {
1701 try {
1702 long[] groupPKs = new long[groups.size()];
1703
1704 for (int i = 0; i < groups.size(); i++) {
1705 com.liferay.portal.model.Group group = groups.get(i);
1706
1707 groupPKs[i] = group.getPrimaryKey();
1708 }
1709
1710 setGroups(pk, groupPKs);
1711 }
1712 catch (Exception e) {
1713 throw processException(e);
1714 }
1715 finally {
1716 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
1717 }
1718 }
1719
1720
1727 public List<com.liferay.portal.model.Role> getRoles(long pk)
1728 throws SystemException {
1729 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1730 }
1731
1732
1745 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
1746 int end) throws SystemException {
1747 return getRoles(pk, start, end, null);
1748 }
1749
1750 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1751 PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1752 PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
1753 "getRoles",
1754 new String[] {
1755 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1756 "com.liferay.portal.kernel.util.OrderByComparator"
1757 });
1758
1759
1773 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
1774 int end, OrderByComparator orderByComparator) throws SystemException {
1775 Object[] finderArgs = new Object[] {
1776 pk, String.valueOf(start), String.valueOf(end),
1777 String.valueOf(orderByComparator)
1778 };
1779
1780 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
1781 finderArgs, this);
1782
1783 if (list == null) {
1784 Session session = null;
1785
1786 try {
1787 session = openSession();
1788
1789 String sql = null;
1790
1791 if (orderByComparator != null) {
1792 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
1793 .concat(orderByComparator.getOrderBy());
1794 }
1795 else {
1796 sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
1797 }
1798
1799 SQLQuery q = session.createSQLQuery(sql);
1800
1801 q.addEntity("Role_",
1802 com.liferay.portal.model.impl.RoleImpl.class);
1803
1804 QueryPos qPos = QueryPos.getInstance(q);
1805
1806 qPos.add(pk);
1807
1808 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
1809 getDialect(), start, end);
1810 }
1811 catch (Exception e) {
1812 throw processException(e);
1813 }
1814 finally {
1815 if (list == null) {
1816 list = new ArrayList<com.liferay.portal.model.Role>();
1817 }
1818
1819 rolePersistence.cacheResult(list);
1820
1821 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
1822 list);
1823
1824 closeSession(session);
1825 }
1826 }
1827
1828 return list;
1829 }
1830
1831 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1832 PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1833 PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
1834 "getRolesSize", new String[] { Long.class.getName() });
1835
1836
1843 public int getRolesSize(long pk) throws SystemException {
1844 Object[] finderArgs = new Object[] { pk };
1845
1846 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
1847 finderArgs, this);
1848
1849 if (count == null) {
1850 Session session = null;
1851
1852 try {
1853 session = openSession();
1854
1855 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
1856
1857 q.addScalar(COUNT_COLUMN_NAME,
1858 com.liferay.portal.kernel.dao.orm.Type.LONG);
1859
1860 QueryPos qPos = QueryPos.getInstance(q);
1861
1862 qPos.add(pk);
1863
1864 count = (Long)q.uniqueResult();
1865 }
1866 catch (Exception e) {
1867 throw processException(e);
1868 }
1869 finally {
1870 if (count == null) {
1871 count = Long.valueOf(0);
1872 }
1873
1874 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
1875 finderArgs, count);
1876
1877 closeSession(session);
1878 }
1879 }
1880
1881 return count.intValue();
1882 }
1883
1884 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1885 PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1886 PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
1887 "containsRole",
1888 new String[] { Long.class.getName(), Long.class.getName() });
1889
1890
1898 public boolean containsRole(long pk, long rolePK) throws SystemException {
1899 Object[] finderArgs = new Object[] { pk, rolePK };
1900
1901 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
1902 finderArgs, this);
1903
1904 if (value == null) {
1905 try {
1906 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
1907 }
1908 catch (Exception e) {
1909 throw processException(e);
1910 }
1911 finally {
1912 if (value == null) {
1913 value = Boolean.FALSE;
1914 }
1915
1916 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
1917 finderArgs, value);
1918 }
1919 }
1920
1921 return value.booleanValue();
1922 }
1923
1924
1931 public boolean containsRoles(long pk) throws SystemException {
1932 if (getRolesSize(pk) > 0) {
1933 return true;
1934 }
1935 else {
1936 return false;
1937 }
1938 }
1939
1940
1947 public void addRole(long pk, long rolePK) throws SystemException {
1948 try {
1949 addRole.add(pk, rolePK);
1950 }
1951 catch (Exception e) {
1952 throw processException(e);
1953 }
1954 finally {
1955 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
1956 }
1957 }
1958
1959
1966 public void addRole(long pk, com.liferay.portal.model.Role role)
1967 throws SystemException {
1968 try {
1969 addRole.add(pk, role.getPrimaryKey());
1970 }
1971 catch (Exception e) {
1972 throw processException(e);
1973 }
1974 finally {
1975 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
1976 }
1977 }
1978
1979
1986 public void addRoles(long pk, long[] rolePKs) throws SystemException {
1987 try {
1988 for (long rolePK : rolePKs) {
1989 addRole.add(pk, rolePK);
1990 }
1991 }
1992 catch (Exception e) {
1993 throw processException(e);
1994 }
1995 finally {
1996 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
1997 }
1998 }
1999
2000
2007 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
2008 throws SystemException {
2009 try {
2010 for (com.liferay.portal.model.Role role : roles) {
2011 addRole.add(pk, role.getPrimaryKey());
2012 }
2013 }
2014 catch (Exception e) {
2015 throw processException(e);
2016 }
2017 finally {
2018 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2019 }
2020 }
2021
2022
2028 public void clearRoles(long pk) throws SystemException {
2029 try {
2030 clearRoles.clear(pk);
2031 }
2032 catch (Exception e) {
2033 throw processException(e);
2034 }
2035 finally {
2036 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2037 }
2038 }
2039
2040
2047 public void removeRole(long pk, long rolePK) throws SystemException {
2048 try {
2049 removeRole.remove(pk, rolePK);
2050 }
2051 catch (Exception e) {
2052 throw processException(e);
2053 }
2054 finally {
2055 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2056 }
2057 }
2058
2059
2066 public void removeRole(long pk, com.liferay.portal.model.Role role)
2067 throws SystemException {
2068 try {
2069 removeRole.remove(pk, role.getPrimaryKey());
2070 }
2071 catch (Exception e) {
2072 throw processException(e);
2073 }
2074 finally {
2075 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2076 }
2077 }
2078
2079
2086 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
2087 try {
2088 for (long rolePK : rolePKs) {
2089 removeRole.remove(pk, rolePK);
2090 }
2091 }
2092 catch (Exception e) {
2093 throw processException(e);
2094 }
2095 finally {
2096 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2097 }
2098 }
2099
2100
2107 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
2108 throws SystemException {
2109 try {
2110 for (com.liferay.portal.model.Role role : roles) {
2111 removeRole.remove(pk, role.getPrimaryKey());
2112 }
2113 }
2114 catch (Exception e) {
2115 throw processException(e);
2116 }
2117 finally {
2118 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2119 }
2120 }
2121
2122
2129 public void setRoles(long pk, long[] rolePKs) throws SystemException {
2130 try {
2131 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
2132
2133 List<com.liferay.portal.model.Role> roles = getRoles(pk);
2134
2135 for (com.liferay.portal.model.Role role : roles) {
2136 if (!rolePKSet.remove(role.getPrimaryKey())) {
2137 removeRole.remove(pk, role.getPrimaryKey());
2138 }
2139 }
2140
2141 for (Long rolePK : rolePKSet) {
2142 addRole.add(pk, rolePK);
2143 }
2144 }
2145 catch (Exception e) {
2146 throw processException(e);
2147 }
2148 finally {
2149 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2150 }
2151 }
2152
2153
2160 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
2161 throws SystemException {
2162 try {
2163 long[] rolePKs = new long[roles.size()];
2164
2165 for (int i = 0; i < roles.size(); i++) {
2166 com.liferay.portal.model.Role role = roles.get(i);
2167
2168 rolePKs[i] = role.getPrimaryKey();
2169 }
2170
2171 setRoles(pk, rolePKs);
2172 }
2173 catch (Exception e) {
2174 throw processException(e);
2175 }
2176 finally {
2177 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2178 }
2179 }
2180
2181
2188 public List<com.liferay.portal.model.User> getUsers(long pk)
2189 throws SystemException {
2190 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2191 }
2192
2193
2206 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2207 int end) throws SystemException {
2208 return getUsers(pk, start, end, null);
2209 }
2210
2211 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2212 PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
2213 PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
2214 "getUsers",
2215 new String[] {
2216 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2217 "com.liferay.portal.kernel.util.OrderByComparator"
2218 });
2219
2220
2234 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2235 int end, OrderByComparator orderByComparator) throws SystemException {
2236 Object[] finderArgs = new Object[] {
2237 pk, String.valueOf(start), String.valueOf(end),
2238 String.valueOf(orderByComparator)
2239 };
2240
2241 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
2242 finderArgs, this);
2243
2244 if (list == null) {
2245 Session session = null;
2246
2247 try {
2248 session = openSession();
2249
2250 String sql = null;
2251
2252 if (orderByComparator != null) {
2253 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
2254 .concat(orderByComparator.getOrderBy());
2255 }
2256 else {
2257 sql = _SQL_GETUSERS;
2258 }
2259
2260 SQLQuery q = session.createSQLQuery(sql);
2261
2262 q.addEntity("User_",
2263 com.liferay.portal.model.impl.UserImpl.class);
2264
2265 QueryPos qPos = QueryPos.getInstance(q);
2266
2267 qPos.add(pk);
2268
2269 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
2270 getDialect(), start, end);
2271 }
2272 catch (Exception e) {
2273 throw processException(e);
2274 }
2275 finally {
2276 if (list == null) {
2277 list = new ArrayList<com.liferay.portal.model.User>();
2278 }
2279
2280 userPersistence.cacheResult(list);
2281
2282 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
2283 list);
2284
2285 closeSession(session);
2286 }
2287 }
2288
2289 return list;
2290 }
2291
2292 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2293 PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
2294 PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
2295 "getUsersSize", new String[] { Long.class.getName() });
2296
2297
2304 public int getUsersSize(long pk) throws SystemException {
2305 Object[] finderArgs = new Object[] { pk };
2306
2307 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
2308 finderArgs, this);
2309
2310 if (count == null) {
2311 Session session = null;
2312
2313 try {
2314 session = openSession();
2315
2316 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
2317
2318 q.addScalar(COUNT_COLUMN_NAME,
2319 com.liferay.portal.kernel.dao.orm.Type.LONG);
2320
2321 QueryPos qPos = QueryPos.getInstance(q);
2322
2323 qPos.add(pk);
2324
2325 count = (Long)q.uniqueResult();
2326 }
2327 catch (Exception e) {
2328 throw processException(e);
2329 }
2330 finally {
2331 if (count == null) {
2332 count = Long.valueOf(0);
2333 }
2334
2335 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
2336 finderArgs, count);
2337
2338 closeSession(session);
2339 }
2340 }
2341
2342 return count.intValue();
2343 }
2344
2345 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2346 PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
2347 PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
2348 "containsUser",
2349 new String[] { Long.class.getName(), Long.class.getName() });
2350
2351
2359 public boolean containsUser(long pk, long userPK) throws SystemException {
2360 Object[] finderArgs = new Object[] { pk, userPK };
2361
2362 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
2363 finderArgs, this);
2364
2365 if (value == null) {
2366 try {
2367 value = Boolean.valueOf(containsUser.contains(pk, userPK));
2368 }
2369 catch (Exception e) {
2370 throw processException(e);
2371 }
2372 finally {
2373 if (value == null) {
2374 value = Boolean.FALSE;
2375 }
2376
2377 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
2378 finderArgs, value);
2379 }
2380 }
2381
2382 return value.booleanValue();
2383 }
2384
2385
2392 public boolean containsUsers(long pk) throws SystemException {
2393 if (getUsersSize(pk) > 0) {
2394 return true;
2395 }
2396 else {
2397 return false;
2398 }
2399 }
2400
2401
2408 public void addUser(long pk, long userPK) throws SystemException {
2409 try {
2410 addUser.add(pk, userPK);
2411 }
2412 catch (Exception e) {
2413 throw processException(e);
2414 }
2415 finally {
2416 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2417 }
2418 }
2419
2420
2427 public void addUser(long pk, com.liferay.portal.model.User user)
2428 throws SystemException {
2429 try {
2430 addUser.add(pk, user.getPrimaryKey());
2431 }
2432 catch (Exception e) {
2433 throw processException(e);
2434 }
2435 finally {
2436 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2437 }
2438 }
2439
2440
2447 public void addUsers(long pk, long[] userPKs) throws SystemException {
2448 try {
2449 for (long userPK : userPKs) {
2450 addUser.add(pk, userPK);
2451 }
2452 }
2453 catch (Exception e) {
2454 throw processException(e);
2455 }
2456 finally {
2457 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2458 }
2459 }
2460
2461
2468 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
2469 throws SystemException {
2470 try {
2471 for (com.liferay.portal.model.User user : users) {
2472 addUser.add(pk, user.getPrimaryKey());
2473 }
2474 }
2475 catch (Exception e) {
2476 throw processException(e);
2477 }
2478 finally {
2479 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2480 }
2481 }
2482
2483
2489 public void clearUsers(long pk) throws SystemException {
2490 try {
2491 clearUsers.clear(pk);
2492 }
2493 catch (Exception e) {
2494 throw processException(e);
2495 }
2496 finally {
2497 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2498 }
2499 }
2500
2501
2508 public void removeUser(long pk, long userPK) throws SystemException {
2509 try {
2510 removeUser.remove(pk, userPK);
2511 }
2512 catch (Exception e) {
2513 throw processException(e);
2514 }
2515 finally {
2516 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2517 }
2518 }
2519
2520
2527 public void removeUser(long pk, com.liferay.portal.model.User user)
2528 throws SystemException {
2529 try {
2530 removeUser.remove(pk, user.getPrimaryKey());
2531 }
2532 catch (Exception e) {
2533 throw processException(e);
2534 }
2535 finally {
2536 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2537 }
2538 }
2539
2540
2547 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2548 try {
2549 for (long userPK : userPKs) {
2550 removeUser.remove(pk, userPK);
2551 }
2552 }
2553 catch (Exception e) {
2554 throw processException(e);
2555 }
2556 finally {
2557 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2558 }
2559 }
2560
2561
2568 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2569 throws SystemException {
2570 try {
2571 for (com.liferay.portal.model.User user : users) {
2572 removeUser.remove(pk, user.getPrimaryKey());
2573 }
2574 }
2575 catch (Exception e) {
2576 throw processException(e);
2577 }
2578 finally {
2579 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2580 }
2581 }
2582
2583
2590 public void setUsers(long pk, long[] userPKs) throws SystemException {
2591 try {
2592 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2593
2594 List<com.liferay.portal.model.User> users = getUsers(pk);
2595
2596 for (com.liferay.portal.model.User user : users) {
2597 if (!userPKSet.remove(user.getPrimaryKey())) {
2598 removeUser.remove(pk, user.getPrimaryKey());
2599 }
2600 }
2601
2602 for (Long userPK : userPKSet) {
2603 addUser.add(pk, userPK);
2604 }
2605 }
2606 catch (Exception e) {
2607 throw processException(e);
2608 }
2609 finally {
2610 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2611 }
2612 }
2613
2614
2621 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2622 throws SystemException {
2623 try {
2624 long[] userPKs = new long[users.size()];
2625
2626 for (int i = 0; i < users.size(); i++) {
2627 com.liferay.portal.model.User user = users.get(i);
2628
2629 userPKs[i] = user.getPrimaryKey();
2630 }
2631
2632 setUsers(pk, userPKs);
2633 }
2634 catch (Exception e) {
2635 throw processException(e);
2636 }
2637 finally {
2638 FinderCacheUtil.clearCache(PermissionModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
2639 }
2640 }
2641
2642
2645 public void afterPropertiesSet() {
2646 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2647 com.liferay.portal.util.PropsUtil.get(
2648 "value.object.listener.com.liferay.portal.model.Permission")));
2649
2650 if (listenerClassNames.length > 0) {
2651 try {
2652 List<ModelListener<Permission>> listenersList = new ArrayList<ModelListener<Permission>>();
2653
2654 for (String listenerClassName : listenerClassNames) {
2655 listenersList.add((ModelListener<Permission>)InstanceFactory.newInstance(
2656 listenerClassName));
2657 }
2658
2659 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2660 }
2661 catch (Exception e) {
2662 _log.error(e);
2663 }
2664 }
2665
2666 containsGroup = new ContainsGroup(this);
2667
2668 addGroup = new AddGroup(this);
2669 clearGroups = new ClearGroups(this);
2670 removeGroup = new RemoveGroup(this);
2671
2672 containsRole = new ContainsRole(this);
2673
2674 addRole = new AddRole(this);
2675 clearRoles = new ClearRoles(this);
2676 removeRole = new RemoveRole(this);
2677
2678 containsUser = new ContainsUser(this);
2679
2680 addUser = new AddUser(this);
2681 clearUsers = new ClearUsers(this);
2682 removeUser = new RemoveUser(this);
2683 }
2684
2685 @BeanReference(type = AccountPersistence.class)
2686 protected AccountPersistence accountPersistence;
2687 @BeanReference(type = AddressPersistence.class)
2688 protected AddressPersistence addressPersistence;
2689 @BeanReference(type = BrowserTrackerPersistence.class)
2690 protected BrowserTrackerPersistence browserTrackerPersistence;
2691 @BeanReference(type = ClassNamePersistence.class)
2692 protected ClassNamePersistence classNamePersistence;
2693 @BeanReference(type = ClusterGroupPersistence.class)
2694 protected ClusterGroupPersistence clusterGroupPersistence;
2695 @BeanReference(type = CompanyPersistence.class)
2696 protected CompanyPersistence companyPersistence;
2697 @BeanReference(type = ContactPersistence.class)
2698 protected ContactPersistence contactPersistence;
2699 @BeanReference(type = CountryPersistence.class)
2700 protected CountryPersistence countryPersistence;
2701 @BeanReference(type = EmailAddressPersistence.class)
2702 protected EmailAddressPersistence emailAddressPersistence;
2703 @BeanReference(type = GroupPersistence.class)
2704 protected GroupPersistence groupPersistence;
2705 @BeanReference(type = ImagePersistence.class)
2706 protected ImagePersistence imagePersistence;
2707 @BeanReference(type = LayoutPersistence.class)
2708 protected LayoutPersistence layoutPersistence;
2709 @BeanReference(type = LayoutPrototypePersistence.class)
2710 protected LayoutPrototypePersistence layoutPrototypePersistence;
2711 @BeanReference(type = LayoutSetPersistence.class)
2712 protected LayoutSetPersistence layoutSetPersistence;
2713 @BeanReference(type = LayoutSetPrototypePersistence.class)
2714 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2715 @BeanReference(type = ListTypePersistence.class)
2716 protected ListTypePersistence listTypePersistence;
2717 @BeanReference(type = LockPersistence.class)
2718 protected LockPersistence lockPersistence;
2719 @BeanReference(type = MembershipRequestPersistence.class)
2720 protected MembershipRequestPersistence membershipRequestPersistence;
2721 @BeanReference(type = OrganizationPersistence.class)
2722 protected OrganizationPersistence organizationPersistence;
2723 @BeanReference(type = OrgGroupPermissionPersistence.class)
2724 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2725 @BeanReference(type = OrgGroupRolePersistence.class)
2726 protected OrgGroupRolePersistence orgGroupRolePersistence;
2727 @BeanReference(type = OrgLaborPersistence.class)
2728 protected OrgLaborPersistence orgLaborPersistence;
2729 @BeanReference(type = PasswordPolicyPersistence.class)
2730 protected PasswordPolicyPersistence passwordPolicyPersistence;
2731 @BeanReference(type = PasswordPolicyRelPersistence.class)
2732 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2733 @BeanReference(type = PasswordTrackerPersistence.class)
2734 protected PasswordTrackerPersistence passwordTrackerPersistence;
2735 @BeanReference(type = PermissionPersistence.class)
2736 protected PermissionPersistence permissionPersistence;
2737 @BeanReference(type = PhonePersistence.class)
2738 protected PhonePersistence phonePersistence;
2739 @BeanReference(type = PluginSettingPersistence.class)
2740 protected PluginSettingPersistence pluginSettingPersistence;
2741 @BeanReference(type = PortletPersistence.class)
2742 protected PortletPersistence portletPersistence;
2743 @BeanReference(type = PortletItemPersistence.class)
2744 protected PortletItemPersistence portletItemPersistence;
2745 @BeanReference(type = PortletPreferencesPersistence.class)
2746 protected PortletPreferencesPersistence portletPreferencesPersistence;
2747 @BeanReference(type = RegionPersistence.class)
2748 protected RegionPersistence regionPersistence;
2749 @BeanReference(type = ReleasePersistence.class)
2750 protected ReleasePersistence releasePersistence;
2751 @BeanReference(type = ResourcePersistence.class)
2752 protected ResourcePersistence resourcePersistence;
2753 @BeanReference(type = ResourceActionPersistence.class)
2754 protected ResourceActionPersistence resourceActionPersistence;
2755 @BeanReference(type = ResourceCodePersistence.class)
2756 protected ResourceCodePersistence resourceCodePersistence;
2757 @BeanReference(type = ResourcePermissionPersistence.class)
2758 protected ResourcePermissionPersistence resourcePermissionPersistence;
2759 @BeanReference(type = RolePersistence.class)
2760 protected RolePersistence rolePersistence;
2761 @BeanReference(type = ServiceComponentPersistence.class)
2762 protected ServiceComponentPersistence serviceComponentPersistence;
2763 @BeanReference(type = ShardPersistence.class)
2764 protected ShardPersistence shardPersistence;
2765 @BeanReference(type = SubscriptionPersistence.class)
2766 protected SubscriptionPersistence subscriptionPersistence;
2767 @BeanReference(type = TicketPersistence.class)
2768 protected TicketPersistence ticketPersistence;
2769 @BeanReference(type = TeamPersistence.class)
2770 protected TeamPersistence teamPersistence;
2771 @BeanReference(type = UserPersistence.class)
2772 protected UserPersistence userPersistence;
2773 @BeanReference(type = UserGroupPersistence.class)
2774 protected UserGroupPersistence userGroupPersistence;
2775 @BeanReference(type = UserGroupGroupRolePersistence.class)
2776 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2777 @BeanReference(type = UserGroupRolePersistence.class)
2778 protected UserGroupRolePersistence userGroupRolePersistence;
2779 @BeanReference(type = UserIdMapperPersistence.class)
2780 protected UserIdMapperPersistence userIdMapperPersistence;
2781 @BeanReference(type = UserTrackerPersistence.class)
2782 protected UserTrackerPersistence userTrackerPersistence;
2783 @BeanReference(type = UserTrackerPathPersistence.class)
2784 protected UserTrackerPathPersistence userTrackerPathPersistence;
2785 @BeanReference(type = WebDAVPropsPersistence.class)
2786 protected WebDAVPropsPersistence webDAVPropsPersistence;
2787 @BeanReference(type = WebsitePersistence.class)
2788 protected WebsitePersistence websitePersistence;
2789 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2790 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2791 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2792 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2793 protected ContainsGroup containsGroup;
2794 protected AddGroup addGroup;
2795 protected ClearGroups clearGroups;
2796 protected RemoveGroup removeGroup;
2797 protected ContainsRole containsRole;
2798 protected AddRole addRole;
2799 protected ClearRoles clearRoles;
2800 protected RemoveRole removeRole;
2801 protected ContainsUser containsUser;
2802 protected AddUser addUser;
2803 protected ClearUsers clearUsers;
2804 protected RemoveUser removeUser;
2805
2806 protected class ContainsGroup {
2807 protected ContainsGroup(PermissionPersistenceImpl persistenceImpl) {
2808 super();
2809
2810 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2811 _SQL_CONTAINSGROUP,
2812 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2813 RowMapper.COUNT);
2814 }
2815
2816 protected boolean contains(long permissionId, long groupId) {
2817 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2818 new Long(permissionId), new Long(groupId)
2819 });
2820
2821 if (results.size() > 0) {
2822 Integer count = results.get(0);
2823
2824 if (count.intValue() > 0) {
2825 return true;
2826 }
2827 }
2828
2829 return false;
2830 }
2831
2832 private MappingSqlQuery<Integer> _mappingSqlQuery;
2833 }
2834
2835 protected class AddGroup {
2836 protected AddGroup(PermissionPersistenceImpl persistenceImpl) {
2837 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2838 "INSERT INTO Groups_Permissions (permissionId, groupId) VALUES (?, ?)",
2839 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2840 _persistenceImpl = persistenceImpl;
2841 }
2842
2843 protected void add(long permissionId, long groupId)
2844 throws SystemException {
2845 if (!_persistenceImpl.containsGroup.contains(permissionId, groupId)) {
2846 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2847
2848 for (ModelListener<Permission> listener : listeners) {
2849 listener.onBeforeAddAssociation(permissionId,
2850 com.liferay.portal.model.Group.class.getName(), groupId);
2851 }
2852
2853 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2854 listener.onBeforeAddAssociation(groupId,
2855 Permission.class.getName(), permissionId);
2856 }
2857
2858 _sqlUpdate.update(new Object[] {
2859 new Long(permissionId), new Long(groupId)
2860 });
2861
2862 for (ModelListener<Permission> listener : listeners) {
2863 listener.onAfterAddAssociation(permissionId,
2864 com.liferay.portal.model.Group.class.getName(), groupId);
2865 }
2866
2867 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2868 listener.onAfterAddAssociation(groupId,
2869 Permission.class.getName(), permissionId);
2870 }
2871 }
2872 }
2873
2874 private SqlUpdate _sqlUpdate;
2875 private PermissionPersistenceImpl _persistenceImpl;
2876 }
2877
2878 protected class ClearGroups {
2879 protected ClearGroups(PermissionPersistenceImpl persistenceImpl) {
2880 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2881 "DELETE FROM Groups_Permissions WHERE permissionId = ?",
2882 new int[] { java.sql.Types.BIGINT });
2883 }
2884
2885 protected void clear(long permissionId) throws SystemException {
2886 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2887
2888 List<com.liferay.portal.model.Group> groups = null;
2889
2890 if ((listeners.length > 0) || (groupListeners.length > 0)) {
2891 groups = getGroups(permissionId);
2892
2893 for (com.liferay.portal.model.Group group : groups) {
2894 for (ModelListener<Permission> listener : listeners) {
2895 listener.onBeforeRemoveAssociation(permissionId,
2896 com.liferay.portal.model.Group.class.getName(),
2897 group.getPrimaryKey());
2898 }
2899
2900 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2901 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
2902 Permission.class.getName(), permissionId);
2903 }
2904 }
2905 }
2906
2907 _sqlUpdate.update(new Object[] { new Long(permissionId) });
2908
2909 if ((listeners.length > 0) || (groupListeners.length > 0)) {
2910 for (com.liferay.portal.model.Group group : groups) {
2911 for (ModelListener<Permission> listener : listeners) {
2912 listener.onAfterRemoveAssociation(permissionId,
2913 com.liferay.portal.model.Group.class.getName(),
2914 group.getPrimaryKey());
2915 }
2916
2917 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2918 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
2919 Permission.class.getName(), permissionId);
2920 }
2921 }
2922 }
2923 }
2924
2925 private SqlUpdate _sqlUpdate;
2926 }
2927
2928 protected class RemoveGroup {
2929 protected RemoveGroup(PermissionPersistenceImpl persistenceImpl) {
2930 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2931 "DELETE FROM Groups_Permissions WHERE permissionId = ? AND groupId = ?",
2932 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2933 _persistenceImpl = persistenceImpl;
2934 }
2935
2936 protected void remove(long permissionId, long groupId)
2937 throws SystemException {
2938 if (_persistenceImpl.containsGroup.contains(permissionId, groupId)) {
2939 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2940
2941 for (ModelListener<Permission> listener : listeners) {
2942 listener.onBeforeRemoveAssociation(permissionId,
2943 com.liferay.portal.model.Group.class.getName(), groupId);
2944 }
2945
2946 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2947 listener.onBeforeRemoveAssociation(groupId,
2948 Permission.class.getName(), permissionId);
2949 }
2950
2951 _sqlUpdate.update(new Object[] {
2952 new Long(permissionId), new Long(groupId)
2953 });
2954
2955 for (ModelListener<Permission> listener : listeners) {
2956 listener.onAfterRemoveAssociation(permissionId,
2957 com.liferay.portal.model.Group.class.getName(), groupId);
2958 }
2959
2960 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2961 listener.onAfterRemoveAssociation(groupId,
2962 Permission.class.getName(), permissionId);
2963 }
2964 }
2965 }
2966
2967 private SqlUpdate _sqlUpdate;
2968 private PermissionPersistenceImpl _persistenceImpl;
2969 }
2970
2971 protected class ContainsRole {
2972 protected ContainsRole(PermissionPersistenceImpl persistenceImpl) {
2973 super();
2974
2975 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2976 _SQL_CONTAINSROLE,
2977 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2978 RowMapper.COUNT);
2979 }
2980
2981 protected boolean contains(long permissionId, long roleId) {
2982 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2983 new Long(permissionId), new Long(roleId)
2984 });
2985
2986 if (results.size() > 0) {
2987 Integer count = results.get(0);
2988
2989 if (count.intValue() > 0) {
2990 return true;
2991 }
2992 }
2993
2994 return false;
2995 }
2996
2997 private MappingSqlQuery<Integer> _mappingSqlQuery;
2998 }
2999
3000 protected class AddRole {
3001 protected AddRole(PermissionPersistenceImpl persistenceImpl) {
3002 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3003 "INSERT INTO Roles_Permissions (permissionId, roleId) VALUES (?, ?)",
3004 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3005 _persistenceImpl = persistenceImpl;
3006 }
3007
3008 protected void add(long permissionId, long roleId)
3009 throws SystemException {
3010 if (!_persistenceImpl.containsRole.contains(permissionId, roleId)) {
3011 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
3012
3013 for (ModelListener<Permission> listener : listeners) {
3014 listener.onBeforeAddAssociation(permissionId,
3015 com.liferay.portal.model.Role.class.getName(), roleId);
3016 }
3017
3018 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3019 listener.onBeforeAddAssociation(roleId,
3020 Permission.class.getName(), permissionId);
3021 }
3022
3023 _sqlUpdate.update(new Object[] {
3024 new Long(permissionId), new Long(roleId)
3025 });
3026
3027 for (ModelListener<Permission> listener : listeners) {
3028 listener.onAfterAddAssociation(permissionId,
3029 com.liferay.portal.model.Role.class.getName(), roleId);
3030 }
3031
3032 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3033 listener.onAfterAddAssociation(roleId,
3034 Permission.class.getName(), permissionId);
3035 }
3036 }
3037 }
3038
3039 private SqlUpdate _sqlUpdate;
3040 private PermissionPersistenceImpl _persistenceImpl;
3041 }
3042
3043 protected class ClearRoles {
3044 protected ClearRoles(PermissionPersistenceImpl persistenceImpl) {
3045 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3046 "DELETE FROM Roles_Permissions WHERE permissionId = ?",
3047 new int[] { java.sql.Types.BIGINT });
3048 }
3049
3050 protected void clear(long permissionId) throws SystemException {
3051 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
3052
3053 List<com.liferay.portal.model.Role> roles = null;
3054
3055 if ((listeners.length > 0) || (roleListeners.length > 0)) {
3056 roles = getRoles(permissionId);
3057
3058 for (com.liferay.portal.model.Role role : roles) {
3059 for (ModelListener<Permission> listener : listeners) {
3060 listener.onBeforeRemoveAssociation(permissionId,
3061 com.liferay.portal.model.Role.class.getName(),
3062 role.getPrimaryKey());
3063 }
3064
3065 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3066 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
3067 Permission.class.getName(), permissionId);
3068 }
3069 }
3070 }
3071
3072 _sqlUpdate.update(new Object[] { new Long(permissionId) });
3073
3074 if ((listeners.length > 0) || (roleListeners.length > 0)) {
3075 for (com.liferay.portal.model.Role role : roles) {
3076 for (ModelListener<Permission> listener : listeners) {
3077 listener.onAfterRemoveAssociation(permissionId,
3078 com.liferay.portal.model.Role.class.getName(),
3079 role.getPrimaryKey());
3080 }
3081
3082 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3083 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
3084 Permission.class.getName(), permissionId);
3085 }
3086 }
3087 }
3088 }
3089
3090 private SqlUpdate _sqlUpdate;
3091 }
3092
3093 protected class RemoveRole {
3094 protected RemoveRole(PermissionPersistenceImpl persistenceImpl) {
3095 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3096 "DELETE FROM Roles_Permissions WHERE permissionId = ? AND roleId = ?",
3097 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3098 _persistenceImpl = persistenceImpl;
3099 }
3100
3101 protected void remove(long permissionId, long roleId)
3102 throws SystemException {
3103 if (_persistenceImpl.containsRole.contains(permissionId, roleId)) {
3104 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
3105
3106 for (ModelListener<Permission> listener : listeners) {
3107 listener.onBeforeRemoveAssociation(permissionId,
3108 com.liferay.portal.model.Role.class.getName(), roleId);
3109 }
3110
3111 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3112 listener.onBeforeRemoveAssociation(roleId,
3113 Permission.class.getName(), permissionId);
3114 }
3115
3116 _sqlUpdate.update(new Object[] {
3117 new Long(permissionId), new Long(roleId)
3118 });
3119
3120 for (ModelListener<Permission> listener : listeners) {
3121 listener.onAfterRemoveAssociation(permissionId,
3122 com.liferay.portal.model.Role.class.getName(), roleId);
3123 }
3124
3125 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
3126 listener.onAfterRemoveAssociation(roleId,
3127 Permission.class.getName(), permissionId);
3128 }
3129 }
3130 }
3131
3132 private SqlUpdate _sqlUpdate;
3133 private PermissionPersistenceImpl _persistenceImpl;
3134 }
3135
3136 protected class ContainsUser {
3137 protected ContainsUser(PermissionPersistenceImpl persistenceImpl) {
3138 super();
3139
3140 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3141 _SQL_CONTAINSUSER,
3142 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3143 RowMapper.COUNT);
3144 }
3145
3146 protected boolean contains(long permissionId, long userId) {
3147 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3148 new Long(permissionId), new Long(userId)
3149 });
3150
3151 if (results.size() > 0) {
3152 Integer count = results.get(0);
3153
3154 if (count.intValue() > 0) {
3155 return true;
3156 }
3157 }
3158
3159 return false;
3160 }
3161
3162 private MappingSqlQuery<Integer> _mappingSqlQuery;
3163 }
3164
3165 protected class AddUser {
3166 protected AddUser(PermissionPersistenceImpl persistenceImpl) {
3167 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3168 "INSERT INTO Users_Permissions (permissionId, userId) VALUES (?, ?)",
3169 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3170 _persistenceImpl = persistenceImpl;
3171 }
3172
3173 protected void add(long permissionId, long userId)
3174 throws SystemException {
3175 if (!_persistenceImpl.containsUser.contains(permissionId, userId)) {
3176 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3177
3178 for (ModelListener<Permission> listener : listeners) {
3179 listener.onBeforeAddAssociation(permissionId,
3180 com.liferay.portal.model.User.class.getName(), userId);
3181 }
3182
3183 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3184 listener.onBeforeAddAssociation(userId,
3185 Permission.class.getName(), permissionId);
3186 }
3187
3188 _sqlUpdate.update(new Object[] {
3189 new Long(permissionId), new Long(userId)
3190 });
3191
3192 for (ModelListener<Permission> listener : listeners) {
3193 listener.onAfterAddAssociation(permissionId,
3194 com.liferay.portal.model.User.class.getName(), userId);
3195 }
3196
3197 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3198 listener.onAfterAddAssociation(userId,
3199 Permission.class.getName(), permissionId);
3200 }
3201 }
3202 }
3203
3204 private SqlUpdate _sqlUpdate;
3205 private PermissionPersistenceImpl _persistenceImpl;
3206 }
3207
3208 protected class ClearUsers {
3209 protected ClearUsers(PermissionPersistenceImpl persistenceImpl) {
3210 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3211 "DELETE FROM Users_Permissions WHERE permissionId = ?",
3212 new int[] { java.sql.Types.BIGINT });
3213 }
3214
3215 protected void clear(long permissionId) throws SystemException {
3216 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3217
3218 List<com.liferay.portal.model.User> users = null;
3219
3220 if ((listeners.length > 0) || (userListeners.length > 0)) {
3221 users = getUsers(permissionId);
3222
3223 for (com.liferay.portal.model.User user : users) {
3224 for (ModelListener<Permission> listener : listeners) {
3225 listener.onBeforeRemoveAssociation(permissionId,
3226 com.liferay.portal.model.User.class.getName(),
3227 user.getPrimaryKey());
3228 }
3229
3230 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3231 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
3232 Permission.class.getName(), permissionId);
3233 }
3234 }
3235 }
3236
3237 _sqlUpdate.update(new Object[] { new Long(permissionId) });
3238
3239 if ((listeners.length > 0) || (userListeners.length > 0)) {
3240 for (com.liferay.portal.model.User user : users) {
3241 for (ModelListener<Permission> listener : listeners) {
3242 listener.onAfterRemoveAssociation(permissionId,
3243 com.liferay.portal.model.User.class.getName(),
3244 user.getPrimaryKey());
3245 }
3246
3247 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3248 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
3249 Permission.class.getName(), permissionId);
3250 }
3251 }
3252 }
3253 }
3254
3255 private SqlUpdate _sqlUpdate;
3256 }
3257
3258 protected class RemoveUser {
3259 protected RemoveUser(PermissionPersistenceImpl persistenceImpl) {
3260 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3261 "DELETE FROM Users_Permissions WHERE permissionId = ? AND userId = ?",
3262 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3263 _persistenceImpl = persistenceImpl;
3264 }
3265
3266 protected void remove(long permissionId, long userId)
3267 throws SystemException {
3268 if (_persistenceImpl.containsUser.contains(permissionId, userId)) {
3269 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3270
3271 for (ModelListener<Permission> listener : listeners) {
3272 listener.onBeforeRemoveAssociation(permissionId,
3273 com.liferay.portal.model.User.class.getName(), userId);
3274 }
3275
3276 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3277 listener.onBeforeRemoveAssociation(userId,
3278 Permission.class.getName(), permissionId);
3279 }
3280
3281 _sqlUpdate.update(new Object[] {
3282 new Long(permissionId), new Long(userId)
3283 });
3284
3285 for (ModelListener<Permission> listener : listeners) {
3286 listener.onAfterRemoveAssociation(permissionId,
3287 com.liferay.portal.model.User.class.getName(), userId);
3288 }
3289
3290 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3291 listener.onAfterRemoveAssociation(userId,
3292 Permission.class.getName(), permissionId);
3293 }
3294 }
3295 }
3296
3297 private SqlUpdate _sqlUpdate;
3298 private PermissionPersistenceImpl _persistenceImpl;
3299 }
3300
3301 private static final String _SQL_SELECT_PERMISSION = "SELECT permission FROM Permission permission";
3302 private static final String _SQL_SELECT_PERMISSION_WHERE = "SELECT permission FROM Permission permission WHERE ";
3303 private static final String _SQL_COUNT_PERMISSION = "SELECT COUNT(permission) FROM Permission permission";
3304 private static final String _SQL_COUNT_PERMISSION_WHERE = "SELECT COUNT(permission) FROM Permission permission WHERE ";
3305 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Permissions ON (Groups_Permissions.groupId = Group_.groupId) WHERE (Groups_Permissions.permissionId = ?)";
3306 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE permissionId = ?";
3307 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE permissionId = ? AND groupId = ?";
3308 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Roles_Permissions ON (Roles_Permissions.roleId = Role_.roleId) WHERE (Roles_Permissions.permissionId = ?)";
3309 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE permissionId = ?";
3310 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE permissionId = ? AND roleId = ?";
3311 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Permissions ON (Users_Permissions.userId = User_.userId) WHERE (Users_Permissions.permissionId = ?)";
3312 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE permissionId = ?";
3313 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE permissionId = ? AND userId = ?";
3314 private static final String _FINDER_COLUMN_RESOURCEID_RESOURCEID_2 = "permission.resourceId = ?";
3315 private static final String _FINDER_COLUMN_A_R_ACTIONID_1 = "permission.actionId IS NULL AND ";
3316 private static final String _FINDER_COLUMN_A_R_ACTIONID_2 = "permission.actionId = ? AND ";
3317 private static final String _FINDER_COLUMN_A_R_ACTIONID_3 = "(permission.actionId IS NULL OR permission.actionId = ?) AND ";
3318 private static final String _FINDER_COLUMN_A_R_RESOURCEID_2 = "permission.resourceId = ?";
3319 private static final String _ORDER_BY_ENTITY_ALIAS = "permission.";
3320 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Permission exists with the primary key ";
3321 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Permission exists with the key {";
3322 private static Log _log = LogFactoryUtil.getLog(PermissionPersistenceImpl.class);
3323 }