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