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