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