1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.messageboards.service.http;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.IntegerWrapper;
20  import com.liferay.portal.kernel.util.LongWrapper;
21  import com.liferay.portal.kernel.util.MethodWrapper;
22  import com.liferay.portal.kernel.util.NullWrapper;
23  import com.liferay.portal.security.auth.HttpPrincipal;
24  import com.liferay.portal.service.http.TunnelUtil;
25  
26  import com.liferay.portlet.messageboards.service.MBThreadServiceUtil;
27  
28  /**
29   * <a href="MBThreadServiceHttp.java.html"><b><i>View Source</i></b></a>
30   *
31   * <p>
32   * ServiceBuilder generated this class. Modifications in this class will be
33   * overwritten the next time is generated.
34   * </p>
35   *
36   * <p>
37   * This class provides a HTTP utility for the
38   * {@link com.liferay.portlet.messageboards.service.MBThreadServiceUtil} service utility. The
39   * static methods of this class calls the same methods of the service utility.
40   * However, the signatures are different because it requires an additional
41   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
42   * </p>
43   *
44   * <p>
45   * The benefits of using the HTTP utility is that it is fast and allows for
46   * tunneling without the cost of serializing to text. The drawback is that it
47   * only works with Java.
48   * </p>
49   *
50   * <p>
51   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
52   * configure security.
53   * </p>
54   *
55   * <p>
56   * The HTTP utility is only generated for remote services.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       MBThreadServiceSoap
61   * @see       com.liferay.portal.security.auth.HttpPrincipal
62   * @see       com.liferay.portlet.messageboards.service.MBThreadServiceUtil
63   * @generated
64   */
65  public class MBThreadServiceHttp {
66      public static void deleteThread(HttpPrincipal httpPrincipal, long threadId)
67          throws com.liferay.portal.kernel.exception.PortalException,
68              com.liferay.portal.kernel.exception.SystemException {
69          try {
70              Object paramObj0 = new LongWrapper(threadId);
71  
72              MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
73                      "deleteThread", new Object[] { paramObj0 });
74  
75              try {
76                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
77              }
78              catch (Exception e) {
79                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
80                      throw (com.liferay.portal.kernel.exception.PortalException)e;
81                  }
82  
83                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
84                      throw (com.liferay.portal.kernel.exception.SystemException)e;
85                  }
86  
87                  throw new com.liferay.portal.kernel.exception.SystemException(e);
88              }
89          }
90          catch (com.liferay.portal.kernel.exception.SystemException se) {
91              _log.error(se, se);
92  
93              throw se;
94          }
95      }
96  
97      public static java.util.List<com.liferay.portlet.messageboards.model.MBThread> getThreads(
98          HttpPrincipal httpPrincipal, long groupId, long categoryId, int status,
99          int start, int end)
100         throws com.liferay.portal.kernel.exception.SystemException {
101         try {
102             Object paramObj0 = new LongWrapper(groupId);
103 
104             Object paramObj1 = new LongWrapper(categoryId);
105 
106             Object paramObj2 = new IntegerWrapper(status);
107 
108             Object paramObj3 = new IntegerWrapper(start);
109 
110             Object paramObj4 = new IntegerWrapper(end);
111 
112             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
113                     "getThreads",
114                     new Object[] {
115                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
116                     });
117 
118             Object returnObj = null;
119 
120             try {
121                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
122             }
123             catch (Exception e) {
124                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
125                     throw (com.liferay.portal.kernel.exception.SystemException)e;
126                 }
127 
128                 throw new com.liferay.portal.kernel.exception.SystemException(e);
129             }
130 
131             return (java.util.List<com.liferay.portlet.messageboards.model.MBThread>)returnObj;
132         }
133         catch (com.liferay.portal.kernel.exception.SystemException se) {
134             _log.error(se, se);
135 
136             throw se;
137         }
138     }
139 
140     public static int getThreadsCount(HttpPrincipal httpPrincipal,
141         long groupId, long categoryId, int status)
142         throws com.liferay.portal.kernel.exception.SystemException {
143         try {
144             Object paramObj0 = new LongWrapper(groupId);
145 
146             Object paramObj1 = new LongWrapper(categoryId);
147 
148             Object paramObj2 = new IntegerWrapper(status);
149 
150             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
151                     "getThreadsCount",
152                     new Object[] { paramObj0, paramObj1, paramObj2 });
153 
154             Object returnObj = null;
155 
156             try {
157                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
158             }
159             catch (Exception e) {
160                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
161                     throw (com.liferay.portal.kernel.exception.SystemException)e;
162                 }
163 
164                 throw new com.liferay.portal.kernel.exception.SystemException(e);
165             }
166 
167             return ((Integer)returnObj).intValue();
168         }
169         catch (com.liferay.portal.kernel.exception.SystemException se) {
170             _log.error(se, se);
171 
172             throw se;
173         }
174     }
175 
176     public static com.liferay.portal.model.Lock lockThread(
177         HttpPrincipal httpPrincipal, long threadId)
178         throws com.liferay.portal.kernel.exception.PortalException,
179             com.liferay.portal.kernel.exception.SystemException {
180         try {
181             Object paramObj0 = new LongWrapper(threadId);
182 
183             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
184                     "lockThread", new Object[] { paramObj0 });
185 
186             Object returnObj = null;
187 
188             try {
189                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
190             }
191             catch (Exception e) {
192                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
193                     throw (com.liferay.portal.kernel.exception.PortalException)e;
194                 }
195 
196                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
197                     throw (com.liferay.portal.kernel.exception.SystemException)e;
198                 }
199 
200                 throw new com.liferay.portal.kernel.exception.SystemException(e);
201             }
202 
203             return (com.liferay.portal.model.Lock)returnObj;
204         }
205         catch (com.liferay.portal.kernel.exception.SystemException se) {
206             _log.error(se, se);
207 
208             throw se;
209         }
210     }
211 
212     public static com.liferay.portlet.messageboards.model.MBThread moveThread(
213         HttpPrincipal httpPrincipal, long categoryId, long threadId)
214         throws com.liferay.portal.kernel.exception.PortalException,
215             com.liferay.portal.kernel.exception.SystemException {
216         try {
217             Object paramObj0 = new LongWrapper(categoryId);
218 
219             Object paramObj1 = new LongWrapper(threadId);
220 
221             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
222                     "moveThread", new Object[] { paramObj0, paramObj1 });
223 
224             Object returnObj = null;
225 
226             try {
227                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
228             }
229             catch (Exception e) {
230                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
231                     throw (com.liferay.portal.kernel.exception.PortalException)e;
232                 }
233 
234                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
235                     throw (com.liferay.portal.kernel.exception.SystemException)e;
236                 }
237 
238                 throw new com.liferay.portal.kernel.exception.SystemException(e);
239             }
240 
241             return (com.liferay.portlet.messageboards.model.MBThread)returnObj;
242         }
243         catch (com.liferay.portal.kernel.exception.SystemException se) {
244             _log.error(se, se);
245 
246             throw se;
247         }
248     }
249 
250     public static com.liferay.portlet.messageboards.model.MBThread splitThread(
251         HttpPrincipal httpPrincipal, long messageId,
252         com.liferay.portal.service.ServiceContext serviceContext)
253         throws com.liferay.portal.kernel.exception.PortalException,
254             com.liferay.portal.kernel.exception.SystemException {
255         try {
256             Object paramObj0 = new LongWrapper(messageId);
257 
258             Object paramObj1 = serviceContext;
259 
260             if (serviceContext == null) {
261                 paramObj1 = new NullWrapper(
262                         "com.liferay.portal.service.ServiceContext");
263             }
264 
265             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
266                     "splitThread", 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.kernel.exception.PortalException) {
275                     throw (com.liferay.portal.kernel.exception.PortalException)e;
276                 }
277 
278                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
279                     throw (com.liferay.portal.kernel.exception.SystemException)e;
280                 }
281 
282                 throw new com.liferay.portal.kernel.exception.SystemException(e);
283             }
284 
285             return (com.liferay.portlet.messageboards.model.MBThread)returnObj;
286         }
287         catch (com.liferay.portal.kernel.exception.SystemException se) {
288             _log.error(se, se);
289 
290             throw se;
291         }
292     }
293 
294     public static void unlockThread(HttpPrincipal httpPrincipal, long threadId)
295         throws com.liferay.portal.kernel.exception.PortalException,
296             com.liferay.portal.kernel.exception.SystemException {
297         try {
298             Object paramObj0 = new LongWrapper(threadId);
299 
300             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
301                     "unlockThread", new Object[] { paramObj0 });
302 
303             try {
304                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
305             }
306             catch (Exception e) {
307                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
308                     throw (com.liferay.portal.kernel.exception.PortalException)e;
309                 }
310 
311                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
312                     throw (com.liferay.portal.kernel.exception.SystemException)e;
313                 }
314 
315                 throw new com.liferay.portal.kernel.exception.SystemException(e);
316             }
317         }
318         catch (com.liferay.portal.kernel.exception.SystemException se) {
319             _log.error(se, se);
320 
321             throw se;
322         }
323     }
324 
325     private static Log _log = LogFactoryUtil.getLog(MBThreadServiceHttp.class);
326 }