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.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 plid, long parentCategoryId,
79          java.lang.String name, java.lang.String description,
80          boolean addCommunityPermissions, boolean addGuestPermissions)
81          throws com.liferay.portal.SystemException,
82              com.liferay.portal.PortalException {
83          try {
84              Object paramObj0 = new LongWrapper(plid);
85  
86              Object paramObj1 = new LongWrapper(parentCategoryId);
87  
88              Object paramObj2 = name;
89  
90              if (name == null) {
91                  paramObj2 = new NullWrapper("java.lang.String");
92              }
93  
94              Object paramObj3 = description;
95  
96              if (description == null) {
97                  paramObj3 = new NullWrapper("java.lang.String");
98              }
99  
100             Object paramObj4 = new BooleanWrapper(addCommunityPermissions);
101 
102             Object paramObj5 = new BooleanWrapper(addGuestPermissions);
103 
104             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
105                     "addCategory",
106                     new Object[] {
107                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
108                         paramObj5
109                     });
110 
111             Object returnObj = null;
112 
113             try {
114                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
115             }
116             catch (Exception e) {
117                 if (e instanceof com.liferay.portal.SystemException) {
118                     throw (com.liferay.portal.SystemException)e;
119                 }
120 
121                 if (e instanceof com.liferay.portal.PortalException) {
122                     throw (com.liferay.portal.PortalException)e;
123                 }
124 
125                 throw new com.liferay.portal.SystemException(e);
126             }
127 
128             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
129         }
130         catch (com.liferay.portal.SystemException se) {
131             _log.error(se, se);
132 
133             throw se;
134         }
135     }
136 
137     public static com.liferay.portlet.messageboards.model.MBCategory addCategory(
138         HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
139         java.lang.String name, java.lang.String description,
140         java.lang.String[] communityPermissions,
141         java.lang.String[] guestPermissions)
142         throws com.liferay.portal.SystemException,
143             com.liferay.portal.PortalException {
144         try {
145             Object paramObj0 = new LongWrapper(plid);
146 
147             Object paramObj1 = new LongWrapper(parentCategoryId);
148 
149             Object paramObj2 = name;
150 
151             if (name == null) {
152                 paramObj2 = new NullWrapper("java.lang.String");
153             }
154 
155             Object paramObj3 = description;
156 
157             if (description == null) {
158                 paramObj3 = new NullWrapper("java.lang.String");
159             }
160 
161             Object paramObj4 = communityPermissions;
162 
163             if (communityPermissions == null) {
164                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
165             }
166 
167             Object paramObj5 = guestPermissions;
168 
169             if (guestPermissions == null) {
170                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
171             }
172 
173             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
174                     "addCategory",
175                     new Object[] {
176                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
177                         paramObj5
178                     });
179 
180             Object returnObj = null;
181 
182             try {
183                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
184             }
185             catch (Exception e) {
186                 if (e instanceof com.liferay.portal.SystemException) {
187                     throw (com.liferay.portal.SystemException)e;
188                 }
189 
190                 if (e instanceof com.liferay.portal.PortalException) {
191                     throw (com.liferay.portal.PortalException)e;
192                 }
193 
194                 throw new com.liferay.portal.SystemException(e);
195             }
196 
197             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
198         }
199         catch (com.liferay.portal.SystemException se) {
200             _log.error(se, se);
201 
202             throw se;
203         }
204     }
205 
206     public static void deleteCategory(HttpPrincipal httpPrincipal,
207         long categoryId)
208         throws com.liferay.portal.SystemException,
209             com.liferay.portal.PortalException {
210         try {
211             Object paramObj0 = new LongWrapper(categoryId);
212 
213             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
214                     "deleteCategory", new Object[] { paramObj0 });
215 
216             try {
217                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
218             }
219             catch (Exception e) {
220                 if (e instanceof com.liferay.portal.SystemException) {
221                     throw (com.liferay.portal.SystemException)e;
222                 }
223 
224                 if (e instanceof com.liferay.portal.PortalException) {
225                     throw (com.liferay.portal.PortalException)e;
226                 }
227 
228                 throw new com.liferay.portal.SystemException(e);
229             }
230         }
231         catch (com.liferay.portal.SystemException se) {
232             _log.error(se, se);
233 
234             throw se;
235         }
236     }
237 
238     public static com.liferay.portlet.messageboards.model.MBCategory getCategory(
239         HttpPrincipal httpPrincipal, long categoryId)
240         throws com.liferay.portal.SystemException,
241             com.liferay.portal.PortalException {
242         try {
243             Object paramObj0 = new LongWrapper(categoryId);
244 
245             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
246                     "getCategory", new Object[] { paramObj0 });
247 
248             Object returnObj = null;
249 
250             try {
251                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
252             }
253             catch (Exception e) {
254                 if (e instanceof com.liferay.portal.SystemException) {
255                     throw (com.liferay.portal.SystemException)e;
256                 }
257 
258                 if (e instanceof com.liferay.portal.PortalException) {
259                     throw (com.liferay.portal.PortalException)e;
260                 }
261 
262                 throw new com.liferay.portal.SystemException(e);
263             }
264 
265             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
266         }
267         catch (com.liferay.portal.SystemException se) {
268             _log.error(se, se);
269 
270             throw se;
271         }
272     }
273 
274     public static java.util.List<com.liferay.portlet.messageboards.model.MBCategory> getCategories(
275         HttpPrincipal httpPrincipal, long groupId, long parentCategoryId,
276         int begin, int end)
277         throws com.liferay.portal.SystemException,
278             com.liferay.portal.PortalException {
279         try {
280             Object paramObj0 = new LongWrapper(groupId);
281 
282             Object paramObj1 = new LongWrapper(parentCategoryId);
283 
284             Object paramObj2 = new IntegerWrapper(begin);
285 
286             Object paramObj3 = new IntegerWrapper(end);
287 
288             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
289                     "getCategories",
290                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
291 
292             Object returnObj = null;
293 
294             try {
295                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
296             }
297             catch (Exception e) {
298                 if (e instanceof com.liferay.portal.SystemException) {
299                     throw (com.liferay.portal.SystemException)e;
300                 }
301 
302                 if (e instanceof com.liferay.portal.PortalException) {
303                     throw (com.liferay.portal.PortalException)e;
304                 }
305 
306                 throw new com.liferay.portal.SystemException(e);
307             }
308 
309             return (java.util.List<com.liferay.portlet.messageboards.model.MBCategory>)returnObj;
310         }
311         catch (com.liferay.portal.SystemException se) {
312             _log.error(se, se);
313 
314             throw se;
315         }
316     }
317 
318     public static int getCategoriesCount(HttpPrincipal httpPrincipal,
319         long groupId, long parentCategoryId)
320         throws com.liferay.portal.SystemException {
321         try {
322             Object paramObj0 = new LongWrapper(groupId);
323 
324             Object paramObj1 = new LongWrapper(parentCategoryId);
325 
326             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
327                     "getCategoriesCount", new Object[] { paramObj0, paramObj1 });
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 ((Integer)returnObj).intValue();
343         }
344         catch (com.liferay.portal.SystemException se) {
345             _log.error(se, se);
346 
347             throw se;
348         }
349     }
350 
351     public static void subscribeCategory(HttpPrincipal httpPrincipal,
352         long categoryId)
353         throws com.liferay.portal.SystemException,
354             com.liferay.portal.PortalException {
355         try {
356             Object paramObj0 = new LongWrapper(categoryId);
357 
358             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
359                     "subscribeCategory", new Object[] { paramObj0 });
360 
361             try {
362                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
363             }
364             catch (Exception e) {
365                 if (e instanceof com.liferay.portal.SystemException) {
366                     throw (com.liferay.portal.SystemException)e;
367                 }
368 
369                 if (e instanceof com.liferay.portal.PortalException) {
370                     throw (com.liferay.portal.PortalException)e;
371                 }
372 
373                 throw new com.liferay.portal.SystemException(e);
374             }
375         }
376         catch (com.liferay.portal.SystemException se) {
377             _log.error(se, se);
378 
379             throw se;
380         }
381     }
382 
383     public static void unsubscribeCategory(HttpPrincipal httpPrincipal,
384         long categoryId)
385         throws com.liferay.portal.SystemException,
386             com.liferay.portal.PortalException {
387         try {
388             Object paramObj0 = new LongWrapper(categoryId);
389 
390             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
391                     "unsubscribeCategory", new Object[] { paramObj0 });
392 
393             try {
394                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
395             }
396             catch (Exception e) {
397                 if (e instanceof com.liferay.portal.SystemException) {
398                     throw (com.liferay.portal.SystemException)e;
399                 }
400 
401                 if (e instanceof com.liferay.portal.PortalException) {
402                     throw (com.liferay.portal.PortalException)e;
403                 }
404 
405                 throw new com.liferay.portal.SystemException(e);
406             }
407         }
408         catch (com.liferay.portal.SystemException se) {
409             _log.error(se, se);
410 
411             throw se;
412         }
413     }
414 
415     public static com.liferay.portlet.messageboards.model.MBCategory updateCategory(
416         HttpPrincipal httpPrincipal, long categoryId, long parentCategoryId,
417         java.lang.String name, java.lang.String description,
418         boolean mergeWithParentCategory)
419         throws com.liferay.portal.SystemException,
420             com.liferay.portal.PortalException {
421         try {
422             Object paramObj0 = new LongWrapper(categoryId);
423 
424             Object paramObj1 = new LongWrapper(parentCategoryId);
425 
426             Object paramObj2 = name;
427 
428             if (name == null) {
429                 paramObj2 = new NullWrapper("java.lang.String");
430             }
431 
432             Object paramObj3 = description;
433 
434             if (description == null) {
435                 paramObj3 = new NullWrapper("java.lang.String");
436             }
437 
438             Object paramObj4 = new BooleanWrapper(mergeWithParentCategory);
439 
440             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
441                     "updateCategory",
442                     new Object[] {
443                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
444                     });
445 
446             Object returnObj = null;
447 
448             try {
449                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
450             }
451             catch (Exception e) {
452                 if (e instanceof com.liferay.portal.SystemException) {
453                     throw (com.liferay.portal.SystemException)e;
454                 }
455 
456                 if (e instanceof com.liferay.portal.PortalException) {
457                     throw (com.liferay.portal.PortalException)e;
458                 }
459 
460                 throw new com.liferay.portal.SystemException(e);
461             }
462 
463             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
464         }
465         catch (com.liferay.portal.SystemException se) {
466             _log.error(se, se);
467 
468             throw se;
469         }
470     }
471 
472     private static Log _log = LogFactoryUtil.getLog(MBCategoryServiceHttp.class);
473 }