001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.http;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.MethodHandler;
020    import com.liferay.portal.kernel.util.MethodKey;
021    import com.liferay.portal.security.auth.HttpPrincipal;
022    import com.liferay.portal.service.RoleServiceUtil;
023    
024    /**
025     * <p>
026     * This class provides a HTTP utility for the
027     * {@link com.liferay.portal.service.RoleServiceUtil} service utility. The
028     * static methods of this class calls the same methods of the service utility.
029     * However, the signatures are different because it requires an additional
030     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
031     * </p>
032     *
033     * <p>
034     * The benefits of using the HTTP utility is that it is fast and allows for
035     * tunneling without the cost of serializing to text. The drawback is that it
036     * only works with Java.
037     * </p>
038     *
039     * <p>
040     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
041     * configure security.
042     * </p>
043     *
044     * <p>
045     * The HTTP utility is only generated for remote services.
046     * </p>
047     *
048     * @author    Brian Wing Shun Chan
049     * @see       RoleServiceSoap
050     * @see       com.liferay.portal.security.auth.HttpPrincipal
051     * @see       com.liferay.portal.service.RoleServiceUtil
052     * @generated
053     */
054    public class RoleServiceHttp {
055            public static com.liferay.portal.model.Role addRole(
056                    HttpPrincipal httpPrincipal, java.lang.String name,
057                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
058                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
059                    int type)
060                    throws com.liferay.portal.kernel.exception.PortalException,
061                            com.liferay.portal.kernel.exception.SystemException {
062                    try {
063                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
064                                            "addRole", _addRoleParameterTypes0);
065    
066                            MethodHandler methodHandler = new MethodHandler(methodKey, name,
067                                            titleMap, descriptionMap, type);
068    
069                            Object returnObj = null;
070    
071                            try {
072                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
073                            }
074                            catch (Exception e) {
075                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
076                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
077                                    }
078    
079                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
080                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
081                                    }
082    
083                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
084                            }
085    
086                            return (com.liferay.portal.model.Role)returnObj;
087                    }
088                    catch (com.liferay.portal.kernel.exception.SystemException se) {
089                            _log.error(se, se);
090    
091                            throw se;
092                    }
093            }
094    
095            public static void addUserRoles(HttpPrincipal httpPrincipal, long userId,
096                    long[] roleIds)
097                    throws com.liferay.portal.kernel.exception.PortalException,
098                            com.liferay.portal.kernel.exception.SystemException {
099                    try {
100                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
101                                            "addUserRoles", _addUserRolesParameterTypes1);
102    
103                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
104                                            roleIds);
105    
106                            try {
107                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
108                            }
109                            catch (Exception e) {
110                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
111                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
112                                    }
113    
114                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
115                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
116                                    }
117    
118                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
119                            }
120                    }
121                    catch (com.liferay.portal.kernel.exception.SystemException se) {
122                            _log.error(se, se);
123    
124                            throw se;
125                    }
126            }
127    
128            public static void deleteRole(HttpPrincipal httpPrincipal, long roleId)
129                    throws com.liferay.portal.kernel.exception.PortalException,
130                            com.liferay.portal.kernel.exception.SystemException {
131                    try {
132                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
133                                            "deleteRole", _deleteRoleParameterTypes2);
134    
135                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId);
136    
137                            try {
138                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
139                            }
140                            catch (Exception e) {
141                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
142                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
143                                    }
144    
145                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
146                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
147                                    }
148    
149                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
150                            }
151                    }
152                    catch (com.liferay.portal.kernel.exception.SystemException se) {
153                            _log.error(se, se);
154    
155                            throw se;
156                    }
157            }
158    
159            public static java.util.List<com.liferay.portal.model.Role> getGroupRoles(
160                    HttpPrincipal httpPrincipal, long groupId)
161                    throws com.liferay.portal.kernel.exception.PortalException,
162                            com.liferay.portal.kernel.exception.SystemException {
163                    try {
164                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
165                                            "getGroupRoles", _getGroupRolesParameterTypes3);
166    
167                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId);
168    
169                            Object returnObj = null;
170    
171                            try {
172                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
173                            }
174                            catch (Exception e) {
175                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
176                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
177                                    }
178    
179                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
180                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
181                                    }
182    
183                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
184                            }
185    
186                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
187                    }
188                    catch (com.liferay.portal.kernel.exception.SystemException se) {
189                            _log.error(se, se);
190    
191                            throw se;
192                    }
193            }
194    
195            public static com.liferay.portal.model.Role getRole(
196                    HttpPrincipal httpPrincipal, long roleId)
197                    throws com.liferay.portal.kernel.exception.PortalException,
198                            com.liferay.portal.kernel.exception.SystemException {
199                    try {
200                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
201                                            "getRole", _getRoleParameterTypes4);
202    
203                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId);
204    
205                            Object returnObj = null;
206    
207                            try {
208                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
209                            }
210                            catch (Exception e) {
211                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
212                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
213                                    }
214    
215                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
216                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
217                                    }
218    
219                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
220                            }
221    
222                            return (com.liferay.portal.model.Role)returnObj;
223                    }
224                    catch (com.liferay.portal.kernel.exception.SystemException se) {
225                            _log.error(se, se);
226    
227                            throw se;
228                    }
229            }
230    
231            public static com.liferay.portal.model.Role getRole(
232                    HttpPrincipal httpPrincipal, long companyId, java.lang.String name)
233                    throws com.liferay.portal.kernel.exception.PortalException,
234                            com.liferay.portal.kernel.exception.SystemException {
235                    try {
236                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
237                                            "getRole", _getRoleParameterTypes5);
238    
239                            MethodHandler methodHandler = new MethodHandler(methodKey,
240                                            companyId, name);
241    
242                            Object returnObj = null;
243    
244                            try {
245                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
246                            }
247                            catch (Exception e) {
248                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
249                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
250                                    }
251    
252                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
253                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
254                                    }
255    
256                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
257                            }
258    
259                            return (com.liferay.portal.model.Role)returnObj;
260                    }
261                    catch (com.liferay.portal.kernel.exception.SystemException se) {
262                            _log.error(se, se);
263    
264                            throw se;
265                    }
266            }
267    
268            public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles(
269                    HttpPrincipal httpPrincipal, long userId, long groupId)
270                    throws com.liferay.portal.kernel.exception.PortalException,
271                            com.liferay.portal.kernel.exception.SystemException {
272                    try {
273                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
274                                            "getUserGroupGroupRoles",
275                                            _getUserGroupGroupRolesParameterTypes6);
276    
277                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
278                                            groupId);
279    
280                            Object returnObj = null;
281    
282                            try {
283                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
284                            }
285                            catch (Exception e) {
286                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
287                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
288                                    }
289    
290                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
291                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
292                                    }
293    
294                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
295                            }
296    
297                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
298                    }
299                    catch (com.liferay.portal.kernel.exception.SystemException se) {
300                            _log.error(se, se);
301    
302                            throw se;
303                    }
304            }
305    
306            public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles(
307                    HttpPrincipal httpPrincipal, long userId, long groupId)
308                    throws com.liferay.portal.kernel.exception.PortalException,
309                            com.liferay.portal.kernel.exception.SystemException {
310                    try {
311                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
312                                            "getUserGroupRoles", _getUserGroupRolesParameterTypes7);
313    
314                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
315                                            groupId);
316    
317                            Object returnObj = null;
318    
319                            try {
320                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
321                            }
322                            catch (Exception e) {
323                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
324                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
325                                    }
326    
327                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
328                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
329                                    }
330    
331                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
332                            }
333    
334                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
335                    }
336                    catch (com.liferay.portal.kernel.exception.SystemException se) {
337                            _log.error(se, se);
338    
339                            throw se;
340                    }
341            }
342    
343            public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles(
344                    HttpPrincipal httpPrincipal, long userId,
345                    java.util.List<com.liferay.portal.model.Group> groups)
346                    throws com.liferay.portal.kernel.exception.PortalException,
347                            com.liferay.portal.kernel.exception.SystemException {
348                    try {
349                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
350                                            "getUserRelatedRoles", _getUserRelatedRolesParameterTypes8);
351    
352                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
353                                            groups);
354    
355                            Object returnObj = null;
356    
357                            try {
358                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
359                            }
360                            catch (Exception e) {
361                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
362                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
363                                    }
364    
365                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
366                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
367                                    }
368    
369                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
370                            }
371    
372                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
373                    }
374                    catch (com.liferay.portal.kernel.exception.SystemException se) {
375                            _log.error(se, se);
376    
377                            throw se;
378                    }
379            }
380    
381            public static java.util.List<com.liferay.portal.model.Role> getUserRoles(
382                    HttpPrincipal httpPrincipal, long userId)
383                    throws com.liferay.portal.kernel.exception.PortalException,
384                            com.liferay.portal.kernel.exception.SystemException {
385                    try {
386                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
387                                            "getUserRoles", _getUserRolesParameterTypes9);
388    
389                            MethodHandler methodHandler = new MethodHandler(methodKey, userId);
390    
391                            Object returnObj = null;
392    
393                            try {
394                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
395                            }
396                            catch (Exception e) {
397                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
398                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
399                                    }
400    
401                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
402                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
403                                    }
404    
405                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
406                            }
407    
408                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
409                    }
410                    catch (com.liferay.portal.kernel.exception.SystemException se) {
411                            _log.error(se, se);
412    
413                            throw se;
414                    }
415            }
416    
417            public static boolean hasUserRole(HttpPrincipal httpPrincipal, long userId,
418                    long companyId, java.lang.String name, boolean inherited)
419                    throws com.liferay.portal.kernel.exception.PortalException,
420                            com.liferay.portal.kernel.exception.SystemException {
421                    try {
422                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
423                                            "hasUserRole", _hasUserRoleParameterTypes10);
424    
425                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
426                                            companyId, name, inherited);
427    
428                            Object returnObj = null;
429    
430                            try {
431                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
432                            }
433                            catch (Exception e) {
434                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
435                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
436                                    }
437    
438                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
439                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
440                                    }
441    
442                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
443                            }
444    
445                            return ((Boolean)returnObj).booleanValue();
446                    }
447                    catch (com.liferay.portal.kernel.exception.SystemException se) {
448                            _log.error(se, se);
449    
450                            throw se;
451                    }
452            }
453    
454            public static boolean hasUserRoles(HttpPrincipal httpPrincipal,
455                    long userId, long companyId, java.lang.String[] names, boolean inherited)
456                    throws com.liferay.portal.kernel.exception.PortalException,
457                            com.liferay.portal.kernel.exception.SystemException {
458                    try {
459                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
460                                            "hasUserRoles", _hasUserRolesParameterTypes11);
461    
462                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
463                                            companyId, names, inherited);
464    
465                            Object returnObj = null;
466    
467                            try {
468                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
469                            }
470                            catch (Exception e) {
471                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
472                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
473                                    }
474    
475                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
476                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
477                                    }
478    
479                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
480                            }
481    
482                            return ((Boolean)returnObj).booleanValue();
483                    }
484                    catch (com.liferay.portal.kernel.exception.SystemException se) {
485                            _log.error(se, se);
486    
487                            throw se;
488                    }
489            }
490    
491            public static void unsetUserRoles(HttpPrincipal httpPrincipal, long userId,
492                    long[] roleIds)
493                    throws com.liferay.portal.kernel.exception.PortalException,
494                            com.liferay.portal.kernel.exception.SystemException {
495                    try {
496                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
497                                            "unsetUserRoles", _unsetUserRolesParameterTypes12);
498    
499                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
500                                            roleIds);
501    
502                            try {
503                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
504                            }
505                            catch (Exception e) {
506                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
507                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
508                                    }
509    
510                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
511                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
512                                    }
513    
514                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
515                            }
516                    }
517                    catch (com.liferay.portal.kernel.exception.SystemException se) {
518                            _log.error(se, se);
519    
520                            throw se;
521                    }
522            }
523    
524            public static com.liferay.portal.model.Role updateRole(
525                    HttpPrincipal httpPrincipal, long roleId, java.lang.String name,
526                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
527                    java.util.Map<java.util.Locale, java.lang.String> descriptionMap,
528                    java.lang.String subtype)
529                    throws com.liferay.portal.kernel.exception.PortalException,
530                            com.liferay.portal.kernel.exception.SystemException {
531                    try {
532                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
533                                            "updateRole", _updateRoleParameterTypes13);
534    
535                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId,
536                                            name, titleMap, descriptionMap, subtype);
537    
538                            Object returnObj = null;
539    
540                            try {
541                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
542                            }
543                            catch (Exception e) {
544                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
545                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
546                                    }
547    
548                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
549                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
550                                    }
551    
552                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
553                            }
554    
555                            return (com.liferay.portal.model.Role)returnObj;
556                    }
557                    catch (com.liferay.portal.kernel.exception.SystemException se) {
558                            _log.error(se, se);
559    
560                            throw se;
561                    }
562            }
563    
564            private static Log _log = LogFactoryUtil.getLog(RoleServiceHttp.class);
565            private static final Class<?>[] _addRoleParameterTypes0 = new Class[] {
566                            java.lang.String.class, java.util.Map.class, java.util.Map.class,
567                            int.class
568                    };
569            private static final Class<?>[] _addUserRolesParameterTypes1 = new Class[] {
570                            long.class, long[].class
571                    };
572            private static final Class<?>[] _deleteRoleParameterTypes2 = new Class[] {
573                            long.class
574                    };
575            private static final Class<?>[] _getGroupRolesParameterTypes3 = new Class[] {
576                            long.class
577                    };
578            private static final Class<?>[] _getRoleParameterTypes4 = new Class[] {
579                            long.class
580                    };
581            private static final Class<?>[] _getRoleParameterTypes5 = new Class[] {
582                            long.class, java.lang.String.class
583                    };
584            private static final Class<?>[] _getUserGroupGroupRolesParameterTypes6 = new Class[] {
585                            long.class, long.class
586                    };
587            private static final Class<?>[] _getUserGroupRolesParameterTypes7 = new Class[] {
588                            long.class, long.class
589                    };
590            private static final Class<?>[] _getUserRelatedRolesParameterTypes8 = new Class[] {
591                            long.class, java.util.List.class
592                    };
593            private static final Class<?>[] _getUserRolesParameterTypes9 = new Class[] {
594                            long.class
595                    };
596            private static final Class<?>[] _hasUserRoleParameterTypes10 = new Class[] {
597                            long.class, long.class, java.lang.String.class, boolean.class
598                    };
599            private static final Class<?>[] _hasUserRolesParameterTypes11 = new Class[] {
600                            long.class, long.class, java.lang.String[].class, boolean.class
601                    };
602            private static final Class<?>[] _unsetUserRolesParameterTypes12 = new Class[] {
603                            long.class, long[].class
604                    };
605            private static final Class<?>[] _updateRoleParameterTypes13 = new Class[] {
606                            long.class, java.lang.String.class, java.util.Map.class,
607                            java.util.Map.class, java.lang.String.class
608                    };
609    }