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