1   /**
2    * Copyright (c) 2000-2009 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, java.lang.String code, boolean autoCode,
80          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          com.liferay.portal.service.ServiceContext serviceContext)
88          throws com.liferay.portal.PortalException,
89              com.liferay.portal.SystemException {
90          try {
91              Object paramObj0 = code;
92  
93              if (code == null) {
94                  paramObj0 = new NullWrapper("java.lang.String");
95              }
96  
97              Object paramObj1 = new BooleanWrapper(autoCode);
98  
99              Object paramObj2 = name;
100 
101             if (name == null) {
102                 paramObj2 = new NullWrapper("java.lang.String");
103             }
104 
105             Object paramObj3 = description;
106 
107             if (description == null) {
108                 paramObj3 = new NullWrapper("java.lang.String");
109             }
110 
111             Object paramObj4 = new IntegerWrapper(startDateMonth);
112 
113             Object paramObj5 = new IntegerWrapper(startDateDay);
114 
115             Object paramObj6 = new IntegerWrapper(startDateYear);
116 
117             Object paramObj7 = new IntegerWrapper(startDateHour);
118 
119             Object paramObj8 = new IntegerWrapper(startDateMinute);
120 
121             Object paramObj9 = new IntegerWrapper(endDateMonth);
122 
123             Object paramObj10 = new IntegerWrapper(endDateDay);
124 
125             Object paramObj11 = new IntegerWrapper(endDateYear);
126 
127             Object paramObj12 = new IntegerWrapper(endDateHour);
128 
129             Object paramObj13 = new IntegerWrapper(endDateMinute);
130 
131             Object paramObj14 = new BooleanWrapper(neverExpire);
132 
133             Object paramObj15 = new BooleanWrapper(active);
134 
135             Object paramObj16 = limitCategories;
136 
137             if (limitCategories == null) {
138                 paramObj16 = new NullWrapper("java.lang.String");
139             }
140 
141             Object paramObj17 = limitSkus;
142 
143             if (limitSkus == null) {
144                 paramObj17 = new NullWrapper("java.lang.String");
145             }
146 
147             Object paramObj18 = new DoubleWrapper(minOrder);
148 
149             Object paramObj19 = new DoubleWrapper(discount);
150 
151             Object paramObj20 = discountType;
152 
153             if (discountType == null) {
154                 paramObj20 = new NullWrapper("java.lang.String");
155             }
156 
157             Object paramObj21 = serviceContext;
158 
159             if (serviceContext == null) {
160                 paramObj21 = new NullWrapper(
161                         "com.liferay.portal.service.ServiceContext");
162             }
163 
164             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
165                     "addCoupon",
166                     new Object[] {
167                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
168                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
169                         paramObj10, paramObj11, paramObj12, paramObj13,
170                         paramObj14, paramObj15, paramObj16, paramObj17,
171                         paramObj18, paramObj19, paramObj20, paramObj21
172                     });
173 
174             Object returnObj = null;
175 
176             try {
177                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
178             }
179             catch (Exception e) {
180                 if (e instanceof com.liferay.portal.PortalException) {
181                     throw (com.liferay.portal.PortalException)e;
182                 }
183 
184                 if (e instanceof com.liferay.portal.SystemException) {
185                     throw (com.liferay.portal.SystemException)e;
186                 }
187 
188                 throw new com.liferay.portal.SystemException(e);
189             }
190 
191             return (com.liferay.portlet.shopping.model.ShoppingCoupon)returnObj;
192         }
193         catch (com.liferay.portal.SystemException se) {
194             _log.error(se, se);
195 
196             throw se;
197         }
198     }
199 
200     public static void deleteCoupon(HttpPrincipal httpPrincipal, long groupId,
201         long couponId)
202         throws com.liferay.portal.PortalException,
203             com.liferay.portal.SystemException {
204         try {
205             Object paramObj0 = new LongWrapper(groupId);
206 
207             Object paramObj1 = new LongWrapper(couponId);
208 
209             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
210                     "deleteCoupon", new Object[] { paramObj0, paramObj1 });
211 
212             try {
213                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
214             }
215             catch (Exception e) {
216                 if (e instanceof com.liferay.portal.PortalException) {
217                     throw (com.liferay.portal.PortalException)e;
218                 }
219 
220                 if (e instanceof com.liferay.portal.SystemException) {
221                     throw (com.liferay.portal.SystemException)e;
222                 }
223 
224                 throw new com.liferay.portal.SystemException(e);
225             }
226         }
227         catch (com.liferay.portal.SystemException se) {
228             _log.error(se, se);
229 
230             throw se;
231         }
232     }
233 
234     public static com.liferay.portlet.shopping.model.ShoppingCoupon getCoupon(
235         HttpPrincipal httpPrincipal, long groupId, long couponId)
236         throws com.liferay.portal.PortalException,
237             com.liferay.portal.SystemException {
238         try {
239             Object paramObj0 = new LongWrapper(groupId);
240 
241             Object paramObj1 = new LongWrapper(couponId);
242 
243             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
244                     "getCoupon", new Object[] { paramObj0, paramObj1 });
245 
246             Object returnObj = null;
247 
248             try {
249                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
250             }
251             catch (Exception e) {
252                 if (e instanceof com.liferay.portal.PortalException) {
253                     throw (com.liferay.portal.PortalException)e;
254                 }
255 
256                 if (e instanceof com.liferay.portal.SystemException) {
257                     throw (com.liferay.portal.SystemException)e;
258                 }
259 
260                 throw new com.liferay.portal.SystemException(e);
261             }
262 
263             return (com.liferay.portlet.shopping.model.ShoppingCoupon)returnObj;
264         }
265         catch (com.liferay.portal.SystemException se) {
266             _log.error(se, se);
267 
268             throw se;
269         }
270     }
271 
272     public static java.util.List<com.liferay.portlet.shopping.model.ShoppingCoupon> search(
273         HttpPrincipal httpPrincipal, long groupId, long companyId,
274         java.lang.String code, boolean active, java.lang.String discountType,
275         boolean andOperator, int start, int end)
276         throws com.liferay.portal.PortalException,
277             com.liferay.portal.SystemException {
278         try {
279             Object paramObj0 = new LongWrapper(groupId);
280 
281             Object paramObj1 = new LongWrapper(companyId);
282 
283             Object paramObj2 = code;
284 
285             if (code == null) {
286                 paramObj2 = new NullWrapper("java.lang.String");
287             }
288 
289             Object paramObj3 = new BooleanWrapper(active);
290 
291             Object paramObj4 = discountType;
292 
293             if (discountType == null) {
294                 paramObj4 = new NullWrapper("java.lang.String");
295             }
296 
297             Object paramObj5 = new BooleanWrapper(andOperator);
298 
299             Object paramObj6 = new IntegerWrapper(start);
300 
301             Object paramObj7 = new IntegerWrapper(end);
302 
303             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
304                     "search",
305                     new Object[] {
306                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
307                         paramObj5, paramObj6, paramObj7
308                     });
309 
310             Object returnObj = null;
311 
312             try {
313                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
314             }
315             catch (Exception e) {
316                 if (e instanceof com.liferay.portal.PortalException) {
317                     throw (com.liferay.portal.PortalException)e;
318                 }
319 
320                 if (e instanceof com.liferay.portal.SystemException) {
321                     throw (com.liferay.portal.SystemException)e;
322                 }
323 
324                 throw new com.liferay.portal.SystemException(e);
325             }
326 
327             return (java.util.List<com.liferay.portlet.shopping.model.ShoppingCoupon>)returnObj;
328         }
329         catch (com.liferay.portal.SystemException se) {
330             _log.error(se, se);
331 
332             throw se;
333         }
334     }
335 
336     public static com.liferay.portlet.shopping.model.ShoppingCoupon updateCoupon(
337         HttpPrincipal httpPrincipal, long couponId, java.lang.String name,
338         java.lang.String description, int startDateMonth, int startDateDay,
339         int startDateYear, int startDateHour, int startDateMinute,
340         int endDateMonth, int endDateDay, int endDateYear, int endDateHour,
341         int endDateMinute, boolean neverExpire, boolean active,
342         java.lang.String limitCategories, java.lang.String limitSkus,
343         double minOrder, double discount, java.lang.String discountType,
344         com.liferay.portal.service.ServiceContext serviceContext)
345         throws com.liferay.portal.PortalException,
346             com.liferay.portal.SystemException {
347         try {
348             Object paramObj0 = new LongWrapper(couponId);
349 
350             Object paramObj1 = name;
351 
352             if (name == null) {
353                 paramObj1 = new NullWrapper("java.lang.String");
354             }
355 
356             Object paramObj2 = description;
357 
358             if (description == null) {
359                 paramObj2 = new NullWrapper("java.lang.String");
360             }
361 
362             Object paramObj3 = new IntegerWrapper(startDateMonth);
363 
364             Object paramObj4 = new IntegerWrapper(startDateDay);
365 
366             Object paramObj5 = new IntegerWrapper(startDateYear);
367 
368             Object paramObj6 = new IntegerWrapper(startDateHour);
369 
370             Object paramObj7 = new IntegerWrapper(startDateMinute);
371 
372             Object paramObj8 = new IntegerWrapper(endDateMonth);
373 
374             Object paramObj9 = new IntegerWrapper(endDateDay);
375 
376             Object paramObj10 = new IntegerWrapper(endDateYear);
377 
378             Object paramObj11 = new IntegerWrapper(endDateHour);
379 
380             Object paramObj12 = new IntegerWrapper(endDateMinute);
381 
382             Object paramObj13 = new BooleanWrapper(neverExpire);
383 
384             Object paramObj14 = new BooleanWrapper(active);
385 
386             Object paramObj15 = limitCategories;
387 
388             if (limitCategories == null) {
389                 paramObj15 = new NullWrapper("java.lang.String");
390             }
391 
392             Object paramObj16 = limitSkus;
393 
394             if (limitSkus == null) {
395                 paramObj16 = new NullWrapper("java.lang.String");
396             }
397 
398             Object paramObj17 = new DoubleWrapper(minOrder);
399 
400             Object paramObj18 = new DoubleWrapper(discount);
401 
402             Object paramObj19 = discountType;
403 
404             if (discountType == null) {
405                 paramObj19 = new NullWrapper("java.lang.String");
406             }
407 
408             Object paramObj20 = serviceContext;
409 
410             if (serviceContext == null) {
411                 paramObj20 = new NullWrapper(
412                         "com.liferay.portal.service.ServiceContext");
413             }
414 
415             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
416                     "updateCoupon",
417                     new Object[] {
418                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
419                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
420                         paramObj10, paramObj11, paramObj12, paramObj13,
421                         paramObj14, paramObj15, paramObj16, paramObj17,
422                         paramObj18, paramObj19, paramObj20
423                     });
424 
425             Object returnObj = null;
426 
427             try {
428                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
429             }
430             catch (Exception e) {
431                 if (e instanceof com.liferay.portal.PortalException) {
432                     throw (com.liferay.portal.PortalException)e;
433                 }
434 
435                 if (e instanceof com.liferay.portal.SystemException) {
436                     throw (com.liferay.portal.SystemException)e;
437                 }
438 
439                 throw new com.liferay.portal.SystemException(e);
440             }
441 
442             return (com.liferay.portlet.shopping.model.ShoppingCoupon)returnObj;
443         }
444         catch (com.liferay.portal.SystemException se) {
445             _log.error(se, se);
446 
447             throw se;
448         }
449     }
450 
451     private static Log _log = LogFactoryUtil.getLog(ShoppingCouponServiceHttp.class);
452 }