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.LongWrapper;
20  import com.liferay.portal.kernel.util.MethodWrapper;
21  import com.liferay.portal.kernel.util.NullWrapper;
22  import com.liferay.portal.security.auth.HttpPrincipal;
23  import com.liferay.portal.service.UserGroupServiceUtil;
24  
25  /**
26   * <a href="UserGroupServiceHttp.java.html"><b><i>View Source</i></b></a>
27   *
28   * <p>
29   * ServiceBuilder generated this class. Modifications in this class will be
30   * overwritten the next time is generated.
31   * </p>
32   *
33   * <p>
34   * This class provides a HTTP utility for the
35   * {@link com.liferay.portal.service.UserGroupServiceUtil} service utility. The
36   * static methods of this class calls the same methods of the service utility.
37   * However, the signatures are different because it requires an additional
38   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
39   * </p>
40   *
41   * <p>
42   * The benefits of using the HTTP utility is that it is fast and allows for
43   * tunneling without the cost of serializing to text. The drawback is that it
44   * only works with Java.
45   * </p>
46   *
47   * <p>
48   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
49   * configure security.
50   * </p>
51   *
52   * <p>
53   * The HTTP utility is only generated for remote services.
54   * </p>
55   *
56   * @author    Brian Wing Shun Chan
57   * @see       UserGroupServiceSoap
58   * @see       com.liferay.portal.security.auth.HttpPrincipal
59   * @see       com.liferay.portal.service.UserGroupServiceUtil
60   * @generated
61   */
62  public class UserGroupServiceHttp {
63      public static void addGroupUserGroups(HttpPrincipal httpPrincipal,
64          long groupId, long[] userGroupIds)
65          throws com.liferay.portal.kernel.exception.PortalException,
66              com.liferay.portal.kernel.exception.SystemException {
67          try {
68              Object paramObj0 = new LongWrapper(groupId);
69  
70              Object paramObj1 = userGroupIds;
71  
72              if (userGroupIds == null) {
73                  paramObj1 = new NullWrapper("[J");
74              }
75  
76              MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
77                      "addGroupUserGroups", new Object[] { paramObj0, paramObj1 });
78  
79              try {
80                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
81              }
82              catch (Exception e) {
83                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
84                      throw (com.liferay.portal.kernel.exception.PortalException)e;
85                  }
86  
87                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
88                      throw (com.liferay.portal.kernel.exception.SystemException)e;
89                  }
90  
91                  throw new com.liferay.portal.kernel.exception.SystemException(e);
92              }
93          }
94          catch (com.liferay.portal.kernel.exception.SystemException se) {
95              _log.error(se, se);
96  
97              throw se;
98          }
99      }
100 
101     public static com.liferay.portal.model.UserGroup addUserGroup(
102         HttpPrincipal httpPrincipal, java.lang.String name,
103         java.lang.String description)
104         throws com.liferay.portal.kernel.exception.PortalException,
105             com.liferay.portal.kernel.exception.SystemException {
106         try {
107             Object paramObj0 = name;
108 
109             if (name == null) {
110                 paramObj0 = new NullWrapper("java.lang.String");
111             }
112 
113             Object paramObj1 = description;
114 
115             if (description == null) {
116                 paramObj1 = new NullWrapper("java.lang.String");
117             }
118 
119             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
120                     "addUserGroup", new Object[] { paramObj0, paramObj1 });
121 
122             Object returnObj = null;
123 
124             try {
125                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
126             }
127             catch (Exception e) {
128                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
129                     throw (com.liferay.portal.kernel.exception.PortalException)e;
130                 }
131 
132                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
133                     throw (com.liferay.portal.kernel.exception.SystemException)e;
134                 }
135 
136                 throw new com.liferay.portal.kernel.exception.SystemException(e);
137             }
138 
139             return (com.liferay.portal.model.UserGroup)returnObj;
140         }
141         catch (com.liferay.portal.kernel.exception.SystemException se) {
142             _log.error(se, se);
143 
144             throw se;
145         }
146     }
147 
148     public static void deleteUserGroup(HttpPrincipal httpPrincipal,
149         long userGroupId)
150         throws com.liferay.portal.kernel.exception.PortalException,
151             com.liferay.portal.kernel.exception.SystemException {
152         try {
153             Object paramObj0 = new LongWrapper(userGroupId);
154 
155             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
156                     "deleteUserGroup", new Object[] { paramObj0 });
157 
158             try {
159                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
160             }
161             catch (Exception e) {
162                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
163                     throw (com.liferay.portal.kernel.exception.PortalException)e;
164                 }
165 
166                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
167                     throw (com.liferay.portal.kernel.exception.SystemException)e;
168                 }
169 
170                 throw new com.liferay.portal.kernel.exception.SystemException(e);
171             }
172         }
173         catch (com.liferay.portal.kernel.exception.SystemException se) {
174             _log.error(se, se);
175 
176             throw se;
177         }
178     }
179 
180     public static com.liferay.portal.model.UserGroup getUserGroup(
181         HttpPrincipal httpPrincipal, long userGroupId)
182         throws com.liferay.portal.kernel.exception.PortalException,
183             com.liferay.portal.kernel.exception.SystemException {
184         try {
185             Object paramObj0 = new LongWrapper(userGroupId);
186 
187             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
188                     "getUserGroup", new Object[] { paramObj0 });
189 
190             Object returnObj = null;
191 
192             try {
193                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
194             }
195             catch (Exception e) {
196                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
197                     throw (com.liferay.portal.kernel.exception.PortalException)e;
198                 }
199 
200                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
201                     throw (com.liferay.portal.kernel.exception.SystemException)e;
202                 }
203 
204                 throw new com.liferay.portal.kernel.exception.SystemException(e);
205             }
206 
207             return (com.liferay.portal.model.UserGroup)returnObj;
208         }
209         catch (com.liferay.portal.kernel.exception.SystemException se) {
210             _log.error(se, se);
211 
212             throw se;
213         }
214     }
215 
216     public static com.liferay.portal.model.UserGroup getUserGroup(
217         HttpPrincipal httpPrincipal, java.lang.String name)
218         throws com.liferay.portal.kernel.exception.PortalException,
219             com.liferay.portal.kernel.exception.SystemException {
220         try {
221             Object paramObj0 = name;
222 
223             if (name == null) {
224                 paramObj0 = new NullWrapper("java.lang.String");
225             }
226 
227             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
228                     "getUserGroup", new Object[] { paramObj0 });
229 
230             Object returnObj = null;
231 
232             try {
233                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
234             }
235             catch (Exception e) {
236                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
237                     throw (com.liferay.portal.kernel.exception.PortalException)e;
238                 }
239 
240                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
241                     throw (com.liferay.portal.kernel.exception.SystemException)e;
242                 }
243 
244                 throw new com.liferay.portal.kernel.exception.SystemException(e);
245             }
246 
247             return (com.liferay.portal.model.UserGroup)returnObj;
248         }
249         catch (com.liferay.portal.kernel.exception.SystemException se) {
250             _log.error(se, se);
251 
252             throw se;
253         }
254     }
255 
256     public static java.util.List<com.liferay.portal.model.UserGroup> getUserUserGroups(
257         HttpPrincipal httpPrincipal, long userId)
258         throws com.liferay.portal.kernel.exception.SystemException {
259         try {
260             Object paramObj0 = new LongWrapper(userId);
261 
262             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
263                     "getUserUserGroups", new Object[] { paramObj0 });
264 
265             Object returnObj = null;
266 
267             try {
268                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
269             }
270             catch (Exception e) {
271                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
272                     throw (com.liferay.portal.kernel.exception.SystemException)e;
273                 }
274 
275                 throw new com.liferay.portal.kernel.exception.SystemException(e);
276             }
277 
278             return (java.util.List<com.liferay.portal.model.UserGroup>)returnObj;
279         }
280         catch (com.liferay.portal.kernel.exception.SystemException se) {
281             _log.error(se, se);
282 
283             throw se;
284         }
285     }
286 
287     public static void unsetGroupUserGroups(HttpPrincipal httpPrincipal,
288         long groupId, long[] userGroupIds)
289         throws com.liferay.portal.kernel.exception.PortalException,
290             com.liferay.portal.kernel.exception.SystemException {
291         try {
292             Object paramObj0 = new LongWrapper(groupId);
293 
294             Object paramObj1 = userGroupIds;
295 
296             if (userGroupIds == null) {
297                 paramObj1 = new NullWrapper("[J");
298             }
299 
300             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
301                     "unsetGroupUserGroups",
302                     new Object[] { paramObj0, paramObj1 });
303 
304             try {
305                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
306             }
307             catch (Exception e) {
308                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
309                     throw (com.liferay.portal.kernel.exception.PortalException)e;
310                 }
311 
312                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
313                     throw (com.liferay.portal.kernel.exception.SystemException)e;
314                 }
315 
316                 throw new com.liferay.portal.kernel.exception.SystemException(e);
317             }
318         }
319         catch (com.liferay.portal.kernel.exception.SystemException se) {
320             _log.error(se, se);
321 
322             throw se;
323         }
324     }
325 
326     public static com.liferay.portal.model.UserGroup updateUserGroup(
327         HttpPrincipal httpPrincipal, long userGroupId, java.lang.String name,
328         java.lang.String description)
329         throws com.liferay.portal.kernel.exception.PortalException,
330             com.liferay.portal.kernel.exception.SystemException {
331         try {
332             Object paramObj0 = new LongWrapper(userGroupId);
333 
334             Object paramObj1 = name;
335 
336             if (name == null) {
337                 paramObj1 = new NullWrapper("java.lang.String");
338             }
339 
340             Object paramObj2 = description;
341 
342             if (description == null) {
343                 paramObj2 = new NullWrapper("java.lang.String");
344             }
345 
346             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
347                     "updateUserGroup",
348                     new Object[] { paramObj0, paramObj1, paramObj2 });
349 
350             Object returnObj = null;
351 
352             try {
353                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
354             }
355             catch (Exception e) {
356                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
357                     throw (com.liferay.portal.kernel.exception.PortalException)e;
358                 }
359 
360                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
361                     throw (com.liferay.portal.kernel.exception.SystemException)e;
362                 }
363 
364                 throw new com.liferay.portal.kernel.exception.SystemException(e);
365             }
366 
367             return (com.liferay.portal.model.UserGroup)returnObj;
368         }
369         catch (com.liferay.portal.kernel.exception.SystemException se) {
370             _log.error(se, se);
371 
372             throw se;
373         }
374     }
375 
376     private static Log _log = LogFactoryUtil.getLog(UserGroupServiceHttp.class);
377 }