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.OrganizationServiceUtil;
34  import com.liferay.portal.service.http.TunnelUtil;
35  
36  /**
37   * <a href="OrganizationServiceHttp.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.OrganizationServiceUtil</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.OrganizationServiceUtil
70   * @see com.liferay.portal.service.http.OrganizationServiceSoap
71   *
72   */
73  public class OrganizationServiceHttp {
74      public static void addGroupOrganizations(HttpPrincipal httpPrincipal,
75          long groupId, long[] organizationIds)
76          throws com.liferay.portal.SystemException, 
77              com.liferay.portal.PortalException {
78          try {
79              Object paramObj0 = new LongWrapper(groupId);
80              Object paramObj1 = organizationIds;
81  
82              if (organizationIds == null) {
83                  paramObj1 = new NullWrapper("[J");
84              }
85  
86              MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
87                      "addGroupOrganizations",
88                      new Object[] { paramObj0, paramObj1 });
89  
90              try {
91                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
92              }
93              catch (Exception e) {
94                  if (e instanceof com.liferay.portal.SystemException) {
95                      throw (com.liferay.portal.SystemException)e;
96                  }
97  
98                  if (e instanceof com.liferay.portal.PortalException) {
99                      throw (com.liferay.portal.PortalException)e;
100                 }
101 
102                 throw new com.liferay.portal.SystemException(e);
103             }
104         }
105         catch (com.liferay.portal.SystemException se) {
106             _log.error(se, se);
107             throw se;
108         }
109     }
110 
111     public static void addPasswordPolicyOrganizations(
112         HttpPrincipal httpPrincipal, long passwordPolicyId,
113         long[] organizationIds)
114         throws com.liferay.portal.SystemException, 
115             com.liferay.portal.PortalException {
116         try {
117             Object paramObj0 = new LongWrapper(passwordPolicyId);
118             Object paramObj1 = organizationIds;
119 
120             if (organizationIds == null) {
121                 paramObj1 = new NullWrapper("[J");
122             }
123 
124             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
125                     "addPasswordPolicyOrganizations",
126                     new Object[] { paramObj0, paramObj1 });
127 
128             try {
129                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
130             }
131             catch (Exception e) {
132                 if (e instanceof com.liferay.portal.SystemException) {
133                     throw (com.liferay.portal.SystemException)e;
134                 }
135 
136                 if (e instanceof com.liferay.portal.PortalException) {
137                     throw (com.liferay.portal.PortalException)e;
138                 }
139 
140                 throw new com.liferay.portal.SystemException(e);
141             }
142         }
143         catch (com.liferay.portal.SystemException se) {
144             _log.error(se, se);
145             throw se;
146         }
147     }
148 
149     public static com.liferay.portal.model.Organization addOrganization(
150         HttpPrincipal httpPrincipal, long parentOrganizationId,
151         java.lang.String name, boolean location, boolean recursable,
152         long regionId, long countryId, int statusId)
153         throws com.liferay.portal.SystemException, 
154             com.liferay.portal.PortalException {
155         try {
156             Object paramObj0 = new LongWrapper(parentOrganizationId);
157             Object paramObj1 = name;
158 
159             if (name == null) {
160                 paramObj1 = new NullWrapper("java.lang.String");
161             }
162 
163             Object paramObj2 = new BooleanWrapper(location);
164             Object paramObj3 = new BooleanWrapper(recursable);
165             Object paramObj4 = new LongWrapper(regionId);
166             Object paramObj5 = new LongWrapper(countryId);
167             Object paramObj6 = new IntegerWrapper(statusId);
168             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
169                     "addOrganization",
170                     new Object[] {
171                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
172                         paramObj5, paramObj6
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.Organization)returnObj;
192         }
193         catch (com.liferay.portal.SystemException se) {
194             _log.error(se, se);
195             throw se;
196         }
197     }
198 
199     public static void deleteOrganization(HttpPrincipal httpPrincipal,
200         long organizationId)
201         throws com.liferay.portal.SystemException, 
202             com.liferay.portal.PortalException {
203         try {
204             Object paramObj0 = new LongWrapper(organizationId);
205             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
206                     "deleteOrganization", new Object[] { paramObj0 });
207 
208             try {
209                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
210             }
211             catch (Exception e) {
212                 if (e instanceof com.liferay.portal.SystemException) {
213                     throw (com.liferay.portal.SystemException)e;
214                 }
215 
216                 if (e instanceof com.liferay.portal.PortalException) {
217                     throw (com.liferay.portal.PortalException)e;
218                 }
219 
220                 throw new com.liferay.portal.SystemException(e);
221             }
222         }
223         catch (com.liferay.portal.SystemException se) {
224             _log.error(se, se);
225             throw se;
226         }
227     }
228 
229     public static com.liferay.portal.model.Organization getOrganization(
230         HttpPrincipal httpPrincipal, long organizationId)
231         throws com.liferay.portal.SystemException, 
232             com.liferay.portal.PortalException {
233         try {
234             Object paramObj0 = new LongWrapper(organizationId);
235             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
236                     "getOrganization", new Object[] { paramObj0 });
237             Object returnObj = null;
238 
239             try {
240                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
241             }
242             catch (Exception e) {
243                 if (e instanceof com.liferay.portal.SystemException) {
244                     throw (com.liferay.portal.SystemException)e;
245                 }
246 
247                 if (e instanceof com.liferay.portal.PortalException) {
248                     throw (com.liferay.portal.PortalException)e;
249                 }
250 
251                 throw new com.liferay.portal.SystemException(e);
252             }
253 
254             return (com.liferay.portal.model.Organization)returnObj;
255         }
256         catch (com.liferay.portal.SystemException se) {
257             _log.error(se, se);
258             throw se;
259         }
260     }
261 
262     public static long getOrganizationId(HttpPrincipal httpPrincipal,
263         long companyId, java.lang.String name)
264         throws com.liferay.portal.SystemException, 
265             com.liferay.portal.PortalException {
266         try {
267             Object paramObj0 = new LongWrapper(companyId);
268             Object paramObj1 = name;
269 
270             if (name == null) {
271                 paramObj1 = new NullWrapper("java.lang.String");
272             }
273 
274             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
275                     "getOrganizationId", new Object[] { paramObj0, paramObj1 });
276             Object returnObj = null;
277 
278             try {
279                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
280             }
281             catch (Exception e) {
282                 if (e instanceof com.liferay.portal.SystemException) {
283                     throw (com.liferay.portal.SystemException)e;
284                 }
285 
286                 if (e instanceof com.liferay.portal.PortalException) {
287                     throw (com.liferay.portal.PortalException)e;
288                 }
289 
290                 throw new com.liferay.portal.SystemException(e);
291             }
292 
293             return ((Long)returnObj).longValue();
294         }
295         catch (com.liferay.portal.SystemException se) {
296             _log.error(se, se);
297             throw se;
298         }
299     }
300 
301     public static java.util.List getUserOrganizations(
302         HttpPrincipal httpPrincipal, long userId)
303         throws com.liferay.portal.SystemException, 
304             com.liferay.portal.PortalException {
305         try {
306             Object paramObj0 = new LongWrapper(userId);
307             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
308                     "getUserOrganizations", new Object[] { paramObj0 });
309             Object returnObj = null;
310 
311             try {
312                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
313             }
314             catch (Exception e) {
315                 if (e instanceof com.liferay.portal.SystemException) {
316                     throw (com.liferay.portal.SystemException)e;
317                 }
318 
319                 if (e instanceof com.liferay.portal.PortalException) {
320                     throw (com.liferay.portal.PortalException)e;
321                 }
322 
323                 throw new com.liferay.portal.SystemException(e);
324             }
325 
326             return (java.util.List)returnObj;
327         }
328         catch (com.liferay.portal.SystemException se) {
329             _log.error(se, se);
330             throw se;
331         }
332     }
333 
334     public static void setGroupOrganizations(HttpPrincipal httpPrincipal,
335         long groupId, long[] organizationIds)
336         throws com.liferay.portal.SystemException, 
337             com.liferay.portal.PortalException {
338         try {
339             Object paramObj0 = new LongWrapper(groupId);
340             Object paramObj1 = organizationIds;
341 
342             if (organizationIds == null) {
343                 paramObj1 = new NullWrapper("[J");
344             }
345 
346             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
347                     "setGroupOrganizations",
348                     new Object[] { paramObj0, paramObj1 });
349 
350             try {
351                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
352             }
353             catch (Exception e) {
354                 if (e instanceof com.liferay.portal.SystemException) {
355                     throw (com.liferay.portal.SystemException)e;
356                 }
357 
358                 if (e instanceof com.liferay.portal.PortalException) {
359                     throw (com.liferay.portal.PortalException)e;
360                 }
361 
362                 throw new com.liferay.portal.SystemException(e);
363             }
364         }
365         catch (com.liferay.portal.SystemException se) {
366             _log.error(se, se);
367             throw se;
368         }
369     }
370 
371     public static void unsetGroupOrganizations(HttpPrincipal httpPrincipal,
372         long groupId, long[] organizationIds)
373         throws com.liferay.portal.SystemException, 
374             com.liferay.portal.PortalException {
375         try {
376             Object paramObj0 = new LongWrapper(groupId);
377             Object paramObj1 = organizationIds;
378 
379             if (organizationIds == null) {
380                 paramObj1 = new NullWrapper("[J");
381             }
382 
383             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
384                     "unsetGroupOrganizations",
385                     new Object[] { paramObj0, paramObj1 });
386 
387             try {
388                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
389             }
390             catch (Exception e) {
391                 if (e instanceof com.liferay.portal.SystemException) {
392                     throw (com.liferay.portal.SystemException)e;
393                 }
394 
395                 if (e instanceof com.liferay.portal.PortalException) {
396                     throw (com.liferay.portal.PortalException)e;
397                 }
398 
399                 throw new com.liferay.portal.SystemException(e);
400             }
401         }
402         catch (com.liferay.portal.SystemException se) {
403             _log.error(se, se);
404             throw se;
405         }
406     }
407 
408     public static void unsetPasswordPolicyOrganizations(
409         HttpPrincipal httpPrincipal, long passwordPolicyId,
410         long[] organizationIds)
411         throws com.liferay.portal.SystemException, 
412             com.liferay.portal.PortalException {
413         try {
414             Object paramObj0 = new LongWrapper(passwordPolicyId);
415             Object paramObj1 = organizationIds;
416 
417             if (organizationIds == null) {
418                 paramObj1 = new NullWrapper("[J");
419             }
420 
421             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
422                     "unsetPasswordPolicyOrganizations",
423                     new Object[] { paramObj0, paramObj1 });
424 
425             try {
426                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
427             }
428             catch (Exception e) {
429                 if (e instanceof com.liferay.portal.SystemException) {
430                     throw (com.liferay.portal.SystemException)e;
431                 }
432 
433                 if (e instanceof com.liferay.portal.PortalException) {
434                     throw (com.liferay.portal.PortalException)e;
435                 }
436 
437                 throw new com.liferay.portal.SystemException(e);
438             }
439         }
440         catch (com.liferay.portal.SystemException se) {
441             _log.error(se, se);
442             throw se;
443         }
444     }
445 
446     public static com.liferay.portal.model.Organization updateOrganization(
447         HttpPrincipal httpPrincipal, long organizationId,
448         long parentOrganizationId, java.lang.String name, boolean location,
449         boolean recursable, long regionId, long countryId, int statusId)
450         throws com.liferay.portal.SystemException, 
451             com.liferay.portal.PortalException {
452         try {
453             Object paramObj0 = new LongWrapper(organizationId);
454             Object paramObj1 = new LongWrapper(parentOrganizationId);
455             Object paramObj2 = name;
456 
457             if (name == null) {
458                 paramObj2 = new NullWrapper("java.lang.String");
459             }
460 
461             Object paramObj3 = new BooleanWrapper(location);
462             Object paramObj4 = new BooleanWrapper(recursable);
463             Object paramObj5 = new LongWrapper(regionId);
464             Object paramObj6 = new LongWrapper(countryId);
465             Object paramObj7 = new IntegerWrapper(statusId);
466             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
467                     "updateOrganization",
468                     new Object[] {
469                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
470                         paramObj5, paramObj6, paramObj7
471                     });
472             Object returnObj = null;
473 
474             try {
475                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
476             }
477             catch (Exception e) {
478                 if (e instanceof com.liferay.portal.SystemException) {
479                     throw (com.liferay.portal.SystemException)e;
480                 }
481 
482                 if (e instanceof com.liferay.portal.PortalException) {
483                     throw (com.liferay.portal.PortalException)e;
484                 }
485 
486                 throw new com.liferay.portal.SystemException(e);
487             }
488 
489             return (com.liferay.portal.model.Organization)returnObj;
490         }
491         catch (com.liferay.portal.SystemException se) {
492             _log.error(se, se);
493             throw se;
494         }
495     }
496 
497     public static com.liferay.portal.model.Organization updateOrganization(
498         HttpPrincipal httpPrincipal, long organizationId,
499         java.lang.String comments)
500         throws com.liferay.portal.SystemException, 
501             com.liferay.portal.PortalException {
502         try {
503             Object paramObj0 = new LongWrapper(organizationId);
504             Object paramObj1 = comments;
505 
506             if (comments == null) {
507                 paramObj1 = new NullWrapper("java.lang.String");
508             }
509 
510             MethodWrapper methodWrapper = new MethodWrapper(OrganizationServiceUtil.class.getName(),
511                     "updateOrganization", new Object[] { paramObj0, paramObj1 });
512             Object returnObj = null;
513 
514             try {
515                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
516             }
517             catch (Exception e) {
518                 if (e instanceof com.liferay.portal.SystemException) {
519                     throw (com.liferay.portal.SystemException)e;
520                 }
521 
522                 if (e instanceof com.liferay.portal.PortalException) {
523                     throw (com.liferay.portal.PortalException)e;
524                 }
525 
526                 throw new com.liferay.portal.SystemException(e);
527             }
528 
529             return (com.liferay.portal.model.Organization)returnObj;
530         }
531         catch (com.liferay.portal.SystemException se) {
532             _log.error(se, se);
533             throw se;
534         }
535     }
536 
537     private static Log _log = LogFactoryUtil.getLog(OrganizationServiceHttp.class);
538 }