1   /**
2    * Copyright (c) 2000-2008 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.BooleanWrapper;
28  import com.liferay.portal.kernel.util.IntegerWrapper;
29  import com.liferay.portal.kernel.util.LongWrapper;
30  import com.liferay.portal.kernel.util.MethodWrapper;
31  import com.liferay.portal.kernel.util.NullWrapper;
32  import com.liferay.portal.security.auth.HttpPrincipal;
33  import com.liferay.portal.service.GroupServiceUtil;
34  
35  /**
36   * <a href="GroupServiceHttp.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be
40   * overwritten the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class provides a HTTP utility for the
45   * <code>com.liferay.portal.service.GroupServiceUtil</code> service
46   * utility. The static methods of this class calls the same methods of the
47   * service utility. However, the signatures are different because it requires an
48   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
49   * parameter.
50   * </p>
51   *
52   * <p>
53   * The benefits of using the HTTP utility is that it is fast and allows for
54   * tunneling without the cost of serializing to text. The drawback is that it
55   * only works with Java.
56   * </p>
57   *
58   * <p>
59   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
60   * portal.properties to configure security.
61   * </p>
62   *
63   * <p>
64   * The HTTP utility is only generated for remote services.
65   * </p>
66   *
67   * @author Brian Wing Shun Chan
68   *
69   * @see com.liferay.portal.security.auth.HttpPrincipal
70   * @see com.liferay.portal.service.GroupServiceUtil
71   * @see com.liferay.portal.service.http.GroupServiceSoap
72   *
73   */
74  public class GroupServiceHttp {
75      public static com.liferay.portal.model.Group addGroup(
76          HttpPrincipal httpPrincipal, java.lang.String name,
77          java.lang.String description, int type, java.lang.String friendlyURL,
78          boolean active)
79          throws com.liferay.portal.SystemException, 
80              com.liferay.portal.PortalException {
81          try {
82              Object paramObj0 = name;
83  
84              if (name == null) {
85                  paramObj0 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj1 = description;
89  
90              if (description == null) {
91                  paramObj1 = new NullWrapper("java.lang.String");
92              }
93  
94              Object paramObj2 = new IntegerWrapper(type);
95  
96              Object paramObj3 = friendlyURL;
97  
98              if (friendlyURL == null) {
99                  paramObj3 = new NullWrapper("java.lang.String");
100             }
101 
102             Object paramObj4 = new BooleanWrapper(active);
103 
104             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
105                     "addGroup",
106                     new Object[] {
107                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
108                     });
109 
110             Object returnObj = null;
111 
112             try {
113                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
114             }
115             catch (Exception e) {
116                 if (e instanceof com.liferay.portal.SystemException) {
117                     throw (com.liferay.portal.SystemException)e;
118                 }
119 
120                 if (e instanceof com.liferay.portal.PortalException) {
121                     throw (com.liferay.portal.PortalException)e;
122                 }
123 
124                 throw new com.liferay.portal.SystemException(e);
125             }
126 
127             return (com.liferay.portal.model.Group)returnObj;
128         }
129         catch (com.liferay.portal.SystemException se) {
130             _log.error(se, se);
131 
132             throw se;
133         }
134     }
135 
136     public static com.liferay.portal.model.Group addGroup(
137         HttpPrincipal httpPrincipal, long liveGroupId, java.lang.String name,
138         java.lang.String description, int type, java.lang.String friendlyURL,
139         boolean active)
140         throws com.liferay.portal.SystemException, 
141             com.liferay.portal.PortalException {
142         try {
143             Object paramObj0 = new LongWrapper(liveGroupId);
144 
145             Object paramObj1 = name;
146 
147             if (name == null) {
148                 paramObj1 = new NullWrapper("java.lang.String");
149             }
150 
151             Object paramObj2 = description;
152 
153             if (description == null) {
154                 paramObj2 = new NullWrapper("java.lang.String");
155             }
156 
157             Object paramObj3 = new IntegerWrapper(type);
158 
159             Object paramObj4 = friendlyURL;
160 
161             if (friendlyURL == null) {
162                 paramObj4 = new NullWrapper("java.lang.String");
163             }
164 
165             Object paramObj5 = new BooleanWrapper(active);
166 
167             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
168                     "addGroup",
169                     new Object[] {
170                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
171                         paramObj5
172                     });
173 
174             Object returnObj = null;
175 
176             try {
177                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
178             }
179             catch (Exception e) {
180                 if (e instanceof com.liferay.portal.SystemException) {
181                     throw (com.liferay.portal.SystemException)e;
182                 }
183 
184                 if (e instanceof com.liferay.portal.PortalException) {
185                     throw (com.liferay.portal.PortalException)e;
186                 }
187 
188                 throw new com.liferay.portal.SystemException(e);
189             }
190 
191             return (com.liferay.portal.model.Group)returnObj;
192         }
193         catch (com.liferay.portal.SystemException se) {
194             _log.error(se, se);
195 
196             throw se;
197         }
198     }
199 
200     public static void addRoleGroups(HttpPrincipal httpPrincipal, long roleId,
201         long[] groupIds)
202         throws com.liferay.portal.SystemException, 
203             com.liferay.portal.PortalException {
204         try {
205             Object paramObj0 = new LongWrapper(roleId);
206 
207             Object paramObj1 = groupIds;
208 
209             if (groupIds == null) {
210                 paramObj1 = new NullWrapper("[J");
211             }
212 
213             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
214                     "addRoleGroups", new Object[] { paramObj0, paramObj1 });
215 
216             try {
217                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
218             }
219             catch (Exception e) {
220                 if (e instanceof com.liferay.portal.SystemException) {
221                     throw (com.liferay.portal.SystemException)e;
222                 }
223 
224                 if (e instanceof com.liferay.portal.PortalException) {
225                     throw (com.liferay.portal.PortalException)e;
226                 }
227 
228                 throw new com.liferay.portal.SystemException(e);
229             }
230         }
231         catch (com.liferay.portal.SystemException se) {
232             _log.error(se, se);
233 
234             throw se;
235         }
236     }
237 
238     public static void deleteGroup(HttpPrincipal httpPrincipal, long groupId)
239         throws com.liferay.portal.SystemException, 
240             com.liferay.portal.PortalException {
241         try {
242             Object paramObj0 = new LongWrapper(groupId);
243 
244             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
245                     "deleteGroup", new Object[] { paramObj0 });
246 
247             try {
248                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
249             }
250             catch (Exception e) {
251                 if (e instanceof com.liferay.portal.SystemException) {
252                     throw (com.liferay.portal.SystemException)e;
253                 }
254 
255                 if (e instanceof com.liferay.portal.PortalException) {
256                     throw (com.liferay.portal.PortalException)e;
257                 }
258 
259                 throw new com.liferay.portal.SystemException(e);
260             }
261         }
262         catch (com.liferay.portal.SystemException se) {
263             _log.error(se, se);
264 
265             throw se;
266         }
267     }
268 
269     public static com.liferay.portal.model.Group getGroup(
270         HttpPrincipal httpPrincipal, long groupId)
271         throws com.liferay.portal.SystemException, 
272             com.liferay.portal.PortalException {
273         try {
274             Object paramObj0 = new LongWrapper(groupId);
275 
276             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
277                     "getGroup", new Object[] { paramObj0 });
278 
279             Object returnObj = null;
280 
281             try {
282                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
283             }
284             catch (Exception e) {
285                 if (e instanceof com.liferay.portal.SystemException) {
286                     throw (com.liferay.portal.SystemException)e;
287                 }
288 
289                 if (e instanceof com.liferay.portal.PortalException) {
290                     throw (com.liferay.portal.PortalException)e;
291                 }
292 
293                 throw new com.liferay.portal.SystemException(e);
294             }
295 
296             return (com.liferay.portal.model.Group)returnObj;
297         }
298         catch (com.liferay.portal.SystemException se) {
299             _log.error(se, se);
300 
301             throw se;
302         }
303     }
304 
305     public static com.liferay.portal.model.Group getGroup(
306         HttpPrincipal httpPrincipal, long companyId, java.lang.String name)
307         throws com.liferay.portal.SystemException, 
308             com.liferay.portal.PortalException {
309         try {
310             Object paramObj0 = new LongWrapper(companyId);
311 
312             Object paramObj1 = name;
313 
314             if (name == null) {
315                 paramObj1 = new NullWrapper("java.lang.String");
316             }
317 
318             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
319                     "getGroup", new Object[] { paramObj0, paramObj1 });
320 
321             Object returnObj = null;
322 
323             try {
324                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
325             }
326             catch (Exception e) {
327                 if (e instanceof com.liferay.portal.SystemException) {
328                     throw (com.liferay.portal.SystemException)e;
329                 }
330 
331                 if (e instanceof com.liferay.portal.PortalException) {
332                     throw (com.liferay.portal.PortalException)e;
333                 }
334 
335                 throw new com.liferay.portal.SystemException(e);
336             }
337 
338             return (com.liferay.portal.model.Group)returnObj;
339         }
340         catch (com.liferay.portal.SystemException se) {
341             _log.error(se, se);
342 
343             throw se;
344         }
345     }
346 
347     public static java.util.List getOrganizationsGroups(
348         HttpPrincipal httpPrincipal, java.util.List organizations)
349         throws com.liferay.portal.SystemException, 
350             com.liferay.portal.PortalException {
351         try {
352             Object paramObj0 = organizations;
353 
354             if (organizations == null) {
355                 paramObj0 = new NullWrapper("java.util.List");
356             }
357 
358             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
359                     "getOrganizationsGroups", new Object[] { paramObj0 });
360 
361             Object returnObj = null;
362 
363             try {
364                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
365             }
366             catch (Exception e) {
367                 if (e instanceof com.liferay.portal.SystemException) {
368                     throw (com.liferay.portal.SystemException)e;
369                 }
370 
371                 if (e instanceof com.liferay.portal.PortalException) {
372                     throw (com.liferay.portal.PortalException)e;
373                 }
374 
375                 throw new com.liferay.portal.SystemException(e);
376             }
377 
378             return (java.util.List)returnObj;
379         }
380         catch (com.liferay.portal.SystemException se) {
381             _log.error(se, se);
382 
383             throw se;
384         }
385     }
386 
387     public static java.util.List getUserGroupsGroups(
388         HttpPrincipal httpPrincipal, java.util.List userGroups)
389         throws com.liferay.portal.SystemException, 
390             com.liferay.portal.PortalException {
391         try {
392             Object paramObj0 = userGroups;
393 
394             if (userGroups == null) {
395                 paramObj0 = new NullWrapper("java.util.List");
396             }
397 
398             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
399                     "getUserGroupsGroups", new Object[] { paramObj0 });
400 
401             Object returnObj = null;
402 
403             try {
404                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
405             }
406             catch (Exception e) {
407                 if (e instanceof com.liferay.portal.SystemException) {
408                     throw (com.liferay.portal.SystemException)e;
409                 }
410 
411                 if (e instanceof com.liferay.portal.PortalException) {
412                     throw (com.liferay.portal.PortalException)e;
413                 }
414 
415                 throw new com.liferay.portal.SystemException(e);
416             }
417 
418             return (java.util.List)returnObj;
419         }
420         catch (com.liferay.portal.SystemException se) {
421             _log.error(se, se);
422 
423             throw se;
424         }
425     }
426 
427     public static boolean hasUserGroup(HttpPrincipal httpPrincipal,
428         long userId, long groupId) throws com.liferay.portal.SystemException {
429         try {
430             Object paramObj0 = new LongWrapper(userId);
431 
432             Object paramObj1 = new LongWrapper(groupId);
433 
434             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
435                     "hasUserGroup", new Object[] { paramObj0, paramObj1 });
436 
437             Object returnObj = null;
438 
439             try {
440                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
441             }
442             catch (Exception e) {
443                 if (e instanceof com.liferay.portal.SystemException) {
444                     throw (com.liferay.portal.SystemException)e;
445                 }
446 
447                 throw new com.liferay.portal.SystemException(e);
448             }
449 
450             return ((Boolean)returnObj).booleanValue();
451         }
452         catch (com.liferay.portal.SystemException se) {
453             _log.error(se, se);
454 
455             throw se;
456         }
457     }
458 
459     public static java.util.List search(HttpPrincipal httpPrincipal,
460         long companyId, java.lang.String name, java.lang.String description,
461         java.lang.String[] params, int begin, int end)
462         throws com.liferay.portal.SystemException {
463         try {
464             Object paramObj0 = new LongWrapper(companyId);
465 
466             Object paramObj1 = name;
467 
468             if (name == null) {
469                 paramObj1 = new NullWrapper("java.lang.String");
470             }
471 
472             Object paramObj2 = description;
473 
474             if (description == null) {
475                 paramObj2 = new NullWrapper("java.lang.String");
476             }
477 
478             Object paramObj3 = params;
479 
480             if (params == null) {
481                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
482             }
483 
484             Object paramObj4 = new IntegerWrapper(begin);
485 
486             Object paramObj5 = new IntegerWrapper(end);
487 
488             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
489                     "search",
490                     new Object[] {
491                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
492                         paramObj5
493                     });
494 
495             Object returnObj = null;
496 
497             try {
498                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
499             }
500             catch (Exception e) {
501                 if (e instanceof com.liferay.portal.SystemException) {
502                     throw (com.liferay.portal.SystemException)e;
503                 }
504 
505                 throw new com.liferay.portal.SystemException(e);
506             }
507 
508             return (java.util.List)returnObj;
509         }
510         catch (com.liferay.portal.SystemException se) {
511             _log.error(se, se);
512 
513             throw se;
514         }
515     }
516 
517     public static int searchCount(HttpPrincipal httpPrincipal, long companyId,
518         java.lang.String name, java.lang.String description,
519         java.lang.String[] params) throws com.liferay.portal.SystemException {
520         try {
521             Object paramObj0 = new LongWrapper(companyId);
522 
523             Object paramObj1 = name;
524 
525             if (name == null) {
526                 paramObj1 = new NullWrapper("java.lang.String");
527             }
528 
529             Object paramObj2 = description;
530 
531             if (description == null) {
532                 paramObj2 = new NullWrapper("java.lang.String");
533             }
534 
535             Object paramObj3 = params;
536 
537             if (params == null) {
538                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
539             }
540 
541             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
542                     "searchCount",
543                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
544 
545             Object returnObj = null;
546 
547             try {
548                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
549             }
550             catch (Exception e) {
551                 if (e instanceof com.liferay.portal.SystemException) {
552                     throw (com.liferay.portal.SystemException)e;
553                 }
554 
555                 throw new com.liferay.portal.SystemException(e);
556             }
557 
558             return ((Integer)returnObj).intValue();
559         }
560         catch (com.liferay.portal.SystemException se) {
561             _log.error(se, se);
562 
563             throw se;
564         }
565     }
566 
567     public static void setRoleGroups(HttpPrincipal httpPrincipal, long roleId,
568         long[] groupIds)
569         throws com.liferay.portal.SystemException, 
570             com.liferay.portal.PortalException {
571         try {
572             Object paramObj0 = new LongWrapper(roleId);
573 
574             Object paramObj1 = groupIds;
575 
576             if (groupIds == null) {
577                 paramObj1 = new NullWrapper("[J");
578             }
579 
580             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
581                     "setRoleGroups", new Object[] { paramObj0, paramObj1 });
582 
583             try {
584                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
585             }
586             catch (Exception e) {
587                 if (e instanceof com.liferay.portal.SystemException) {
588                     throw (com.liferay.portal.SystemException)e;
589                 }
590 
591                 if (e instanceof com.liferay.portal.PortalException) {
592                     throw (com.liferay.portal.PortalException)e;
593                 }
594 
595                 throw new com.liferay.portal.SystemException(e);
596             }
597         }
598         catch (com.liferay.portal.SystemException se) {
599             _log.error(se, se);
600 
601             throw se;
602         }
603     }
604 
605     public static void unsetRoleGroups(HttpPrincipal httpPrincipal,
606         long roleId, long[] groupIds)
607         throws com.liferay.portal.SystemException, 
608             com.liferay.portal.PortalException {
609         try {
610             Object paramObj0 = new LongWrapper(roleId);
611 
612             Object paramObj1 = groupIds;
613 
614             if (groupIds == null) {
615                 paramObj1 = new NullWrapper("[J");
616             }
617 
618             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
619                     "unsetRoleGroups", new Object[] { paramObj0, paramObj1 });
620 
621             try {
622                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
623             }
624             catch (Exception e) {
625                 if (e instanceof com.liferay.portal.SystemException) {
626                     throw (com.liferay.portal.SystemException)e;
627                 }
628 
629                 if (e instanceof com.liferay.portal.PortalException) {
630                     throw (com.liferay.portal.PortalException)e;
631                 }
632 
633                 throw new com.liferay.portal.SystemException(e);
634             }
635         }
636         catch (com.liferay.portal.SystemException se) {
637             _log.error(se, se);
638 
639             throw se;
640         }
641     }
642 
643     public static com.liferay.portal.model.Group updateGroup(
644         HttpPrincipal httpPrincipal, long groupId, java.lang.String name,
645         java.lang.String description, int type, java.lang.String friendlyURL,
646         boolean active)
647         throws com.liferay.portal.SystemException, 
648             com.liferay.portal.PortalException {
649         try {
650             Object paramObj0 = new LongWrapper(groupId);
651 
652             Object paramObj1 = name;
653 
654             if (name == null) {
655                 paramObj1 = new NullWrapper("java.lang.String");
656             }
657 
658             Object paramObj2 = description;
659 
660             if (description == null) {
661                 paramObj2 = new NullWrapper("java.lang.String");
662             }
663 
664             Object paramObj3 = new IntegerWrapper(type);
665 
666             Object paramObj4 = friendlyURL;
667 
668             if (friendlyURL == null) {
669                 paramObj4 = new NullWrapper("java.lang.String");
670             }
671 
672             Object paramObj5 = new BooleanWrapper(active);
673 
674             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
675                     "updateGroup",
676                     new Object[] {
677                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
678                         paramObj5
679                     });
680 
681             Object returnObj = null;
682 
683             try {
684                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
685             }
686             catch (Exception e) {
687                 if (e instanceof com.liferay.portal.SystemException) {
688                     throw (com.liferay.portal.SystemException)e;
689                 }
690 
691                 if (e instanceof com.liferay.portal.PortalException) {
692                     throw (com.liferay.portal.PortalException)e;
693                 }
694 
695                 throw new com.liferay.portal.SystemException(e);
696             }
697 
698             return (com.liferay.portal.model.Group)returnObj;
699         }
700         catch (com.liferay.portal.SystemException se) {
701             _log.error(se, se);
702 
703             throw se;
704         }
705     }
706 
707     public static com.liferay.portal.model.Group updateGroup(
708         HttpPrincipal httpPrincipal, long groupId, java.lang.String typeSettings)
709         throws com.liferay.portal.SystemException, 
710             com.liferay.portal.PortalException {
711         try {
712             Object paramObj0 = new LongWrapper(groupId);
713 
714             Object paramObj1 = typeSettings;
715 
716             if (typeSettings == null) {
717                 paramObj1 = new NullWrapper("java.lang.String");
718             }
719 
720             MethodWrapper methodWrapper = new MethodWrapper(GroupServiceUtil.class.getName(),
721                     "updateGroup", new Object[] { paramObj0, paramObj1 });
722 
723             Object returnObj = null;
724 
725             try {
726                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
727             }
728             catch (Exception e) {
729                 if (e instanceof com.liferay.portal.SystemException) {
730                     throw (com.liferay.portal.SystemException)e;
731                 }
732 
733                 if (e instanceof com.liferay.portal.PortalException) {
734                     throw (com.liferay.portal.PortalException)e;
735                 }
736 
737                 throw new com.liferay.portal.SystemException(e);
738             }
739 
740             return (com.liferay.portal.model.Group)returnObj;
741         }
742         catch (com.liferay.portal.SystemException se) {
743             _log.error(se, se);
744 
745             throw se;
746         }
747     }
748 
749     private static Log _log = LogFactoryUtil.getLog(GroupServiceHttp.class);
750 }