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.PortalException,
67              com.liferay.portal.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.PortalException) {
79                      throw (com.liferay.portal.PortalException)e;
80                  }
81  
82                  if (e instanceof com.liferay.portal.SystemException) {
83                      throw (com.liferay.portal.SystemException)e;
84                  }
85  
86                  throw new com.liferay.portal.SystemException(e);
87              }
88          }
89          catch (com.liferay.portal.SystemException se) {
90              _log.error(se, se);
91  
92              throw se;
93          }
94      }
95  
96      public static com.liferay.portlet.messageboards.model.MBThread moveThread(
97          HttpPrincipal httpPrincipal, long categoryId, long threadId)
98          throws com.liferay.portal.PortalException,
99              com.liferay.portal.SystemException {
100         try {
101             Object paramObj0 = new LongWrapper(categoryId);
102 
103             Object paramObj1 = new LongWrapper(threadId);
104 
105             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
106                     "moveThread", new Object[] { paramObj0, paramObj1 });
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.MBThread)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.MBThread splitThread(
135         HttpPrincipal httpPrincipal, long messageId,
136         javax.portlet.PortletPreferences prefs,
137         com.liferay.portal.theme.ThemeDisplay themeDisplay)
138         throws com.liferay.portal.PortalException,
139             com.liferay.portal.SystemException {
140         try {
141             Object paramObj0 = new LongWrapper(messageId);
142 
143             Object paramObj1 = prefs;
144 
145             if (prefs == null) {
146                 paramObj1 = new NullWrapper("javax.portlet.PortletPreferences");
147             }
148 
149             Object paramObj2 = themeDisplay;
150 
151             if (themeDisplay == null) {
152                 paramObj2 = new NullWrapper(
153                         "com.liferay.portal.theme.ThemeDisplay");
154             }
155 
156             MethodWrapper methodWrapper = new MethodWrapper(MBThreadServiceUtil.class.getName(),
157                     "splitThread",
158                     new Object[] { paramObj0, paramObj1, paramObj2 });
159 
160             Object returnObj = null;
161 
162             try {
163                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
164             }
165             catch (Exception e) {
166                 if (e instanceof com.liferay.portal.PortalException) {
167                     throw (com.liferay.portal.PortalException)e;
168                 }
169 
170                 if (e instanceof com.liferay.portal.SystemException) {
171                     throw (com.liferay.portal.SystemException)e;
172                 }
173 
174                 throw new com.liferay.portal.SystemException(e);
175             }
176 
177             return (com.liferay.portlet.messageboards.model.MBThread)returnObj;
178         }
179         catch (com.liferay.portal.SystemException se) {
180             _log.error(se, se);
181 
182             throw se;
183         }
184     }
185 
186     private static Log _log = LogFactoryUtil.getLog(MBThreadServiceHttp.class);
187 }