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.ResourcePermissionServiceUtil;
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 ResourcePermissionServiceUtil} 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 ResourcePermissionServiceSoap
051     * @see HttpPrincipal
052     * @see ResourcePermissionServiceUtil
053     * @generated
054     */
055    @ProviderType
056    public class ResourcePermissionServiceHttp {
057            public static void addResourcePermission(HttpPrincipal httpPrincipal,
058                    long groupId, long companyId, java.lang.String name, int scope,
059                    java.lang.String primKey, long roleId, java.lang.String actionId)
060                    throws com.liferay.portal.kernel.exception.PortalException {
061                    try {
062                            MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class,
063                                            "addResourcePermission",
064                                            _addResourcePermissionParameterTypes0);
065    
066                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
067                                            companyId, name, scope, primKey, roleId, actionId);
068    
069                            try {
070                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
071                            }
072                            catch (Exception e) {
073                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
074                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
075                                    }
076    
077                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
078                            }
079                    }
080                    catch (com.liferay.portal.kernel.exception.SystemException se) {
081                            _log.error(se, se);
082    
083                            throw se;
084                    }
085            }
086    
087            public static void removeResourcePermission(HttpPrincipal httpPrincipal,
088                    long groupId, long companyId, java.lang.String name, int scope,
089                    java.lang.String primKey, long roleId, java.lang.String actionId)
090                    throws com.liferay.portal.kernel.exception.PortalException {
091                    try {
092                            MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class,
093                                            "removeResourcePermission",
094                                            _removeResourcePermissionParameterTypes1);
095    
096                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
097                                            companyId, name, scope, primKey, roleId, actionId);
098    
099                            try {
100                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
101                            }
102                            catch (Exception e) {
103                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
104                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
105                                    }
106    
107                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
108                            }
109                    }
110                    catch (com.liferay.portal.kernel.exception.SystemException se) {
111                            _log.error(se, se);
112    
113                            throw se;
114                    }
115            }
116    
117            public static void removeResourcePermissions(HttpPrincipal httpPrincipal,
118                    long groupId, long companyId, java.lang.String name, int scope,
119                    long roleId, java.lang.String actionId)
120                    throws com.liferay.portal.kernel.exception.PortalException {
121                    try {
122                            MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class,
123                                            "removeResourcePermissions",
124                                            _removeResourcePermissionsParameterTypes2);
125    
126                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
127                                            companyId, name, scope, roleId, actionId);
128    
129                            try {
130                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
131                            }
132                            catch (Exception e) {
133                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
134                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
135                                    }
136    
137                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
138                            }
139                    }
140                    catch (com.liferay.portal.kernel.exception.SystemException se) {
141                            _log.error(se, se);
142    
143                            throw se;
144                    }
145            }
146    
147            public static void setIndividualResourcePermissions(
148                    HttpPrincipal httpPrincipal, long groupId, long companyId,
149                    java.lang.String name, java.lang.String primKey, long roleId,
150                    java.lang.String[] actionIds)
151                    throws com.liferay.portal.kernel.exception.PortalException {
152                    try {
153                            MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class,
154                                            "setIndividualResourcePermissions",
155                                            _setIndividualResourcePermissionsParameterTypes3);
156    
157                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
158                                            companyId, name, primKey, roleId, actionIds);
159    
160                            try {
161                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
162                            }
163                            catch (Exception e) {
164                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
165                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
166                                    }
167    
168                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
169                            }
170                    }
171                    catch (com.liferay.portal.kernel.exception.SystemException se) {
172                            _log.error(se, se);
173    
174                            throw se;
175                    }
176            }
177    
178            public static void setIndividualResourcePermissions(
179                    HttpPrincipal httpPrincipal, long groupId, long companyId,
180                    java.lang.String name, java.lang.String primKey,
181                    java.util.Map<java.lang.Long, java.lang.String[]> roleIdsToActionIds)
182                    throws com.liferay.portal.kernel.exception.PortalException {
183                    try {
184                            MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class,
185                                            "setIndividualResourcePermissions",
186                                            _setIndividualResourcePermissionsParameterTypes4);
187    
188                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
189                                            companyId, name, primKey, roleIdsToActionIds);
190    
191                            try {
192                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
193                            }
194                            catch (Exception e) {
195                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
196                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
197                                    }
198    
199                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
200                            }
201                    }
202                    catch (com.liferay.portal.kernel.exception.SystemException se) {
203                            _log.error(se, se);
204    
205                            throw se;
206                    }
207            }
208    
209            private static Log _log = LogFactoryUtil.getLog(ResourcePermissionServiceHttp.class);
210            private static final Class<?>[] _addResourcePermissionParameterTypes0 = new Class[] {
211                            long.class, long.class, java.lang.String.class, int.class,
212                            java.lang.String.class, long.class, java.lang.String.class
213                    };
214            private static final Class<?>[] _removeResourcePermissionParameterTypes1 = new Class[] {
215                            long.class, long.class, java.lang.String.class, int.class,
216                            java.lang.String.class, long.class, java.lang.String.class
217                    };
218            private static final Class<?>[] _removeResourcePermissionsParameterTypes2 = new Class[] {
219                            long.class, long.class, java.lang.String.class, int.class,
220                            long.class, java.lang.String.class
221                    };
222            private static final Class<?>[] _setIndividualResourcePermissionsParameterTypes3 =
223                    new Class[] {
224                            long.class, long.class, java.lang.String.class,
225                            java.lang.String.class, long.class, java.lang.String[].class
226                    };
227            private static final Class<?>[] _setIndividualResourcePermissionsParameterTypes4 =
228                    new Class[] {
229                            long.class, long.class, java.lang.String.class,
230                            java.lang.String.class, java.util.Map.class
231                    };
232    }