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,
82          java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices,
83          boolean addCommunityPermissions, boolean addGuestPermissions)
84          throws com.liferay.portal.SystemException,
85              com.liferay.portal.PortalException {
86          try {
87              Object paramObj0 = new LongWrapper(plid);
88  
89              Object paramObj1 = title;
90  
91              if (title == null) {
92                  paramObj1 = new NullWrapper("java.lang.String");
93              }
94  
95              Object paramObj2 = description;
96  
97              if (description == null) {
98                  paramObj2 = new NullWrapper("java.lang.String");
99              }
100 
101             Object paramObj3 = new IntegerWrapper(expirationDateMonth);
102 
103             Object paramObj4 = new IntegerWrapper(expirationDateDay);
104 
105             Object paramObj5 = new IntegerWrapper(expirationDateYear);
106 
107             Object paramObj6 = new IntegerWrapper(expirationDateHour);
108 
109             Object paramObj7 = new IntegerWrapper(expirationDateMinute);
110 
111             Object paramObj8 = new BooleanWrapper(neverExpire);
112 
113             Object paramObj9 = choices;
114 
115             if (choices == null) {
116                 paramObj9 = new NullWrapper("java.util.List");
117             }
118 
119             Object paramObj10 = new BooleanWrapper(addCommunityPermissions);
120 
121             Object paramObj11 = new BooleanWrapper(addGuestPermissions);
122 
123             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
124                     "addQuestion",
125                     new Object[] {
126                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
127                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
128                         paramObj10, paramObj11
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.SystemException) {
138                     throw (com.liferay.portal.SystemException)e;
139                 }
140 
141                 if (e instanceof com.liferay.portal.PortalException) {
142                     throw (com.liferay.portal.PortalException)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 com.liferay.portlet.polls.model.PollsQuestion addQuestion(
158         HttpPrincipal httpPrincipal, long plid, java.lang.String title,
159         java.lang.String description, int expirationDateMonth,
160         int expirationDateDay, int expirationDateYear, int expirationDateHour,
161         int expirationDateMinute, boolean neverExpire,
162         java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices,
163         java.lang.String[] communityPermissions,
164         java.lang.String[] guestPermissions)
165         throws com.liferay.portal.SystemException,
166             com.liferay.portal.PortalException {
167         try {
168             Object paramObj0 = new LongWrapper(plid);
169 
170             Object paramObj1 = title;
171 
172             if (title == null) {
173                 paramObj1 = new NullWrapper("java.lang.String");
174             }
175 
176             Object paramObj2 = description;
177 
178             if (description == null) {
179                 paramObj2 = new NullWrapper("java.lang.String");
180             }
181 
182             Object paramObj3 = new IntegerWrapper(expirationDateMonth);
183 
184             Object paramObj4 = new IntegerWrapper(expirationDateDay);
185 
186             Object paramObj5 = new IntegerWrapper(expirationDateYear);
187 
188             Object paramObj6 = new IntegerWrapper(expirationDateHour);
189 
190             Object paramObj7 = new IntegerWrapper(expirationDateMinute);
191 
192             Object paramObj8 = new BooleanWrapper(neverExpire);
193 
194             Object paramObj9 = choices;
195 
196             if (choices == null) {
197                 paramObj9 = new NullWrapper("java.util.List");
198             }
199 
200             Object paramObj10 = communityPermissions;
201 
202             if (communityPermissions == null) {
203                 paramObj10 = new NullWrapper("[Ljava.lang.String;");
204             }
205 
206             Object paramObj11 = guestPermissions;
207 
208             if (guestPermissions == null) {
209                 paramObj11 = new NullWrapper("[Ljava.lang.String;");
210             }
211 
212             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
213                     "addQuestion",
214                     new Object[] {
215                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
216                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
217                         paramObj10, paramObj11
218                     });
219 
220             Object returnObj = null;
221 
222             try {
223                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
224             }
225             catch (Exception e) {
226                 if (e instanceof com.liferay.portal.SystemException) {
227                     throw (com.liferay.portal.SystemException)e;
228                 }
229 
230                 if (e instanceof com.liferay.portal.PortalException) {
231                     throw (com.liferay.portal.PortalException)e;
232                 }
233 
234                 throw new com.liferay.portal.SystemException(e);
235             }
236 
237             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
238         }
239         catch (com.liferay.portal.SystemException se) {
240             _log.error(se, se);
241 
242             throw se;
243         }
244     }
245 
246     public static void deleteQuestion(HttpPrincipal httpPrincipal,
247         long questionId)
248         throws com.liferay.portal.SystemException,
249             com.liferay.portal.PortalException {
250         try {
251             Object paramObj0 = new LongWrapper(questionId);
252 
253             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
254                     "deleteQuestion", new Object[] { paramObj0 });
255 
256             try {
257                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
258             }
259             catch (Exception e) {
260                 if (e instanceof com.liferay.portal.SystemException) {
261                     throw (com.liferay.portal.SystemException)e;
262                 }
263 
264                 if (e instanceof com.liferay.portal.PortalException) {
265                     throw (com.liferay.portal.PortalException)e;
266                 }
267 
268                 throw new com.liferay.portal.SystemException(e);
269             }
270         }
271         catch (com.liferay.portal.SystemException se) {
272             _log.error(se, se);
273 
274             throw se;
275         }
276     }
277 
278     public static com.liferay.portlet.polls.model.PollsQuestion getQuestion(
279         HttpPrincipal httpPrincipal, long questionId)
280         throws com.liferay.portal.SystemException,
281             com.liferay.portal.PortalException {
282         try {
283             Object paramObj0 = new LongWrapper(questionId);
284 
285             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
286                     "getQuestion", new Object[] { paramObj0 });
287 
288             Object returnObj = null;
289 
290             try {
291                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
292             }
293             catch (Exception e) {
294                 if (e instanceof com.liferay.portal.SystemException) {
295                     throw (com.liferay.portal.SystemException)e;
296                 }
297 
298                 if (e instanceof com.liferay.portal.PortalException) {
299                     throw (com.liferay.portal.PortalException)e;
300                 }
301 
302                 throw new com.liferay.portal.SystemException(e);
303             }
304 
305             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
306         }
307         catch (com.liferay.portal.SystemException se) {
308             _log.error(se, se);
309 
310             throw se;
311         }
312     }
313 
314     public static com.liferay.portlet.polls.model.PollsQuestion updateQuestion(
315         HttpPrincipal httpPrincipal, long questionId, java.lang.String title,
316         java.lang.String description, int expirationDateMonth,
317         int expirationDateDay, int expirationDateYear, int expirationDateHour,
318         int expirationDateMinute, boolean neverExpire,
319         java.util.List<com.liferay.portlet.polls.model.PollsChoice> choices)
320         throws com.liferay.portal.SystemException,
321             com.liferay.portal.PortalException {
322         try {
323             Object paramObj0 = new LongWrapper(questionId);
324 
325             Object paramObj1 = title;
326 
327             if (title == null) {
328                 paramObj1 = new NullWrapper("java.lang.String");
329             }
330 
331             Object paramObj2 = description;
332 
333             if (description == null) {
334                 paramObj2 = new NullWrapper("java.lang.String");
335             }
336 
337             Object paramObj3 = new IntegerWrapper(expirationDateMonth);
338 
339             Object paramObj4 = new IntegerWrapper(expirationDateDay);
340 
341             Object paramObj5 = new IntegerWrapper(expirationDateYear);
342 
343             Object paramObj6 = new IntegerWrapper(expirationDateHour);
344 
345             Object paramObj7 = new IntegerWrapper(expirationDateMinute);
346 
347             Object paramObj8 = new BooleanWrapper(neverExpire);
348 
349             Object paramObj9 = choices;
350 
351             if (choices == null) {
352                 paramObj9 = new NullWrapper("java.util.List");
353             }
354 
355             MethodWrapper methodWrapper = new MethodWrapper(PollsQuestionServiceUtil.class.getName(),
356                     "updateQuestion",
357                     new Object[] {
358                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
359                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9
360                     });
361 
362             Object returnObj = null;
363 
364             try {
365                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
366             }
367             catch (Exception e) {
368                 if (e instanceof com.liferay.portal.SystemException) {
369                     throw (com.liferay.portal.SystemException)e;
370                 }
371 
372                 if (e instanceof com.liferay.portal.PortalException) {
373                     throw (com.liferay.portal.PortalException)e;
374                 }
375 
376                 throw new com.liferay.portal.SystemException(e);
377             }
378 
379             return (com.liferay.portlet.polls.model.PollsQuestion)returnObj;
380         }
381         catch (com.liferay.portal.SystemException se) {
382             _log.error(se, se);
383 
384             throw se;
385         }
386     }
387 
388     private static Log _log = LogFactoryUtil.getLog(PollsQuestionServiceHttp.class);
389 }