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.SystemException, 
88              com.liferay.portal.PortalException {
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.SystemException) {
175                     throw (com.liferay.portal.SystemException)e;
176                 }
177 
178                 if (e instanceof com.liferay.portal.PortalException) {
179                     throw (com.liferay.portal.PortalException)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.SystemException, 
197             com.liferay.portal.PortalException {
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.SystemException) {
211                     throw (com.liferay.portal.SystemException)e;
212                 }
213 
214                 if (e instanceof com.liferay.portal.PortalException) {
215                     throw (com.liferay.portal.PortalException)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.SystemException, 
231             com.liferay.portal.PortalException {
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.SystemException) {
247                     throw (com.liferay.portal.SystemException)e;
248                 }
249 
250                 if (e instanceof com.liferay.portal.PortalException) {
251                     throw (com.liferay.portal.PortalException)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 search(HttpPrincipal httpPrincipal, long plid,
267         long companyId, java.lang.String code, boolean active,
268         java.lang.String discountType, boolean andOperator, int begin, int end)
269         throws com.liferay.portal.SystemException, 
270             com.liferay.portal.PortalException {
271         try {
272             Object paramObj0 = new LongWrapper(plid);
273 
274             Object paramObj1 = new LongWrapper(companyId);
275 
276             Object paramObj2 = code;
277 
278             if (code == null) {
279                 paramObj2 = new NullWrapper("java.lang.String");
280             }
281 
282             Object paramObj3 = new BooleanWrapper(active);
283 
284             Object paramObj4 = discountType;
285 
286             if (discountType == null) {
287                 paramObj4 = new NullWrapper("java.lang.String");
288             }
289 
290             Object paramObj5 = new BooleanWrapper(andOperator);
291 
292             Object paramObj6 = new IntegerWrapper(begin);
293 
294             Object paramObj7 = new IntegerWrapper(end);
295 
296             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
297                     "search",
298                     new Object[] {
299                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
300                         paramObj5, paramObj6, paramObj7
301                     });
302 
303             Object returnObj = null;
304 
305             try {
306                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
307             }
308             catch (Exception e) {
309                 if (e instanceof com.liferay.portal.SystemException) {
310                     throw (com.liferay.portal.SystemException)e;
311                 }
312 
313                 if (e instanceof com.liferay.portal.PortalException) {
314                     throw (com.liferay.portal.PortalException)e;
315                 }
316 
317                 throw new com.liferay.portal.SystemException(e);
318             }
319 
320             return (java.util.List)returnObj;
321         }
322         catch (com.liferay.portal.SystemException se) {
323             _log.error(se, se);
324 
325             throw se;
326         }
327     }
328 
329     public static com.liferay.portlet.shopping.model.ShoppingCoupon updateCoupon(
330         HttpPrincipal httpPrincipal, long plid, long couponId,
331         java.lang.String name, java.lang.String description,
332         int startDateMonth, int startDateDay, int startDateYear,
333         int startDateHour, int startDateMinute, int endDateMonth,
334         int endDateDay, int endDateYear, int endDateHour, int endDateMinute,
335         boolean neverExpire, boolean active, java.lang.String limitCategories,
336         java.lang.String limitSkus, double minOrder, double discount,
337         java.lang.String discountType)
338         throws com.liferay.portal.SystemException, 
339             com.liferay.portal.PortalException {
340         try {
341             Object paramObj0 = new LongWrapper(plid);
342 
343             Object paramObj1 = new LongWrapper(couponId);
344 
345             Object paramObj2 = name;
346 
347             if (name == null) {
348                 paramObj2 = new NullWrapper("java.lang.String");
349             }
350 
351             Object paramObj3 = description;
352 
353             if (description == null) {
354                 paramObj3 = new NullWrapper("java.lang.String");
355             }
356 
357             Object paramObj4 = new IntegerWrapper(startDateMonth);
358 
359             Object paramObj5 = new IntegerWrapper(startDateDay);
360 
361             Object paramObj6 = new IntegerWrapper(startDateYear);
362 
363             Object paramObj7 = new IntegerWrapper(startDateHour);
364 
365             Object paramObj8 = new IntegerWrapper(startDateMinute);
366 
367             Object paramObj9 = new IntegerWrapper(endDateMonth);
368 
369             Object paramObj10 = new IntegerWrapper(endDateDay);
370 
371             Object paramObj11 = new IntegerWrapper(endDateYear);
372 
373             Object paramObj12 = new IntegerWrapper(endDateHour);
374 
375             Object paramObj13 = new IntegerWrapper(endDateMinute);
376 
377             Object paramObj14 = new BooleanWrapper(neverExpire);
378 
379             Object paramObj15 = new BooleanWrapper(active);
380 
381             Object paramObj16 = limitCategories;
382 
383             if (limitCategories == null) {
384                 paramObj16 = new NullWrapper("java.lang.String");
385             }
386 
387             Object paramObj17 = limitSkus;
388 
389             if (limitSkus == null) {
390                 paramObj17 = new NullWrapper("java.lang.String");
391             }
392 
393             Object paramObj18 = new DoubleWrapper(minOrder);
394 
395             Object paramObj19 = new DoubleWrapper(discount);
396 
397             Object paramObj20 = discountType;
398 
399             if (discountType == null) {
400                 paramObj20 = new NullWrapper("java.lang.String");
401             }
402 
403             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCouponServiceUtil.class.getName(),
404                     "updateCoupon",
405                     new Object[] {
406                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
407                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
408                         paramObj10, paramObj11, paramObj12, paramObj13,
409                         paramObj14, paramObj15, paramObj16, paramObj17,
410                         paramObj18, paramObj19, paramObj20
411                     });
412 
413             Object returnObj = null;
414 
415             try {
416                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
417             }
418             catch (Exception e) {
419                 if (e instanceof com.liferay.portal.SystemException) {
420                     throw (com.liferay.portal.SystemException)e;
421                 }
422 
423                 if (e instanceof com.liferay.portal.PortalException) {
424                     throw (com.liferay.portal.PortalException)e;
425                 }
426 
427                 throw new com.liferay.portal.SystemException(e);
428             }
429 
430             return (com.liferay.portlet.shopping.model.ShoppingCoupon)returnObj;
431         }
432         catch (com.liferay.portal.SystemException se) {
433             _log.error(se, se);
434 
435             throw se;
436         }
437     }
438 
439     private static Log _log = LogFactoryUtil.getLog(ShoppingCouponServiceHttp.class);
440 }