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