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   * <code>com.liferay.portal.service.ResourcePermissionServiceUtil</code> service
45   * utility. The static methods of this class calls the same methods of the
46   * service utility. However, the signatures are different because it requires an
47   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
48   * parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for
53   * tunneling without the cost of serializing to text. The drawback is that it
54   * only works with Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
59   * portal.properties to configure security.
60   * </p>
61   *
62   * <p>
63   * The HTTP utility is only generated for remote services.
64   * </p>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   * @see com.liferay.portal.security.auth.HttpPrincipal
69   * @see com.liferay.portal.service.ResourcePermissionServiceUtil
70   * @see com.liferay.portal.service.http.ResourcePermissionServiceSoap
71   *
72   */
73  public class ResourcePermissionServiceHttp {
74      public static void addResourcePermission(HttpPrincipal httpPrincipal,
75          long groupId, long companyId, java.lang.String name, int scope,
76          java.lang.String primKey, long roleId, java.lang.String actionId)
77          throws com.liferay.portal.PortalException,
78              com.liferay.portal.SystemException {
79          try {
80              Object paramObj0 = new LongWrapper(groupId);
81  
82              Object paramObj1 = new LongWrapper(companyId);
83  
84              Object paramObj2 = name;
85  
86              if (name == null) {
87                  paramObj2 = new NullWrapper("java.lang.String");
88              }
89  
90              Object paramObj3 = new IntegerWrapper(scope);
91  
92              Object paramObj4 = primKey;
93  
94              if (primKey == null) {
95                  paramObj4 = new NullWrapper("java.lang.String");
96              }
97  
98              Object paramObj5 = new LongWrapper(roleId);
99  
100             Object paramObj6 = actionId;
101 
102             if (actionId == null) {
103                 paramObj6 = new NullWrapper("java.lang.String");
104             }
105 
106             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
107                     "addResourcePermission",
108                     new Object[] {
109                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
110                         paramObj5, paramObj6
111                     });
112 
113             try {
114                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
115             }
116             catch (Exception e) {
117                 if (e instanceof com.liferay.portal.PortalException) {
118                     throw (com.liferay.portal.PortalException)e;
119                 }
120 
121                 if (e instanceof com.liferay.portal.SystemException) {
122                     throw (com.liferay.portal.SystemException)e;
123                 }
124 
125                 throw new com.liferay.portal.SystemException(e);
126             }
127         }
128         catch (com.liferay.portal.SystemException se) {
129             _log.error(se, se);
130 
131             throw se;
132         }
133     }
134 
135     public static void setIndividualResourcePermissions(
136         HttpPrincipal httpPrincipal, long groupId, long companyId,
137         java.lang.String name, java.lang.String primKey, long roleId,
138         java.lang.String[] actionIds)
139         throws com.liferay.portal.PortalException,
140             com.liferay.portal.SystemException {
141         try {
142             Object paramObj0 = new LongWrapper(groupId);
143 
144             Object paramObj1 = new LongWrapper(companyId);
145 
146             Object paramObj2 = name;
147 
148             if (name == null) {
149                 paramObj2 = new NullWrapper("java.lang.String");
150             }
151 
152             Object paramObj3 = primKey;
153 
154             if (primKey == null) {
155                 paramObj3 = new NullWrapper("java.lang.String");
156             }
157 
158             Object paramObj4 = new LongWrapper(roleId);
159 
160             Object paramObj5 = actionIds;
161 
162             if (actionIds == null) {
163                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
164             }
165 
166             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
167                     "setIndividualResourcePermissions",
168                     new Object[] {
169                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
170                         paramObj5
171                     });
172 
173             try {
174                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
175             }
176             catch (Exception e) {
177                 if (e instanceof com.liferay.portal.PortalException) {
178                     throw (com.liferay.portal.PortalException)e;
179                 }
180 
181                 if (e instanceof com.liferay.portal.SystemException) {
182                     throw (com.liferay.portal.SystemException)e;
183                 }
184 
185                 throw new com.liferay.portal.SystemException(e);
186             }
187         }
188         catch (com.liferay.portal.SystemException se) {
189             _log.error(se, se);
190 
191             throw se;
192         }
193     }
194 
195     public static void removeResourcePermission(HttpPrincipal httpPrincipal,
196         long groupId, long companyId, java.lang.String name, int scope,
197         java.lang.String primKey, long roleId, java.lang.String actionId)
198         throws com.liferay.portal.PortalException,
199             com.liferay.portal.SystemException {
200         try {
201             Object paramObj0 = new LongWrapper(groupId);
202 
203             Object paramObj1 = new LongWrapper(companyId);
204 
205             Object paramObj2 = name;
206 
207             if (name == null) {
208                 paramObj2 = new NullWrapper("java.lang.String");
209             }
210 
211             Object paramObj3 = new IntegerWrapper(scope);
212 
213             Object paramObj4 = primKey;
214 
215             if (primKey == null) {
216                 paramObj4 = new NullWrapper("java.lang.String");
217             }
218 
219             Object paramObj5 = new LongWrapper(roleId);
220 
221             Object paramObj6 = actionId;
222 
223             if (actionId == null) {
224                 paramObj6 = new NullWrapper("java.lang.String");
225             }
226 
227             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
228                     "removeResourcePermission",
229                     new Object[] {
230                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
231                         paramObj5, paramObj6
232                     });
233 
234             try {
235                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
236             }
237             catch (Exception e) {
238                 if (e instanceof com.liferay.portal.PortalException) {
239                     throw (com.liferay.portal.PortalException)e;
240                 }
241 
242                 if (e instanceof com.liferay.portal.SystemException) {
243                     throw (com.liferay.portal.SystemException)e;
244                 }
245 
246                 throw new com.liferay.portal.SystemException(e);
247             }
248         }
249         catch (com.liferay.portal.SystemException se) {
250             _log.error(se, se);
251 
252             throw se;
253         }
254     }
255 
256     public static void removeResourcePermissions(HttpPrincipal httpPrincipal,
257         long groupId, long companyId, java.lang.String name, int scope,
258         long roleId, java.lang.String actionId)
259         throws com.liferay.portal.PortalException,
260             com.liferay.portal.SystemException {
261         try {
262             Object paramObj0 = new LongWrapper(groupId);
263 
264             Object paramObj1 = new LongWrapper(companyId);
265 
266             Object paramObj2 = name;
267 
268             if (name == null) {
269                 paramObj2 = new NullWrapper("java.lang.String");
270             }
271 
272             Object paramObj3 = new IntegerWrapper(scope);
273 
274             Object paramObj4 = new LongWrapper(roleId);
275 
276             Object paramObj5 = actionId;
277 
278             if (actionId == null) {
279                 paramObj5 = new NullWrapper("java.lang.String");
280             }
281 
282             MethodWrapper methodWrapper = new MethodWrapper(ResourcePermissionServiceUtil.class.getName(),
283                     "removeResourcePermissions",
284                     new Object[] {
285                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
286                         paramObj5
287                     });
288 
289             try {
290                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
291             }
292             catch (Exception e) {
293                 if (e instanceof com.liferay.portal.PortalException) {
294                     throw (com.liferay.portal.PortalException)e;
295                 }
296 
297                 if (e instanceof com.liferay.portal.SystemException) {
298                     throw (com.liferay.portal.SystemException)e;
299                 }
300 
301                 throw new com.liferay.portal.SystemException(e);
302             }
303         }
304         catch (com.liferay.portal.SystemException se) {
305             _log.error(se, se);
306 
307             throw se;
308         }
309     }
310 
311     private static Log _log = LogFactoryUtil.getLog(ResourcePermissionServiceHttp.class);
312 }