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