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