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.portlet.messageboards.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.http.TunnelUtil;
26  
27  import com.liferay.portlet.messageboards.service.MBCategoryServiceUtil;
28  
29  /**
30   * <a href="MBCategoryServiceHttp.java.html"><b><i>View Source</i></b></a>
31   *
32   * <p>
33   * ServiceBuilder generated this class. Modifications in this class will be
34   * overwritten the next time is generated.
35   * </p>
36   *
37   * <p>
38   * This class provides a HTTP utility for the
39   * {@link com.liferay.portlet.messageboards.service.MBCategoryServiceUtil} service utility. The
40   * static methods of this class calls the same methods of the service utility.
41   * However, the signatures are different because it requires an additional
42   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
43   * </p>
44   *
45   * <p>
46   * The benefits of using the HTTP utility is that it is fast and allows for
47   * tunneling without the cost of serializing to text. The drawback is that it
48   * only works with Java.
49   * </p>
50   *
51   * <p>
52   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
53   * configure security.
54   * </p>
55   *
56   * <p>
57   * The HTTP utility is only generated for remote services.
58   * </p>
59   *
60   * @author    Brian Wing Shun Chan
61   * @see       MBCategoryServiceSoap
62   * @see       com.liferay.portal.security.auth.HttpPrincipal
63   * @see       com.liferay.portlet.messageboards.service.MBCategoryServiceUtil
64   * @generated
65   */
66  public class MBCategoryServiceHttp {
67      public static com.liferay.portlet.messageboards.model.MBCategory addCategory(
68          HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
69          java.lang.String name, java.lang.String description,
70          boolean addCommunityPermissions, boolean addGuestPermissions)
71          throws com.liferay.portal.PortalException,
72              com.liferay.portal.SystemException {
73          try {
74              Object paramObj0 = new LongWrapper(plid);
75  
76              Object paramObj1 = new LongWrapper(parentCategoryId);
77  
78              Object paramObj2 = name;
79  
80              if (name == null) {
81                  paramObj2 = new NullWrapper("java.lang.String");
82              }
83  
84              Object paramObj3 = description;
85  
86              if (description == null) {
87                  paramObj3 = new NullWrapper("java.lang.String");
88              }
89  
90              Object paramObj4 = new BooleanWrapper(addCommunityPermissions);
91  
92              Object paramObj5 = new BooleanWrapper(addGuestPermissions);
93  
94              MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
95                      "addCategory",
96                      new Object[] {
97                          paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
98                          paramObj5
99                      });
100 
101             Object returnObj = null;
102 
103             try {
104                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
105             }
106             catch (Exception e) {
107                 if (e instanceof com.liferay.portal.PortalException) {
108                     throw (com.liferay.portal.PortalException)e;
109                 }
110 
111                 if (e instanceof com.liferay.portal.SystemException) {
112                     throw (com.liferay.portal.SystemException)e;
113                 }
114 
115                 throw new com.liferay.portal.SystemException(e);
116             }
117 
118             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
119         }
120         catch (com.liferay.portal.SystemException se) {
121             _log.error(se, se);
122 
123             throw se;
124         }
125     }
126 
127     public static com.liferay.portlet.messageboards.model.MBCategory addCategory(
128         HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
129         java.lang.String name, java.lang.String description,
130         java.lang.String[] communityPermissions,
131         java.lang.String[] guestPermissions)
132         throws com.liferay.portal.PortalException,
133             com.liferay.portal.SystemException {
134         try {
135             Object paramObj0 = new LongWrapper(plid);
136 
137             Object paramObj1 = new LongWrapper(parentCategoryId);
138 
139             Object paramObj2 = name;
140 
141             if (name == null) {
142                 paramObj2 = new NullWrapper("java.lang.String");
143             }
144 
145             Object paramObj3 = description;
146 
147             if (description == null) {
148                 paramObj3 = new NullWrapper("java.lang.String");
149             }
150 
151             Object paramObj4 = communityPermissions;
152 
153             if (communityPermissions == null) {
154                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
155             }
156 
157             Object paramObj5 = guestPermissions;
158 
159             if (guestPermissions == null) {
160                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
161             }
162 
163             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
164                     "addCategory",
165                     new Object[] {
166                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
167                         paramObj5
168                     });
169 
170             Object returnObj = null;
171 
172             try {
173                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
174             }
175             catch (Exception e) {
176                 if (e instanceof com.liferay.portal.PortalException) {
177                     throw (com.liferay.portal.PortalException)e;
178                 }
179 
180                 if (e instanceof com.liferay.portal.SystemException) {
181                     throw (com.liferay.portal.SystemException)e;
182                 }
183 
184                 throw new com.liferay.portal.SystemException(e);
185             }
186 
187             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
188         }
189         catch (com.liferay.portal.SystemException se) {
190             _log.error(se, se);
191 
192             throw se;
193         }
194     }
195 
196     public static void deleteCategory(HttpPrincipal httpPrincipal,
197         long categoryId)
198         throws com.liferay.portal.PortalException,
199             com.liferay.portal.SystemException {
200         try {
201             Object paramObj0 = new LongWrapper(categoryId);
202 
203             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
204                     "deleteCategory", new Object[] { paramObj0 });
205 
206             try {
207                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
208             }
209             catch (Exception e) {
210                 if (e instanceof com.liferay.portal.PortalException) {
211                     throw (com.liferay.portal.PortalException)e;
212                 }
213 
214                 if (e instanceof com.liferay.portal.SystemException) {
215                     throw (com.liferay.portal.SystemException)e;
216                 }
217 
218                 throw new com.liferay.portal.SystemException(e);
219             }
220         }
221         catch (com.liferay.portal.SystemException se) {
222             _log.error(se, se);
223 
224             throw se;
225         }
226     }
227 
228     public static java.util.List<com.liferay.portlet.messageboards.model.MBCategory> getCategories(
229         HttpPrincipal httpPrincipal, long groupId, long parentCategoryId,
230         int start, int end)
231         throws com.liferay.portal.PortalException,
232             com.liferay.portal.SystemException {
233         try {
234             Object paramObj0 = new LongWrapper(groupId);
235 
236             Object paramObj1 = new LongWrapper(parentCategoryId);
237 
238             Object paramObj2 = new IntegerWrapper(start);
239 
240             Object paramObj3 = new IntegerWrapper(end);
241 
242             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
243                     "getCategories",
244                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
245 
246             Object returnObj = null;
247 
248             try {
249                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
250             }
251             catch (Exception e) {
252                 if (e instanceof com.liferay.portal.PortalException) {
253                     throw (com.liferay.portal.PortalException)e;
254                 }
255 
256                 if (e instanceof com.liferay.portal.SystemException) {
257                     throw (com.liferay.portal.SystemException)e;
258                 }
259 
260                 throw new com.liferay.portal.SystemException(e);
261             }
262 
263             return (java.util.List<com.liferay.portlet.messageboards.model.MBCategory>)returnObj;
264         }
265         catch (com.liferay.portal.SystemException se) {
266             _log.error(se, se);
267 
268             throw se;
269         }
270     }
271 
272     public static int getCategoriesCount(HttpPrincipal httpPrincipal,
273         long groupId, long parentCategoryId)
274         throws com.liferay.portal.SystemException {
275         try {
276             Object paramObj0 = new LongWrapper(groupId);
277 
278             Object paramObj1 = new LongWrapper(parentCategoryId);
279 
280             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
281                     "getCategoriesCount", new Object[] { paramObj0, paramObj1 });
282 
283             Object returnObj = null;
284 
285             try {
286                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
287             }
288             catch (Exception e) {
289                 if (e instanceof com.liferay.portal.SystemException) {
290                     throw (com.liferay.portal.SystemException)e;
291                 }
292 
293                 throw new com.liferay.portal.SystemException(e);
294             }
295 
296             return ((Integer)returnObj).intValue();
297         }
298         catch (com.liferay.portal.SystemException se) {
299             _log.error(se, se);
300 
301             throw se;
302         }
303     }
304 
305     public static com.liferay.portlet.messageboards.model.MBCategory getCategory(
306         HttpPrincipal httpPrincipal, long categoryId)
307         throws com.liferay.portal.PortalException,
308             com.liferay.portal.SystemException {
309         try {
310             Object paramObj0 = new LongWrapper(categoryId);
311 
312             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
313                     "getCategory", new Object[] { paramObj0 });
314 
315             Object returnObj = null;
316 
317             try {
318                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
319             }
320             catch (Exception e) {
321                 if (e instanceof com.liferay.portal.PortalException) {
322                     throw (com.liferay.portal.PortalException)e;
323                 }
324 
325                 if (e instanceof com.liferay.portal.SystemException) {
326                     throw (com.liferay.portal.SystemException)e;
327                 }
328 
329                 throw new com.liferay.portal.SystemException(e);
330             }
331 
332             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
333         }
334         catch (com.liferay.portal.SystemException se) {
335             _log.error(se, se);
336 
337             throw se;
338         }
339     }
340 
341     public static void subscribeCategory(HttpPrincipal httpPrincipal,
342         long categoryId)
343         throws com.liferay.portal.PortalException,
344             com.liferay.portal.SystemException {
345         try {
346             Object paramObj0 = new LongWrapper(categoryId);
347 
348             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
349                     "subscribeCategory", new Object[] { paramObj0 });
350 
351             try {
352                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
353             }
354             catch (Exception e) {
355                 if (e instanceof com.liferay.portal.PortalException) {
356                     throw (com.liferay.portal.PortalException)e;
357                 }
358 
359                 if (e instanceof com.liferay.portal.SystemException) {
360                     throw (com.liferay.portal.SystemException)e;
361                 }
362 
363                 throw new com.liferay.portal.SystemException(e);
364             }
365         }
366         catch (com.liferay.portal.SystemException se) {
367             _log.error(se, se);
368 
369             throw se;
370         }
371     }
372 
373     public static void unsubscribeCategory(HttpPrincipal httpPrincipal,
374         long categoryId)
375         throws com.liferay.portal.PortalException,
376             com.liferay.portal.SystemException {
377         try {
378             Object paramObj0 = new LongWrapper(categoryId);
379 
380             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
381                     "unsubscribeCategory", new Object[] { paramObj0 });
382 
383             try {
384                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
385             }
386             catch (Exception e) {
387                 if (e instanceof com.liferay.portal.PortalException) {
388                     throw (com.liferay.portal.PortalException)e;
389                 }
390 
391                 if (e instanceof com.liferay.portal.SystemException) {
392                     throw (com.liferay.portal.SystemException)e;
393                 }
394 
395                 throw new com.liferay.portal.SystemException(e);
396             }
397         }
398         catch (com.liferay.portal.SystemException se) {
399             _log.error(se, se);
400 
401             throw se;
402         }
403     }
404 
405     public static com.liferay.portlet.messageboards.model.MBCategory updateCategory(
406         HttpPrincipal httpPrincipal, long categoryId, long parentCategoryId,
407         java.lang.String name, java.lang.String description,
408         boolean mergeWithParentCategory)
409         throws com.liferay.portal.PortalException,
410             com.liferay.portal.SystemException {
411         try {
412             Object paramObj0 = new LongWrapper(categoryId);
413 
414             Object paramObj1 = new LongWrapper(parentCategoryId);
415 
416             Object paramObj2 = name;
417 
418             if (name == null) {
419                 paramObj2 = new NullWrapper("java.lang.String");
420             }
421 
422             Object paramObj3 = description;
423 
424             if (description == null) {
425                 paramObj3 = new NullWrapper("java.lang.String");
426             }
427 
428             Object paramObj4 = new BooleanWrapper(mergeWithParentCategory);
429 
430             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
431                     "updateCategory",
432                     new Object[] {
433                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
434                     });
435 
436             Object returnObj = null;
437 
438             try {
439                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
440             }
441             catch (Exception e) {
442                 if (e instanceof com.liferay.portal.PortalException) {
443                     throw (com.liferay.portal.PortalException)e;
444                 }
445 
446                 if (e instanceof com.liferay.portal.SystemException) {
447                     throw (com.liferay.portal.SystemException)e;
448                 }
449 
450                 throw new com.liferay.portal.SystemException(e);
451             }
452 
453             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
454         }
455         catch (com.liferay.portal.SystemException se) {
456             _log.error(se, se);
457 
458             throw se;
459         }
460     }
461 
462     private static Log _log = LogFactoryUtil.getLog(MBCategoryServiceHttp.class);
463 }