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.PortalException,
79 com.liferay.portal.SystemException {
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.PortalException) {
105 throw (com.liferay.portal.PortalException)e;
106 }
107
108 if (e instanceof com.liferay.portal.SystemException) {
109 throw (com.liferay.portal.SystemException)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.PortalException,
127 com.liferay.portal.SystemException {
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.PortalException) {
145 throw (com.liferay.portal.PortalException)e;
146 }
147
148 if (e instanceof com.liferay.portal.SystemException) {
149 throw (com.liferay.portal.SystemException)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.PortalException,
164 com.liferay.portal.SystemException {
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.PortalException) {
176 throw (com.liferay.portal.PortalException)e;
177 }
178
179 if (e instanceof com.liferay.portal.SystemException) {
180 throw (com.liferay.portal.SystemException)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.PortalException,
196 com.liferay.portal.SystemException {
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.PortalException) {
212 throw (com.liferay.portal.PortalException)e;
213 }
214
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 (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<com.liferay.portal.model.Role> getGroupRoles(
232 HttpPrincipal httpPrincipal, long groupId)
233 throws com.liferay.portal.SystemException {
234 try {
235 Object paramObj0 = new LongWrapper(groupId);
236
237 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
238 "getGroupRoles", new Object[] { paramObj0 });
239
240 Object returnObj = null;
241
242 try {
243 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
244 }
245 catch (Exception e) {
246 if (e instanceof com.liferay.portal.SystemException) {
247 throw (com.liferay.portal.SystemException)e;
248 }
249
250 throw new com.liferay.portal.SystemException(e);
251 }
252
253 return (java.util.List<com.liferay.portal.model.Role>)returnObj;
254 }
255 catch (com.liferay.portal.SystemException se) {
256 _log.error(se, se);
257
258 throw se;
259 }
260 }
261
262 public static com.liferay.portal.model.Role getRole(
263 HttpPrincipal httpPrincipal, long roleId)
264 throws com.liferay.portal.PortalException,
265 com.liferay.portal.SystemException {
266 try {
267 Object paramObj0 = new LongWrapper(roleId);
268
269 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
270 "getRole", new Object[] { paramObj0 });
271
272 Object returnObj = null;
273
274 try {
275 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
276 }
277 catch (Exception e) {
278 if (e instanceof com.liferay.portal.PortalException) {
279 throw (com.liferay.portal.PortalException)e;
280 }
281
282 if (e instanceof com.liferay.portal.SystemException) {
283 throw (com.liferay.portal.SystemException)e;
284 }
285
286 throw new com.liferay.portal.SystemException(e);
287 }
288
289 return (com.liferay.portal.model.Role)returnObj;
290 }
291 catch (com.liferay.portal.SystemException se) {
292 _log.error(se, se);
293
294 throw se;
295 }
296 }
297
298 public static com.liferay.portal.model.Role getRole(
299 HttpPrincipal httpPrincipal, long companyId, java.lang.String name)
300 throws com.liferay.portal.PortalException,
301 com.liferay.portal.SystemException {
302 try {
303 Object paramObj0 = new LongWrapper(companyId);
304
305 Object paramObj1 = name;
306
307 if (name == null) {
308 paramObj1 = new NullWrapper("java.lang.String");
309 }
310
311 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
312 "getRole", new Object[] { paramObj0, paramObj1 });
313
314 Object returnObj = null;
315
316 try {
317 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
318 }
319 catch (Exception e) {
320 if (e instanceof com.liferay.portal.PortalException) {
321 throw (com.liferay.portal.PortalException)e;
322 }
323
324 if (e instanceof com.liferay.portal.SystemException) {
325 throw (com.liferay.portal.SystemException)e;
326 }
327
328 throw new com.liferay.portal.SystemException(e);
329 }
330
331 return (com.liferay.portal.model.Role)returnObj;
332 }
333 catch (com.liferay.portal.SystemException se) {
334 _log.error(se, se);
335
336 throw se;
337 }
338 }
339
340 public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles(
341 HttpPrincipal httpPrincipal, long userId, long groupId)
342 throws com.liferay.portal.SystemException {
343 try {
344 Object paramObj0 = new LongWrapper(userId);
345
346 Object paramObj1 = new LongWrapper(groupId);
347
348 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
349 "getUserGroupRoles", new Object[] { paramObj0, paramObj1 });
350
351 Object returnObj = null;
352
353 try {
354 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
355 }
356 catch (Exception e) {
357 if (e instanceof com.liferay.portal.SystemException) {
358 throw (com.liferay.portal.SystemException)e;
359 }
360
361 throw new com.liferay.portal.SystemException(e);
362 }
363
364 return (java.util.List<com.liferay.portal.model.Role>)returnObj;
365 }
366 catch (com.liferay.portal.SystemException se) {
367 _log.error(se, se);
368
369 throw se;
370 }
371 }
372
373 public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles(
374 HttpPrincipal httpPrincipal, long userId,
375 java.util.List<com.liferay.portal.model.Group> groups)
376 throws com.liferay.portal.SystemException {
377 try {
378 Object paramObj0 = new LongWrapper(userId);
379
380 Object paramObj1 = groups;
381
382 if (groups == null) {
383 paramObj1 = new NullWrapper("java.util.List");
384 }
385
386 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
387 "getUserRelatedRoles", new Object[] { paramObj0, paramObj1 });
388
389 Object returnObj = null;
390
391 try {
392 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
393 }
394 catch (Exception e) {
395 if (e instanceof com.liferay.portal.SystemException) {
396 throw (com.liferay.portal.SystemException)e;
397 }
398
399 throw new com.liferay.portal.SystemException(e);
400 }
401
402 return (java.util.List<com.liferay.portal.model.Role>)returnObj;
403 }
404 catch (com.liferay.portal.SystemException se) {
405 _log.error(se, se);
406
407 throw se;
408 }
409 }
410
411 public static java.util.List<com.liferay.portal.model.Role> getUserRoles(
412 HttpPrincipal httpPrincipal, long userId)
413 throws com.liferay.portal.SystemException {
414 try {
415 Object paramObj0 = new LongWrapper(userId);
416
417 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
418 "getUserRoles", new Object[] { paramObj0 });
419
420 Object returnObj = null;
421
422 try {
423 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
424 }
425 catch (Exception e) {
426 if (e instanceof com.liferay.portal.SystemException) {
427 throw (com.liferay.portal.SystemException)e;
428 }
429
430 throw new com.liferay.portal.SystemException(e);
431 }
432
433 return (java.util.List<com.liferay.portal.model.Role>)returnObj;
434 }
435 catch (com.liferay.portal.SystemException se) {
436 _log.error(se, se);
437
438 throw se;
439 }
440 }
441
442 public static boolean hasUserRole(HttpPrincipal httpPrincipal, long userId,
443 long companyId, java.lang.String name, boolean inherited)
444 throws com.liferay.portal.PortalException,
445 com.liferay.portal.SystemException {
446 try {
447 Object paramObj0 = new LongWrapper(userId);
448
449 Object paramObj1 = new LongWrapper(companyId);
450
451 Object paramObj2 = name;
452
453 if (name == null) {
454 paramObj2 = new NullWrapper("java.lang.String");
455 }
456
457 Object paramObj3 = new BooleanWrapper(inherited);
458
459 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
460 "hasUserRole",
461 new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
462
463 Object returnObj = null;
464
465 try {
466 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
467 }
468 catch (Exception e) {
469 if (e instanceof com.liferay.portal.PortalException) {
470 throw (com.liferay.portal.PortalException)e;
471 }
472
473 if (e instanceof com.liferay.portal.SystemException) {
474 throw (com.liferay.portal.SystemException)e;
475 }
476
477 throw new com.liferay.portal.SystemException(e);
478 }
479
480 return ((Boolean)returnObj).booleanValue();
481 }
482 catch (com.liferay.portal.SystemException se) {
483 _log.error(se, se);
484
485 throw se;
486 }
487 }
488
489 public static boolean hasUserRoles(HttpPrincipal httpPrincipal,
490 long userId, long companyId, java.lang.String[] names, boolean inherited)
491 throws com.liferay.portal.PortalException,
492 com.liferay.portal.SystemException {
493 try {
494 Object paramObj0 = new LongWrapper(userId);
495
496 Object paramObj1 = new LongWrapper(companyId);
497
498 Object paramObj2 = names;
499
500 if (names == null) {
501 paramObj2 = new NullWrapper("[Ljava.lang.String;");
502 }
503
504 Object paramObj3 = new BooleanWrapper(inherited);
505
506 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
507 "hasUserRoles",
508 new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
509
510 Object returnObj = null;
511
512 try {
513 returnObj = 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 return ((Boolean)returnObj).booleanValue();
528 }
529 catch (com.liferay.portal.SystemException se) {
530 _log.error(se, se);
531
532 throw se;
533 }
534 }
535
536 public static void unsetUserRoles(HttpPrincipal httpPrincipal, long userId,
537 long[] roleIds)
538 throws com.liferay.portal.PortalException,
539 com.liferay.portal.SystemException {
540 try {
541 Object paramObj0 = new LongWrapper(userId);
542
543 Object paramObj1 = roleIds;
544
545 if (roleIds == null) {
546 paramObj1 = new NullWrapper("[J");
547 }
548
549 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
550 "unsetUserRoles", new Object[] { paramObj0, paramObj1 });
551
552 try {
553 TunnelUtil.invoke(httpPrincipal, methodWrapper);
554 }
555 catch (Exception e) {
556 if (e instanceof com.liferay.portal.PortalException) {
557 throw (com.liferay.portal.PortalException)e;
558 }
559
560 if (e instanceof com.liferay.portal.SystemException) {
561 throw (com.liferay.portal.SystemException)e;
562 }
563
564 throw new com.liferay.portal.SystemException(e);
565 }
566 }
567 catch (com.liferay.portal.SystemException se) {
568 _log.error(se, se);
569
570 throw se;
571 }
572 }
573
574 public static com.liferay.portal.model.Role updateRole(
575 HttpPrincipal httpPrincipal, long roleId, java.lang.String name,
576 java.util.Map<java.util.Locale, String> localeTitlesMap,
577 java.lang.String description, java.lang.String subtype)
578 throws com.liferay.portal.PortalException,
579 com.liferay.portal.SystemException {
580 try {
581 Object paramObj0 = new LongWrapper(roleId);
582
583 Object paramObj1 = name;
584
585 if (name == null) {
586 paramObj1 = new NullWrapper("java.lang.String");
587 }
588
589 Object paramObj2 = localeTitlesMap;
590
591 if (localeTitlesMap == null) {
592 paramObj2 = new NullWrapper("java.util.Map");
593 }
594
595 Object paramObj3 = description;
596
597 if (description == null) {
598 paramObj3 = new NullWrapper("java.lang.String");
599 }
600
601 Object paramObj4 = subtype;
602
603 if (subtype == null) {
604 paramObj4 = new NullWrapper("java.lang.String");
605 }
606
607 MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
608 "updateRole",
609 new Object[] {
610 paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
611 });
612
613 Object returnObj = null;
614
615 try {
616 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
617 }
618 catch (Exception e) {
619 if (e instanceof com.liferay.portal.PortalException) {
620 throw (com.liferay.portal.PortalException)e;
621 }
622
623 if (e instanceof com.liferay.portal.SystemException) {
624 throw (com.liferay.portal.SystemException)e;
625 }
626
627 throw new com.liferay.portal.SystemException(e);
628 }
629
630 return (com.liferay.portal.model.Role)returnObj;
631 }
632 catch (com.liferay.portal.SystemException se) {
633 _log.error(se, se);
634
635 throw se;
636 }
637 }
638
639 private static Log _log = LogFactoryUtil.getLog(RoleServiceHttp.class);
640 }