001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.log.Log;
020    import com.liferay.portal.kernel.log.LogFactoryUtil;
021    import com.liferay.portal.kernel.security.auth.HttpPrincipal;
022    import com.liferay.portal.kernel.service.UserGroupRoleServiceUtil;
023    import com.liferay.portal.kernel.service.http.TunnelUtil;
024    import com.liferay.portal.kernel.util.MethodHandler;
025    import com.liferay.portal.kernel.util.MethodKey;
026    
027    /**
028     * Provides the HTTP utility for the
029     * {@link UserGroupRoleServiceUtil} service utility. The
030     * static methods of this class calls the same methods of the service utility.
031     * However, the signatures are different because it requires an additional
032     * {@link HttpPrincipal} parameter.
033     *
034     * <p>
035     * The benefits of using the HTTP utility is that it is fast and allows for
036     * tunneling without the cost of serializing to text. The drawback is that it
037     * only works with Java.
038     * </p>
039     *
040     * <p>
041     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
042     * configure security.
043     * </p>
044     *
045     * <p>
046     * The HTTP utility is only generated for remote services.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see UserGroupRoleServiceSoap
051     * @see HttpPrincipal
052     * @see UserGroupRoleServiceUtil
053     * @generated
054     */
055    @ProviderType
056    public class UserGroupRoleServiceHttp {
057            public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
058                    long userId, long groupId, long[] roleIds)
059                    throws com.liferay.portal.kernel.exception.PortalException {
060                    try {
061                            MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class,
062                                            "addUserGroupRoles", _addUserGroupRolesParameterTypes0);
063    
064                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
065                                            groupId, roleIds);
066    
067                            try {
068                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
069                            }
070                            catch (Exception e) {
071                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
072                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
073                                    }
074    
075                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
076                            }
077                    }
078                    catch (com.liferay.portal.kernel.exception.SystemException se) {
079                            _log.error(se, se);
080    
081                            throw se;
082                    }
083            }
084    
085            public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
086                    long[] userIds, long groupId, long roleId)
087                    throws com.liferay.portal.kernel.exception.PortalException {
088                    try {
089                            MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class,
090                                            "addUserGroupRoles", _addUserGroupRolesParameterTypes1);
091    
092                            MethodHandler methodHandler = new MethodHandler(methodKey, userIds,
093                                            groupId, roleId);
094    
095                            try {
096                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
097                            }
098                            catch (Exception e) {
099                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
100                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
101                                    }
102    
103                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
104                            }
105                    }
106                    catch (com.liferay.portal.kernel.exception.SystemException se) {
107                            _log.error(se, se);
108    
109                            throw se;
110                    }
111            }
112    
113            public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
114                    long userId, long groupId, long[] roleIds)
115                    throws com.liferay.portal.kernel.exception.PortalException {
116                    try {
117                            MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class,
118                                            "deleteUserGroupRoles", _deleteUserGroupRolesParameterTypes2);
119    
120                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
121                                            groupId, roleIds);
122    
123                            try {
124                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
125                            }
126                            catch (Exception e) {
127                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
128                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
129                                    }
130    
131                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
132                            }
133                    }
134                    catch (com.liferay.portal.kernel.exception.SystemException se) {
135                            _log.error(se, se);
136    
137                            throw se;
138                    }
139            }
140    
141            public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
142                    long[] userIds, long groupId, long roleId)
143                    throws com.liferay.portal.kernel.exception.PortalException {
144                    try {
145                            MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class,
146                                            "deleteUserGroupRoles", _deleteUserGroupRolesParameterTypes3);
147    
148                            MethodHandler methodHandler = new MethodHandler(methodKey, userIds,
149                                            groupId, roleId);
150    
151                            try {
152                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
153                            }
154                            catch (Exception e) {
155                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
156                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
157                                    }
158    
159                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
160                            }
161                    }
162                    catch (com.liferay.portal.kernel.exception.SystemException se) {
163                            _log.error(se, se);
164    
165                            throw se;
166                    }
167            }
168    
169            public static void updateUserGroupRoles(HttpPrincipal httpPrincipal,
170                    long userId, long groupId, long[] addedRoleIds, long[] deletedRoleIds)
171                    throws com.liferay.portal.kernel.exception.PortalException {
172                    try {
173                            MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class,
174                                            "updateUserGroupRoles", _updateUserGroupRolesParameterTypes4);
175    
176                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
177                                            groupId, addedRoleIds, deletedRoleIds);
178    
179                            try {
180                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
181                            }
182                            catch (Exception e) {
183                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
184                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
185                                    }
186    
187                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
188                            }
189                    }
190                    catch (com.liferay.portal.kernel.exception.SystemException se) {
191                            _log.error(se, se);
192    
193                            throw se;
194                    }
195            }
196    
197            private static Log _log = LogFactoryUtil.getLog(UserGroupRoleServiceHttp.class);
198            private static final Class<?>[] _addUserGroupRolesParameterTypes0 = new Class[] {
199                            long.class, long.class, long[].class
200                    };
201            private static final Class<?>[] _addUserGroupRolesParameterTypes1 = new Class[] {
202                            long[].class, long.class, long.class
203                    };
204            private static final Class<?>[] _deleteUserGroupRolesParameterTypes2 = new Class[] {
205                            long.class, long.class, long[].class
206                    };
207            private static final Class<?>[] _deleteUserGroupRolesParameterTypes3 = new Class[] {
208                            long[].class, long.class, long.class
209                    };
210            private static final Class<?>[] _updateUserGroupRolesParameterTypes4 = new Class[] {
211                            long.class, long.class, long[].class, long[].class
212                    };
213    }