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