1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.shopping.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.shopping.service.ShoppingItemServiceUtil;
28  
29  /**
30   * <a href="ShoppingItemServiceHttp.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.shopping.service.ShoppingItemServiceUtil} 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       ShoppingItemServiceSoap
62   * @see       com.liferay.portal.security.auth.HttpPrincipal
63   * @see       com.liferay.portlet.shopping.service.ShoppingItemServiceUtil
64   * @generated
65   */
66  public class ShoppingItemServiceHttp {
67      public static void addBookItems(HttpPrincipal httpPrincipal, long groupId,
68          long categoryId, java.lang.String[] isbns)
69          throws com.liferay.portal.kernel.exception.PortalException,
70              com.liferay.portal.kernel.exception.SystemException {
71          try {
72              Object paramObj0 = new LongWrapper(groupId);
73  
74              Object paramObj1 = new LongWrapper(categoryId);
75  
76              Object paramObj2 = isbns;
77  
78              if (isbns == null) {
79                  paramObj2 = new NullWrapper("[Ljava.lang.String;");
80              }
81  
82              MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
83                      "addBookItems",
84                      new Object[] { paramObj0, paramObj1, paramObj2 });
85  
86              try {
87                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
88              }
89              catch (Exception e) {
90                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
91                      throw (com.liferay.portal.kernel.exception.PortalException)e;
92                  }
93  
94                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
95                      throw (com.liferay.portal.kernel.exception.SystemException)e;
96                  }
97  
98                  throw new com.liferay.portal.kernel.exception.SystemException(e);
99              }
100         }
101         catch (com.liferay.portal.kernel.exception.SystemException se) {
102             _log.error(se, se);
103 
104             throw se;
105         }
106     }
107 
108     public static com.liferay.portlet.shopping.model.ShoppingItem addItem(
109         HttpPrincipal httpPrincipal, long groupId, long categoryId,
110         java.lang.String sku, java.lang.String name,
111         java.lang.String description, java.lang.String properties,
112         java.lang.String fieldsQuantities, boolean requiresShipping,
113         int stockQuantity, boolean featured, java.lang.Boolean sale,
114         boolean smallImage, java.lang.String smallImageURL,
115         java.io.File smallFile, boolean mediumImage,
116         java.lang.String mediumImageURL, java.io.File mediumFile,
117         boolean largeImage, java.lang.String largeImageURL,
118         java.io.File largeFile,
119         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
120         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices,
121         com.liferay.portal.service.ServiceContext serviceContext)
122         throws com.liferay.portal.kernel.exception.PortalException,
123             com.liferay.portal.kernel.exception.SystemException {
124         try {
125             Object paramObj0 = new LongWrapper(groupId);
126 
127             Object paramObj1 = new LongWrapper(categoryId);
128 
129             Object paramObj2 = sku;
130 
131             if (sku == null) {
132                 paramObj2 = new NullWrapper("java.lang.String");
133             }
134 
135             Object paramObj3 = name;
136 
137             if (name == null) {
138                 paramObj3 = new NullWrapper("java.lang.String");
139             }
140 
141             Object paramObj4 = description;
142 
143             if (description == null) {
144                 paramObj4 = new NullWrapper("java.lang.String");
145             }
146 
147             Object paramObj5 = properties;
148 
149             if (properties == null) {
150                 paramObj5 = new NullWrapper("java.lang.String");
151             }
152 
153             Object paramObj6 = fieldsQuantities;
154 
155             if (fieldsQuantities == null) {
156                 paramObj6 = new NullWrapper("java.lang.String");
157             }
158 
159             Object paramObj7 = new BooleanWrapper(requiresShipping);
160 
161             Object paramObj8 = new IntegerWrapper(stockQuantity);
162 
163             Object paramObj9 = new BooleanWrapper(featured);
164 
165             Object paramObj10 = sale;
166 
167             if (sale == null) {
168                 paramObj10 = new NullWrapper("java.lang.Boolean");
169             }
170 
171             Object paramObj11 = new BooleanWrapper(smallImage);
172 
173             Object paramObj12 = smallImageURL;
174 
175             if (smallImageURL == null) {
176                 paramObj12 = new NullWrapper("java.lang.String");
177             }
178 
179             Object paramObj13 = smallFile;
180 
181             if (smallFile == null) {
182                 paramObj13 = new NullWrapper("java.io.File");
183             }
184 
185             Object paramObj14 = new BooleanWrapper(mediumImage);
186 
187             Object paramObj15 = mediumImageURL;
188 
189             if (mediumImageURL == null) {
190                 paramObj15 = new NullWrapper("java.lang.String");
191             }
192 
193             Object paramObj16 = mediumFile;
194 
195             if (mediumFile == null) {
196                 paramObj16 = new NullWrapper("java.io.File");
197             }
198 
199             Object paramObj17 = new BooleanWrapper(largeImage);
200 
201             Object paramObj18 = largeImageURL;
202 
203             if (largeImageURL == null) {
204                 paramObj18 = new NullWrapper("java.lang.String");
205             }
206 
207             Object paramObj19 = largeFile;
208 
209             if (largeFile == null) {
210                 paramObj19 = new NullWrapper("java.io.File");
211             }
212 
213             Object paramObj20 = itemFields;
214 
215             if (itemFields == null) {
216                 paramObj20 = new NullWrapper("java.util.List");
217             }
218 
219             Object paramObj21 = itemPrices;
220 
221             if (itemPrices == null) {
222                 paramObj21 = new NullWrapper("java.util.List");
223             }
224 
225             Object paramObj22 = serviceContext;
226 
227             if (serviceContext == null) {
228                 paramObj22 = new NullWrapper(
229                         "com.liferay.portal.service.ServiceContext");
230             }
231 
232             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
233                     "addItem",
234                     new Object[] {
235                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
236                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
237                         paramObj10, paramObj11, paramObj12, paramObj13,
238                         paramObj14, paramObj15, paramObj16, paramObj17,
239                         paramObj18, paramObj19, paramObj20, paramObj21,
240                         paramObj22
241                     });
242 
243             Object returnObj = null;
244 
245             try {
246                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
247             }
248             catch (Exception e) {
249                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
250                     throw (com.liferay.portal.kernel.exception.PortalException)e;
251                 }
252 
253                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
254                     throw (com.liferay.portal.kernel.exception.SystemException)e;
255                 }
256 
257                 throw new com.liferay.portal.kernel.exception.SystemException(e);
258             }
259 
260             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
261         }
262         catch (com.liferay.portal.kernel.exception.SystemException se) {
263             _log.error(se, se);
264 
265             throw se;
266         }
267     }
268 
269     public static void deleteItem(HttpPrincipal httpPrincipal, long itemId)
270         throws com.liferay.portal.kernel.exception.PortalException,
271             com.liferay.portal.kernel.exception.SystemException {
272         try {
273             Object paramObj0 = new LongWrapper(itemId);
274 
275             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
276                     "deleteItem", new Object[] { paramObj0 });
277 
278             try {
279                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
280             }
281             catch (Exception e) {
282                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
283                     throw (com.liferay.portal.kernel.exception.PortalException)e;
284                 }
285 
286                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
287                     throw (com.liferay.portal.kernel.exception.SystemException)e;
288                 }
289 
290                 throw new com.liferay.portal.kernel.exception.SystemException(e);
291             }
292         }
293         catch (com.liferay.portal.kernel.exception.SystemException se) {
294             _log.error(se, se);
295 
296             throw se;
297         }
298     }
299 
300     public static com.liferay.portlet.shopping.model.ShoppingItem getItem(
301         HttpPrincipal httpPrincipal, long itemId)
302         throws com.liferay.portal.kernel.exception.PortalException,
303             com.liferay.portal.kernel.exception.SystemException {
304         try {
305             Object paramObj0 = new LongWrapper(itemId);
306 
307             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
308                     "getItem", new Object[] { paramObj0 });
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.kernel.exception.PortalException) {
317                     throw (com.liferay.portal.kernel.exception.PortalException)e;
318                 }
319 
320                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
321                     throw (com.liferay.portal.kernel.exception.SystemException)e;
322                 }
323 
324                 throw new com.liferay.portal.kernel.exception.SystemException(e);
325             }
326 
327             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
328         }
329         catch (com.liferay.portal.kernel.exception.SystemException se) {
330             _log.error(se, se);
331 
332             throw se;
333         }
334     }
335 
336     public static com.liferay.portlet.shopping.model.ShoppingItem updateItem(
337         HttpPrincipal httpPrincipal, long itemId, long groupId,
338         long categoryId, java.lang.String sku, java.lang.String name,
339         java.lang.String description, java.lang.String properties,
340         java.lang.String fieldsQuantities, boolean requiresShipping,
341         int stockQuantity, boolean featured, java.lang.Boolean sale,
342         boolean smallImage, java.lang.String smallImageURL,
343         java.io.File smallFile, boolean mediumImage,
344         java.lang.String mediumImageURL, java.io.File mediumFile,
345         boolean largeImage, java.lang.String largeImageURL,
346         java.io.File largeFile,
347         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
348         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices,
349         com.liferay.portal.service.ServiceContext serviceContext)
350         throws com.liferay.portal.kernel.exception.PortalException,
351             com.liferay.portal.kernel.exception.SystemException {
352         try {
353             Object paramObj0 = new LongWrapper(itemId);
354 
355             Object paramObj1 = new LongWrapper(groupId);
356 
357             Object paramObj2 = new LongWrapper(categoryId);
358 
359             Object paramObj3 = sku;
360 
361             if (sku == null) {
362                 paramObj3 = new NullWrapper("java.lang.String");
363             }
364 
365             Object paramObj4 = name;
366 
367             if (name == null) {
368                 paramObj4 = new NullWrapper("java.lang.String");
369             }
370 
371             Object paramObj5 = description;
372 
373             if (description == null) {
374                 paramObj5 = new NullWrapper("java.lang.String");
375             }
376 
377             Object paramObj6 = properties;
378 
379             if (properties == null) {
380                 paramObj6 = new NullWrapper("java.lang.String");
381             }
382 
383             Object paramObj7 = fieldsQuantities;
384 
385             if (fieldsQuantities == null) {
386                 paramObj7 = new NullWrapper("java.lang.String");
387             }
388 
389             Object paramObj8 = new BooleanWrapper(requiresShipping);
390 
391             Object paramObj9 = new IntegerWrapper(stockQuantity);
392 
393             Object paramObj10 = new BooleanWrapper(featured);
394 
395             Object paramObj11 = sale;
396 
397             if (sale == null) {
398                 paramObj11 = new NullWrapper("java.lang.Boolean");
399             }
400 
401             Object paramObj12 = new BooleanWrapper(smallImage);
402 
403             Object paramObj13 = smallImageURL;
404 
405             if (smallImageURL == null) {
406                 paramObj13 = new NullWrapper("java.lang.String");
407             }
408 
409             Object paramObj14 = smallFile;
410 
411             if (smallFile == null) {
412                 paramObj14 = new NullWrapper("java.io.File");
413             }
414 
415             Object paramObj15 = new BooleanWrapper(mediumImage);
416 
417             Object paramObj16 = mediumImageURL;
418 
419             if (mediumImageURL == null) {
420                 paramObj16 = new NullWrapper("java.lang.String");
421             }
422 
423             Object paramObj17 = mediumFile;
424 
425             if (mediumFile == null) {
426                 paramObj17 = new NullWrapper("java.io.File");
427             }
428 
429             Object paramObj18 = new BooleanWrapper(largeImage);
430 
431             Object paramObj19 = largeImageURL;
432 
433             if (largeImageURL == null) {
434                 paramObj19 = new NullWrapper("java.lang.String");
435             }
436 
437             Object paramObj20 = largeFile;
438 
439             if (largeFile == null) {
440                 paramObj20 = new NullWrapper("java.io.File");
441             }
442 
443             Object paramObj21 = itemFields;
444 
445             if (itemFields == null) {
446                 paramObj21 = new NullWrapper("java.util.List");
447             }
448 
449             Object paramObj22 = itemPrices;
450 
451             if (itemPrices == null) {
452                 paramObj22 = new NullWrapper("java.util.List");
453             }
454 
455             Object paramObj23 = serviceContext;
456 
457             if (serviceContext == null) {
458                 paramObj23 = new NullWrapper(
459                         "com.liferay.portal.service.ServiceContext");
460             }
461 
462             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
463                     "updateItem",
464                     new Object[] {
465                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
466                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
467                         paramObj10, paramObj11, paramObj12, paramObj13,
468                         paramObj14, paramObj15, paramObj16, paramObj17,
469                         paramObj18, paramObj19, paramObj20, paramObj21,
470                         paramObj22, paramObj23
471                     });
472 
473             Object returnObj = null;
474 
475             try {
476                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
477             }
478             catch (Exception e) {
479                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
480                     throw (com.liferay.portal.kernel.exception.PortalException)e;
481                 }
482 
483                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
484                     throw (com.liferay.portal.kernel.exception.SystemException)e;
485                 }
486 
487                 throw new com.liferay.portal.kernel.exception.SystemException(e);
488             }
489 
490             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
491         }
492         catch (com.liferay.portal.kernel.exception.SystemException se) {
493             _log.error(se, se);
494 
495             throw se;
496         }
497     }
498 
499     private static Log _log = LogFactoryUtil.getLog(ShoppingItemServiceHttp.class);
500 }