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