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.BooleanWrapper;
020    import com.liferay.portal.kernel.util.IntegerWrapper;
021    import com.liferay.portal.kernel.util.LongWrapper;
022    import com.liferay.portal.kernel.util.MethodWrapper;
023    import com.liferay.portal.kernel.util.NullWrapper;
024    import com.liferay.portal.security.auth.HttpPrincipal;
025    import com.liferay.portal.service.RoleServiceUtil;
026    
027    /**
028     * <p>
029     * This class provides a HTTP utility for the
030     * {@link com.liferay.portal.service.RoleServiceUtil} service utility. The
031     * static methods of this class calls the same methods of the service utility.
032     * However, the signatures are different because it requires an additional
033     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
034     * </p>
035     *
036     * <p>
037     * The benefits of using the HTTP utility is that it is fast and allows for
038     * tunneling without the cost of serializing to text. The drawback is that it
039     * only works with Java.
040     * </p>
041     *
042     * <p>
043     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
044     * configure security.
045     * </p>
046     *
047     * <p>
048     * The HTTP utility is only generated for remote services.
049     * </p>
050     *
051     * @author    Brian Wing Shun Chan
052     * @see       RoleServiceSoap
053     * @see       com.liferay.portal.security.auth.HttpPrincipal
054     * @see       com.liferay.portal.service.RoleServiceUtil
055     * @generated
056     */
057    public class RoleServiceHttp {
058            public static com.liferay.portal.model.Role addRole(
059                    HttpPrincipal httpPrincipal, java.lang.String name,
060                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
061                    java.lang.String description, int type)
062                    throws com.liferay.portal.kernel.exception.PortalException,
063                            com.liferay.portal.kernel.exception.SystemException {
064                    try {
065                            Object paramObj0 = name;
066    
067                            if (name == null) {
068                                    paramObj0 = new NullWrapper("java.lang.String");
069                            }
070    
071                            Object paramObj1 = titleMap;
072    
073                            if (titleMap == null) {
074                                    paramObj1 = new NullWrapper("java.util.Map");
075                            }
076    
077                            Object paramObj2 = description;
078    
079                            if (description == null) {
080                                    paramObj2 = new NullWrapper("java.lang.String");
081                            }
082    
083                            Object paramObj3 = new IntegerWrapper(type);
084    
085                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
086                                            "addRole",
087                                            new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
088    
089                            Object returnObj = null;
090    
091                            try {
092                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
093                            }
094                            catch (Exception e) {
095                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
096                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
097                                    }
098    
099                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
100                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
101                                    }
102    
103                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
104                            }
105    
106                            return (com.liferay.portal.model.Role)returnObj;
107                    }
108                    catch (com.liferay.portal.kernel.exception.SystemException se) {
109                            _log.error(se, se);
110    
111                            throw se;
112                    }
113            }
114    
115            public static void addUserRoles(HttpPrincipal httpPrincipal, long userId,
116                    long[] roleIds)
117                    throws com.liferay.portal.kernel.exception.PortalException,
118                            com.liferay.portal.kernel.exception.SystemException {
119                    try {
120                            Object paramObj0 = new LongWrapper(userId);
121    
122                            Object paramObj1 = roleIds;
123    
124                            if (roleIds == null) {
125                                    paramObj1 = new NullWrapper("[J");
126                            }
127    
128                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
129                                            "addUserRoles", new Object[] { paramObj0, paramObj1 });
130    
131                            try {
132                                    TunnelUtil.invoke(httpPrincipal, methodWrapper);
133                            }
134                            catch (Exception e) {
135                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
136                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
137                                    }
138    
139                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
140                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
141                                    }
142    
143                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
144                            }
145                    }
146                    catch (com.liferay.portal.kernel.exception.SystemException se) {
147                            _log.error(se, se);
148    
149                            throw se;
150                    }
151            }
152    
153            public static void deleteRole(HttpPrincipal httpPrincipal, long roleId)
154                    throws com.liferay.portal.kernel.exception.PortalException,
155                            com.liferay.portal.kernel.exception.SystemException {
156                    try {
157                            Object paramObj0 = new LongWrapper(roleId);
158    
159                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
160                                            "deleteRole", new Object[] { paramObj0 });
161    
162                            try {
163                                    TunnelUtil.invoke(httpPrincipal, methodWrapper);
164                            }
165                            catch (Exception e) {
166                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
167                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
168                                    }
169    
170                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
171                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
172                                    }
173    
174                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
175                            }
176                    }
177                    catch (com.liferay.portal.kernel.exception.SystemException se) {
178                            _log.error(se, se);
179    
180                            throw se;
181                    }
182            }
183    
184            public static java.util.List<com.liferay.portal.model.Role> getGroupRoles(
185                    HttpPrincipal httpPrincipal, long groupId)
186                    throws com.liferay.portal.kernel.exception.SystemException {
187                    try {
188                            Object paramObj0 = new LongWrapper(groupId);
189    
190                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
191                                            "getGroupRoles", new Object[] { paramObj0 });
192    
193                            Object returnObj = null;
194    
195                            try {
196                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
197                            }
198                            catch (Exception e) {
199                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
200                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
201                                    }
202    
203                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
204                            }
205    
206                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
207                    }
208                    catch (com.liferay.portal.kernel.exception.SystemException se) {
209                            _log.error(se, se);
210    
211                            throw se;
212                    }
213            }
214    
215            public static com.liferay.portal.model.Role getRole(
216                    HttpPrincipal httpPrincipal, long roleId)
217                    throws com.liferay.portal.kernel.exception.PortalException,
218                            com.liferay.portal.kernel.exception.SystemException {
219                    try {
220                            Object paramObj0 = new LongWrapper(roleId);
221    
222                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
223                                            "getRole", new Object[] { paramObj0 });
224    
225                            Object returnObj = null;
226    
227                            try {
228                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
229                            }
230                            catch (Exception e) {
231                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
232                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
233                                    }
234    
235                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
236                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
237                                    }
238    
239                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
240                            }
241    
242                            return (com.liferay.portal.model.Role)returnObj;
243                    }
244                    catch (com.liferay.portal.kernel.exception.SystemException se) {
245                            _log.error(se, se);
246    
247                            throw se;
248                    }
249            }
250    
251            public static com.liferay.portal.model.Role getRole(
252                    HttpPrincipal httpPrincipal, long companyId, java.lang.String name)
253                    throws com.liferay.portal.kernel.exception.PortalException,
254                            com.liferay.portal.kernel.exception.SystemException {
255                    try {
256                            Object paramObj0 = new LongWrapper(companyId);
257    
258                            Object paramObj1 = name;
259    
260                            if (name == null) {
261                                    paramObj1 = new NullWrapper("java.lang.String");
262                            }
263    
264                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
265                                            "getRole", new Object[] { paramObj0, paramObj1 });
266    
267                            Object returnObj = null;
268    
269                            try {
270                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
271                            }
272                            catch (Exception e) {
273                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
274                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
275                                    }
276    
277                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
278                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
279                                    }
280    
281                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
282                            }
283    
284                            return (com.liferay.portal.model.Role)returnObj;
285                    }
286                    catch (com.liferay.portal.kernel.exception.SystemException se) {
287                            _log.error(se, se);
288    
289                            throw se;
290                    }
291            }
292    
293            public static java.util.List<com.liferay.portal.model.Role> getUserGroupGroupRoles(
294                    HttpPrincipal httpPrincipal, long userId, long groupId)
295                    throws com.liferay.portal.kernel.exception.SystemException {
296                    try {
297                            Object paramObj0 = new LongWrapper(userId);
298    
299                            Object paramObj1 = new LongWrapper(groupId);
300    
301                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
302                                            "getUserGroupGroupRoles",
303                                            new Object[] { paramObj0, paramObj1 });
304    
305                            Object returnObj = null;
306    
307                            try {
308                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
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> getUserGroupRoles(
328                    HttpPrincipal httpPrincipal, long userId, long groupId)
329                    throws com.liferay.portal.kernel.exception.SystemException {
330                    try {
331                            Object paramObj0 = new LongWrapper(userId);
332    
333                            Object paramObj1 = new LongWrapper(groupId);
334    
335                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
336                                            "getUserGroupRoles", new Object[] { paramObj0, paramObj1 });
337    
338                            Object returnObj = null;
339    
340                            try {
341                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
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> getUserRelatedRoles(
361                    HttpPrincipal httpPrincipal, long userId,
362                    java.util.List<com.liferay.portal.model.Group> groups)
363                    throws com.liferay.portal.kernel.exception.SystemException {
364                    try {
365                            Object paramObj0 = new LongWrapper(userId);
366    
367                            Object paramObj1 = groups;
368    
369                            if (groups == null) {
370                                    paramObj1 = new NullWrapper("java.util.List");
371                            }
372    
373                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
374                                            "getUserRelatedRoles", new Object[] { paramObj0, paramObj1 });
375    
376                            Object returnObj = null;
377    
378                            try {
379                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
380                            }
381                            catch (Exception e) {
382                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
383                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
384                                    }
385    
386                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
387                            }
388    
389                            return (java.util.List<com.liferay.portal.model.Role>)returnObj;
390                    }
391                    catch (com.liferay.portal.kernel.exception.SystemException se) {
392                            _log.error(se, se);
393    
394                            throw se;
395                    }
396            }
397    
398            public static java.util.List<com.liferay.portal.model.Role> getUserRoles(
399                    HttpPrincipal httpPrincipal, long userId)
400                    throws com.liferay.portal.kernel.exception.SystemException {
401                    try {
402                            Object paramObj0 = new LongWrapper(userId);
403    
404                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
405                                            "getUserRoles", new Object[] { paramObj0 });
406    
407                            Object returnObj = null;
408    
409                            try {
410                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
411                            }
412                            catch (Exception e) {
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 (java.util.List<com.liferay.portal.model.Role>)returnObj;
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 hasUserRole(HttpPrincipal httpPrincipal, long userId,
430                    long companyId, java.lang.String name, boolean inherited)
431                    throws com.liferay.portal.kernel.exception.PortalException,
432                            com.liferay.portal.kernel.exception.SystemException {
433                    try {
434                            Object paramObj0 = new LongWrapper(userId);
435    
436                            Object paramObj1 = new LongWrapper(companyId);
437    
438                            Object paramObj2 = name;
439    
440                            if (name == null) {
441                                    paramObj2 = new NullWrapper("java.lang.String");
442                            }
443    
444                            Object paramObj3 = new BooleanWrapper(inherited);
445    
446                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
447                                            "hasUserRole",
448                                            new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
449    
450                            Object returnObj = null;
451    
452                            try {
453                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
454                            }
455                            catch (Exception e) {
456                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
457                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
458                                    }
459    
460                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
461                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
462                                    }
463    
464                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
465                            }
466    
467                            return ((Boolean)returnObj).booleanValue();
468                    }
469                    catch (com.liferay.portal.kernel.exception.SystemException se) {
470                            _log.error(se, se);
471    
472                            throw se;
473                    }
474            }
475    
476            public static boolean hasUserRoles(HttpPrincipal httpPrincipal,
477                    long userId, long companyId, java.lang.String[] names, boolean inherited)
478                    throws com.liferay.portal.kernel.exception.PortalException,
479                            com.liferay.portal.kernel.exception.SystemException {
480                    try {
481                            Object paramObj0 = new LongWrapper(userId);
482    
483                            Object paramObj1 = new LongWrapper(companyId);
484    
485                            Object paramObj2 = names;
486    
487                            if (names == null) {
488                                    paramObj2 = new NullWrapper("[Ljava.lang.String;");
489                            }
490    
491                            Object paramObj3 = new BooleanWrapper(inherited);
492    
493                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
494                                            "hasUserRoles",
495                                            new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
496    
497                            Object returnObj = null;
498    
499                            try {
500                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
501                            }
502                            catch (Exception e) {
503                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
504                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
505                                    }
506    
507                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
508                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
509                                    }
510    
511                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
512                            }
513    
514                            return ((Boolean)returnObj).booleanValue();
515                    }
516                    catch (com.liferay.portal.kernel.exception.SystemException se) {
517                            _log.error(se, se);
518    
519                            throw se;
520                    }
521            }
522    
523            public static void unsetUserRoles(HttpPrincipal httpPrincipal, long userId,
524                    long[] roleIds)
525                    throws com.liferay.portal.kernel.exception.PortalException,
526                            com.liferay.portal.kernel.exception.SystemException {
527                    try {
528                            Object paramObj0 = new LongWrapper(userId);
529    
530                            Object paramObj1 = roleIds;
531    
532                            if (roleIds == null) {
533                                    paramObj1 = new NullWrapper("[J");
534                            }
535    
536                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
537                                            "unsetUserRoles", new Object[] { paramObj0, paramObj1 });
538    
539                            try {
540                                    TunnelUtil.invoke(httpPrincipal, methodWrapper);
541                            }
542                            catch (Exception e) {
543                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
544                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
545                                    }
546    
547                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
548                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
549                                    }
550    
551                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
552                            }
553                    }
554                    catch (com.liferay.portal.kernel.exception.SystemException se) {
555                            _log.error(se, se);
556    
557                            throw se;
558                    }
559            }
560    
561            public static com.liferay.portal.model.Role updateRole(
562                    HttpPrincipal httpPrincipal, long roleId, java.lang.String name,
563                    java.util.Map<java.util.Locale, java.lang.String> titleMap,
564                    java.lang.String description, java.lang.String subtype)
565                    throws com.liferay.portal.kernel.exception.PortalException,
566                            com.liferay.portal.kernel.exception.SystemException {
567                    try {
568                            Object paramObj0 = new LongWrapper(roleId);
569    
570                            Object paramObj1 = name;
571    
572                            if (name == null) {
573                                    paramObj1 = new NullWrapper("java.lang.String");
574                            }
575    
576                            Object paramObj2 = titleMap;
577    
578                            if (titleMap == null) {
579                                    paramObj2 = new NullWrapper("java.util.Map");
580                            }
581    
582                            Object paramObj3 = description;
583    
584                            if (description == null) {
585                                    paramObj3 = new NullWrapper("java.lang.String");
586                            }
587    
588                            Object paramObj4 = subtype;
589    
590                            if (subtype == null) {
591                                    paramObj4 = new NullWrapper("java.lang.String");
592                            }
593    
594                            MethodWrapper methodWrapper = new MethodWrapper(RoleServiceUtil.class.getName(),
595                                            "updateRole",
596                                            new Object[] {
597                                                    paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
598                                            });
599    
600                            Object returnObj = null;
601    
602                            try {
603                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
604                            }
605                            catch (Exception e) {
606                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
607                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
608                                    }
609    
610                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
611                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
612                                    }
613    
614                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
615                            }
616    
617                            return (com.liferay.portal.model.Role)returnObj;
618                    }
619                    catch (com.liferay.portal.kernel.exception.SystemException se) {
620                            _log.error(se, se);
621    
622                            throw se;
623                    }
624            }
625    
626            private static Log _log = LogFactoryUtil.getLog(RoleServiceHttp.class);
627    }