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