1   /**
2    * Copyright (c) 2000-2007 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.LongWrapper;
29  import com.liferay.portal.kernel.util.MethodWrapper;
30  import com.liferay.portal.kernel.util.NullWrapper;
31  import com.liferay.portal.security.auth.HttpPrincipal;
32  import com.liferay.portal.service.http.TunnelUtil;
33  
34  import com.liferay.portlet.messageboards.service.MBCategoryServiceUtil;
35  
36  /**
37   * <a href="MBCategoryServiceHttp.java.html"><b><i>View Source</i></b></a>
38   *
39   * <p>
40   * ServiceBuilder generated this class. Modifications in this class will be overwritten
41   * the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This class provides a HTTP utility for the <code>com.liferay.portlet.messageboards.service.MBCategoryServiceUtil</code>
46   * service utility. The static methods of this class calls the same methods of the
47   * service utility. However, the signatures are different because it requires an
48   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code> parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for tunneling
53   * without the cost of serializing to text. The drawback is that it only works with
54   * Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in portal.properties
59   * 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.SystemException, 
79              com.liferay.portal.PortalException {
80          try {
81              Object paramObj0 = new LongWrapper(plid);
82              Object paramObj1 = new LongWrapper(parentCategoryId);
83              Object paramObj2 = name;
84  
85              if (name == null) {
86                  paramObj2 = new NullWrapper("java.lang.String");
87              }
88  
89              Object paramObj3 = description;
90  
91              if (description == null) {
92                  paramObj3 = new NullWrapper("java.lang.String");
93              }
94  
95              Object paramObj4 = new BooleanWrapper(addCommunityPermissions);
96              Object paramObj5 = new BooleanWrapper(addGuestPermissions);
97              MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
98                      "addCategory",
99                      new Object[] {
100                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
101                         paramObj5
102                     });
103             Object returnObj = null;
104 
105             try {
106                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
107             }
108             catch (Exception e) {
109                 if (e instanceof com.liferay.portal.SystemException) {
110                     throw (com.liferay.portal.SystemException)e;
111                 }
112 
113                 if (e instanceof com.liferay.portal.PortalException) {
114                     throw (com.liferay.portal.PortalException)e;
115                 }
116 
117                 throw new com.liferay.portal.SystemException(e);
118             }
119 
120             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
121         }
122         catch (com.liferay.portal.SystemException se) {
123             _log.error(se, se);
124             throw se;
125         }
126     }
127 
128     public static com.liferay.portlet.messageboards.model.MBCategory addCategory(
129         HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
130         java.lang.String name, java.lang.String description,
131         java.lang.String[] communityPermissions,
132         java.lang.String[] guestPermissions)
133         throws com.liferay.portal.SystemException, 
134             com.liferay.portal.PortalException {
135         try {
136             Object paramObj0 = new LongWrapper(plid);
137             Object paramObj1 = new LongWrapper(parentCategoryId);
138             Object paramObj2 = name;
139 
140             if (name == null) {
141                 paramObj2 = new NullWrapper("java.lang.String");
142             }
143 
144             Object paramObj3 = description;
145 
146             if (description == null) {
147                 paramObj3 = new NullWrapper("java.lang.String");
148             }
149 
150             Object paramObj4 = communityPermissions;
151 
152             if (communityPermissions == null) {
153                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
154             }
155 
156             Object paramObj5 = guestPermissions;
157 
158             if (guestPermissions == null) {
159                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
160             }
161 
162             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
163                     "addCategory",
164                     new Object[] {
165                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
166                         paramObj5
167                     });
168             Object returnObj = null;
169 
170             try {
171                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
172             }
173             catch (Exception e) {
174                 if (e instanceof com.liferay.portal.SystemException) {
175                     throw (com.liferay.portal.SystemException)e;
176                 }
177 
178                 if (e instanceof com.liferay.portal.PortalException) {
179                     throw (com.liferay.portal.PortalException)e;
180                 }
181 
182                 throw new com.liferay.portal.SystemException(e);
183             }
184 
185             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
186         }
187         catch (com.liferay.portal.SystemException se) {
188             _log.error(se, se);
189             throw se;
190         }
191     }
192 
193     public static void deleteCategory(HttpPrincipal httpPrincipal,
194         long categoryId)
195         throws com.liferay.portal.SystemException, 
196             com.liferay.portal.PortalException {
197         try {
198             Object paramObj0 = new LongWrapper(categoryId);
199             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
200                     "deleteCategory", new Object[] { paramObj0 });
201 
202             try {
203                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
204             }
205             catch (Exception e) {
206                 if (e instanceof com.liferay.portal.SystemException) {
207                     throw (com.liferay.portal.SystemException)e;
208                 }
209 
210                 if (e instanceof com.liferay.portal.PortalException) {
211                     throw (com.liferay.portal.PortalException)e;
212                 }
213 
214                 throw new com.liferay.portal.SystemException(e);
215             }
216         }
217         catch (com.liferay.portal.SystemException se) {
218             _log.error(se, se);
219             throw se;
220         }
221     }
222 
223     public static com.liferay.portlet.messageboards.model.MBCategory getCategory(
224         HttpPrincipal httpPrincipal, long categoryId)
225         throws com.liferay.portal.SystemException, 
226             com.liferay.portal.PortalException {
227         try {
228             Object paramObj0 = new LongWrapper(categoryId);
229             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
230                     "getCategory", new Object[] { paramObj0 });
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 (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
249         }
250         catch (com.liferay.portal.SystemException se) {
251             _log.error(se, se);
252             throw se;
253         }
254     }
255 
256     public static void subscribeCategory(HttpPrincipal httpPrincipal,
257         long categoryId)
258         throws com.liferay.portal.SystemException, 
259             com.liferay.portal.PortalException {
260         try {
261             Object paramObj0 = new LongWrapper(categoryId);
262             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
263                     "subscribeCategory", new Object[] { paramObj0 });
264 
265             try {
266                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
267             }
268             catch (Exception e) {
269                 if (e instanceof com.liferay.portal.SystemException) {
270                     throw (com.liferay.portal.SystemException)e;
271                 }
272 
273                 if (e instanceof com.liferay.portal.PortalException) {
274                     throw (com.liferay.portal.PortalException)e;
275                 }
276 
277                 throw new com.liferay.portal.SystemException(e);
278             }
279         }
280         catch (com.liferay.portal.SystemException se) {
281             _log.error(se, se);
282             throw se;
283         }
284     }
285 
286     public static void unsubscribeCategory(HttpPrincipal httpPrincipal,
287         long categoryId)
288         throws com.liferay.portal.SystemException, 
289             com.liferay.portal.PortalException {
290         try {
291             Object paramObj0 = new LongWrapper(categoryId);
292             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
293                     "unsubscribeCategory", new Object[] { paramObj0 });
294 
295             try {
296                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
297             }
298             catch (Exception e) {
299                 if (e instanceof com.liferay.portal.SystemException) {
300                     throw (com.liferay.portal.SystemException)e;
301                 }
302 
303                 if (e instanceof com.liferay.portal.PortalException) {
304                     throw (com.liferay.portal.PortalException)e;
305                 }
306 
307                 throw new com.liferay.portal.SystemException(e);
308             }
309         }
310         catch (com.liferay.portal.SystemException se) {
311             _log.error(se, se);
312             throw se;
313         }
314     }
315 
316     public static com.liferay.portlet.messageboards.model.MBCategory updateCategory(
317         HttpPrincipal httpPrincipal, long categoryId, long parentCategoryId,
318         java.lang.String name, java.lang.String description,
319         boolean mergeWithParentCategory)
320         throws com.liferay.portal.SystemException, 
321             com.liferay.portal.PortalException {
322         try {
323             Object paramObj0 = new LongWrapper(categoryId);
324             Object paramObj1 = new LongWrapper(parentCategoryId);
325             Object paramObj2 = name;
326 
327             if (name == null) {
328                 paramObj2 = new NullWrapper("java.lang.String");
329             }
330 
331             Object paramObj3 = description;
332 
333             if (description == null) {
334                 paramObj3 = new NullWrapper("java.lang.String");
335             }
336 
337             Object paramObj4 = new BooleanWrapper(mergeWithParentCategory);
338             MethodWrapper methodWrapper = new MethodWrapper(MBCategoryServiceUtil.class.getName(),
339                     "updateCategory",
340                     new Object[] {
341                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
342                     });
343             Object returnObj = null;
344 
345             try {
346                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
347             }
348             catch (Exception e) {
349                 if (e instanceof com.liferay.portal.SystemException) {
350                     throw (com.liferay.portal.SystemException)e;
351                 }
352 
353                 if (e instanceof com.liferay.portal.PortalException) {
354                     throw (com.liferay.portal.PortalException)e;
355                 }
356 
357                 throw new com.liferay.portal.SystemException(e);
358             }
359 
360             return (com.liferay.portlet.messageboards.model.MBCategory)returnObj;
361         }
362         catch (com.liferay.portal.SystemException se) {
363             _log.error(se, se);
364             throw se;
365         }
366     }
367 
368     private static Log _log = LogFactoryUtil.getLog(MBCategoryServiceHttp.class);
369 }