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