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