1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.polls.service.http;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  import com.liferay.portal.kernel.util.BooleanWrapper;
25  import com.liferay.portal.kernel.util.IntegerWrapper;
26  import com.liferay.portal.kernel.util.LongWrapper;
27  import com.liferay.portal.kernel.util.MethodWrapper;
28  import com.liferay.portal.kernel.util.NullWrapper;
29  import com.liferay.portal.security.auth.HttpPrincipal;
30  import com.liferay.portal.service.http.TunnelUtil;
31  
32  import com.liferay.portlet.polls.service.PollsQuestionServiceUtil;
33  
34  /**
35   * <a href="PollsQuestionServiceHttp.java.html"><b><i>View Source</i></b></a>
36   *
37   * <p>
38   * ServiceBuilder generated this class. Modifications in this class will be
39   * overwritten the next time is generated.
40   * </p>
41   *
42   * <p>
43   * This class provides a HTTP utility for the
44   * <code>com.liferay.portlet.polls.service.PollsQuestionServiceUtil</code> service
45   * utility. The static methods of this class calls the same methods of the
46   * service utility. However, the signatures are different because it requires an
47   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
48   * parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for
53   * tunneling without the cost of serializing to text. The drawback is that it
54   * only works with Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
59   * portal.properties to configure security.
60   * </p>
61   *
62   * <p>
63   * The HTTP utility is only generated for remote services.
64   * </p>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   * @see com.liferay.portal.security.auth.HttpPrincipal
69   * @see com.liferay.portlet.polls.service.PollsQuestionServiceUtil
70   * @see com.liferay.portlet.polls.service.http.PollsQuestionServiceSoap
71   *
72   */
73  public class PollsQuestionServiceHttp {
74      public static com.liferay.portlet.polls.model.PollsQuestion addQuestion(
75          HttpPrincipal httpPrincipal, long plid, java.lang.String title,
76          java.lang.String description, int expirationDateMonth,
77          int expirationDateDay, int expirationDateYear, int expirationDateHour,
78          int expirationDateMinute, boolean neverExpire,
79          java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices,
80          boolean addCommunityPermissions, boolean addGuestPermissions)
81          throws com.liferay.portal.PortalException,
82              com.liferay.portal.SystemException {
83          try {
84              Object paramObj0 = new LongWrapper(plid);
85  
86              Object paramObj1 = title;
87  
88              if (title == null) {
89                  paramObj1 = new NullWrapper("java.lang.String");
90              }
91  
92              Object paramObj2 = description;
93  
94              if (description == null) {
95                  paramObj2 = new NullWrapper("java.lang.String");
96              }
97  
98              Object paramObj3 = new IntegerWrapper(expirationDateMonth);
99  
100             Object paramObj4 = new IntegerWrapper(expirationDateDay);
101 
102             Object paramObj5 = new IntegerWrapper(expirationDateYear);
103 
104             Object paramObj6 = new IntegerWrapper(expirationDateHour);
105 
106             Object paramObj7 = new IntegerWrapper(expirationDateMinute);
107 
108             Object paramObj8 = new BooleanWrapper(neverExpire);
109 
110             Object paramObj9 = choices;
111 
112             if (choices == null) {
113                 paramObj9 = new NullWrapper("java.util.List");
114             }
115 
116             Object paramObj10 = new BooleanWrapper(addCommunityPermissions);
117 
118             Object paramObj11 = new BooleanWrapper(addGuestPermissions);
119 
120             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
121                     "addQuestion",
122                     new Object[] {
123                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
124                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
125                         paramObj10, paramObj11
126                     });
127 
128             Object returnObj = null;
129 
130             try {
131                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
132             }
133             catch (Exception e) {
134                 if (e instanceof com.liferay.portal.PortalException) {
135                     throw (com.liferay.portal.PortalException)e;
136                 }
137 
138                 if (e instanceof com.liferay.portal.SystemException) {
139                     throw (com.liferay.portal.SystemException)e;
140                 }
141 
142                 throw new com.liferay.portal.SystemException(e);
143             }
144 
145             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
146         }
147         catch (com.liferay.portal.SystemException se) {
148             _log.error(se, se);
149 
150             throw se;
151         }
152     }
153 
154     public static com.liferay.portlet.polls.model.PollsQuestion addQuestion(
155         HttpPrincipal httpPrincipal, long plid, java.lang.String title,
156         java.lang.String description, int expirationDateMonth,
157         int expirationDateDay, int expirationDateYear, int expirationDateHour,
158         int expirationDateMinute, boolean neverExpire,
159         java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices,
160         java.lang.String[] communityPermissions,
161         java.lang.String[] guestPermissions)
162         throws com.liferay.portal.PortalException,
163             com.liferay.portal.SystemException {
164         try {
165             Object paramObj0 = new LongWrapper(plid);
166 
167             Object paramObj1 = title;
168 
169             if (title == null) {
170                 paramObj1 = new NullWrapper("java.lang.String");
171             }
172 
173             Object paramObj2 = description;
174 
175             if (description == null) {
176                 paramObj2 = new NullWrapper("java.lang.String");
177             }
178 
179             Object paramObj3 = new IntegerWrapper(expirationDateMonth);
180 
181             Object paramObj4 = new IntegerWrapper(expirationDateDay);
182 
183             Object paramObj5 = new IntegerWrapper(expirationDateYear);
184 
185             Object paramObj6 = new IntegerWrapper(expirationDateHour);
186 
187             Object paramObj7 = new IntegerWrapper(expirationDateMinute);
188 
189             Object paramObj8 = new BooleanWrapper(neverExpire);
190 
191             Object paramObj9 = choices;
192 
193             if (choices == null) {
194                 paramObj9 = new NullWrapper("java.util.List");
195             }
196 
197             Object paramObj10 = communityPermissions;
198 
199             if (communityPermissions == null) {
200                 paramObj10 = new NullWrapper("[Ljava.lang.String;");
201             }
202 
203             Object paramObj11 = guestPermissions;
204 
205             if (guestPermissions == null) {
206                 paramObj11 = new NullWrapper("[Ljava.lang.String;");
207             }
208 
209             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
210                     "addQuestion",
211                     new Object[] {
212                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
213                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
214                         paramObj10, paramObj11
215                     });
216 
217             Object returnObj = null;
218 
219             try {
220                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
221             }
222             catch (Exception e) {
223                 if (e instanceof com.liferay.portal.PortalException) {
224                     throw (com.liferay.portal.PortalException)e;
225                 }
226 
227                 if (e instanceof com.liferay.portal.SystemException) {
228                     throw (com.liferay.portal.SystemException)e;
229                 }
230 
231                 throw new com.liferay.portal.SystemException(e);
232             }
233 
234             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
235         }
236         catch (com.liferay.portal.SystemException se) {
237             _log.error(se, se);
238 
239             throw se;
240         }
241     }
242 
243     public static void deleteQuestion(HttpPrincipal httpPrincipal,
244         long questionId)
245         throws com.liferay.portal.PortalException,
246             com.liferay.portal.SystemException {
247         try {
248             Object paramObj0 = new LongWrapper(questionId);
249 
250             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
251                     "deleteQuestion", new Object[] { paramObj0 });
252 
253             try {
254                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
255             }
256             catch (Exception e) {
257                 if (e instanceof com.liferay.portal.PortalException) {
258                     throw (com.liferay.portal.PortalException)e;
259                 }
260 
261                 if (e instanceof com.liferay.portal.SystemException) {
262                     throw (com.liferay.portal.SystemException)e;
263                 }
264 
265                 throw new com.liferay.portal.SystemException(e);
266             }
267         }
268         catch (com.liferay.portal.SystemException se) {
269             _log.error(se, se);
270 
271             throw se;
272         }
273     }
274 
275     public static com.liferay.portlet.polls.model.PollsQuestion getQuestion(
276         HttpPrincipal httpPrincipal, long questionId)
277         throws com.liferay.portal.PortalException,
278             com.liferay.portal.SystemException {
279         try {
280             Object paramObj0 = new LongWrapper(questionId);
281 
282             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
283                     "getQuestion", new Object[] { paramObj0 });
284 
285             Object returnObj = null;
286 
287             try {
288                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
289             }
290             catch (Exception e) {
291                 if (e instanceof com.liferay.portal.PortalException) {
292                     throw (com.liferay.portal.PortalException)e;
293                 }
294 
295                 if (e instanceof com.liferay.portal.SystemException) {
296                     throw (com.liferay.portal.SystemException)e;
297                 }
298 
299                 throw new com.liferay.portal.SystemException(e);
300             }
301 
302             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
303         }
304         catch (com.liferay.portal.SystemException se) {
305             _log.error(se, se);
306 
307             throw se;
308         }
309     }
310 
311     public static com.liferay.portlet.polls.model.PollsQuestion updateQuestion(
312         HttpPrincipal httpPrincipal, long questionId, java.lang.String title,
313         java.lang.String description, int expirationDateMonth,
314         int expirationDateDay, int expirationDateYear, int expirationDateHour,
315         int expirationDateMinute, boolean neverExpire,
316         java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices)
317         throws com.liferay.portal.PortalException,
318             com.liferay.portal.SystemException {
319         try {
320             Object paramObj0 = new LongWrapper(questionId);
321 
322             Object paramObj1 = title;
323 
324             if (title == null) {
325                 paramObj1 = new NullWrapper("java.lang.String");
326             }
327 
328             Object paramObj2 = description;
329 
330             if (description == null) {
331                 paramObj2 = new NullWrapper("java.lang.String");
332             }
333 
334             Object paramObj3 = new IntegerWrapper(expirationDateMonth);
335 
336             Object paramObj4 = new IntegerWrapper(expirationDateDay);
337 
338             Object paramObj5 = new IntegerWrapper(expirationDateYear);
339 
340             Object paramObj6 = new IntegerWrapper(expirationDateHour);
341 
342             Object paramObj7 = new IntegerWrapper(expirationDateMinute);
343 
344             Object paramObj8 = new BooleanWrapper(neverExpire);
345 
346             Object paramObj9 = choices;
347 
348             if (choices == null) {
349                 paramObj9 = new NullWrapper("java.util.List");
350             }
351 
352             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
353                     "updateQuestion",
354                     new Object[] {
355                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
356                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9
357                     });
358 
359             Object returnObj = null;
360 
361             try {
362                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
363             }
364             catch (Exception e) {
365                 if (e instanceof com.liferay.portal.PortalException) {
366                     throw (com.liferay.portal.PortalException)e;
367                 }
368 
369                 if (e instanceof com.liferay.portal.SystemException) {
370                     throw (com.liferay.portal.SystemException)e;
371                 }
372 
373                 throw new com.liferay.portal.SystemException(e);
374             }
375 
376             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
377         }
378         catch (com.liferay.portal.SystemException se) {
379             _log.error(se, se);
380 
381             throw se;
382         }
383     }
384 
385     private static Log _log = LogFactoryUtil.getLog(PollsQuestionServiceHttp.class);
386 }