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.UserGroupServiceUtil;
29  
30  /**
31   * <a href="UserGroupServiceHttp.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.UserGroupServiceUtil</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.UserGroupServiceUtil
66   * @see com.liferay.portal.service.http.UserGroupServiceSoap
67   *
68   */
69  public class UserGroupServiceHttp {
70      public static void addGroupUserGroups(HttpPrincipal httpPrincipal,
71          long groupId, long[] userGroupIds)
72          throws com.liferay.portal.PortalException,
73              com.liferay.portal.SystemException {
74          try {
75              Object paramObj0 = new LongWrapper(groupId);
76  
77              Object paramObj1 = userGroupIds;
78  
79              if (userGroupIds == null) {
80                  paramObj1 = new NullWrapper("[J");
81              }
82  
83              MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
84                      "addGroupUserGroups", new Object[] { paramObj0, paramObj1 });
85  
86              try {
87                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
88              }
89              catch (Exception e) {
90                  if (e instanceof com.liferay.portal.PortalException) {
91                      throw (com.liferay.portal.PortalException)e;
92                  }
93  
94                  if (e instanceof com.liferay.portal.SystemException) {
95                      throw (com.liferay.portal.SystemException)e;
96                  }
97  
98                  throw new com.liferay.portal.SystemException(e);
99              }
100         }
101         catch (com.liferay.portal.SystemException se) {
102             _log.error(se, se);
103 
104             throw se;
105         }
106     }
107 
108     public static com.liferay.portal.model.UserGroup addUserGroup(
109         HttpPrincipal httpPrincipal, java.lang.String name,
110         java.lang.String description)
111         throws com.liferay.portal.PortalException,
112             com.liferay.portal.SystemException {
113         try {
114             Object paramObj0 = name;
115 
116             if (name == null) {
117                 paramObj0 = new NullWrapper("java.lang.String");
118             }
119 
120             Object paramObj1 = description;
121 
122             if (description == null) {
123                 paramObj1 = new NullWrapper("java.lang.String");
124             }
125 
126             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
127                     "addUserGroup", new Object[] { paramObj0, paramObj1 });
128 
129             Object returnObj = null;
130 
131             try {
132                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
133             }
134             catch (Exception e) {
135                 if (e instanceof com.liferay.portal.PortalException) {
136                     throw (com.liferay.portal.PortalException)e;
137                 }
138 
139                 if (e instanceof com.liferay.portal.SystemException) {
140                     throw (com.liferay.portal.SystemException)e;
141                 }
142 
143                 throw new com.liferay.portal.SystemException(e);
144             }
145 
146             return (com.liferay.portal.model.UserGroup)returnObj;
147         }
148         catch (com.liferay.portal.SystemException se) {
149             _log.error(se, se);
150 
151             throw se;
152         }
153     }
154 
155     public static void deleteUserGroup(HttpPrincipal httpPrincipal,
156         long userGroupId)
157         throws com.liferay.portal.PortalException,
158             com.liferay.portal.SystemException {
159         try {
160             Object paramObj0 = new LongWrapper(userGroupId);
161 
162             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
163                     "deleteUserGroup", new Object[] { paramObj0 });
164 
165             try {
166                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
167             }
168             catch (Exception e) {
169                 if (e instanceof com.liferay.portal.PortalException) {
170                     throw (com.liferay.portal.PortalException)e;
171                 }
172 
173                 if (e instanceof com.liferay.portal.SystemException) {
174                     throw (com.liferay.portal.SystemException)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 
183             throw se;
184         }
185     }
186 
187     public static com.liferay.portal.model.UserGroup getUserGroup(
188         HttpPrincipal httpPrincipal, long userGroupId)
189         throws com.liferay.portal.PortalException,
190             com.liferay.portal.SystemException {
191         try {
192             Object paramObj0 = new LongWrapper(userGroupId);
193 
194             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
195                     "getUserGroup", new Object[] { paramObj0 });
196 
197             Object returnObj = null;
198 
199             try {
200                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
201             }
202             catch (Exception e) {
203                 if (e instanceof com.liferay.portal.PortalException) {
204                     throw (com.liferay.portal.PortalException)e;
205                 }
206 
207                 if (e instanceof com.liferay.portal.SystemException) {
208                     throw (com.liferay.portal.SystemException)e;
209                 }
210 
211                 throw new com.liferay.portal.SystemException(e);
212             }
213 
214             return (com.liferay.portal.model.UserGroup)returnObj;
215         }
216         catch (com.liferay.portal.SystemException se) {
217             _log.error(se, se);
218 
219             throw se;
220         }
221     }
222 
223     public static com.liferay.portal.model.UserGroup getUserGroup(
224         HttpPrincipal httpPrincipal, java.lang.String name)
225         throws com.liferay.portal.PortalException,
226             com.liferay.portal.SystemException {
227         try {
228             Object paramObj0 = name;
229 
230             if (name == null) {
231                 paramObj0 = new NullWrapper("java.lang.String");
232             }
233 
234             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
235                     "getUserGroup", new Object[] { paramObj0 });
236 
237             Object returnObj = null;
238 
239             try {
240                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
241             }
242             catch (Exception e) {
243                 if (e instanceof com.liferay.portal.PortalException) {
244                     throw (com.liferay.portal.PortalException)e;
245                 }
246 
247                 if (e instanceof com.liferay.portal.SystemException) {
248                     throw (com.liferay.portal.SystemException)e;
249                 }
250 
251                 throw new com.liferay.portal.SystemException(e);
252             }
253 
254             return (com.liferay.portal.model.UserGroup)returnObj;
255         }
256         catch (com.liferay.portal.SystemException se) {
257             _log.error(se, se);
258 
259             throw se;
260         }
261     }
262 
263     public static java.util.List<com.liferay.portal.model.UserGroup> getUserUserGroups(
264         HttpPrincipal httpPrincipal, long userId)
265         throws com.liferay.portal.SystemException {
266         try {
267             Object paramObj0 = new LongWrapper(userId);
268 
269             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
270                     "getUserUserGroups", new Object[] { paramObj0 });
271 
272             Object returnObj = null;
273 
274             try {
275                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
276             }
277             catch (Exception e) {
278                 if (e instanceof com.liferay.portal.SystemException) {
279                     throw (com.liferay.portal.SystemException)e;
280                 }
281 
282                 throw new com.liferay.portal.SystemException(e);
283             }
284 
285             return (java.util.List<com.liferay.portal.model.UserGroup>)returnObj;
286         }
287         catch (com.liferay.portal.SystemException se) {
288             _log.error(se, se);
289 
290             throw se;
291         }
292     }
293 
294     public static void unsetGroupUserGroups(HttpPrincipal httpPrincipal,
295         long groupId, long[] userGroupIds)
296         throws com.liferay.portal.PortalException,
297             com.liferay.portal.SystemException {
298         try {
299             Object paramObj0 = new LongWrapper(groupId);
300 
301             Object paramObj1 = userGroupIds;
302 
303             if (userGroupIds == null) {
304                 paramObj1 = new NullWrapper("[J");
305             }
306 
307             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
308                     "unsetGroupUserGroups",
309                     new Object[] { paramObj0, paramObj1 });
310 
311             try {
312                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
313             }
314             catch (Exception e) {
315                 if (e instanceof com.liferay.portal.PortalException) {
316                     throw (com.liferay.portal.PortalException)e;
317                 }
318 
319                 if (e instanceof com.liferay.portal.SystemException) {
320                     throw (com.liferay.portal.SystemException)e;
321                 }
322 
323                 throw new com.liferay.portal.SystemException(e);
324             }
325         }
326         catch (com.liferay.portal.SystemException se) {
327             _log.error(se, se);
328 
329             throw se;
330         }
331     }
332 
333     public static com.liferay.portal.model.UserGroup updateUserGroup(
334         HttpPrincipal httpPrincipal, long userGroupId, java.lang.String name,
335         java.lang.String description)
336         throws com.liferay.portal.PortalException,
337             com.liferay.portal.SystemException {
338         try {
339             Object paramObj0 = new LongWrapper(userGroupId);
340 
341             Object paramObj1 = name;
342 
343             if (name == null) {
344                 paramObj1 = new NullWrapper("java.lang.String");
345             }
346 
347             Object paramObj2 = description;
348 
349             if (description == null) {
350                 paramObj2 = new NullWrapper("java.lang.String");
351             }
352 
353             MethodWrapper methodWrapper = new MethodWrapper(UserGroupServiceUtil.class.getName(),
354                     "updateUserGroup",
355                     new Object[] { paramObj0, paramObj1, paramObj2 });
356 
357             Object returnObj = null;
358 
359             try {
360                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
361             }
362             catch (Exception e) {
363                 if (e instanceof com.liferay.portal.PortalException) {
364                     throw (com.liferay.portal.PortalException)e;
365                 }
366 
367                 if (e instanceof com.liferay.portal.SystemException) {
368                     throw (com.liferay.portal.SystemException)e;
369                 }
370 
371                 throw new com.liferay.portal.SystemException(e);
372             }
373 
374             return (com.liferay.portal.model.UserGroup)returnObj;
375         }
376         catch (com.liferay.portal.SystemException se) {
377             _log.error(se, se);
378 
379             throw se;
380         }
381     }
382 
383     private static Log _log = LogFactoryUtil.getLog(UserGroupServiceHttp.class);
384 }