1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service.http;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  import com.liferay.portal.kernel.util.LongWrapper;
25  import com.liferay.portal.kernel.util.MethodWrapper;
26  import com.liferay.portal.kernel.util.NullWrapper;
27  import com.liferay.portal.security.auth.HttpPrincipal;
28  import com.liferay.portal.service.UserGroupRoleServiceUtil;
29  
30  /**
31   * <a href="UserGroupRoleServiceHttp.java.html"><b><i>View Source</i></b></a>
32   *
33   * <p>
34   * ServiceBuilder generated this class. Modifications in this class will be
35   * overwritten the next time is generated.
36   * </p>
37   *
38   * <p>
39   * This class provides a HTTP utility for the
40   * <code>com.liferay.portal.service.UserGroupRoleServiceUtil</code> service
41   * utility. The static methods of this class calls the same methods of the
42   * service utility. However, the signatures are different because it requires an
43   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
44   * parameter.
45   * </p>
46   *
47   * <p>
48   * The benefits of using the HTTP utility is that it is fast and allows for
49   * tunneling without the cost of serializing to text. The drawback is that it
50   * only works with Java.
51   * </p>
52   *
53   * <p>
54   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
55   * portal.properties to configure security.
56   * </p>
57   *
58   * <p>
59   * The HTTP utility is only generated for remote services.
60   * </p>
61   *
62   * @author Brian Wing Shun Chan
63   *
64   * @see com.liferay.portal.security.auth.HttpPrincipal
65   * @see com.liferay.portal.service.UserGroupRoleServiceUtil
66   * @see com.liferay.portal.service.http.UserGroupRoleServiceSoap
67   *
68   */
69  public class UserGroupRoleServiceHttp {
70      public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
71          long userId, long groupId, long[] roleIds)
72          throws com.liferay.portal.PortalException,
73              com.liferay.portal.SystemException {
74          try {
75              Object paramObj0 = new LongWrapper(userId);
76  
77              Object paramObj1 = new LongWrapper(groupId);
78  
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.PortalException) {
94                      throw (com.liferay.portal.PortalException)e;
95                  }
96  
97                  if (e instanceof com.liferay.portal.SystemException) {
98                      throw (com.liferay.portal.SystemException)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 
107             throw se;
108         }
109     }
110 
111     public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
112         long[] userIds, long groupId, long roleId)
113         throws com.liferay.portal.PortalException,
114             com.liferay.portal.SystemException {
115         try {
116             Object paramObj0 = userIds;
117 
118             if (userIds == null) {
119                 paramObj0 = new NullWrapper("[J");
120             }
121 
122             Object paramObj1 = new LongWrapper(groupId);
123 
124             Object paramObj2 = new LongWrapper(roleId);
125 
126             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
127                     "addUserGroupRoles",
128                     new Object[] { paramObj0, paramObj1, paramObj2 });
129 
130             try {
131                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
132             }
133             catch (Exception e) {
134                 if (e instanceof com.liferay.portal.PortalException) {
135                     throw (com.liferay.portal.PortalException)e;
136                 }
137 
138                 if (e instanceof com.liferay.portal.SystemException) {
139                     throw (com.liferay.portal.SystemException)e;
140                 }
141 
142                 throw new com.liferay.portal.SystemException(e);
143             }
144         }
145         catch (com.liferay.portal.SystemException se) {
146             _log.error(se, se);
147 
148             throw se;
149         }
150     }
151 
152     public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
153         long userId, long groupId, long[] roleIds)
154         throws com.liferay.portal.PortalException,
155             com.liferay.portal.SystemException {
156         try {
157             Object paramObj0 = new LongWrapper(userId);
158 
159             Object paramObj1 = new LongWrapper(groupId);
160 
161             Object paramObj2 = roleIds;
162 
163             if (roleIds == null) {
164                 paramObj2 = new NullWrapper("[J");
165             }
166 
167             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
168                     "deleteUserGroupRoles",
169                     new Object[] { paramObj0, paramObj1, paramObj2 });
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 deleteUserGroupRoles(HttpPrincipal httpPrincipal,
194         long[] userIds, long groupId, long roleId)
195         throws com.liferay.portal.PortalException,
196             com.liferay.portal.SystemException {
197         try {
198             Object paramObj0 = userIds;
199 
200             if (userIds == null) {
201                 paramObj0 = new NullWrapper("[J");
202             }
203 
204             Object paramObj1 = new LongWrapper(groupId);
205 
206             Object paramObj2 = new LongWrapper(roleId);
207 
208             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
209                     "deleteUserGroupRoles",
210                     new Object[] { paramObj0, paramObj1, paramObj2 });
211 
212             try {
213                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
214             }
215             catch (Exception e) {
216                 if (e instanceof com.liferay.portal.PortalException) {
217                     throw (com.liferay.portal.PortalException)e;
218                 }
219 
220                 if (e instanceof com.liferay.portal.SystemException) {
221                     throw (com.liferay.portal.SystemException)e;
222                 }
223 
224                 throw new com.liferay.portal.SystemException(e);
225             }
226         }
227         catch (com.liferay.portal.SystemException se) {
228             _log.error(se, se);
229 
230             throw se;
231         }
232     }
233 
234     private static Log _log = LogFactoryUtil.getLog(UserGroupRoleServiceHttp.class);
235 }