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.polls.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.polls.service.PollsQuestionServiceUtil;
36  
37  /**
38   * <a href="PollsQuestionServiceHttp.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.polls.service.PollsQuestionServiceUtil} 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       PollsQuestionServiceSoap
70   * @see       com.liferay.portal.security.auth.HttpPrincipal
71   * @see       com.liferay.portlet.polls.service.PollsQuestionServiceUtil
72   * @generated
73   */
74  public class PollsQuestionServiceHttp {
75      public static com.liferay.portlet.polls.model.PollsQuestion addQuestion(
76          HttpPrincipal httpPrincipal, java.lang.String title,
77          java.lang.String description, int expirationDateMonth,
78          int expirationDateDay, int expirationDateYear, int expirationDateHour,
79          int expirationDateMinute, boolean neverExpire,
80          java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices,
81          com.liferay.portal.service.ServiceContext serviceContext)
82          throws com.liferay.portal.PortalException,
83              com.liferay.portal.SystemException {
84          try {
85              Object paramObj0 = title;
86  
87              if (title == null) {
88                  paramObj0 = new NullWrapper("java.lang.String");
89              }
90  
91              Object paramObj1 = description;
92  
93              if (description == null) {
94                  paramObj1 = new NullWrapper("java.lang.String");
95              }
96  
97              Object paramObj2 = new IntegerWrapper(expirationDateMonth);
98  
99              Object paramObj3 = new IntegerWrapper(expirationDateDay);
100 
101             Object paramObj4 = new IntegerWrapper(expirationDateYear);
102 
103             Object paramObj5 = new IntegerWrapper(expirationDateHour);
104 
105             Object paramObj6 = new IntegerWrapper(expirationDateMinute);
106 
107             Object paramObj7 = new BooleanWrapper(neverExpire);
108 
109             Object paramObj8 = choices;
110 
111             if (choices == null) {
112                 paramObj8 = new NullWrapper("java.util.List");
113             }
114 
115             Object paramObj9 = serviceContext;
116 
117             if (serviceContext == null) {
118                 paramObj9 = new NullWrapper(
119                         "com.liferay.portal.service.ServiceContext");
120             }
121 
122             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
123                     "addQuestion",
124                     new Object[] {
125                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
126                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9
127                     });
128 
129             Object returnObj = null;
130 
131             try {
132                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
133             }
134             catch (Exception e) {
135                 if (e instanceof com.liferay.portal.PortalException) {
136                     throw (com.liferay.portal.PortalException)e;
137                 }
138 
139                 if (e instanceof com.liferay.portal.SystemException) {
140                     throw (com.liferay.portal.SystemException)e;
141                 }
142 
143                 throw new com.liferay.portal.SystemException(e);
144             }
145 
146             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
147         }
148         catch (com.liferay.portal.SystemException se) {
149             _log.error(se, se);
150 
151             throw se;
152         }
153     }
154 
155     public static void deleteQuestion(HttpPrincipal httpPrincipal,
156         long questionId)
157         throws com.liferay.portal.PortalException,
158             com.liferay.portal.SystemException {
159         try {
160             Object paramObj0 = new LongWrapper(questionId);
161 
162             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
163                     "deleteQuestion", new Object[] { paramObj0 });
164 
165             try {
166                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
167             }
168             catch (Exception e) {
169                 if (e instanceof com.liferay.portal.PortalException) {
170                     throw (com.liferay.portal.PortalException)e;
171                 }
172 
173                 if (e instanceof com.liferay.portal.SystemException) {
174                     throw (com.liferay.portal.SystemException)e;
175                 }
176 
177                 throw new com.liferay.portal.SystemException(e);
178             }
179         }
180         catch (com.liferay.portal.SystemException se) {
181             _log.error(se, se);
182 
183             throw se;
184         }
185     }
186 
187     public static com.liferay.portlet.polls.model.PollsQuestion getQuestion(
188         HttpPrincipal httpPrincipal, long questionId)
189         throws com.liferay.portal.PortalException,
190             com.liferay.portal.SystemException {
191         try {
192             Object paramObj0 = new LongWrapper(questionId);
193 
194             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
195                     "getQuestion", new Object[] { paramObj0 });
196 
197             Object returnObj = null;
198 
199             try {
200                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
201             }
202             catch (Exception e) {
203                 if (e instanceof com.liferay.portal.PortalException) {
204                     throw (com.liferay.portal.PortalException)e;
205                 }
206 
207                 if (e instanceof com.liferay.portal.SystemException) {
208                     throw (com.liferay.portal.SystemException)e;
209                 }
210 
211                 throw new com.liferay.portal.SystemException(e);
212             }
213 
214             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
215         }
216         catch (com.liferay.portal.SystemException se) {
217             _log.error(se, se);
218 
219             throw se;
220         }
221     }
222 
223     public static com.liferay.portlet.polls.model.PollsQuestion updateQuestion(
224         HttpPrincipal httpPrincipal, long questionId, java.lang.String title,
225         java.lang.String description, int expirationDateMonth,
226         int expirationDateDay, int expirationDateYear, int expirationDateHour,
227         int expirationDateMinute, boolean neverExpire,
228         java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices,
229         com.liferay.portal.service.ServiceContext serviceContext)
230         throws com.liferay.portal.PortalException,
231             com.liferay.portal.SystemException {
232         try {
233             Object paramObj0 = new LongWrapper(questionId);
234 
235             Object paramObj1 = title;
236 
237             if (title == null) {
238                 paramObj1 = new NullWrapper("java.lang.String");
239             }
240 
241             Object paramObj2 = description;
242 
243             if (description == null) {
244                 paramObj2 = new NullWrapper("java.lang.String");
245             }
246 
247             Object paramObj3 = new IntegerWrapper(expirationDateMonth);
248 
249             Object paramObj4 = new IntegerWrapper(expirationDateDay);
250 
251             Object paramObj5 = new IntegerWrapper(expirationDateYear);
252 
253             Object paramObj6 = new IntegerWrapper(expirationDateHour);
254 
255             Object paramObj7 = new IntegerWrapper(expirationDateMinute);
256 
257             Object paramObj8 = new BooleanWrapper(neverExpire);
258 
259             Object paramObj9 = choices;
260 
261             if (choices == null) {
262                 paramObj9 = new NullWrapper("java.util.List");
263             }
264 
265             Object paramObj10 = serviceContext;
266 
267             if (serviceContext == null) {
268                 paramObj10 = new NullWrapper(
269                         "com.liferay.portal.service.ServiceContext");
270             }
271 
272             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
273                     "updateQuestion",
274                     new Object[] {
275                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
276                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
277                         paramObj10
278                     });
279 
280             Object returnObj = null;
281 
282             try {
283                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
284             }
285             catch (Exception e) {
286                 if (e instanceof com.liferay.portal.PortalException) {
287                     throw (com.liferay.portal.PortalException)e;
288                 }
289 
290                 if (e instanceof com.liferay.portal.SystemException) {
291                     throw (com.liferay.portal.SystemException)e;
292                 }
293 
294                 throw new com.liferay.portal.SystemException(e);
295             }
296 
297             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
298         }
299         catch (com.liferay.portal.SystemException se) {
300             _log.error(se, se);
301 
302             throw se;
303         }
304     }
305 
306     private static Log _log = LogFactoryUtil.getLog(PollsQuestionServiceHttp.class);
307 }