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