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