1   /**
2    * Copyright (c) 2000-2009 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.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   * <code>com.liferay.portlet.polls.service.PollsQuestionServiceUtil</code> service
48   * utility. The static methods of this class calls the same methods of the
49   * service utility. However, the signatures are different because it requires an
50   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
51   * parameter.
52   * </p>
53   *
54   * <p>
55   * The benefits of using the HTTP utility is that it is fast and allows for
56   * tunneling without the cost of serializing to text. The drawback is that it
57   * only works with Java.
58   * </p>
59   *
60   * <p>
61   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
62   * portal.properties to configure security.
63   * </p>
64   *
65   * <p>
66   * The HTTP utility is only generated for remote services.
67   * </p>
68   *
69   * @author Brian Wing Shun Chan
70   *
71   * @see com.liferay.portal.security.auth.HttpPrincipal
72   * @see com.liferay.portlet.polls.service.PollsQuestionServiceUtil
73   * @see com.liferay.portlet.polls.service.http.PollsQuestionServiceSoap
74   *
75   */
76  public class PollsQuestionServiceHttp {
77      public static com.liferay.portlet.polls.model.PollsQuestion addQuestion(
78          HttpPrincipal httpPrincipal, java.lang.String title,
79          java.lang.String description, int expirationDateMonth,
80          int expirationDateDay, int expirationDateYear, int expirationDateHour,
81          int expirationDateMinute, boolean neverExpire,
82          java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices,
83          com.liferay.portal.service.ServiceContext serviceContext)
84          throws com.liferay.portal.PortalException,
85              com.liferay.portal.SystemException {
86          try {
87              Object paramObj0 = title;
88  
89              if (title == null) {
90                  paramObj0 = new NullWrapper("java.lang.String");
91              }
92  
93              Object paramObj1 = description;
94  
95              if (description == null) {
96                  paramObj1 = new NullWrapper("java.lang.String");
97              }
98  
99              Object paramObj2 = new IntegerWrapper(expirationDateMonth);
100 
101             Object paramObj3 = new IntegerWrapper(expirationDateDay);
102 
103             Object paramObj4 = new IntegerWrapper(expirationDateYear);
104 
105             Object paramObj5 = new IntegerWrapper(expirationDateHour);
106 
107             Object paramObj6 = new IntegerWrapper(expirationDateMinute);
108 
109             Object paramObj7 = new BooleanWrapper(neverExpire);
110 
111             Object paramObj8 = choices;
112 
113             if (choices == null) {
114                 paramObj8 = new NullWrapper("java.util.List");
115             }
116 
117             Object paramObj9 = serviceContext;
118 
119             if (serviceContext == null) {
120                 paramObj9 = new NullWrapper(
121                         "com.liferay.portal.service.ServiceContext");
122             }
123 
124             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
125                     "addQuestion",
126                     new Object[] {
127                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
128                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9
129                     });
130 
131             Object returnObj = null;
132 
133             try {
134                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
135             }
136             catch (Exception e) {
137                 if (e instanceof com.liferay.portal.PortalException) {
138                     throw (com.liferay.portal.PortalException)e;
139                 }
140 
141                 if (e instanceof com.liferay.portal.SystemException) {
142                     throw (com.liferay.portal.SystemException)e;
143                 }
144 
145                 throw new com.liferay.portal.SystemException(e);
146             }
147 
148             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
149         }
150         catch (com.liferay.portal.SystemException se) {
151             _log.error(se, se);
152 
153             throw se;
154         }
155     }
156 
157     public static void deleteQuestion(HttpPrincipal httpPrincipal,
158         long questionId)
159         throws com.liferay.portal.PortalException,
160             com.liferay.portal.SystemException {
161         try {
162             Object paramObj0 = new LongWrapper(questionId);
163 
164             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
165                     "deleteQuestion", new Object[] { paramObj0 });
166 
167             try {
168                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
169             }
170             catch (Exception e) {
171                 if (e instanceof com.liferay.portal.PortalException) {
172                     throw (com.liferay.portal.PortalException)e;
173                 }
174 
175                 if (e instanceof com.liferay.portal.SystemException) {
176                     throw (com.liferay.portal.SystemException)e;
177                 }
178 
179                 throw new com.liferay.portal.SystemException(e);
180             }
181         }
182         catch (com.liferay.portal.SystemException se) {
183             _log.error(se, se);
184 
185             throw se;
186         }
187     }
188 
189     public static com.liferay.portlet.polls.model.PollsQuestion getQuestion(
190         HttpPrincipal httpPrincipal, long questionId)
191         throws com.liferay.portal.PortalException,
192             com.liferay.portal.SystemException {
193         try {
194             Object paramObj0 = new LongWrapper(questionId);
195 
196             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
197                     "getQuestion", new Object[] { paramObj0 });
198 
199             Object returnObj = null;
200 
201             try {
202                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
203             }
204             catch (Exception e) {
205                 if (e instanceof com.liferay.portal.PortalException) {
206                     throw (com.liferay.portal.PortalException)e;
207                 }
208 
209                 if (e instanceof com.liferay.portal.SystemException) {
210                     throw (com.liferay.portal.SystemException)e;
211                 }
212 
213                 throw new com.liferay.portal.SystemException(e);
214             }
215 
216             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
217         }
218         catch (com.liferay.portal.SystemException se) {
219             _log.error(se, se);
220 
221             throw se;
222         }
223     }
224 
225     public static com.liferay.portlet.polls.model.PollsQuestion updateQuestion(
226         HttpPrincipal httpPrincipal, long questionId, java.lang.String title,
227         java.lang.String description, int expirationDateMonth,
228         int expirationDateDay, int expirationDateYear, int expirationDateHour,
229         int expirationDateMinute, boolean neverExpire,
230         java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices,
231         com.liferay.portal.service.ServiceContext serviceContext)
232         throws com.liferay.portal.PortalException,
233             com.liferay.portal.SystemException {
234         try {
235             Object paramObj0 = new LongWrapper(questionId);
236 
237             Object paramObj1 = title;
238 
239             if (title == null) {
240                 paramObj1 = new NullWrapper("java.lang.String");
241             }
242 
243             Object paramObj2 = description;
244 
245             if (description == null) {
246                 paramObj2 = new NullWrapper("java.lang.String");
247             }
248 
249             Object paramObj3 = new IntegerWrapper(expirationDateMonth);
250 
251             Object paramObj4 = new IntegerWrapper(expirationDateDay);
252 
253             Object paramObj5 = new IntegerWrapper(expirationDateYear);
254 
255             Object paramObj6 = new IntegerWrapper(expirationDateHour);
256 
257             Object paramObj7 = new IntegerWrapper(expirationDateMinute);
258 
259             Object paramObj8 = new BooleanWrapper(neverExpire);
260 
261             Object paramObj9 = choices;
262 
263             if (choices == null) {
264                 paramObj9 = new NullWrapper("java.util.List");
265             }
266 
267             Object paramObj10 = serviceContext;
268 
269             if (serviceContext == null) {
270                 paramObj10 = new NullWrapper(
271                         "com.liferay.portal.service.ServiceContext");
272             }
273 
274             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
275                     "updateQuestion",
276                     new Object[] {
277                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
278                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
279                         paramObj10
280                     });
281 
282             Object returnObj = null;
283 
284             try {
285                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
286             }
287             catch (Exception e) {
288                 if (e instanceof com.liferay.portal.PortalException) {
289                     throw (com.liferay.portal.PortalException)e;
290                 }
291 
292                 if (e instanceof com.liferay.portal.SystemException) {
293                     throw (com.liferay.portal.SystemException)e;
294                 }
295 
296                 throw new com.liferay.portal.SystemException(e);
297             }
298 
299             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
300         }
301         catch (com.liferay.portal.SystemException se) {
302             _log.error(se, se);
303 
304             throw se;
305         }
306     }
307 
308     private static Log _log = LogFactoryUtil.getLog(PollsQuestionServiceHttp.class);
309 }