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