1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
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  /**
28   * <a href="RoleServiceHttp.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * ServiceBuilder generated this class. Modifications in this class will be
32   * overwritten the next time is generated.
33   * </p>
34   *
35   * <p>
36   * This class provides a HTTP utility for the
37   * {@link com.liferay.portal.service.RoleServiceUtil} service utility. The
38   * static methods of this class calls the same methods of the service utility.
39   * However, the signatures are different because it requires an additional
40   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
41   * </p>
42   *
43   * <p>
44   * The benefits of using the HTTP utility is that it is fast and allows for
45   * tunneling without the cost of serializing to text. The drawback is that it
46   * only works with Java.
47   * </p>
48   *
49   * <p>
50   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
51   * configure security.
52   * </p>
53   *
54   * <p>
55   * The HTTP utility is only generated for remote services.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       RoleServiceSoap
60   * @see       com.liferay.portal.security.auth.HttpPrincipal
61   * @see       com.liferay.portal.service.RoleServiceUtil
62   * @generated
63   */
64  public class RoleServiceHttp {
65      public static com.liferay.portal.model.Role addRole(
66          HttpPrincipal httpPrincipal, java.lang.String name,
67          java.lang.String description, int type)
68          throws com.liferay.portal.PortalException,
69              com.liferay.portal.SystemException {
70          try {
71              Object paramObj0 = name;
72  
73              if (name == null) {
74                  paramObj0 = new NullWrapper("java.lang.String");
75              }
76  
77              Object paramObj1 = description;
78  
79              if (description == null) {
80                  paramObj1 = new NullWrapper("java.lang.String");
81              }
82  
83              Object paramObj2 = new IntegerWrapper(type);
84  
85              MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
86                      "addRole", new Object[] { paramObj0, paramObj1, paramObj2 });
87  
88              Object returnObj = null;
89  
90              try {
91                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
92              }
93              catch (Exception e) {
94                  if (e instanceof com.liferay.portal.PortalException) {
95                      throw (com.liferay.portal.PortalException)e;
96                  }
97  
98                  if (e instanceof com.liferay.portal.SystemException) {
99                      throw (com.liferay.portal.SystemException)e;
100                 }
101 
102                 throw new com.liferay.portal.SystemException(e);
103             }
104 
105             return (com.liferay.portal.model.Role)returnObj;
106         }
107         catch (com.liferay.portal.SystemException se) {
108             _log.error(se, se);
109 
110             throw se;
111         }
112     }
113 
114     public static void addUserRoles(HttpPrincipal httpPrincipal, long userId,
115         long[] roleIds)
116         throws com.liferay.portal.PortalException,
117             com.liferay.portal.SystemException {
118         try {
119             Object paramObj0 = new LongWrapper(userId);
120 
121             Object paramObj1 = roleIds;
122 
123             if (roleIds == null) {
124                 paramObj1 = new NullWrapper("[J");
125             }
126 
127             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
128                     "addUserRoles", new Object[] { paramObj0, paramObj1 });
129 
130             try {
131                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
132             }
133             catch (Exception e) {
134                 if (e instanceof com.liferay.portal.PortalException) {
135                     throw (com.liferay.portal.PortalException)e;
136                 }
137 
138                 if (e instanceof com.liferay.portal.SystemException) {
139                     throw (com.liferay.portal.SystemException)e;
140                 }
141 
142                 throw new com.liferay.portal.SystemException(e);
143             }
144         }
145         catch (com.liferay.portal.SystemException se) {
146             _log.error(se, se);
147 
148             throw se;
149         }
150     }
151 
152     public static void deleteRole(HttpPrincipal httpPrincipal, long roleId)
153         throws com.liferay.portal.PortalException,
154             com.liferay.portal.SystemException {
155         try {
156             Object paramObj0 = new LongWrapper(roleId);
157 
158             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
159                     "deleteRole", new Object[] { paramObj0 });
160 
161             try {
162                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
163             }
164             catch (Exception e) {
165                 if (e instanceof com.liferay.portal.PortalException) {
166                     throw (com.liferay.portal.PortalException)e;
167                 }
168 
169                 if (e instanceof com.liferay.portal.SystemException) {
170                     throw (com.liferay.portal.SystemException)e;
171                 }
172 
173                 throw new com.liferay.portal.SystemException(e);
174             }
175         }
176         catch (com.liferay.portal.SystemException se) {
177             _log.error(se, se);
178 
179             throw se;
180         }
181     }
182 
183     public static com.liferay.portal.model.Role getGroupRole(
184         HttpPrincipal httpPrincipal, long companyId, long groupId)
185         throws com.liferay.portal.PortalException,
186             com.liferay.portal.SystemException {
187         try {
188             Object paramObj0 = new LongWrapper(companyId);
189 
190             Object paramObj1 = new LongWrapper(groupId);
191 
192             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
193                     "getGroupRole", new Object[] { paramObj0, paramObj1 });
194 
195             Object returnObj = null;
196 
197             try {
198                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
199             }
200             catch (Exception e) {
201                 if (e instanceof com.liferay.portal.PortalException) {
202                     throw (com.liferay.portal.PortalException)e;
203                 }
204 
205                 if (e instanceof com.liferay.portal.SystemException) {
206                     throw (com.liferay.portal.SystemException)e;
207                 }
208 
209                 throw new com.liferay.portal.SystemException(e);
210             }
211 
212             return (com.liferay.portal.model.Role)returnObj;
213         }
214         catch (com.liferay.portal.SystemException se) {
215             _log.error(se, se);
216 
217             throw se;
218         }
219     }
220 
221     public static java.util.List<com.liferay.portal.model.Role> getGroupRoles(
222         HttpPrincipal httpPrincipal, long groupId)
223         throws com.liferay.portal.SystemException {
224         try {
225             Object paramObj0 = new LongWrapper(groupId);
226 
227             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
228                     "getGroupRoles", new Object[] { paramObj0 });
229 
230             Object returnObj = null;
231 
232             try {
233                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
234             }
235             catch (Exception e) {
236                 if (e instanceof com.liferay.portal.SystemException) {
237                     throw (com.liferay.portal.SystemException)e;
238                 }
239 
240                 throw new com.liferay.portal.SystemException(e);
241             }
242 
243             return (java.util.List<com.liferay.portal.model.Role>)returnObj;
244         }
245         catch (com.liferay.portal.SystemException se) {
246             _log.error(se, se);
247 
248             throw se;
249         }
250     }
251 
252     public static com.liferay.portal.model.Role getRole(
253         HttpPrincipal httpPrincipal, long roleId)
254         throws com.liferay.portal.PortalException,
255             com.liferay.portal.SystemException {
256         try {
257             Object paramObj0 = new LongWrapper(roleId);
258 
259             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
260                     "getRole", new Object[] { paramObj0 });
261 
262             Object returnObj = null;
263 
264             try {
265                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
266             }
267             catch (Exception e) {
268                 if (e instanceof com.liferay.portal.PortalException) {
269                     throw (com.liferay.portal.PortalException)e;
270                 }
271 
272                 if (e instanceof com.liferay.portal.SystemException) {
273                     throw (com.liferay.portal.SystemException)e;
274                 }
275 
276                 throw new com.liferay.portal.SystemException(e);
277             }
278 
279             return (com.liferay.portal.model.Role)returnObj;
280         }
281         catch (com.liferay.portal.SystemException se) {
282             _log.error(se, se);
283 
284             throw se;
285         }
286     }
287 
288     public static com.liferay.portal.model.Role getRole(
289         HttpPrincipal httpPrincipal, long companyId, java.lang.String name)
290         throws com.liferay.portal.PortalException,
291             com.liferay.portal.SystemException {
292         try {
293             Object paramObj0 = new LongWrapper(companyId);
294 
295             Object paramObj1 = name;
296 
297             if (name == null) {
298                 paramObj1 = new NullWrapper("java.lang.String");
299             }
300 
301             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
302                     "getRole", new Object[] { paramObj0, paramObj1 });
303 
304             Object returnObj = null;
305 
306             try {
307                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
308             }
309             catch (Exception e) {
310                 if (e instanceof com.liferay.portal.PortalException) {
311                     throw (com.liferay.portal.PortalException)e;
312                 }
313 
314                 if (e instanceof com.liferay.portal.SystemException) {
315                     throw (com.liferay.portal.SystemException)e;
316                 }
317 
318                 throw new com.liferay.portal.SystemException(e);
319             }
320 
321             return (com.liferay.portal.model.Role)returnObj;
322         }
323         catch (com.liferay.portal.SystemException se) {
324             _log.error(se, se);
325 
326             throw se;
327         }
328     }
329 
330     public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles(
331         HttpPrincipal httpPrincipal, long userId, long groupId)
332         throws com.liferay.portal.SystemException {
333         try {
334             Object paramObj0 = new LongWrapper(userId);
335 
336             Object paramObj1 = new LongWrapper(groupId);
337 
338             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
339                     "getUserGroupRoles", new Object[] { paramObj0, paramObj1 });
340 
341             Object returnObj = null;
342 
343             try {
344                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
345             }
346             catch (Exception e) {
347                 if (e instanceof com.liferay.portal.SystemException) {
348                     throw (com.liferay.portal.SystemException)e;
349                 }
350 
351                 throw new com.liferay.portal.SystemException(e);
352             }
353 
354             return (java.util.List<com.liferay.portal.model.Role>)returnObj;
355         }
356         catch (com.liferay.portal.SystemException se) {
357             _log.error(se, se);
358 
359             throw se;
360         }
361     }
362 
363     public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles(
364         HttpPrincipal httpPrincipal, long userId,
365         java.util.List<com.liferay.portal.model.Group> groups)
366         throws com.liferay.portal.SystemException {
367         try {
368             Object paramObj0 = new LongWrapper(userId);
369 
370             Object paramObj1 = groups;
371 
372             if (groups == null) {
373                 paramObj1 = new NullWrapper("java.util.List");
374             }
375 
376             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
377                     "getUserRelatedRoles", new Object[] { paramObj0, paramObj1 });
378 
379             Object returnObj = null;
380 
381             try {
382                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
383             }
384             catch (Exception e) {
385                 if (e instanceof com.liferay.portal.SystemException) {
386                     throw (com.liferay.portal.SystemException)e;
387                 }
388 
389                 throw new com.liferay.portal.SystemException(e);
390             }
391 
392             return (java.util.List<com.liferay.portal.model.Role>)returnObj;
393         }
394         catch (com.liferay.portal.SystemException se) {
395             _log.error(se, se);
396 
397             throw se;
398         }
399     }
400 
401     public static java.util.List<com.liferay.portal.model.Role> getUserRoles(
402         HttpPrincipal httpPrincipal, long userId)
403         throws com.liferay.portal.SystemException {
404         try {
405             Object paramObj0 = new LongWrapper(userId);
406 
407             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
408                     "getUserRoles", new Object[] { paramObj0 });
409 
410             Object returnObj = null;
411 
412             try {
413                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
414             }
415             catch (Exception e) {
416                 if (e instanceof com.liferay.portal.SystemException) {
417                     throw (com.liferay.portal.SystemException)e;
418                 }
419 
420                 throw new com.liferay.portal.SystemException(e);
421             }
422 
423             return (java.util.List<com.liferay.portal.model.Role>)returnObj;
424         }
425         catch (com.liferay.portal.SystemException se) {
426             _log.error(se, se);
427 
428             throw se;
429         }
430     }
431 
432     public static boolean hasUserRole(HttpPrincipal httpPrincipal, long userId,
433         long companyId, java.lang.String name, boolean inherited)
434         throws com.liferay.portal.PortalException,
435             com.liferay.portal.SystemException {
436         try {
437             Object paramObj0 = new LongWrapper(userId);
438 
439             Object paramObj1 = new LongWrapper(companyId);
440 
441             Object paramObj2 = name;
442 
443             if (name == null) {
444                 paramObj2 = new NullWrapper("java.lang.String");
445             }
446 
447             Object paramObj3 = new BooleanWrapper(inherited);
448 
449             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
450                     "hasUserRole",
451                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
452 
453             Object returnObj = null;
454 
455             try {
456                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
457             }
458             catch (Exception e) {
459                 if (e instanceof com.liferay.portal.PortalException) {
460                     throw (com.liferay.portal.PortalException)e;
461                 }
462 
463                 if (e instanceof com.liferay.portal.SystemException) {
464                     throw (com.liferay.portal.SystemException)e;
465                 }
466 
467                 throw new com.liferay.portal.SystemException(e);
468             }
469 
470             return ((Boolean)returnObj).booleanValue();
471         }
472         catch (com.liferay.portal.SystemException se) {
473             _log.error(se, se);
474 
475             throw se;
476         }
477     }
478 
479     public static boolean hasUserRoles(HttpPrincipal httpPrincipal,
480         long userId, long companyId, java.lang.String[] names, boolean inherited)
481         throws com.liferay.portal.PortalException,
482             com.liferay.portal.SystemException {
483         try {
484             Object paramObj0 = new LongWrapper(userId);
485 
486             Object paramObj1 = new LongWrapper(companyId);
487 
488             Object paramObj2 = names;
489 
490             if (names == null) {
491                 paramObj2 = new NullWrapper("[Ljava.lang.String;");
492             }
493 
494             Object paramObj3 = new BooleanWrapper(inherited);
495 
496             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
497                     "hasUserRoles",
498                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
499 
500             Object returnObj = null;
501 
502             try {
503                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
504             }
505             catch (Exception e) {
506                 if (e instanceof com.liferay.portal.PortalException) {
507                     throw (com.liferay.portal.PortalException)e;
508                 }
509 
510                 if (e instanceof com.liferay.portal.SystemException) {
511                     throw (com.liferay.portal.SystemException)e;
512                 }
513 
514                 throw new com.liferay.portal.SystemException(e);
515             }
516 
517             return ((Boolean)returnObj).booleanValue();
518         }
519         catch (com.liferay.portal.SystemException se) {
520             _log.error(se, se);
521 
522             throw se;
523         }
524     }
525 
526     public static void unsetUserRoles(HttpPrincipal httpPrincipal, long userId,
527         long[] roleIds)
528         throws com.liferay.portal.PortalException,
529             com.liferay.portal.SystemException {
530         try {
531             Object paramObj0 = new LongWrapper(userId);
532 
533             Object paramObj1 = roleIds;
534 
535             if (roleIds == null) {
536                 paramObj1 = new NullWrapper("[J");
537             }
538 
539             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
540                     "unsetUserRoles", new Object[] { paramObj0, paramObj1 });
541 
542             try {
543                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
544             }
545             catch (Exception e) {
546                 if (e instanceof com.liferay.portal.PortalException) {
547                     throw (com.liferay.portal.PortalException)e;
548                 }
549 
550                 if (e instanceof com.liferay.portal.SystemException) {
551                     throw (com.liferay.portal.SystemException)e;
552                 }
553 
554                 throw new com.liferay.portal.SystemException(e);
555             }
556         }
557         catch (com.liferay.portal.SystemException se) {
558             _log.error(se, se);
559 
560             throw se;
561         }
562     }
563 
564     public static com.liferay.portal.model.Role updateRole(
565         HttpPrincipal httpPrincipal, long roleId, java.lang.String name,
566         java.lang.String description)
567         throws com.liferay.portal.PortalException,
568             com.liferay.portal.SystemException {
569         try {
570             Object paramObj0 = new LongWrapper(roleId);
571 
572             Object paramObj1 = name;
573 
574             if (name == null) {
575                 paramObj1 = new NullWrapper("java.lang.String");
576             }
577 
578             Object paramObj2 = description;
579 
580             if (description == null) {
581                 paramObj2 = new NullWrapper("java.lang.String");
582             }
583 
584             MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
585                     "updateRole",
586                     new Object[] { paramObj0, paramObj1, paramObj2 });
587 
588             Object returnObj = null;
589 
590             try {
591                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
592             }
593             catch (Exception e) {
594                 if (e instanceof com.liferay.portal.PortalException) {
595                     throw (com.liferay.portal.PortalException)e;
596                 }
597 
598                 if (e instanceof com.liferay.portal.SystemException) {
599                     throw (com.liferay.portal.SystemException)e;
600                 }
601 
602                 throw new com.liferay.portal.SystemException(e);
603             }
604 
605             return (com.liferay.portal.model.Role)returnObj;
606         }
607         catch (com.liferay.portal.SystemException se) {
608             _log.error(se, se);
609 
610             throw se;
611         }
612     }
613 
614     private static Log _log = LogFactoryUtil.getLog(RoleServiceHttp.class);
615 }