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