001    /**
002     * Copyright (c) 2000-2010 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.lang.String description, int type)
059                    throws com.liferay.portal.kernel.exception.PortalException,
060                            com.liferay.portal.kernel.exception.SystemException {
061                    try {
062                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
063                                            "addRole", java.lang.String.class, java.util.Map.class,
064                                            java.lang.String.class, int.class);
065    
066                            MethodHandler methodHandler = new MethodHandler(methodKey, name,
067                                            titleMap, description, 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", long.class, long[].class);
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", long.class);
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.SystemException {
162                    try {
163                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
164                                            "getGroupRoles", long.class);
165    
166                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId);
167    
168                            Object returnObj = null;
169    
170                            try {
171                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
172                            }
173                            catch (Exception e) {
174                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
175                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
176                                    }
177    
178                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
179                            }
180    
181                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
182                    }
183                    catch (com.liferay.portal.kernel.exception.SystemException se) {
184                            _log.error(se, se);
185    
186                            throw se;
187                    }
188            }
189    
190            public static com.liferay.portal.model.Role getRole(
191                    HttpPrincipal httpPrincipal, long roleId)
192                    throws com.liferay.portal.kernel.exception.PortalException,
193                            com.liferay.portal.kernel.exception.SystemException {
194                    try {
195                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
196                                            "getRole", long.class);
197    
198                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId);
199    
200                            Object returnObj = null;
201    
202                            try {
203                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
204                            }
205                            catch (Exception e) {
206                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
207                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
208                                    }
209    
210                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
211                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
212                                    }
213    
214                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
215                            }
216    
217                            return (com.liferay.portal.model.Role)returnObj;
218                    }
219                    catch (com.liferay.portal.kernel.exception.SystemException se) {
220                            _log.error(se, se);
221    
222                            throw se;
223                    }
224            }
225    
226            public static com.liferay.portal.model.Role getRole(
227                    HttpPrincipal httpPrincipal, long companyId, java.lang.String name)
228                    throws com.liferay.portal.kernel.exception.PortalException,
229                            com.liferay.portal.kernel.exception.SystemException {
230                    try {
231                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
232                                            "getRole", long.class, java.lang.String.class);
233    
234                            MethodHandler methodHandler = new MethodHandler(methodKey,
235                                            companyId, name);
236    
237                            Object returnObj = null;
238    
239                            try {
240                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
241                            }
242                            catch (Exception e) {
243                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
244                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
245                                    }
246    
247                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
248                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
249                                    }
250    
251                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
252                            }
253    
254                            return (com.liferay.portal.model.Role)returnObj;
255                    }
256                    catch (com.liferay.portal.kernel.exception.SystemException se) {
257                            _log.error(se, se);
258    
259                            throw se;
260                    }
261            }
262    
263            public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles(
264                    HttpPrincipal httpPrincipal, long userId, long groupId)
265                    throws com.liferay.portal.kernel.exception.SystemException {
266                    try {
267                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
268                                            "getUserGroupGroupRoles", long.class, long.class);
269    
270                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
271                                            groupId);
272    
273                            Object returnObj = null;
274    
275                            try {
276                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
277                            }
278                            catch (Exception e) {
279                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
280                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
281                                    }
282    
283                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
284                            }
285    
286                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
287                    }
288                    catch (com.liferay.portal.kernel.exception.SystemException se) {
289                            _log.error(se, se);
290    
291                            throw se;
292                    }
293            }
294    
295            public static java.util.List<com.liferay.portal.model.Role> getUserGroupRoles(
296                    HttpPrincipal httpPrincipal, long userId, long groupId)
297                    throws com.liferay.portal.kernel.exception.SystemException {
298                    try {
299                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
300                                            "getUserGroupRoles", long.class, long.class);
301    
302                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
303                                            groupId);
304    
305                            Object returnObj = null;
306    
307                            try {
308                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
309                            }
310                            catch (Exception e) {
311                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
312                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
313                                    }
314    
315                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
316                            }
317    
318                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
319                    }
320                    catch (com.liferay.portal.kernel.exception.SystemException se) {
321                            _log.error(se, se);
322    
323                            throw se;
324                    }
325            }
326    
327            public static java.util.List<com.liferay.portal.model.Role> getUserRelatedRoles(
328                    HttpPrincipal httpPrincipal, long userId,
329                    java.util.List<com.liferay.portal.model.Group> groups)
330                    throws com.liferay.portal.kernel.exception.SystemException {
331                    try {
332                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
333                                            "getUserRelatedRoles", long.class, java.util.List.class);
334    
335                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
336                                            groups);
337    
338                            Object returnObj = null;
339    
340                            try {
341                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
342                            }
343                            catch (Exception e) {
344                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
345                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
346                                    }
347    
348                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
349                            }
350    
351                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
352                    }
353                    catch (com.liferay.portal.kernel.exception.SystemException se) {
354                            _log.error(se, se);
355    
356                            throw se;
357                    }
358            }
359    
360            public static java.util.List<com.liferay.portal.model.Role> getUserRoles(
361                    HttpPrincipal httpPrincipal, long userId)
362                    throws com.liferay.portal.kernel.exception.SystemException {
363                    try {
364                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
365                                            "getUserRoles", long.class);
366    
367                            MethodHandler methodHandler = new MethodHandler(methodKey, userId);
368    
369                            Object returnObj = null;
370    
371                            try {
372                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
373                            }
374                            catch (Exception e) {
375                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
376                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
377                                    }
378    
379                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
380                            }
381    
382                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
383                    }
384                    catch (com.liferay.portal.kernel.exception.SystemException se) {
385                            _log.error(se, se);
386    
387                            throw se;
388                    }
389            }
390    
391            public static boolean hasUserRole(HttpPrincipal httpPrincipal, long userId,
392                    long companyId, java.lang.String name, boolean inherited)
393                    throws com.liferay.portal.kernel.exception.PortalException,
394                            com.liferay.portal.kernel.exception.SystemException {
395                    try {
396                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
397                                            "hasUserRole", long.class, long.class,
398                                            java.lang.String.class, boolean.class);
399    
400                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
401                                            companyId, name, inherited);
402    
403                            Object returnObj = null;
404    
405                            try {
406                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
407                            }
408                            catch (Exception e) {
409                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
410                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
411                                    }
412    
413                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
414                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
415                                    }
416    
417                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
418                            }
419    
420                            return ((Boolean)returnObj).booleanValue();
421                    }
422                    catch (com.liferay.portal.kernel.exception.SystemException se) {
423                            _log.error(se, se);
424    
425                            throw se;
426                    }
427            }
428    
429            public static boolean hasUserRoles(HttpPrincipal httpPrincipal,
430                    long userId, long companyId, java.lang.String[] names, boolean inherited)
431                    throws com.liferay.portal.kernel.exception.PortalException,
432                            com.liferay.portal.kernel.exception.SystemException {
433                    try {
434                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
435                                            "hasUserRoles", long.class, long.class,
436                                            java.lang.String[].class, boolean.class);
437    
438                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
439                                            companyId, names, inherited);
440    
441                            Object returnObj = null;
442    
443                            try {
444                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
445                            }
446                            catch (Exception e) {
447                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
448                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
449                                    }
450    
451                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
452                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
453                                    }
454    
455                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
456                            }
457    
458                            return ((Boolean)returnObj).booleanValue();
459                    }
460                    catch (com.liferay.portal.kernel.exception.SystemException se) {
461                            _log.error(se, se);
462    
463                            throw se;
464                    }
465            }
466    
467            public static void unsetUserRoles(HttpPrincipal httpPrincipal, long userId,
468                    long[] roleIds)
469                    throws com.liferay.portal.kernel.exception.PortalException,
470                            com.liferay.portal.kernel.exception.SystemException {
471                    try {
472                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
473                                            "unsetUserRoles", long.class, long[].class);
474    
475                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
476                                            roleIds);
477    
478                            try {
479                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
480                            }
481                            catch (Exception e) {
482                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
483                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
484                                    }
485    
486                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
487                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
488                                    }
489    
490                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
491                            }
492                    }
493                    catch (com.liferay.portal.kernel.exception.SystemException se) {
494                            _log.error(se, se);
495    
496                            throw se;
497                    }
498            }
499    
500            public static com.liferay.portal.model.Role updateRole(
501                    HttpPrincipal httpPrincipal, long roleId, java.lang.String name,
502                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
503                    java.lang.String description, java.lang.String subtype)
504                    throws com.liferay.portal.kernel.exception.PortalException,
505                            com.liferay.portal.kernel.exception.SystemException {
506                    try {
507                            MethodKey methodKey = new MethodKey(RoleServiceUtil.class.getName(),
508                                            "updateRole", long.class, java.lang.String.class,
509                                            java.util.Map.class, java.lang.String.class,
510                                            java.lang.String.class);
511    
512                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId,
513                                            name, titleMap, description, subtype);
514    
515                            Object returnObj = null;
516    
517                            try {
518                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
519                            }
520                            catch (Exception e) {
521                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
522                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
523                                    }
524    
525                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
526                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
527                                    }
528    
529                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
530                            }
531    
532                            return (com.liferay.portal.model.Role)returnObj;
533                    }
534                    catch (com.liferay.portal.kernel.exception.SystemException se) {
535                            _log.error(se, se);
536    
537                            throw se;
538                    }
539            }
540    
541            private static Log _log = LogFactoryUtil.getLog(RoleServiceHttp.class);
542    }