1   /**
2    * Copyright (c) 2000-2010 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   *
12   * 
13   */
14  
15  package com.liferay.portal.service.http;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.BooleanWrapper;
20  import com.liferay.portal.kernel.util.IntegerWrapper;
21  import com.liferay.portal.kernel.util.LongWrapper;
22  import com.liferay.portal.kernel.util.MethodWrapper;
23  import com.liferay.portal.kernel.util.NullWrapper;
24  import com.liferay.portal.security.auth.HttpPrincipal;
25  import com.liferay.portal.service.OrganizationServiceUtil;
26  
27  /**
28   * <a href="OrganizationServiceHttp.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * ServiceBuilder generated this class. Modifications in this class will be
32   * overwritten the next time is generated.
33   * </p>
34   *
35   * <p>
36   * This class provides a HTTP utility for the
37   * {@link com.liferay.portal.service.OrganizationServiceUtil} service utility. The
38   * static methods of this class calls the same methods of the service utility.
39   * However, the signatures are different because it requires an additional
40   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
41   * </p>
42   *
43   * <p>
44   * The benefits of using the HTTP utility is that it is fast and allows for
45   * tunneling without the cost of serializing to text. The drawback is that it
46   * only works with Java.
47   * </p>
48   *
49   * <p>
50   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
51   * configure security.
52   * </p>
53   *
54   * <p>
55   * The HTTP utility is only generated for remote services.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       OrganizationServiceSoap
60   * @see       com.liferay.portal.security.auth.HttpPrincipal
61   * @see       com.liferay.portal.service.OrganizationServiceUtil
62   * @generated
63   */
64  public class OrganizationServiceHttp {
65      public static void addGroupOrganizations(HttpPrincipal httpPrincipal,
66          long groupId, long[] organizationIds)
67          throws com.liferay.portal.PortalException,
68              com.liferay.portal.SystemException {
69          try {
70              Object paramObj0 = new LongWrapper(groupId);
71  
72              Object paramObj1 = organizationIds;
73  
74              if (organizationIds == null) {
75                  paramObj1 = new NullWrapper("[J");
76              }
77  
78              MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
79                      "addGroupOrganizations",
80                      new Object[] { paramObj0, paramObj1 });
81  
82              try {
83                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
84              }
85              catch (Exception e) {
86                  if (e instanceof com.liferay.portal.PortalException) {
87                      throw (com.liferay.portal.PortalException)e;
88                  }
89  
90                  if (e instanceof com.liferay.portal.SystemException) {
91                      throw (com.liferay.portal.SystemException)e;
92                  }
93  
94                  throw new com.liferay.portal.SystemException(e);
95              }
96          }
97          catch (com.liferay.portal.SystemException se) {
98              _log.error(se, se);
99  
100             throw se;
101         }
102     }
103 
104     public static void addPasswordPolicyOrganizations(
105         HttpPrincipal httpPrincipal, long passwordPolicyId,
106         long[] organizationIds)
107         throws com.liferay.portal.PortalException,
108             com.liferay.portal.SystemException {
109         try {
110             Object paramObj0 = new LongWrapper(passwordPolicyId);
111 
112             Object paramObj1 = organizationIds;
113 
114             if (organizationIds == null) {
115                 paramObj1 = new NullWrapper("[J");
116             }
117 
118             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
119                     "addPasswordPolicyOrganizations",
120                     new Object[] { paramObj0, paramObj1 });
121 
122             try {
123                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
124             }
125             catch (Exception e) {
126                 if (e instanceof com.liferay.portal.PortalException) {
127                     throw (com.liferay.portal.PortalException)e;
128                 }
129 
130                 if (e instanceof com.liferay.portal.SystemException) {
131                     throw (com.liferay.portal.SystemException)e;
132                 }
133 
134                 throw new com.liferay.portal.SystemException(e);
135             }
136         }
137         catch (com.liferay.portal.SystemException se) {
138             _log.error(se, se);
139 
140             throw se;
141         }
142     }
143 
144     public static com.liferay.portal.model.Organization addOrganization(
145         HttpPrincipal httpPrincipal, long parentOrganizationId,
146         java.lang.String name, int type, boolean recursable, long regionId,
147         long countryId, int statusId, java.lang.String comments)
148         throws com.liferay.portal.PortalException,
149             com.liferay.portal.SystemException {
150         try {
151             Object paramObj0 = new LongWrapper(parentOrganizationId);
152 
153             Object paramObj1 = name;
154 
155             if (name == null) {
156                 paramObj1 = new NullWrapper("java.lang.String");
157             }
158 
159             Object paramObj2 = new IntegerWrapper(type);
160 
161             Object paramObj3 = new BooleanWrapper(recursable);
162 
163             Object paramObj4 = new LongWrapper(regionId);
164 
165             Object paramObj5 = new LongWrapper(countryId);
166 
167             Object paramObj6 = new IntegerWrapper(statusId);
168 
169             Object paramObj7 = comments;
170 
171             if (comments == null) {
172                 paramObj7 = new NullWrapper("java.lang.String");
173             }
174 
175             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
176                     "addOrganization",
177                     new Object[] {
178                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
179                         paramObj5, paramObj6, paramObj7
180                     });
181 
182             Object returnObj = null;
183 
184             try {
185                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
186             }
187             catch (Exception e) {
188                 if (e instanceof com.liferay.portal.PortalException) {
189                     throw (com.liferay.portal.PortalException)e;
190                 }
191 
192                 if (e instanceof com.liferay.portal.SystemException) {
193                     throw (com.liferay.portal.SystemException)e;
194                 }
195 
196                 throw new com.liferay.portal.SystemException(e);
197             }
198 
199             return (com.liferay.portal.model.Organization)returnObj;
200         }
201         catch (com.liferay.portal.SystemException se) {
202             _log.error(se, se);
203 
204             throw se;
205         }
206     }
207 
208     public static void deleteOrganization(HttpPrincipal httpPrincipal,
209         long organizationId)
210         throws com.liferay.portal.PortalException,
211             com.liferay.portal.SystemException {
212         try {
213             Object paramObj0 = new LongWrapper(organizationId);
214 
215             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
216                     "deleteOrganization", new Object[] { paramObj0 });
217 
218             try {
219                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
220             }
221             catch (Exception e) {
222                 if (e instanceof com.liferay.portal.PortalException) {
223                     throw (com.liferay.portal.PortalException)e;
224                 }
225 
226                 if (e instanceof com.liferay.portal.SystemException) {
227                     throw (com.liferay.portal.SystemException)e;
228                 }
229 
230                 throw new com.liferay.portal.SystemException(e);
231             }
232         }
233         catch (com.liferay.portal.SystemException se) {
234             _log.error(se, se);
235 
236             throw se;
237         }
238     }
239 
240     public static com.liferay.portal.model.Organization getOrganization(
241         HttpPrincipal httpPrincipal, long organizationId)
242         throws com.liferay.portal.PortalException,
243             com.liferay.portal.SystemException {
244         try {
245             Object paramObj0 = new LongWrapper(organizationId);
246 
247             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
248                     "getOrganization", new Object[] { paramObj0 });
249 
250             Object returnObj = null;
251 
252             try {
253                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
254             }
255             catch (Exception e) {
256                 if (e instanceof com.liferay.portal.PortalException) {
257                     throw (com.liferay.portal.PortalException)e;
258                 }
259 
260                 if (e instanceof com.liferay.portal.SystemException) {
261                     throw (com.liferay.portal.SystemException)e;
262                 }
263 
264                 throw new com.liferay.portal.SystemException(e);
265             }
266 
267             return (com.liferay.portal.model.Organization)returnObj;
268         }
269         catch (com.liferay.portal.SystemException se) {
270             _log.error(se, se);
271 
272             throw se;
273         }
274     }
275 
276     public static long getOrganizationId(HttpPrincipal httpPrincipal,
277         long companyId, java.lang.String name)
278         throws com.liferay.portal.SystemException {
279         try {
280             Object paramObj0 = new LongWrapper(companyId);
281 
282             Object paramObj1 = name;
283 
284             if (name == null) {
285                 paramObj1 = new NullWrapper("java.lang.String");
286             }
287 
288             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
289                     "getOrganizationId", new Object[] { paramObj0, paramObj1 });
290 
291             Object returnObj = null;
292 
293             try {
294                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
295             }
296             catch (Exception e) {
297                 if (e instanceof com.liferay.portal.SystemException) {
298                     throw (com.liferay.portal.SystemException)e;
299                 }
300 
301                 throw new com.liferay.portal.SystemException(e);
302             }
303 
304             return ((Long)returnObj).longValue();
305         }
306         catch (com.liferay.portal.SystemException se) {
307             _log.error(se, se);
308 
309             throw se;
310         }
311     }
312 
313     public static java.util.List<com.liferay.portal.model.Organization> getUserOrganizations(
314         HttpPrincipal httpPrincipal, long userId)
315         throws com.liferay.portal.PortalException,
316             com.liferay.portal.SystemException {
317         try {
318             Object paramObj0 = new LongWrapper(userId);
319 
320             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
321                     "getUserOrganizations", new Object[] { paramObj0 });
322 
323             Object returnObj = null;
324 
325             try {
326                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
327             }
328             catch (Exception e) {
329                 if (e instanceof com.liferay.portal.PortalException) {
330                     throw (com.liferay.portal.PortalException)e;
331                 }
332 
333                 if (e instanceof com.liferay.portal.SystemException) {
334                     throw (com.liferay.portal.SystemException)e;
335                 }
336 
337                 throw new com.liferay.portal.SystemException(e);
338             }
339 
340             return (java.util.List<com.liferay.portal.model.Organization>)returnObj;
341         }
342         catch (com.liferay.portal.SystemException se) {
343             _log.error(se, se);
344 
345             throw se;
346         }
347     }
348 
349     public static java.util.List<com.liferay.portal.model.Organization> getUserOrganizations(
350         HttpPrincipal httpPrincipal, long userId, boolean inheritUserGroups)
351         throws com.liferay.portal.PortalException,
352             com.liferay.portal.SystemException {
353         try {
354             Object paramObj0 = new LongWrapper(userId);
355 
356             Object paramObj1 = new BooleanWrapper(inheritUserGroups);
357 
358             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
359                     "getUserOrganizations",
360                     new Object[] { paramObj0, paramObj1 });
361 
362             Object returnObj = null;
363 
364             try {
365                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
366             }
367             catch (Exception e) {
368                 if (e instanceof com.liferay.portal.PortalException) {
369                     throw (com.liferay.portal.PortalException)e;
370                 }
371 
372                 if (e instanceof com.liferay.portal.SystemException) {
373                     throw (com.liferay.portal.SystemException)e;
374                 }
375 
376                 throw new com.liferay.portal.SystemException(e);
377             }
378 
379             return (java.util.List<com.liferay.portal.model.Organization>)returnObj;
380         }
381         catch (com.liferay.portal.SystemException se) {
382             _log.error(se, se);
383 
384             throw se;
385         }
386     }
387 
388     public static void setGroupOrganizations(HttpPrincipal httpPrincipal,
389         long groupId, long[] organizationIds)
390         throws com.liferay.portal.PortalException,
391             com.liferay.portal.SystemException {
392         try {
393             Object paramObj0 = new LongWrapper(groupId);
394 
395             Object paramObj1 = organizationIds;
396 
397             if (organizationIds == null) {
398                 paramObj1 = new NullWrapper("[J");
399             }
400 
401             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
402                     "setGroupOrganizations",
403                     new Object[] { paramObj0, paramObj1 });
404 
405             try {
406                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
407             }
408             catch (Exception e) {
409                 if (e instanceof com.liferay.portal.PortalException) {
410                     throw (com.liferay.portal.PortalException)e;
411                 }
412 
413                 if (e instanceof com.liferay.portal.SystemException) {
414                     throw (com.liferay.portal.SystemException)e;
415                 }
416 
417                 throw new com.liferay.portal.SystemException(e);
418             }
419         }
420         catch (com.liferay.portal.SystemException se) {
421             _log.error(se, se);
422 
423             throw se;
424         }
425     }
426 
427     public static void unsetGroupOrganizations(HttpPrincipal httpPrincipal,
428         long groupId, long[] organizationIds)
429         throws com.liferay.portal.PortalException,
430             com.liferay.portal.SystemException {
431         try {
432             Object paramObj0 = new LongWrapper(groupId);
433 
434             Object paramObj1 = organizationIds;
435 
436             if (organizationIds == null) {
437                 paramObj1 = new NullWrapper("[J");
438             }
439 
440             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
441                     "unsetGroupOrganizations",
442                     new Object[] { paramObj0, paramObj1 });
443 
444             try {
445                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
446             }
447             catch (Exception e) {
448                 if (e instanceof com.liferay.portal.PortalException) {
449                     throw (com.liferay.portal.PortalException)e;
450                 }
451 
452                 if (e instanceof com.liferay.portal.SystemException) {
453                     throw (com.liferay.portal.SystemException)e;
454                 }
455 
456                 throw new com.liferay.portal.SystemException(e);
457             }
458         }
459         catch (com.liferay.portal.SystemException se) {
460             _log.error(se, se);
461 
462             throw se;
463         }
464     }
465 
466     public static void unsetPasswordPolicyOrganizations(
467         HttpPrincipal httpPrincipal, long passwordPolicyId,
468         long[] organizationIds)
469         throws com.liferay.portal.PortalException,
470             com.liferay.portal.SystemException {
471         try {
472             Object paramObj0 = new LongWrapper(passwordPolicyId);
473 
474             Object paramObj1 = organizationIds;
475 
476             if (organizationIds == null) {
477                 paramObj1 = new NullWrapper("[J");
478             }
479 
480             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
481                     "unsetPasswordPolicyOrganizations",
482                     new Object[] { paramObj0, paramObj1 });
483 
484             try {
485                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
486             }
487             catch (Exception e) {
488                 if (e instanceof com.liferay.portal.PortalException) {
489                     throw (com.liferay.portal.PortalException)e;
490                 }
491 
492                 if (e instanceof com.liferay.portal.SystemException) {
493                     throw (com.liferay.portal.SystemException)e;
494                 }
495 
496                 throw new com.liferay.portal.SystemException(e);
497             }
498         }
499         catch (com.liferay.portal.SystemException se) {
500             _log.error(se, se);
501 
502             throw se;
503         }
504     }
505 
506     public static com.liferay.portal.model.Organization updateOrganization(
507         HttpPrincipal httpPrincipal, long organizationId,
508         long parentOrganizationId, java.lang.String name, int type,
509         boolean recursable, long regionId, long countryId, int statusId,
510         java.lang.String comments)
511         throws com.liferay.portal.PortalException,
512             com.liferay.portal.SystemException {
513         try {
514             Object paramObj0 = new LongWrapper(organizationId);
515 
516             Object paramObj1 = new LongWrapper(parentOrganizationId);
517 
518             Object paramObj2 = name;
519 
520             if (name == null) {
521                 paramObj2 = new NullWrapper("java.lang.String");
522             }
523 
524             Object paramObj3 = new IntegerWrapper(type);
525 
526             Object paramObj4 = new BooleanWrapper(recursable);
527 
528             Object paramObj5 = new LongWrapper(regionId);
529 
530             Object paramObj6 = new LongWrapper(countryId);
531 
532             Object paramObj7 = new IntegerWrapper(statusId);
533 
534             Object paramObj8 = comments;
535 
536             if (comments == null) {
537                 paramObj8 = new NullWrapper("java.lang.String");
538             }
539 
540             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
541                     "updateOrganization",
542                     new Object[] {
543                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
544                         paramObj5, paramObj6, paramObj7, paramObj8
545                     });
546 
547             Object returnObj = null;
548 
549             try {
550                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
551             }
552             catch (Exception e) {
553                 if (e instanceof com.liferay.portal.PortalException) {
554                     throw (com.liferay.portal.PortalException)e;
555                 }
556 
557                 if (e instanceof com.liferay.portal.SystemException) {
558                     throw (com.liferay.portal.SystemException)e;
559                 }
560 
561                 throw new com.liferay.portal.SystemException(e);
562             }
563 
564             return (com.liferay.portal.model.Organization)returnObj;
565         }
566         catch (com.liferay.portal.SystemException se) {
567             _log.error(se, se);
568 
569             throw se;
570         }
571     }
572 
573     private static Log _log = LogFactoryUtil.getLog(OrganizationServiceHttp.class);
574 }