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