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