1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.service.http;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.MethodHandler;
20  import com.liferay.portal.kernel.util.MethodKey;
21  import com.liferay.portal.security.auth.HttpPrincipal;
22  import com.liferay.portal.service.ResourcePermissionServiceUtil;
23  
24  /**
25   * <a href="ResourcePermissionServiceHttp.java.html"><b><i>View Source</i></b></a>
26   *
27   * <p>
28   * ServiceBuilder generated this class. Modifications in this class will be
29   * overwritten the next time is generated.
30   * </p>
31   *
32   * <p>
33   * This class provides a HTTP utility for the
34   * {@link com.liferay.portal.service.ResourcePermissionServiceUtil} service utility. The
35   * static methods of this class calls the same methods of the service utility.
36   * However, the signatures are different because it requires an additional
37   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
38   * </p>
39   *
40   * <p>
41   * The benefits of using the HTTP utility is that it is fast and allows for
42   * tunneling without the cost of serializing to text. The drawback is that it
43   * only works with Java.
44   * </p>
45   *
46   * <p>
47   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
48   * configure security.
49   * </p>
50   *
51   * <p>
52   * The HTTP utility is only generated for remote services.
53   * </p>
54   *
55   * @author    Brian Wing Shun Chan
56   * @see       ResourcePermissionServiceSoap
57   * @see       com.liferay.portal.security.auth.HttpPrincipal
58   * @see       com.liferay.portal.service.ResourcePermissionServiceUtil
59   * @generated
60   */
61  public class ResourcePermissionServiceHttp {
62      public static void addResourcePermission(HttpPrincipal httpPrincipal,
63          long groupId, long companyId, java.lang.String name, int scope,
64          java.lang.String primKey, long roleId, java.lang.String actionId)
65          throws com.liferay.portal.PortalException,
66              com.liferay.portal.SystemException {
67          try {
68              MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class.getName(),
69                      "addResourcePermission",
70                      _addResourcePermissionParameterTypes0);
71  
72              MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
73                      companyId, name, scope, primKey, roleId, actionId);
74  
75              try {
76                  TunnelUtil.invoke(httpPrincipal, methodHandler);
77              }
78              catch (Exception e) {
79                  if (e instanceof com.liferay.portal.PortalException) {
80                      throw (com.liferay.portal.PortalException)e;
81                  }
82  
83                  if (e instanceof com.liferay.portal.SystemException) {
84                      throw (com.liferay.portal.SystemException)e;
85                  }
86  
87                  throw new com.liferay.portal.SystemException(e);
88              }
89          }
90          catch (com.liferay.portal.SystemException se) {
91              _log.error(se, se);
92  
93              throw se;
94          }
95      }
96  
97      public static void setIndividualResourcePermissions(
98          HttpPrincipal httpPrincipal, long groupId, long companyId,
99          java.lang.String name, java.lang.String primKey, long roleId,
100         java.lang.String[] actionIds)
101         throws com.liferay.portal.PortalException,
102             com.liferay.portal.SystemException {
103         try {
104             MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class.getName(),
105                     "setIndividualResourcePermissions",
106                     _setIndividualResourcePermissionsParameterTypes1);
107 
108             MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
109                     companyId, name, primKey, roleId, actionIds);
110 
111             try {
112                 TunnelUtil.invoke(httpPrincipal, methodHandler);
113             }
114             catch (Exception e) {
115                 if (e instanceof com.liferay.portal.PortalException) {
116                     throw (com.liferay.portal.PortalException)e;
117                 }
118 
119                 if (e instanceof com.liferay.portal.SystemException) {
120                     throw (com.liferay.portal.SystemException)e;
121                 }
122 
123                 throw new com.liferay.portal.SystemException(e);
124             }
125         }
126         catch (com.liferay.portal.SystemException se) {
127             _log.error(se, se);
128 
129             throw se;
130         }
131     }
132 
133     public static void removeResourcePermission(HttpPrincipal httpPrincipal,
134         long groupId, long companyId, java.lang.String name, int scope,
135         java.lang.String primKey, long roleId, java.lang.String actionId)
136         throws com.liferay.portal.PortalException,
137             com.liferay.portal.SystemException {
138         try {
139             MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class.getName(),
140                     "removeResourcePermission",
141                     _removeResourcePermissionParameterTypes2);
142 
143             MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
144                     companyId, name, scope, primKey, roleId, actionId);
145 
146             try {
147                 TunnelUtil.invoke(httpPrincipal, methodHandler);
148             }
149             catch (Exception e) {
150                 if (e instanceof com.liferay.portal.PortalException) {
151                     throw (com.liferay.portal.PortalException)e;
152                 }
153 
154                 if (e instanceof com.liferay.portal.SystemException) {
155                     throw (com.liferay.portal.SystemException)e;
156                 }
157 
158                 throw new com.liferay.portal.SystemException(e);
159             }
160         }
161         catch (com.liferay.portal.SystemException se) {
162             _log.error(se, se);
163 
164             throw se;
165         }
166     }
167 
168     public static void removeResourcePermissions(HttpPrincipal httpPrincipal,
169         long groupId, long companyId, java.lang.String name, int scope,
170         long roleId, java.lang.String actionId)
171         throws com.liferay.portal.PortalException,
172             com.liferay.portal.SystemException {
173         try {
174             MethodKey methodKey = new MethodKey(ResourcePermissionServiceUtil.class.getName(),
175                     "removeResourcePermissions",
176                     _removeResourcePermissionsParameterTypes3);
177 
178             MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
179                     companyId, name, scope, roleId, actionId);
180 
181             try {
182                 TunnelUtil.invoke(httpPrincipal, methodHandler);
183             }
184             catch (Exception e) {
185                 if (e instanceof com.liferay.portal.PortalException) {
186                     throw (com.liferay.portal.PortalException)e;
187                 }
188 
189                 if (e instanceof com.liferay.portal.SystemException) {
190                     throw (com.liferay.portal.SystemException)e;
191                 }
192 
193                 throw new com.liferay.portal.SystemException(e);
194             }
195         }
196         catch (com.liferay.portal.SystemException se) {
197             _log.error(se, se);
198 
199             throw se;
200         }
201     }
202 
203     private static Log _log = LogFactoryUtil.getLog(ResourcePermissionServiceHttp.class);
204     private static final Class<?>[] _addResourcePermissionParameterTypes0 = new Class[] {
205             long.class, long.class, java.lang.String.class, int.class,
206             java.lang.String.class, long.class, java.lang.String.class
207         };
208     private static final Class<?>[] _setIndividualResourcePermissionsParameterTypes1 =
209         new Class[] {
210             long.class, long.class, java.lang.String.class,
211             java.lang.String.class, long.class, java.lang.String[].class
212         };
213     private static final Class<?>[] _removeResourcePermissionParameterTypes2 = 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<?>[] _removeResourcePermissionsParameterTypes3 = new Class[] {
218             long.class, long.class, java.lang.String.class, int.class,
219             long.class, java.lang.String.class
220         };
221 }