1
22
23 package com.liferay.portal.service.http;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.util.IntegerWrapper;
28 import com.liferay.portal.kernel.util.LongWrapper;
29 import com.liferay.portal.kernel.util.MethodWrapper;
30 import com.liferay.portal.kernel.util.NullWrapper;
31 import com.liferay.portal.security.auth.HttpPrincipal;
32 import com.liferay.portal.service.PermissionServiceUtil;
33
34
73 public class PermissionServiceHttp {
74 public static void checkPermission(HttpPrincipal httpPrincipal,
75 long groupId, long resourceId)
76 throws com.liferay.portal.PortalException,
77 com.liferay.portal.SystemException {
78 try {
79 Object paramObj0 = new LongWrapper(groupId);
80
81 Object paramObj1 = new LongWrapper(resourceId);
82
83 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
84 "checkPermission", new Object[] { paramObj0, paramObj1 });
85
86 try {
87 TunnelUtil.invoke(httpPrincipal, methodWrapper);
88 }
89 catch (Exception e) {
90 if (e instanceof com.liferay.portal.PortalException) {
91 throw (com.liferay.portal.PortalException)e;
92 }
93
94 if (e instanceof com.liferay.portal.SystemException) {
95 throw (com.liferay.portal.SystemException)e;
96 }
97
98 throw new com.liferay.portal.SystemException(e);
99 }
100 }
101 catch (com.liferay.portal.SystemException se) {
102 _log.error(se, se);
103
104 throw se;
105 }
106 }
107
108 public static void checkPermission(HttpPrincipal httpPrincipal,
109 long groupId, java.lang.String name, long primKey)
110 throws com.liferay.portal.PortalException,
111 com.liferay.portal.SystemException {
112 try {
113 Object paramObj0 = new LongWrapper(groupId);
114
115 Object paramObj1 = name;
116
117 if (name == null) {
118 paramObj1 = new NullWrapper("java.lang.String");
119 }
120
121 Object paramObj2 = new LongWrapper(primKey);
122
123 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
124 "checkPermission",
125 new Object[] { paramObj0, paramObj1, paramObj2 });
126
127 try {
128 TunnelUtil.invoke(httpPrincipal, methodWrapper);
129 }
130 catch (Exception e) {
131 if (e instanceof com.liferay.portal.PortalException) {
132 throw (com.liferay.portal.PortalException)e;
133 }
134
135 if (e instanceof com.liferay.portal.SystemException) {
136 throw (com.liferay.portal.SystemException)e;
137 }
138
139 throw new com.liferay.portal.SystemException(e);
140 }
141 }
142 catch (com.liferay.portal.SystemException se) {
143 _log.error(se, se);
144
145 throw se;
146 }
147 }
148
149 public static void checkPermission(HttpPrincipal httpPrincipal,
150 long groupId, java.lang.String name, java.lang.String primKey)
151 throws com.liferay.portal.PortalException,
152 com.liferay.portal.SystemException {
153 try {
154 Object paramObj0 = new LongWrapper(groupId);
155
156 Object paramObj1 = name;
157
158 if (name == null) {
159 paramObj1 = new NullWrapper("java.lang.String");
160 }
161
162 Object paramObj2 = primKey;
163
164 if (primKey == null) {
165 paramObj2 = new NullWrapper("java.lang.String");
166 }
167
168 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
169 "checkPermission",
170 new Object[] { paramObj0, paramObj1, paramObj2 });
171
172 try {
173 TunnelUtil.invoke(httpPrincipal, methodWrapper);
174 }
175 catch (Exception e) {
176 if (e instanceof com.liferay.portal.PortalException) {
177 throw (com.liferay.portal.PortalException)e;
178 }
179
180 if (e instanceof com.liferay.portal.SystemException) {
181 throw (com.liferay.portal.SystemException)e;
182 }
183
184 throw new com.liferay.portal.SystemException(e);
185 }
186 }
187 catch (com.liferay.portal.SystemException se) {
188 _log.error(se, se);
189
190 throw se;
191 }
192 }
193
194 public static boolean hasGroupPermission(HttpPrincipal httpPrincipal,
195 long groupId, java.lang.String actionId, long resourceId)
196 throws com.liferay.portal.SystemException {
197 try {
198 Object paramObj0 = new LongWrapper(groupId);
199
200 Object paramObj1 = actionId;
201
202 if (actionId == null) {
203 paramObj1 = new NullWrapper("java.lang.String");
204 }
205
206 Object paramObj2 = new LongWrapper(resourceId);
207
208 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
209 "hasGroupPermission",
210 new Object[] { paramObj0, paramObj1, paramObj2 });
211
212 Object returnObj = null;
213
214 try {
215 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
216 }
217 catch (Exception e) {
218 if (e instanceof com.liferay.portal.SystemException) {
219 throw (com.liferay.portal.SystemException)e;
220 }
221
222 throw new com.liferay.portal.SystemException(e);
223 }
224
225 return ((Boolean)returnObj).booleanValue();
226 }
227 catch (com.liferay.portal.SystemException se) {
228 _log.error(se, se);
229
230 throw se;
231 }
232 }
233
234 public static boolean hasUserPermission(HttpPrincipal httpPrincipal,
235 long userId, java.lang.String actionId, long resourceId)
236 throws com.liferay.portal.SystemException {
237 try {
238 Object paramObj0 = new LongWrapper(userId);
239
240 Object paramObj1 = actionId;
241
242 if (actionId == null) {
243 paramObj1 = new NullWrapper("java.lang.String");
244 }
245
246 Object paramObj2 = new LongWrapper(resourceId);
247
248 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
249 "hasUserPermission",
250 new Object[] { paramObj0, paramObj1, paramObj2 });
251
252 Object returnObj = null;
253
254 try {
255 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
256 }
257 catch (Exception e) {
258 if (e instanceof com.liferay.portal.SystemException) {
259 throw (com.liferay.portal.SystemException)e;
260 }
261
262 throw new com.liferay.portal.SystemException(e);
263 }
264
265 return ((Boolean)returnObj).booleanValue();
266 }
267 catch (com.liferay.portal.SystemException se) {
268 _log.error(se, se);
269
270 throw se;
271 }
272 }
273
274 public static boolean hasUserPermissions(HttpPrincipal httpPrincipal,
275 long userId, long groupId,
276 java.util.List<com.liferay.portal.model.Resource> resources,
277 java.lang.String actionId,
278 com.liferay.portal.security.permission.PermissionCheckerBag permissionCheckerBag)
279 throws com.liferay.portal.PortalException,
280 com.liferay.portal.SystemException {
281 try {
282 Object paramObj0 = new LongWrapper(userId);
283
284 Object paramObj1 = new LongWrapper(groupId);
285
286 Object paramObj2 = resources;
287
288 if (resources == null) {
289 paramObj2 = new NullWrapper("java.util.List");
290 }
291
292 Object paramObj3 = actionId;
293
294 if (actionId == null) {
295 paramObj3 = new NullWrapper("java.lang.String");
296 }
297
298 Object paramObj4 = permissionCheckerBag;
299
300 if (permissionCheckerBag == null) {
301 paramObj4 = new NullWrapper(
302 "com.liferay.portal.security.permission.PermissionCheckerBag");
303 }
304
305 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
306 "hasUserPermissions",
307 new Object[] {
308 paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
309 });
310
311 Object returnObj = null;
312
313 try {
314 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
315 }
316 catch (Exception e) {
317 if (e instanceof com.liferay.portal.PortalException) {
318 throw (com.liferay.portal.PortalException)e;
319 }
320
321 if (e instanceof com.liferay.portal.SystemException) {
322 throw (com.liferay.portal.SystemException)e;
323 }
324
325 throw new com.liferay.portal.SystemException(e);
326 }
327
328 return ((Boolean)returnObj).booleanValue();
329 }
330 catch (com.liferay.portal.SystemException se) {
331 _log.error(se, se);
332
333 throw se;
334 }
335 }
336
337 public static void setGroupPermissions(HttpPrincipal httpPrincipal,
338 long groupId, java.lang.String[] actionIds, long resourceId)
339 throws com.liferay.portal.PortalException,
340 com.liferay.portal.SystemException {
341 try {
342 Object paramObj0 = new LongWrapper(groupId);
343
344 Object paramObj1 = actionIds;
345
346 if (actionIds == null) {
347 paramObj1 = new NullWrapper("[Ljava.lang.String;");
348 }
349
350 Object paramObj2 = new LongWrapper(resourceId);
351
352 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
353 "setGroupPermissions",
354 new Object[] { paramObj0, paramObj1, paramObj2 });
355
356 try {
357 TunnelUtil.invoke(httpPrincipal, methodWrapper);
358 }
359 catch (Exception e) {
360 if (e instanceof com.liferay.portal.PortalException) {
361 throw (com.liferay.portal.PortalException)e;
362 }
363
364 if (e instanceof com.liferay.portal.SystemException) {
365 throw (com.liferay.portal.SystemException)e;
366 }
367
368 throw new com.liferay.portal.SystemException(e);
369 }
370 }
371 catch (com.liferay.portal.SystemException se) {
372 _log.error(se, se);
373
374 throw se;
375 }
376 }
377
378 public static void setGroupPermissions(HttpPrincipal httpPrincipal,
379 java.lang.String className, java.lang.String classPK, long groupId,
380 java.lang.String[] actionIds, long resourceId)
381 throws com.liferay.portal.PortalException,
382 com.liferay.portal.SystemException {
383 try {
384 Object paramObj0 = className;
385
386 if (className == null) {
387 paramObj0 = new NullWrapper("java.lang.String");
388 }
389
390 Object paramObj1 = classPK;
391
392 if (classPK == null) {
393 paramObj1 = new NullWrapper("java.lang.String");
394 }
395
396 Object paramObj2 = new LongWrapper(groupId);
397
398 Object paramObj3 = actionIds;
399
400 if (actionIds == null) {
401 paramObj3 = new NullWrapper("[Ljava.lang.String;");
402 }
403
404 Object paramObj4 = new LongWrapper(resourceId);
405
406 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
407 "setGroupPermissions",
408 new Object[] {
409 paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
410 });
411
412 try {
413 TunnelUtil.invoke(httpPrincipal, methodWrapper);
414 }
415 catch (Exception e) {
416 if (e instanceof com.liferay.portal.PortalException) {
417 throw (com.liferay.portal.PortalException)e;
418 }
419
420 if (e instanceof com.liferay.portal.SystemException) {
421 throw (com.liferay.portal.SystemException)e;
422 }
423
424 throw new com.liferay.portal.SystemException(e);
425 }
426 }
427 catch (com.liferay.portal.SystemException se) {
428 _log.error(se, se);
429
430 throw se;
431 }
432 }
433
434 public static void setOrgGroupPermissions(HttpPrincipal httpPrincipal,
435 long organizationId, long groupId, java.lang.String[] actionIds,
436 long resourceId)
437 throws com.liferay.portal.PortalException,
438 com.liferay.portal.SystemException {
439 try {
440 Object paramObj0 = new LongWrapper(organizationId);
441
442 Object paramObj1 = new LongWrapper(groupId);
443
444 Object paramObj2 = actionIds;
445
446 if (actionIds == null) {
447 paramObj2 = new NullWrapper("[Ljava.lang.String;");
448 }
449
450 Object paramObj3 = new LongWrapper(resourceId);
451
452 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
453 "setOrgGroupPermissions",
454 new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
455
456 try {
457 TunnelUtil.invoke(httpPrincipal, methodWrapper);
458 }
459 catch (Exception e) {
460 if (e instanceof com.liferay.portal.PortalException) {
461 throw (com.liferay.portal.PortalException)e;
462 }
463
464 if (e instanceof com.liferay.portal.SystemException) {
465 throw (com.liferay.portal.SystemException)e;
466 }
467
468 throw new com.liferay.portal.SystemException(e);
469 }
470 }
471 catch (com.liferay.portal.SystemException se) {
472 _log.error(se, se);
473
474 throw se;
475 }
476 }
477
478 public static void setRolePermission(HttpPrincipal httpPrincipal,
479 long roleId, long groupId, java.lang.String name, int scope,
480 java.lang.String primKey, java.lang.String actionId)
481 throws com.liferay.portal.PortalException,
482 com.liferay.portal.SystemException {
483 try {
484 Object paramObj0 = new LongWrapper(roleId);
485
486 Object paramObj1 = new LongWrapper(groupId);
487
488 Object paramObj2 = name;
489
490 if (name == null) {
491 paramObj2 = new NullWrapper("java.lang.String");
492 }
493
494 Object paramObj3 = new IntegerWrapper(scope);
495
496 Object paramObj4 = primKey;
497
498 if (primKey == null) {
499 paramObj4 = new NullWrapper("java.lang.String");
500 }
501
502 Object paramObj5 = actionId;
503
504 if (actionId == null) {
505 paramObj5 = new NullWrapper("java.lang.String");
506 }
507
508 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
509 "setRolePermission",
510 new Object[] {
511 paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
512 paramObj5
513 });
514
515 try {
516 TunnelUtil.invoke(httpPrincipal, methodWrapper);
517 }
518 catch (Exception e) {
519 if (e instanceof com.liferay.portal.PortalException) {
520 throw (com.liferay.portal.PortalException)e;
521 }
522
523 if (e instanceof com.liferay.portal.SystemException) {
524 throw (com.liferay.portal.SystemException)e;
525 }
526
527 throw new com.liferay.portal.SystemException(e);
528 }
529 }
530 catch (com.liferay.portal.SystemException se) {
531 _log.error(se, se);
532
533 throw se;
534 }
535 }
536
537 public static void setRolePermissions(HttpPrincipal httpPrincipal,
538 long roleId, long groupId, java.lang.String[] actionIds, long resourceId)
539 throws com.liferay.portal.PortalException,
540 com.liferay.portal.SystemException {
541 try {
542 Object paramObj0 = new LongWrapper(roleId);
543
544 Object paramObj1 = new LongWrapper(groupId);
545
546 Object paramObj2 = actionIds;
547
548 if (actionIds == null) {
549 paramObj2 = new NullWrapper("[Ljava.lang.String;");
550 }
551
552 Object paramObj3 = new LongWrapper(resourceId);
553
554 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
555 "setRolePermissions",
556 new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
557
558 try {
559 TunnelUtil.invoke(httpPrincipal, methodWrapper);
560 }
561 catch (Exception e) {
562 if (e instanceof com.liferay.portal.PortalException) {
563 throw (com.liferay.portal.PortalException)e;
564 }
565
566 if (e instanceof com.liferay.portal.SystemException) {
567 throw (com.liferay.portal.SystemException)e;
568 }
569
570 throw new com.liferay.portal.SystemException(e);
571 }
572 }
573 catch (com.liferay.portal.SystemException se) {
574 _log.error(se, se);
575
576 throw se;
577 }
578 }
579
580 public static void setUserPermissions(HttpPrincipal httpPrincipal,
581 long userId, long groupId, java.lang.String[] actionIds, long resourceId)
582 throws com.liferay.portal.PortalException,
583 com.liferay.portal.SystemException {
584 try {
585 Object paramObj0 = new LongWrapper(userId);
586
587 Object paramObj1 = new LongWrapper(groupId);
588
589 Object paramObj2 = actionIds;
590
591 if (actionIds == null) {
592 paramObj2 = new NullWrapper("[Ljava.lang.String;");
593 }
594
595 Object paramObj3 = new LongWrapper(resourceId);
596
597 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
598 "setUserPermissions",
599 new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
600
601 try {
602 TunnelUtil.invoke(httpPrincipal, methodWrapper);
603 }
604 catch (Exception e) {
605 if (e instanceof com.liferay.portal.PortalException) {
606 throw (com.liferay.portal.PortalException)e;
607 }
608
609 if (e instanceof com.liferay.portal.SystemException) {
610 throw (com.liferay.portal.SystemException)e;
611 }
612
613 throw new com.liferay.portal.SystemException(e);
614 }
615 }
616 catch (com.liferay.portal.SystemException se) {
617 _log.error(se, se);
618
619 throw se;
620 }
621 }
622
623 public static void unsetRolePermission(HttpPrincipal httpPrincipal,
624 long roleId, long groupId, long permissionId)
625 throws com.liferay.portal.PortalException,
626 com.liferay.portal.SystemException {
627 try {
628 Object paramObj0 = new LongWrapper(roleId);
629
630 Object paramObj1 = new LongWrapper(groupId);
631
632 Object paramObj2 = new LongWrapper(permissionId);
633
634 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
635 "unsetRolePermission",
636 new Object[] { paramObj0, paramObj1, paramObj2 });
637
638 try {
639 TunnelUtil.invoke(httpPrincipal, methodWrapper);
640 }
641 catch (Exception e) {
642 if (e instanceof com.liferay.portal.PortalException) {
643 throw (com.liferay.portal.PortalException)e;
644 }
645
646 if (e instanceof com.liferay.portal.SystemException) {
647 throw (com.liferay.portal.SystemException)e;
648 }
649
650 throw new com.liferay.portal.SystemException(e);
651 }
652 }
653 catch (com.liferay.portal.SystemException se) {
654 _log.error(se, se);
655
656 throw se;
657 }
658 }
659
660 public static void unsetRolePermission(HttpPrincipal httpPrincipal,
661 long roleId, long groupId, java.lang.String name, int scope,
662 java.lang.String primKey, java.lang.String actionId)
663 throws com.liferay.portal.PortalException,
664 com.liferay.portal.SystemException {
665 try {
666 Object paramObj0 = new LongWrapper(roleId);
667
668 Object paramObj1 = new LongWrapper(groupId);
669
670 Object paramObj2 = name;
671
672 if (name == null) {
673 paramObj2 = new NullWrapper("java.lang.String");
674 }
675
676 Object paramObj3 = new IntegerWrapper(scope);
677
678 Object paramObj4 = primKey;
679
680 if (primKey == null) {
681 paramObj4 = new NullWrapper("java.lang.String");
682 }
683
684 Object paramObj5 = actionId;
685
686 if (actionId == null) {
687 paramObj5 = new NullWrapper("java.lang.String");
688 }
689
690 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
691 "unsetRolePermission",
692 new Object[] {
693 paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
694 paramObj5
695 });
696
697 try {
698 TunnelUtil.invoke(httpPrincipal, methodWrapper);
699 }
700 catch (Exception e) {
701 if (e instanceof com.liferay.portal.PortalException) {
702 throw (com.liferay.portal.PortalException)e;
703 }
704
705 if (e instanceof com.liferay.portal.SystemException) {
706 throw (com.liferay.portal.SystemException)e;
707 }
708
709 throw new com.liferay.portal.SystemException(e);
710 }
711 }
712 catch (com.liferay.portal.SystemException se) {
713 _log.error(se, se);
714
715 throw se;
716 }
717 }
718
719 public static void unsetRolePermissions(HttpPrincipal httpPrincipal,
720 long roleId, long groupId, java.lang.String name, int scope,
721 java.lang.String actionId)
722 throws com.liferay.portal.PortalException,
723 com.liferay.portal.SystemException {
724 try {
725 Object paramObj0 = new LongWrapper(roleId);
726
727 Object paramObj1 = new LongWrapper(groupId);
728
729 Object paramObj2 = name;
730
731 if (name == null) {
732 paramObj2 = new NullWrapper("java.lang.String");
733 }
734
735 Object paramObj3 = new IntegerWrapper(scope);
736
737 Object paramObj4 = actionId;
738
739 if (actionId == null) {
740 paramObj4 = new NullWrapper("java.lang.String");
741 }
742
743 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
744 "unsetRolePermissions",
745 new Object[] {
746 paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
747 });
748
749 try {
750 TunnelUtil.invoke(httpPrincipal, methodWrapper);
751 }
752 catch (Exception e) {
753 if (e instanceof com.liferay.portal.PortalException) {
754 throw (com.liferay.portal.PortalException)e;
755 }
756
757 if (e instanceof com.liferay.portal.SystemException) {
758 throw (com.liferay.portal.SystemException)e;
759 }
760
761 throw new com.liferay.portal.SystemException(e);
762 }
763 }
764 catch (com.liferay.portal.SystemException se) {
765 _log.error(se, se);
766
767 throw se;
768 }
769 }
770
771 public static void unsetUserPermissions(HttpPrincipal httpPrincipal,
772 long userId, long groupId, java.lang.String[] actionIds, long resourceId)
773 throws com.liferay.portal.PortalException,
774 com.liferay.portal.SystemException {
775 try {
776 Object paramObj0 = new LongWrapper(userId);
777
778 Object paramObj1 = new LongWrapper(groupId);
779
780 Object paramObj2 = actionIds;
781
782 if (actionIds == null) {
783 paramObj2 = new NullWrapper("[Ljava.lang.String;");
784 }
785
786 Object paramObj3 = new LongWrapper(resourceId);
787
788 MethodWrapper methodWrapper = new MethodWrapper(PermissionServiceUtil.class.getName(),
789 "unsetUserPermissions",
790 new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
791
792 try {
793 TunnelUtil.invoke(httpPrincipal, methodWrapper);
794 }
795 catch (Exception e) {
796 if (e instanceof com.liferay.portal.PortalException) {
797 throw (com.liferay.portal.PortalException)e;
798 }
799
800 if (e instanceof com.liferay.portal.SystemException) {
801 throw (com.liferay.portal.SystemException)e;
802 }
803
804 throw new com.liferay.portal.SystemException(e);
805 }
806 }
807 catch (com.liferay.portal.SystemException se) {
808 _log.error(se, se);
809
810 throw se;
811 }
812 }
813
814 private static Log _log = LogFactoryUtil.getLog(PermissionServiceHttp.class);
815 }