1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.kernel.util.GetterUtil;
26 import com.liferay.portal.kernel.util.Validator;
27 import com.liferay.portal.model.ModelListener;
28 import com.liferay.portal.util.PropsUtil;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32
33
39 public class RoleUtil {
40 public static com.liferay.portal.model.Role create(long roleId) {
41 return getPersistence().create(roleId);
42 }
43
44 public static com.liferay.portal.model.Role remove(long roleId)
45 throws com.liferay.portal.SystemException,
46 com.liferay.portal.NoSuchRoleException {
47 ModelListener listener = _getListener();
48
49 if (listener != null) {
50 listener.onBeforeRemove(findByPrimaryKey(roleId));
51 }
52
53 com.liferay.portal.model.Role role = getPersistence().remove(roleId);
54
55 if (listener != null) {
56 listener.onAfterRemove(role);
57 }
58
59 return role;
60 }
61
62 public static com.liferay.portal.model.Role remove(
63 com.liferay.portal.model.Role role)
64 throws com.liferay.portal.SystemException {
65 ModelListener listener = _getListener();
66
67 if (listener != null) {
68 listener.onBeforeRemove(role);
69 }
70
71 role = getPersistence().remove(role);
72
73 if (listener != null) {
74 listener.onAfterRemove(role);
75 }
76
77 return role;
78 }
79
80 public static com.liferay.portal.model.Role update(
81 com.liferay.portal.model.Role role)
82 throws com.liferay.portal.SystemException {
83 ModelListener listener = _getListener();
84 boolean isNew = role.isNew();
85
86 if (listener != null) {
87 if (isNew) {
88 listener.onBeforeCreate(role);
89 }
90 else {
91 listener.onBeforeUpdate(role);
92 }
93 }
94
95 role = getPersistence().update(role);
96
97 if (listener != null) {
98 if (isNew) {
99 listener.onAfterCreate(role);
100 }
101 else {
102 listener.onAfterUpdate(role);
103 }
104 }
105
106 return role;
107 }
108
109 public static com.liferay.portal.model.Role update(
110 com.liferay.portal.model.Role role, boolean merge)
111 throws com.liferay.portal.SystemException {
112 ModelListener listener = _getListener();
113 boolean isNew = role.isNew();
114
115 if (listener != null) {
116 if (isNew) {
117 listener.onBeforeCreate(role);
118 }
119 else {
120 listener.onBeforeUpdate(role);
121 }
122 }
123
124 role = getPersistence().update(role, merge);
125
126 if (listener != null) {
127 if (isNew) {
128 listener.onAfterCreate(role);
129 }
130 else {
131 listener.onAfterUpdate(role);
132 }
133 }
134
135 return role;
136 }
137
138 public static com.liferay.portal.model.Role findByPrimaryKey(long roleId)
139 throws com.liferay.portal.SystemException,
140 com.liferay.portal.NoSuchRoleException {
141 return getPersistence().findByPrimaryKey(roleId);
142 }
143
144 public static com.liferay.portal.model.Role fetchByPrimaryKey(long roleId)
145 throws com.liferay.portal.SystemException {
146 return getPersistence().fetchByPrimaryKey(roleId);
147 }
148
149 public static java.util.List findByCompanyId(long companyId)
150 throws com.liferay.portal.SystemException {
151 return getPersistence().findByCompanyId(companyId);
152 }
153
154 public static java.util.List findByCompanyId(long companyId, int begin,
155 int end) throws com.liferay.portal.SystemException {
156 return getPersistence().findByCompanyId(companyId, begin, end);
157 }
158
159 public static java.util.List findByCompanyId(long companyId, int begin,
160 int end, com.liferay.portal.kernel.util.OrderByComparator obc)
161 throws com.liferay.portal.SystemException {
162 return getPersistence().findByCompanyId(companyId, begin, end, obc);
163 }
164
165 public static com.liferay.portal.model.Role findByCompanyId_First(
166 long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
167 throws com.liferay.portal.SystemException,
168 com.liferay.portal.NoSuchRoleException {
169 return getPersistence().findByCompanyId_First(companyId, obc);
170 }
171
172 public static com.liferay.portal.model.Role findByCompanyId_Last(
173 long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
174 throws com.liferay.portal.SystemException,
175 com.liferay.portal.NoSuchRoleException {
176 return getPersistence().findByCompanyId_Last(companyId, obc);
177 }
178
179 public static com.liferay.portal.model.Role[] findByCompanyId_PrevAndNext(
180 long roleId, long companyId,
181 com.liferay.portal.kernel.util.OrderByComparator obc)
182 throws com.liferay.portal.SystemException,
183 com.liferay.portal.NoSuchRoleException {
184 return getPersistence().findByCompanyId_PrevAndNext(roleId, companyId,
185 obc);
186 }
187
188 public static com.liferay.portal.model.Role findByC_N(long companyId,
189 java.lang.String name)
190 throws com.liferay.portal.SystemException,
191 com.liferay.portal.NoSuchRoleException {
192 return getPersistence().findByC_N(companyId, name);
193 }
194
195 public static com.liferay.portal.model.Role fetchByC_N(long companyId,
196 java.lang.String name) throws com.liferay.portal.SystemException {
197 return getPersistence().fetchByC_N(companyId, name);
198 }
199
200 public static com.liferay.portal.model.Role findByC_C_C(long companyId,
201 long classNameId, long classPK)
202 throws com.liferay.portal.SystemException,
203 com.liferay.portal.NoSuchRoleException {
204 return getPersistence().findByC_C_C(companyId, classNameId, classPK);
205 }
206
207 public static com.liferay.portal.model.Role fetchByC_C_C(long companyId,
208 long classNameId, long classPK)
209 throws com.liferay.portal.SystemException {
210 return getPersistence().fetchByC_C_C(companyId, classNameId, classPK);
211 }
212
213 public static java.util.List findWithDynamicQuery(
214 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
215 throws com.liferay.portal.SystemException {
216 return getPersistence().findWithDynamicQuery(queryInitializer);
217 }
218
219 public static java.util.List findWithDynamicQuery(
220 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
221 int begin, int end) throws com.liferay.portal.SystemException {
222 return getPersistence().findWithDynamicQuery(queryInitializer, begin,
223 end);
224 }
225
226 public static java.util.List findAll()
227 throws com.liferay.portal.SystemException {
228 return getPersistence().findAll();
229 }
230
231 public static java.util.List findAll(int begin, int end)
232 throws com.liferay.portal.SystemException {
233 return getPersistence().findAll(begin, end);
234 }
235
236 public static java.util.List findAll(int begin, int end,
237 com.liferay.portal.kernel.util.OrderByComparator obc)
238 throws com.liferay.portal.SystemException {
239 return getPersistence().findAll(begin, end, obc);
240 }
241
242 public static void removeByCompanyId(long companyId)
243 throws com.liferay.portal.SystemException {
244 getPersistence().removeByCompanyId(companyId);
245 }
246
247 public static void removeByC_N(long companyId, java.lang.String name)
248 throws com.liferay.portal.SystemException,
249 com.liferay.portal.NoSuchRoleException {
250 getPersistence().removeByC_N(companyId, name);
251 }
252
253 public static void removeByC_C_C(long companyId, long classNameId,
254 long classPK)
255 throws com.liferay.portal.SystemException,
256 com.liferay.portal.NoSuchRoleException {
257 getPersistence().removeByC_C_C(companyId, classNameId, classPK);
258 }
259
260 public static void removeAll() throws com.liferay.portal.SystemException {
261 getPersistence().removeAll();
262 }
263
264 public static int countByCompanyId(long companyId)
265 throws com.liferay.portal.SystemException {
266 return getPersistence().countByCompanyId(companyId);
267 }
268
269 public static int countByC_N(long companyId, java.lang.String name)
270 throws com.liferay.portal.SystemException {
271 return getPersistence().countByC_N(companyId, name);
272 }
273
274 public static int countByC_C_C(long companyId, long classNameId,
275 long classPK) throws com.liferay.portal.SystemException {
276 return getPersistence().countByC_C_C(companyId, classNameId, classPK);
277 }
278
279 public static int countAll() throws com.liferay.portal.SystemException {
280 return getPersistence().countAll();
281 }
282
283 public static java.util.List getGroups(long pk)
284 throws com.liferay.portal.SystemException,
285 com.liferay.portal.NoSuchRoleException {
286 return getPersistence().getGroups(pk);
287 }
288
289 public static java.util.List getGroups(long pk, int begin, int end)
290 throws com.liferay.portal.SystemException,
291 com.liferay.portal.NoSuchRoleException {
292 return getPersistence().getGroups(pk, begin, end);
293 }
294
295 public static java.util.List getGroups(long pk, int begin, int end,
296 com.liferay.portal.kernel.util.OrderByComparator obc)
297 throws com.liferay.portal.SystemException,
298 com.liferay.portal.NoSuchRoleException {
299 return getPersistence().getGroups(pk, begin, end, obc);
300 }
301
302 public static int getGroupsSize(long pk)
303 throws com.liferay.portal.SystemException {
304 return getPersistence().getGroupsSize(pk);
305 }
306
307 public static boolean containsGroup(long pk, long groupPK)
308 throws com.liferay.portal.SystemException {
309 return getPersistence().containsGroup(pk, groupPK);
310 }
311
312 public static boolean containsGroups(long pk)
313 throws com.liferay.portal.SystemException {
314 return getPersistence().containsGroups(pk);
315 }
316
317 public static void addGroup(long pk, long groupPK)
318 throws com.liferay.portal.SystemException,
319 com.liferay.portal.NoSuchGroupException,
320 com.liferay.portal.NoSuchRoleException {
321 getPersistence().addGroup(pk, groupPK);
322 }
323
324 public static void addGroup(long pk, com.liferay.portal.model.Group group)
325 throws com.liferay.portal.SystemException,
326 com.liferay.portal.NoSuchGroupException,
327 com.liferay.portal.NoSuchRoleException {
328 getPersistence().addGroup(pk, group);
329 }
330
331 public static void addGroups(long pk, long[] groupPKs)
332 throws com.liferay.portal.SystemException,
333 com.liferay.portal.NoSuchGroupException,
334 com.liferay.portal.NoSuchRoleException {
335 getPersistence().addGroups(pk, groupPKs);
336 }
337
338 public static void addGroups(long pk, java.util.List groups)
339 throws com.liferay.portal.SystemException,
340 com.liferay.portal.NoSuchGroupException,
341 com.liferay.portal.NoSuchRoleException {
342 getPersistence().addGroups(pk, groups);
343 }
344
345 public static void clearGroups(long pk)
346 throws com.liferay.portal.SystemException,
347 com.liferay.portal.NoSuchRoleException {
348 getPersistence().clearGroups(pk);
349 }
350
351 public static void removeGroup(long pk, long groupPK)
352 throws com.liferay.portal.SystemException,
353 com.liferay.portal.NoSuchGroupException,
354 com.liferay.portal.NoSuchRoleException {
355 getPersistence().removeGroup(pk, groupPK);
356 }
357
358 public static void removeGroup(long pk, com.liferay.portal.model.Group group)
359 throws com.liferay.portal.SystemException,
360 com.liferay.portal.NoSuchGroupException,
361 com.liferay.portal.NoSuchRoleException {
362 getPersistence().removeGroup(pk, group);
363 }
364
365 public static void removeGroups(long pk, long[] groupPKs)
366 throws com.liferay.portal.SystemException,
367 com.liferay.portal.NoSuchGroupException,
368 com.liferay.portal.NoSuchRoleException {
369 getPersistence().removeGroups(pk, groupPKs);
370 }
371
372 public static void removeGroups(long pk, java.util.List groups)
373 throws com.liferay.portal.SystemException,
374 com.liferay.portal.NoSuchGroupException,
375 com.liferay.portal.NoSuchRoleException {
376 getPersistence().removeGroups(pk, groups);
377 }
378
379 public static void setGroups(long pk, long[] groupPKs)
380 throws com.liferay.portal.SystemException,
381 com.liferay.portal.NoSuchGroupException,
382 com.liferay.portal.NoSuchRoleException {
383 getPersistence().setGroups(pk, groupPKs);
384 }
385
386 public static void setGroups(long pk, java.util.List groups)
387 throws com.liferay.portal.SystemException,
388 com.liferay.portal.NoSuchGroupException,
389 com.liferay.portal.NoSuchRoleException {
390 getPersistence().setGroups(pk, groups);
391 }
392
393 public static java.util.List getPermissions(long pk)
394 throws com.liferay.portal.SystemException,
395 com.liferay.portal.NoSuchRoleException {
396 return getPersistence().getPermissions(pk);
397 }
398
399 public static java.util.List getPermissions(long pk, int begin, int end)
400 throws com.liferay.portal.SystemException,
401 com.liferay.portal.NoSuchRoleException {
402 return getPersistence().getPermissions(pk, begin, end);
403 }
404
405 public static java.util.List getPermissions(long pk, int begin, int end,
406 com.liferay.portal.kernel.util.OrderByComparator obc)
407 throws com.liferay.portal.SystemException,
408 com.liferay.portal.NoSuchRoleException {
409 return getPersistence().getPermissions(pk, begin, end, obc);
410 }
411
412 public static int getPermissionsSize(long pk)
413 throws com.liferay.portal.SystemException {
414 return getPersistence().getPermissionsSize(pk);
415 }
416
417 public static boolean containsPermission(long pk, long permissionPK)
418 throws com.liferay.portal.SystemException {
419 return getPersistence().containsPermission(pk, permissionPK);
420 }
421
422 public static boolean containsPermissions(long pk)
423 throws com.liferay.portal.SystemException {
424 return getPersistence().containsPermissions(pk);
425 }
426
427 public static void addPermission(long pk, long permissionPK)
428 throws com.liferay.portal.SystemException,
429 com.liferay.portal.NoSuchPermissionException,
430 com.liferay.portal.NoSuchRoleException {
431 getPersistence().addPermission(pk, permissionPK);
432 }
433
434 public static void addPermission(long pk,
435 com.liferay.portal.model.Permission permission)
436 throws com.liferay.portal.SystemException,
437 com.liferay.portal.NoSuchPermissionException,
438 com.liferay.portal.NoSuchRoleException {
439 getPersistence().addPermission(pk, permission);
440 }
441
442 public static void addPermissions(long pk, long[] permissionPKs)
443 throws com.liferay.portal.SystemException,
444 com.liferay.portal.NoSuchPermissionException,
445 com.liferay.portal.NoSuchRoleException {
446 getPersistence().addPermissions(pk, permissionPKs);
447 }
448
449 public static void addPermissions(long pk, java.util.List permissions)
450 throws com.liferay.portal.SystemException,
451 com.liferay.portal.NoSuchPermissionException,
452 com.liferay.portal.NoSuchRoleException {
453 getPersistence().addPermissions(pk, permissions);
454 }
455
456 public static void clearPermissions(long pk)
457 throws com.liferay.portal.SystemException,
458 com.liferay.portal.NoSuchRoleException {
459 getPersistence().clearPermissions(pk);
460 }
461
462 public static void removePermission(long pk, long permissionPK)
463 throws com.liferay.portal.SystemException,
464 com.liferay.portal.NoSuchPermissionException,
465 com.liferay.portal.NoSuchRoleException {
466 getPersistence().removePermission(pk, permissionPK);
467 }
468
469 public static void removePermission(long pk,
470 com.liferay.portal.model.Permission permission)
471 throws com.liferay.portal.SystemException,
472 com.liferay.portal.NoSuchPermissionException,
473 com.liferay.portal.NoSuchRoleException {
474 getPersistence().removePermission(pk, permission);
475 }
476
477 public static void removePermissions(long pk, long[] permissionPKs)
478 throws com.liferay.portal.SystemException,
479 com.liferay.portal.NoSuchPermissionException,
480 com.liferay.portal.NoSuchRoleException {
481 getPersistence().removePermissions(pk, permissionPKs);
482 }
483
484 public static void removePermissions(long pk, java.util.List permissions)
485 throws com.liferay.portal.SystemException,
486 com.liferay.portal.NoSuchPermissionException,
487 com.liferay.portal.NoSuchRoleException {
488 getPersistence().removePermissions(pk, permissions);
489 }
490
491 public static void setPermissions(long pk, long[] permissionPKs)
492 throws com.liferay.portal.SystemException,
493 com.liferay.portal.NoSuchPermissionException,
494 com.liferay.portal.NoSuchRoleException {
495 getPersistence().setPermissions(pk, permissionPKs);
496 }
497
498 public static void setPermissions(long pk, java.util.List permissions)
499 throws com.liferay.portal.SystemException,
500 com.liferay.portal.NoSuchPermissionException,
501 com.liferay.portal.NoSuchRoleException {
502 getPersistence().setPermissions(pk, permissions);
503 }
504
505 public static java.util.List getUsers(long pk)
506 throws com.liferay.portal.SystemException,
507 com.liferay.portal.NoSuchRoleException {
508 return getPersistence().getUsers(pk);
509 }
510
511 public static java.util.List getUsers(long pk, int begin, int end)
512 throws com.liferay.portal.SystemException,
513 com.liferay.portal.NoSuchRoleException {
514 return getPersistence().getUsers(pk, begin, end);
515 }
516
517 public static java.util.List getUsers(long pk, int begin, int end,
518 com.liferay.portal.kernel.util.OrderByComparator obc)
519 throws com.liferay.portal.SystemException,
520 com.liferay.portal.NoSuchRoleException {
521 return getPersistence().getUsers(pk, begin, end, obc);
522 }
523
524 public static int getUsersSize(long pk)
525 throws com.liferay.portal.SystemException {
526 return getPersistence().getUsersSize(pk);
527 }
528
529 public static boolean containsUser(long pk, long userPK)
530 throws com.liferay.portal.SystemException {
531 return getPersistence().containsUser(pk, userPK);
532 }
533
534 public static boolean containsUsers(long pk)
535 throws com.liferay.portal.SystemException {
536 return getPersistence().containsUsers(pk);
537 }
538
539 public static void addUser(long pk, long userPK)
540 throws com.liferay.portal.SystemException,
541 com.liferay.portal.NoSuchRoleException,
542 com.liferay.portal.NoSuchUserException {
543 getPersistence().addUser(pk, userPK);
544 }
545
546 public static void addUser(long pk, com.liferay.portal.model.User user)
547 throws com.liferay.portal.SystemException,
548 com.liferay.portal.NoSuchRoleException,
549 com.liferay.portal.NoSuchUserException {
550 getPersistence().addUser(pk, user);
551 }
552
553 public static void addUsers(long pk, long[] userPKs)
554 throws com.liferay.portal.SystemException,
555 com.liferay.portal.NoSuchRoleException,
556 com.liferay.portal.NoSuchUserException {
557 getPersistence().addUsers(pk, userPKs);
558 }
559
560 public static void addUsers(long pk, java.util.List users)
561 throws com.liferay.portal.SystemException,
562 com.liferay.portal.NoSuchRoleException,
563 com.liferay.portal.NoSuchUserException {
564 getPersistence().addUsers(pk, users);
565 }
566
567 public static void clearUsers(long pk)
568 throws com.liferay.portal.SystemException,
569 com.liferay.portal.NoSuchRoleException {
570 getPersistence().clearUsers(pk);
571 }
572
573 public static void removeUser(long pk, long userPK)
574 throws com.liferay.portal.SystemException,
575 com.liferay.portal.NoSuchRoleException,
576 com.liferay.portal.NoSuchUserException {
577 getPersistence().removeUser(pk, userPK);
578 }
579
580 public static void removeUser(long pk, com.liferay.portal.model.User user)
581 throws com.liferay.portal.SystemException,
582 com.liferay.portal.NoSuchRoleException,
583 com.liferay.portal.NoSuchUserException {
584 getPersistence().removeUser(pk, user);
585 }
586
587 public static void removeUsers(long pk, long[] userPKs)
588 throws com.liferay.portal.SystemException,
589 com.liferay.portal.NoSuchRoleException,
590 com.liferay.portal.NoSuchUserException {
591 getPersistence().removeUsers(pk, userPKs);
592 }
593
594 public static void removeUsers(long pk, java.util.List users)
595 throws com.liferay.portal.SystemException,
596 com.liferay.portal.NoSuchRoleException,
597 com.liferay.portal.NoSuchUserException {
598 getPersistence().removeUsers(pk, users);
599 }
600
601 public static void setUsers(long pk, long[] userPKs)
602 throws com.liferay.portal.SystemException,
603 com.liferay.portal.NoSuchRoleException,
604 com.liferay.portal.NoSuchUserException {
605 getPersistence().setUsers(pk, userPKs);
606 }
607
608 public static void setUsers(long pk, java.util.List users)
609 throws com.liferay.portal.SystemException,
610 com.liferay.portal.NoSuchRoleException,
611 com.liferay.portal.NoSuchUserException {
612 getPersistence().setUsers(pk, users);
613 }
614
615 public static RolePersistence getPersistence() {
616 return _getUtil()._persistence;
617 }
618
619 public void setPersistence(RolePersistence persistence) {
620 _persistence = persistence;
621 }
622
623 private static RoleUtil _getUtil() {
624 if (_util == null) {
625 _util = (RoleUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
626 }
627
628 return _util;
629 }
630
631 private static ModelListener _getListener() {
632 if (Validator.isNotNull(_LISTENER)) {
633 try {
634 return (ModelListener)Class.forName(_LISTENER).newInstance();
635 }
636 catch (Exception e) {
637 _log.error(e);
638 }
639 }
640
641 return null;
642 }
643
644 private static final String _UTIL = RoleUtil.class.getName();
645 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
646 "value.object.listener.com.liferay.portal.model.Role"));
647 private static Log _log = LogFactory.getLog(RoleUtil.class);
648 private static RoleUtil _util;
649 private RolePersistence _persistence;
650 }