1   /**
2    * Copyright (c) 2000-2007 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.LongWrapper;
28  import com.liferay.portal.kernel.util.MethodWrapper;
29  import com.liferay.portal.kernel.util.NullWrapper;
30  import com.liferay.portal.security.auth.HttpPrincipal;
31  import com.liferay.portal.service.UserGroupRoleServiceUtil;
32  import com.liferay.portal.service.http.TunnelUtil;
33  
34  /**
35   * <a href="UserGroupRoleServiceHttp.java.html"><b><i>View Source</i></b></a>
36   *
37   * <p>
38   * ServiceBuilder generated this class. Modifications in this class will be overwritten
39   * the next time is generated.
40   * </p>
41   *
42   * <p>
43   * This class provides a HTTP utility for the <code>com.liferay.portal.service.UserGroupRoleServiceUtil</code>
44   * service utility. The static methods of this class calls the same methods of the
45   * service utility. However, the signatures are different because it requires an
46   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code> parameter.
47   * </p>
48   *
49   * <p>
50   * The benefits of using the HTTP utility is that it is fast and allows for tunneling
51   * without the cost of serializing to text. The drawback is that it only works with
52   * Java.
53   * </p>
54   *
55   * <p>
56   * Set the property <code>tunnel.servlet.hosts.allowed</code> in portal.properties
57   * to configure security.
58   * </p>
59   *
60   * <p>
61   * The HTTP utility is only generated for remote services.
62   * </p>
63   *
64   * @author Brian Wing Shun Chan
65   *
66   * @see com.liferay.portal.security.auth.HttpPrincipal
67   * @see com.liferay.portal.service.UserGroupRoleServiceUtil
68   * @see com.liferay.portal.service.http.UserGroupRoleServiceSoap
69   *
70   */
71  public class UserGroupRoleServiceHttp {
72      public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
73          long userId, long groupId, long[] roleIds)
74          throws com.liferay.portal.SystemException, 
75              com.liferay.portal.PortalException {
76          try {
77              Object paramObj0 = new LongWrapper(userId);
78              Object paramObj1 = new LongWrapper(groupId);
79              Object paramObj2 = roleIds;
80  
81              if (roleIds == null) {
82                  paramObj2 = new NullWrapper("[J");
83              }
84  
85              MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
86                      "addUserGroupRoles",
87                      new Object[] { paramObj0, paramObj1, paramObj2 });
88  
89              try {
90                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
91              }
92              catch (Exception e) {
93                  if (e instanceof com.liferay.portal.SystemException) {
94                      throw (com.liferay.portal.SystemException)e;
95                  }
96  
97                  if (e instanceof com.liferay.portal.PortalException) {
98                      throw (com.liferay.portal.PortalException)e;
99                  }
100 
101                 throw new com.liferay.portal.SystemException(e);
102             }
103         }
104         catch (com.liferay.portal.SystemException se) {
105             _log.error(se, se);
106             throw se;
107         }
108     }
109 
110     public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
111         long[] userIds, long groupId, long roleId)
112         throws com.liferay.portal.SystemException, 
113             com.liferay.portal.PortalException {
114         try {
115             Object paramObj0 = userIds;
116 
117             if (userIds == null) {
118                 paramObj0 = new NullWrapper("[J");
119             }
120 
121             Object paramObj1 = new LongWrapper(groupId);
122             Object paramObj2 = new LongWrapper(roleId);
123             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
124                     "addUserGroupRoles",
125                     new Object[] { paramObj0, paramObj1, paramObj2 });
126 
127             try {
128                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
129             }
130             catch (Exception e) {
131                 if (e instanceof com.liferay.portal.SystemException) {
132                     throw (com.liferay.portal.SystemException)e;
133                 }
134 
135                 if (e instanceof com.liferay.portal.PortalException) {
136                     throw (com.liferay.portal.PortalException)e;
137                 }
138 
139                 throw new com.liferay.portal.SystemException(e);
140             }
141         }
142         catch (com.liferay.portal.SystemException se) {
143             _log.error(se, se);
144             throw se;
145         }
146     }
147 
148     public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
149         long userId, long groupId, long[] roleIds)
150         throws com.liferay.portal.SystemException, 
151             com.liferay.portal.PortalException {
152         try {
153             Object paramObj0 = new LongWrapper(userId);
154             Object paramObj1 = new LongWrapper(groupId);
155             Object paramObj2 = roleIds;
156 
157             if (roleIds == null) {
158                 paramObj2 = new NullWrapper("[J");
159             }
160 
161             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
162                     "deleteUserGroupRoles",
163                     new Object[] { paramObj0, paramObj1, paramObj2 });
164 
165             try {
166                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
167             }
168             catch (Exception e) {
169                 if (e instanceof com.liferay.portal.SystemException) {
170                     throw (com.liferay.portal.SystemException)e;
171                 }
172 
173                 if (e instanceof com.liferay.portal.PortalException) {
174                     throw (com.liferay.portal.PortalException)e;
175                 }
176 
177                 throw new com.liferay.portal.SystemException(e);
178             }
179         }
180         catch (com.liferay.portal.SystemException se) {
181             _log.error(se, se);
182             throw se;
183         }
184     }
185 
186     public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
187         long[] userIds, long groupId, long roleId)
188         throws com.liferay.portal.SystemException, 
189             com.liferay.portal.PortalException {
190         try {
191             Object paramObj0 = userIds;
192 
193             if (userIds == null) {
194                 paramObj0 = new NullWrapper("[J");
195             }
196 
197             Object paramObj1 = new LongWrapper(groupId);
198             Object paramObj2 = new LongWrapper(roleId);
199             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
200                     "deleteUserGroupRoles",
201                     new Object[] { paramObj0, paramObj1, paramObj2 });
202 
203             try {
204                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
205             }
206             catch (Exception e) {
207                 if (e instanceof com.liferay.portal.SystemException) {
208                     throw (com.liferay.portal.SystemException)e;
209                 }
210 
211                 if (e instanceof com.liferay.portal.PortalException) {
212                     throw (com.liferay.portal.PortalException)e;
213                 }
214 
215                 throw new com.liferay.portal.SystemException(e);
216             }
217         }
218         catch (com.liferay.portal.SystemException se) {
219             _log.error(se, se);
220             throw se;
221         }
222     }
223 
224     private static Log _log = LogFactoryUtil.getLog(UserGroupRoleServiceHttp.class);
225 }