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