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