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