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.shopping.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.DoubleWrapper;
29  import com.liferay.portal.kernel.util.IntegerWrapper;
30  import com.liferay.portal.kernel.util.LongWrapper;
31  import com.liferay.portal.kernel.util.MethodWrapper;
32  import com.liferay.portal.kernel.util.NullWrapper;
33  import com.liferay.portal.security.auth.HttpPrincipal;
34  import com.liferay.portal.service.http.TunnelUtil;
35  
36  import com.liferay.portlet.shopping.service.ShoppingCouponServiceUtil;
37  
38  /**
39   * <a href="ShoppingCouponServiceHttp.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class provides a HTTP utility for the
48   * <code>com.liferay.portlet.shopping.service.ShoppingCouponServiceUtil</code> service
49   * utility. The static methods of this class calls the same methods of the
50   * service utility. However, the signatures are different because it requires an
51   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
52   * parameter.
53   * </p>
54   *
55   * <p>
56   * The benefits of using the HTTP utility is that it is fast and allows for
57   * tunneling without the cost of serializing to text. The drawback is that it
58   * only works with Java.
59   * </p>
60   *
61   * <p>
62   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
63   * portal.properties to configure security.
64   * </p>
65   *
66   * <p>
67   * The HTTP utility is only generated for remote services.
68   * </p>
69   *
70   * @author Brian Wing Shun Chan
71   *
72   * @see com.liferay.portal.security.auth.HttpPrincipal
73   * @see com.liferay.portlet.shopping.service.ShoppingCouponServiceUtil
74   * @see com.liferay.portlet.shopping.service.http.ShoppingCouponServiceSoap
75   *
76   */
77  public class ShoppingCouponServiceHttp {
78      public static com.liferay.portlet.shopping.model.ShoppingCoupon addCoupon(
79          HttpPrincipal httpPrincipal, long plid, java.lang.String code,
80          boolean autoCode, java.lang.String name, java.lang.String description,
81          int startDateMonth, int startDateDay, int startDateYear,
82          int startDateHour, int startDateMinute, int endDateMonth,
83          int endDateDay, int endDateYear, int endDateHour, int endDateMinute,
84          boolean neverExpire, boolean active, java.lang.String limitCategories,
85          java.lang.String limitSkus, double minOrder, double discount,
86          java.lang.String discountType)
87          throws com.liferay.portal.PortalException,
88              com.liferay.portal.SystemException {
89          try {
90              Object paramObj0 = new LongWrapper(plid);
91  
92              Object paramObj1 = code;
93  
94              if (code == null) {
95                  paramObj1 = new NullWrapper("java.lang.String");
96              }
97  
98              Object paramObj2 = new BooleanWrapper(autoCode);
99  
100             Object paramObj3 = name;
101 
102             if (name == null) {
103                 paramObj3 = new NullWrapper("java.lang.String");
104             }
105 
106             Object paramObj4 = description;
107 
108             if (description == null) {
109                 paramObj4 = new NullWrapper("java.lang.String");
110             }
111 
112             Object paramObj5 = new IntegerWrapper(startDateMonth);
113 
114             Object paramObj6 = new IntegerWrapper(startDateDay);
115 
116             Object paramObj7 = new IntegerWrapper(startDateYear);
117 
118             Object paramObj8 = new IntegerWrapper(startDateHour);
119 
120             Object paramObj9 = new IntegerWrapper(startDateMinute);
121 
122             Object paramObj10 = new IntegerWrapper(endDateMonth);
123 
124             Object paramObj11 = new IntegerWrapper(endDateDay);
125 
126             Object paramObj12 = new IntegerWrapper(endDateYear);
127 
128             Object paramObj13 = new IntegerWrapper(endDateHour);
129 
130             Object paramObj14 = new IntegerWrapper(endDateMinute);
131 
132             Object paramObj15 = new BooleanWrapper(neverExpire);
133 
134             Object paramObj16 = new BooleanWrapper(active);
135 
136             Object paramObj17 = limitCategories;
137 
138             if (limitCategories == null) {
139                 paramObj17 = new NullWrapper("java.lang.String");
140             }
141 
142             Object paramObj18 = limitSkus;
143 
144             if (limitSkus == null) {
145                 paramObj18 = new NullWrapper("java.lang.String");
146             }
147 
148             Object paramObj19 = new DoubleWrapper(minOrder);
149 
150             Object paramObj20 = new DoubleWrapper(discount);
151 
152             Object paramObj21 = discountType;
153 
154             if (discountType == null) {
155                 paramObj21 = new NullWrapper("java.lang.String");
156             }
157 
158             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
159                     "addCoupon",
160                     new Object[] {
161                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
162                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
163                         paramObj10, paramObj11, paramObj12, paramObj13,
164                         paramObj14, paramObj15, paramObj16, paramObj17,
165                         paramObj18, paramObj19, paramObj20, paramObj21
166                     });
167 
168             Object returnObj = null;
169 
170             try {
171                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
172             }
173             catch (Exception e) {
174                 if (e instanceof com.liferay.portal.PortalException) {
175                     throw (com.liferay.portal.PortalException)e;
176                 }
177 
178                 if (e instanceof com.liferay.portal.SystemException) {
179                     throw (com.liferay.portal.SystemException)e;
180                 }
181 
182                 throw new com.liferay.portal.SystemException(e);
183             }
184 
185             return (com.liferay.portlet.shopping.model.ShoppingCoupon)returnObj;
186         }
187         catch (com.liferay.portal.SystemException se) {
188             _log.error(se, se);
189 
190             throw se;
191         }
192     }
193 
194     public static void deleteCoupon(HttpPrincipal httpPrincipal, long plid,
195         long couponId)
196         throws com.liferay.portal.PortalException,
197             com.liferay.portal.SystemException {
198         try {
199             Object paramObj0 = new LongWrapper(plid);
200 
201             Object paramObj1 = new LongWrapper(couponId);
202 
203             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
204                     "deleteCoupon", new Object[] { paramObj0, paramObj1 });
205 
206             try {
207                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
208             }
209             catch (Exception e) {
210                 if (e instanceof com.liferay.portal.PortalException) {
211                     throw (com.liferay.portal.PortalException)e;
212                 }
213 
214                 if (e instanceof com.liferay.portal.SystemException) {
215                     throw (com.liferay.portal.SystemException)e;
216                 }
217 
218                 throw new com.liferay.portal.SystemException(e);
219             }
220         }
221         catch (com.liferay.portal.SystemException se) {
222             _log.error(se, se);
223 
224             throw se;
225         }
226     }
227 
228     public static com.liferay.portlet.shopping.model.ShoppingCoupon getCoupon(
229         HttpPrincipal httpPrincipal, long plid, long couponId)
230         throws com.liferay.portal.PortalException,
231             com.liferay.portal.SystemException {
232         try {
233             Object paramObj0 = new LongWrapper(plid);
234 
235             Object paramObj1 = new LongWrapper(couponId);
236 
237             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
238                     "getCoupon", new Object[] { paramObj0, paramObj1 });
239 
240             Object returnObj = null;
241 
242             try {
243                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
244             }
245             catch (Exception e) {
246                 if (e instanceof com.liferay.portal.PortalException) {
247                     throw (com.liferay.portal.PortalException)e;
248                 }
249 
250                 if (e instanceof com.liferay.portal.SystemException) {
251                     throw (com.liferay.portal.SystemException)e;
252                 }
253 
254                 throw new com.liferay.portal.SystemException(e);
255             }
256 
257             return (com.liferay.portlet.shopping.model.ShoppingCoupon)returnObj;
258         }
259         catch (com.liferay.portal.SystemException se) {
260             _log.error(se, se);
261 
262             throw se;
263         }
264     }
265 
266     public static java.util.List<com.liferay.portlet.shopping.model.ShoppingCoupon> search(
267         HttpPrincipal httpPrincipal, long plid, long companyId,
268         java.lang.String code, boolean active, java.lang.String discountType,
269         boolean andOperator, int start, int end)
270         throws com.liferay.portal.PortalException,
271             com.liferay.portal.SystemException {
272         try {
273             Object paramObj0 = new LongWrapper(plid);
274 
275             Object paramObj1 = new LongWrapper(companyId);
276 
277             Object paramObj2 = code;
278 
279             if (code == null) {
280                 paramObj2 = new NullWrapper("java.lang.String");
281             }
282 
283             Object paramObj3 = new BooleanWrapper(active);
284 
285             Object paramObj4 = discountType;
286 
287             if (discountType == null) {
288                 paramObj4 = new NullWrapper("java.lang.String");
289             }
290 
291             Object paramObj5 = new BooleanWrapper(andOperator);
292 
293             Object paramObj6 = new IntegerWrapper(start);
294 
295             Object paramObj7 = new IntegerWrapper(end);
296 
297             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
298                     "search",
299                     new Object[] {
300                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
301                         paramObj5, paramObj6, paramObj7
302                     });
303 
304             Object returnObj = null;
305 
306             try {
307                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
308             }
309             catch (Exception e) {
310                 if (e instanceof com.liferay.portal.PortalException) {
311                     throw (com.liferay.portal.PortalException)e;
312                 }
313 
314                 if (e instanceof com.liferay.portal.SystemException) {
315                     throw (com.liferay.portal.SystemException)e;
316                 }
317 
318                 throw new com.liferay.portal.SystemException(e);
319             }
320 
321             return (java.util.List<com.liferay.portlet.shopping.model.ShoppingCoupon>)returnObj;
322         }
323         catch (com.liferay.portal.SystemException se) {
324             _log.error(se, se);
325 
326             throw se;
327         }
328     }
329 
330     public static com.liferay.portlet.shopping.model.ShoppingCoupon updateCoupon(
331         HttpPrincipal httpPrincipal, long plid, long couponId,
332         java.lang.String name, java.lang.String description,
333         int startDateMonth, int startDateDay, int startDateYear,
334         int startDateHour, int startDateMinute, int endDateMonth,
335         int endDateDay, int endDateYear, int endDateHour, int endDateMinute,
336         boolean neverExpire, boolean active, java.lang.String limitCategories,
337         java.lang.String limitSkus, double minOrder, double discount,
338         java.lang.String discountType)
339         throws com.liferay.portal.PortalException,
340             com.liferay.portal.SystemException {
341         try {
342             Object paramObj0 = new LongWrapper(plid);
343 
344             Object paramObj1 = new LongWrapper(couponId);
345 
346             Object paramObj2 = name;
347 
348             if (name == null) {
349                 paramObj2 = new NullWrapper("java.lang.String");
350             }
351 
352             Object paramObj3 = description;
353 
354             if (description == null) {
355                 paramObj3 = new NullWrapper("java.lang.String");
356             }
357 
358             Object paramObj4 = new IntegerWrapper(startDateMonth);
359 
360             Object paramObj5 = new IntegerWrapper(startDateDay);
361 
362             Object paramObj6 = new IntegerWrapper(startDateYear);
363 
364             Object paramObj7 = new IntegerWrapper(startDateHour);
365 
366             Object paramObj8 = new IntegerWrapper(startDateMinute);
367 
368             Object paramObj9 = new IntegerWrapper(endDateMonth);
369 
370             Object paramObj10 = new IntegerWrapper(endDateDay);
371 
372             Object paramObj11 = new IntegerWrapper(endDateYear);
373 
374             Object paramObj12 = new IntegerWrapper(endDateHour);
375 
376             Object paramObj13 = new IntegerWrapper(endDateMinute);
377 
378             Object paramObj14 = new BooleanWrapper(neverExpire);
379 
380             Object paramObj15 = new BooleanWrapper(active);
381 
382             Object paramObj16 = limitCategories;
383 
384             if (limitCategories == null) {
385                 paramObj16 = new NullWrapper("java.lang.String");
386             }
387 
388             Object paramObj17 = limitSkus;
389 
390             if (limitSkus == null) {
391                 paramObj17 = new NullWrapper("java.lang.String");
392             }
393 
394             Object paramObj18 = new DoubleWrapper(minOrder);
395 
396             Object paramObj19 = new DoubleWrapper(discount);
397 
398             Object paramObj20 = discountType;
399 
400             if (discountType == null) {
401                 paramObj20 = new NullWrapper("java.lang.String");
402             }
403 
404             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
405                     "updateCoupon",
406                     new Object[] {
407                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
408                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
409                         paramObj10, paramObj11, paramObj12, paramObj13,
410                         paramObj14, paramObj15, paramObj16, paramObj17,
411                         paramObj18, paramObj19, paramObj20
412                     });
413 
414             Object returnObj = null;
415 
416             try {
417                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
418             }
419             catch (Exception e) {
420                 if (e instanceof com.liferay.portal.PortalException) {
421                     throw (com.liferay.portal.PortalException)e;
422                 }
423 
424                 if (e instanceof com.liferay.portal.SystemException) {
425                     throw (com.liferay.portal.SystemException)e;
426                 }
427 
428                 throw new com.liferay.portal.SystemException(e);
429             }
430 
431             return (com.liferay.portlet.shopping.model.ShoppingCoupon)returnObj;
432         }
433         catch (com.liferay.portal.SystemException se) {
434             _log.error(se, se);
435 
436             throw se;
437         }
438     }
439 
440     private static Log _log = LogFactoryUtil.getLog(ShoppingCouponServiceHttp.class);
441 }