1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.http;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.kernel.util.IntegerWrapper;
28  import com.liferay.portal.kernel.util.LongWrapper;
29  import com.liferay.portal.kernel.util.MethodWrapper;
30  import com.liferay.portal.kernel.util.NullWrapper;
31  import com.liferay.portal.security.auth.HttpPrincipal;
32  import com.liferay.portal.service.ResourcePermissionServiceUtil;
33  
34  /**
35   * <a href="ResourcePermissionServiceHttp.java.html"><b><i>View Source</i></b></a>
36   *
37   * <p>
38   * ServiceBuilder generated this class. Modifications in this class will be
39   * overwritten the next time is generated.
40   * </p>
41   *
42   * <p>
43   * This class provides a HTTP utility for the
44   * {@link com.liferay.portal.service.ResourcePermissionServiceUtil} service utility. The
45   * static methods of this class calls the same methods of the service utility.
46   * However, the signatures are different because it requires an additional
47   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
48   * </p>
49   *
50   * <p>
51   * The benefits of using the HTTP utility is that it is fast and allows for
52   * tunneling without the cost of serializing to text. The drawback is that it
53   * only works with Java.
54   * </p>
55   *
56   * <p>
57   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
58   * configure security.
59   * </p>
60   *
61   * <p>
62   * The HTTP utility is only generated for remote services.
63   * </p>
64   *
65   * @author    Brian Wing Shun Chan
66   * @see       ResourcePermissionServiceSoap
67   * @see       com.liferay.portal.security.auth.HttpPrincipal
68   * @see       com.liferay.portal.service.ResourcePermissionServiceUtil
69   * @generated
70   */
71  public class ResourcePermissionServiceHttp {
72      public static void addResourcePermission(HttpPrincipal httpPrincipal,
73          long groupId, long companyId, java.lang.String name, int scope,
74          java.lang.String primKey, long roleId, java.lang.String actionId)
75          throws com.liferay.portal.PortalException,
76              com.liferay.portal.SystemException {
77          try {
78              Object paramObj0 = new LongWrapper(groupId);
79  
80              Object paramObj1 = new LongWrapper(companyId);
81  
82              Object paramObj2 = name;
83  
84              if (name == null) {
85                  paramObj2 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj3 = new IntegerWrapper(scope);
89  
90              Object paramObj4 = primKey;
91  
92              if (primKey == null) {
93                  paramObj4 = new NullWrapper("java.lang.String");
94              }
95  
96              Object paramObj5 = new LongWrapper(roleId);
97  
98              Object paramObj6 = actionId;
99  
100             if (actionId == null) {
101                 paramObj6 = new NullWrapper("java.lang.String");
102             }
103 
104             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
105                     "addResourcePermission",
106                     new Object[] {
107                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
108                         paramObj5, paramObj6
109                     });
110 
111             try {
112                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
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 setIndividualResourcePermissions(
134         HttpPrincipal httpPrincipal, long groupId, long companyId,
135         java.lang.String name, java.lang.String primKey, long roleId,
136         java.lang.String[] actionIds)
137         throws com.liferay.portal.PortalException,
138             com.liferay.portal.SystemException {
139         try {
140             Object paramObj0 = new LongWrapper(groupId);
141 
142             Object paramObj1 = new LongWrapper(companyId);
143 
144             Object paramObj2 = name;
145 
146             if (name == null) {
147                 paramObj2 = new NullWrapper("java.lang.String");
148             }
149 
150             Object paramObj3 = primKey;
151 
152             if (primKey == null) {
153                 paramObj3 = new NullWrapper("java.lang.String");
154             }
155 
156             Object paramObj4 = new LongWrapper(roleId);
157 
158             Object paramObj5 = actionIds;
159 
160             if (actionIds == null) {
161                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
162             }
163 
164             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
165                     "setIndividualResourcePermissions",
166                     new Object[] {
167                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
168                         paramObj5
169                     });
170 
171             try {
172                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
173             }
174             catch (Exception e) {
175                 if (e instanceof com.liferay.portal.PortalException) {
176                     throw (com.liferay.portal.PortalException)e;
177                 }
178 
179                 if (e instanceof com.liferay.portal.SystemException) {
180                     throw (com.liferay.portal.SystemException)e;
181                 }
182 
183                 throw new com.liferay.portal.SystemException(e);
184             }
185         }
186         catch (com.liferay.portal.SystemException se) {
187             _log.error(se, se);
188 
189             throw se;
190         }
191     }
192 
193     public static void removeResourcePermission(HttpPrincipal httpPrincipal,
194         long groupId, long companyId, java.lang.String name, int scope,
195         java.lang.String primKey, long roleId, java.lang.String actionId)
196         throws com.liferay.portal.PortalException,
197             com.liferay.portal.SystemException {
198         try {
199             Object paramObj0 = new LongWrapper(groupId);
200 
201             Object paramObj1 = new LongWrapper(companyId);
202 
203             Object paramObj2 = name;
204 
205             if (name == null) {
206                 paramObj2 = new NullWrapper("java.lang.String");
207             }
208 
209             Object paramObj3 = new IntegerWrapper(scope);
210 
211             Object paramObj4 = primKey;
212 
213             if (primKey == null) {
214                 paramObj4 = new NullWrapper("java.lang.String");
215             }
216 
217             Object paramObj5 = new LongWrapper(roleId);
218 
219             Object paramObj6 = actionId;
220 
221             if (actionId == null) {
222                 paramObj6 = new NullWrapper("java.lang.String");
223             }
224 
225             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
226                     "removeResourcePermission",
227                     new Object[] {
228                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
229                         paramObj5, paramObj6
230                     });
231 
232             try {
233                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
234             }
235             catch (Exception e) {
236                 if (e instanceof com.liferay.portal.PortalException) {
237                     throw (com.liferay.portal.PortalException)e;
238                 }
239 
240                 if (e instanceof com.liferay.portal.SystemException) {
241                     throw (com.liferay.portal.SystemException)e;
242                 }
243 
244                 throw new com.liferay.portal.SystemException(e);
245             }
246         }
247         catch (com.liferay.portal.SystemException se) {
248             _log.error(se, se);
249 
250             throw se;
251         }
252     }
253 
254     public static void removeResourcePermissions(HttpPrincipal httpPrincipal,
255         long groupId, long companyId, java.lang.String name, int scope,
256         long roleId, java.lang.String actionId)
257         throws com.liferay.portal.PortalException,
258             com.liferay.portal.SystemException {
259         try {
260             Object paramObj0 = new LongWrapper(groupId);
261 
262             Object paramObj1 = new LongWrapper(companyId);
263 
264             Object paramObj2 = name;
265 
266             if (name == null) {
267                 paramObj2 = new NullWrapper("java.lang.String");
268             }
269 
270             Object paramObj3 = new IntegerWrapper(scope);
271 
272             Object paramObj4 = new LongWrapper(roleId);
273 
274             Object paramObj5 = actionId;
275 
276             if (actionId == null) {
277                 paramObj5 = new NullWrapper("java.lang.String");
278             }
279 
280             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
281                     "removeResourcePermissions",
282                     new Object[] {
283                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
284                         paramObj5
285                     });
286 
287             try {
288                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
289             }
290             catch (Exception e) {
291                 if (e instanceof com.liferay.portal.PortalException) {
292                     throw (com.liferay.portal.PortalException)e;
293                 }
294 
295                 if (e instanceof com.liferay.portal.SystemException) {
296                     throw (com.liferay.portal.SystemException)e;
297                 }
298 
299                 throw new com.liferay.portal.SystemException(e);
300             }
301         }
302         catch (com.liferay.portal.SystemException se) {
303             _log.error(se, se);
304 
305             throw se;
306         }
307     }
308 
309     private static Log _log = LogFactoryUtil.getLog(ResourcePermissionServiceHttp.class);
310 }