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