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.LongWrapper;
20  import com.liferay.portal.kernel.util.MethodWrapper;
21  import com.liferay.portal.kernel.util.NullWrapper;
22  import com.liferay.portal.security.auth.HttpPrincipal;
23  import com.liferay.portal.service.http.TunnelUtil;
24  
25  import com.liferay.portlet.messageboards.service.MBThreadServiceUtil;
26  
27  /**
28   * <a href="MBThreadServiceHttp.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * ServiceBuilder generated this class. Modifications in this class will be
32   * overwritten the next time is generated.
33   * </p>
34   *
35   * <p>
36   * This class provides a HTTP utility for the
37   * {@link com.liferay.portlet.messageboards.service.MBThreadServiceUtil} service utility. The
38   * static methods of this class calls the same methods of the service utility.
39   * However, the signatures are different because it requires an additional
40   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
41   * </p>
42   *
43   * <p>
44   * The benefits of using the HTTP utility is that it is fast and allows for
45   * tunneling without the cost of serializing to text. The drawback is that it
46   * only works with Java.
47   * </p>
48   *
49   * <p>
50   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
51   * configure security.
52   * </p>
53   *
54   * <p>
55   * The HTTP utility is only generated for remote services.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       MBThreadServiceSoap
60   * @see       com.liferay.portal.security.auth.HttpPrincipal
61   * @see       com.liferay.portlet.messageboards.service.MBThreadServiceUtil
62   * @generated
63   */
64  public class MBThreadServiceHttp {
65      public static void deleteThread(HttpPrincipal httpPrincipal, long threadId)
66          throws com.liferay.portal.kernel.exception.PortalException,
67              com.liferay.portal.kernel.exception.SystemException {
68          try {
69              Object paramObj0 = new LongWrapper(threadId);
70  
71              MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
72                      "deleteThread", new Object[] { paramObj0 });
73  
74              try {
75                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
76              }
77              catch (Exception e) {
78                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
79                      throw (com.liferay.portal.kernel.exception.PortalException)e;
80                  }
81  
82                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
83                      throw (com.liferay.portal.kernel.exception.SystemException)e;
84                  }
85  
86                  throw new com.liferay.portal.kernel.exception.SystemException(e);
87              }
88          }
89          catch (com.liferay.portal.kernel.exception.SystemException se) {
90              _log.error(se, se);
91  
92              throw se;
93          }
94      }
95  
96      public static com.liferay.portal.model.Lock lockThread(
97          HttpPrincipal httpPrincipal, long threadId)
98          throws com.liferay.portal.kernel.exception.PortalException,
99              com.liferay.portal.kernel.exception.SystemException {
100         try {
101             Object paramObj0 = new LongWrapper(threadId);
102 
103             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
104                     "lockThread", new Object[] { paramObj0 });
105 
106             Object returnObj = null;
107 
108             try {
109                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
110             }
111             catch (Exception e) {
112                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
113                     throw (com.liferay.portal.kernel.exception.PortalException)e;
114                 }
115 
116                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
117                     throw (com.liferay.portal.kernel.exception.SystemException)e;
118                 }
119 
120                 throw new com.liferay.portal.kernel.exception.SystemException(e);
121             }
122 
123             return (com.liferay.portal.model.Lock)returnObj;
124         }
125         catch (com.liferay.portal.kernel.exception.SystemException se) {
126             _log.error(se, se);
127 
128             throw se;
129         }
130     }
131 
132     public static com.liferay.portlet.messageboards.model.MBThread moveThread(
133         HttpPrincipal httpPrincipal, long categoryId, long threadId)
134         throws com.liferay.portal.kernel.exception.PortalException,
135             com.liferay.portal.kernel.exception.SystemException {
136         try {
137             Object paramObj0 = new LongWrapper(categoryId);
138 
139             Object paramObj1 = new LongWrapper(threadId);
140 
141             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
142                     "moveThread", new Object[] { paramObj0, paramObj1 });
143 
144             Object returnObj = null;
145 
146             try {
147                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
148             }
149             catch (Exception e) {
150                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
151                     throw (com.liferay.portal.kernel.exception.PortalException)e;
152                 }
153 
154                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
155                     throw (com.liferay.portal.kernel.exception.SystemException)e;
156                 }
157 
158                 throw new com.liferay.portal.kernel.exception.SystemException(e);
159             }
160 
161             return (com.liferay.portlet.messageboards.model.MBThread)returnObj;
162         }
163         catch (com.liferay.portal.kernel.exception.SystemException se) {
164             _log.error(se, se);
165 
166             throw se;
167         }
168     }
169 
170     public static com.liferay.portlet.messageboards.model.MBThread splitThread(
171         HttpPrincipal httpPrincipal, long messageId,
172         com.liferay.portal.service.ServiceContext serviceContext)
173         throws com.liferay.portal.kernel.exception.PortalException,
174             com.liferay.portal.kernel.exception.SystemException {
175         try {
176             Object paramObj0 = new LongWrapper(messageId);
177 
178             Object paramObj1 = serviceContext;
179 
180             if (serviceContext == null) {
181                 paramObj1 = new NullWrapper(
182                         "com.liferay.portal.service.ServiceContext");
183             }
184 
185             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
186                     "splitThread", new Object[] { paramObj0, paramObj1 });
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.kernel.exception.PortalException) {
195                     throw (com.liferay.portal.kernel.exception.PortalException)e;
196                 }
197 
198                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
199                     throw (com.liferay.portal.kernel.exception.SystemException)e;
200                 }
201 
202                 throw new com.liferay.portal.kernel.exception.SystemException(e);
203             }
204 
205             return (com.liferay.portlet.messageboards.model.MBThread)returnObj;
206         }
207         catch (com.liferay.portal.kernel.exception.SystemException se) {
208             _log.error(se, se);
209 
210             throw se;
211         }
212     }
213 
214     public static void unlockThread(HttpPrincipal httpPrincipal, long threadId)
215         throws com.liferay.portal.kernel.exception.PortalException,
216             com.liferay.portal.kernel.exception.SystemException {
217         try {
218             Object paramObj0 = new LongWrapper(threadId);
219 
220             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
221                     "unlockThread", new Object[] { paramObj0 });
222 
223             try {
224                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
225             }
226             catch (Exception e) {
227                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
228                     throw (com.liferay.portal.kernel.exception.PortalException)e;
229                 }
230 
231                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
232                     throw (com.liferay.portal.kernel.exception.SystemException)e;
233                 }
234 
235                 throw new com.liferay.portal.kernel.exception.SystemException(e);
236             }
237         }
238         catch (com.liferay.portal.kernel.exception.SystemException se) {
239             _log.error(se, se);
240 
241             throw se;
242         }
243     }
244 
245     private static Log _log = LogFactoryUtil.getLog(MBThreadServiceHttp.class);
246 }