1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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.IntegerWrapper;
20  import com.liferay.portal.kernel.util.LongWrapper;
21  import com.liferay.portal.kernel.util.MethodWrapper;
22  import com.liferay.portal.kernel.util.NullWrapper;
23  import com.liferay.portal.security.auth.HttpPrincipal;
24  import com.liferay.portal.service.ResourcePermissionServiceUtil;
25  
26  /**
27   * <a href="ResourcePermissionServiceHttp.java.html"><b><i>View Source</i></b></a>
28   *
29   * <p>
30   * ServiceBuilder generated this class. Modifications in this class will be
31   * overwritten the next time is generated.
32   * </p>
33   *
34   * <p>
35   * This class provides a HTTP utility for the
36   * {@link com.liferay.portal.service.ResourcePermissionServiceUtil} service utility. The
37   * static methods of this class calls the same methods of the service utility.
38   * However, the signatures are different because it requires an additional
39   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
40   * </p>
41   *
42   * <p>
43   * The benefits of using the HTTP utility is that it is fast and allows for
44   * tunneling without the cost of serializing to text. The drawback is that it
45   * only works with Java.
46   * </p>
47   *
48   * <p>
49   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
50   * configure security.
51   * </p>
52   *
53   * <p>
54   * The HTTP utility is only generated for remote services.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       ResourcePermissionServiceSoap
59   * @see       com.liferay.portal.security.auth.HttpPrincipal
60   * @see       com.liferay.portal.service.ResourcePermissionServiceUtil
61   * @generated
62   */
63  public class ResourcePermissionServiceHttp {
64      public static void addResourcePermission(HttpPrincipal httpPrincipal,
65          long groupId, long companyId, java.lang.String name, int scope,
66          java.lang.String primKey, long roleId, java.lang.String actionId)
67          throws com.liferay.portal.kernel.exception.PortalException,
68              com.liferay.portal.kernel.exception.SystemException {
69          try {
70              Object paramObj0 = new LongWrapper(groupId);
71  
72              Object paramObj1 = new LongWrapper(companyId);
73  
74              Object paramObj2 = name;
75  
76              if (name == null) {
77                  paramObj2 = new NullWrapper("java.lang.String");
78              }
79  
80              Object paramObj3 = new IntegerWrapper(scope);
81  
82              Object paramObj4 = primKey;
83  
84              if (primKey == null) {
85                  paramObj4 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj5 = new LongWrapper(roleId);
89  
90              Object paramObj6 = actionId;
91  
92              if (actionId == null) {
93                  paramObj6 = new NullWrapper("java.lang.String");
94              }
95  
96              MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
97                      "addResourcePermission",
98                      new Object[] {
99                          paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
100                         paramObj5, paramObj6
101                     });
102 
103             try {
104                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
105             }
106             catch (Exception e) {
107                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
108                     throw (com.liferay.portal.kernel.exception.PortalException)e;
109                 }
110 
111                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
112                     throw (com.liferay.portal.kernel.exception.SystemException)e;
113                 }
114 
115                 throw new com.liferay.portal.kernel.exception.SystemException(e);
116             }
117         }
118         catch (com.liferay.portal.kernel.exception.SystemException se) {
119             _log.error(se, se);
120 
121             throw se;
122         }
123     }
124 
125     public static void setIndividualResourcePermissions(
126         HttpPrincipal httpPrincipal, long groupId, long companyId,
127         java.lang.String name, java.lang.String primKey, long roleId,
128         java.lang.String[] actionIds)
129         throws com.liferay.portal.kernel.exception.PortalException,
130             com.liferay.portal.kernel.exception.SystemException {
131         try {
132             Object paramObj0 = new LongWrapper(groupId);
133 
134             Object paramObj1 = new LongWrapper(companyId);
135 
136             Object paramObj2 = name;
137 
138             if (name == null) {
139                 paramObj2 = new NullWrapper("java.lang.String");
140             }
141 
142             Object paramObj3 = primKey;
143 
144             if (primKey == null) {
145                 paramObj3 = new NullWrapper("java.lang.String");
146             }
147 
148             Object paramObj4 = new LongWrapper(roleId);
149 
150             Object paramObj5 = actionIds;
151 
152             if (actionIds == null) {
153                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
154             }
155 
156             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
157                     "setIndividualResourcePermissions",
158                     new Object[] {
159                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
160                         paramObj5
161                     });
162 
163             try {
164                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
165             }
166             catch (Exception e) {
167                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
168                     throw (com.liferay.portal.kernel.exception.PortalException)e;
169                 }
170 
171                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
172                     throw (com.liferay.portal.kernel.exception.SystemException)e;
173                 }
174 
175                 throw new com.liferay.portal.kernel.exception.SystemException(e);
176             }
177         }
178         catch (com.liferay.portal.kernel.exception.SystemException se) {
179             _log.error(se, se);
180 
181             throw se;
182         }
183     }
184 
185     public static void removeResourcePermission(HttpPrincipal httpPrincipal,
186         long groupId, long companyId, java.lang.String name, int scope,
187         java.lang.String primKey, long roleId, java.lang.String actionId)
188         throws com.liferay.portal.kernel.exception.PortalException,
189             com.liferay.portal.kernel.exception.SystemException {
190         try {
191             Object paramObj0 = new LongWrapper(groupId);
192 
193             Object paramObj1 = new LongWrapper(companyId);
194 
195             Object paramObj2 = name;
196 
197             if (name == null) {
198                 paramObj2 = new NullWrapper("java.lang.String");
199             }
200 
201             Object paramObj3 = new IntegerWrapper(scope);
202 
203             Object paramObj4 = primKey;
204 
205             if (primKey == null) {
206                 paramObj4 = new NullWrapper("java.lang.String");
207             }
208 
209             Object paramObj5 = new LongWrapper(roleId);
210 
211             Object paramObj6 = actionId;
212 
213             if (actionId == null) {
214                 paramObj6 = new NullWrapper("java.lang.String");
215             }
216 
217             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
218                     "removeResourcePermission",
219                     new Object[] {
220                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
221                         paramObj5, paramObj6
222                     });
223 
224             try {
225                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
226             }
227             catch (Exception e) {
228                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
229                     throw (com.liferay.portal.kernel.exception.PortalException)e;
230                 }
231 
232                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
233                     throw (com.liferay.portal.kernel.exception.SystemException)e;
234                 }
235 
236                 throw new com.liferay.portal.kernel.exception.SystemException(e);
237             }
238         }
239         catch (com.liferay.portal.kernel.exception.SystemException se) {
240             _log.error(se, se);
241 
242             throw se;
243         }
244     }
245 
246     public static void removeResourcePermissions(HttpPrincipal httpPrincipal,
247         long groupId, long companyId, java.lang.String name, int scope,
248         long roleId, java.lang.String actionId)
249         throws com.liferay.portal.kernel.exception.PortalException,
250             com.liferay.portal.kernel.exception.SystemException {
251         try {
252             Object paramObj0 = new LongWrapper(groupId);
253 
254             Object paramObj1 = new LongWrapper(companyId);
255 
256             Object paramObj2 = name;
257 
258             if (name == null) {
259                 paramObj2 = new NullWrapper("java.lang.String");
260             }
261 
262             Object paramObj3 = new IntegerWrapper(scope);
263 
264             Object paramObj4 = new LongWrapper(roleId);
265 
266             Object paramObj5 = actionId;
267 
268             if (actionId == null) {
269                 paramObj5 = new NullWrapper("java.lang.String");
270             }
271 
272             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
273                     "removeResourcePermissions",
274                     new Object[] {
275                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
276                         paramObj5
277                     });
278 
279             try {
280                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
281             }
282             catch (Exception e) {
283                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
284                     throw (com.liferay.portal.kernel.exception.PortalException)e;
285                 }
286 
287                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
288                     throw (com.liferay.portal.kernel.exception.SystemException)e;
289                 }
290 
291                 throw new com.liferay.portal.kernel.exception.SystemException(e);
292             }
293         }
294         catch (com.liferay.portal.kernel.exception.SystemException se) {
295             _log.error(se, se);
296 
297             throw se;
298         }
299     }
300 
301     private static Log _log = LogFactoryUtil.getLog(ResourcePermissionServiceHttp.class);
302 }