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