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