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.IntegerWrapper;
26  import com.liferay.portal.kernel.util.LongWrapper;
27  import com.liferay.portal.kernel.util.MethodWrapper;
28  import com.liferay.portal.kernel.util.NullWrapper;
29  import com.liferay.portal.security.auth.HttpPrincipal;
30  import com.liferay.portal.service.http.TunnelUtil;
31  
32  import com.liferay.portlet.shopping.service.ShoppingItemServiceUtil;
33  
34  /**
35   * <a href="ShoppingItemServiceHttp.java.html"><b><i>View Source</i></b></a>
36   *
37   * <p>
38   * ServiceBuilder generated this class. Modifications in this class will be
39   * overwritten the next time is generated.
40   * </p>
41   *
42   * <p>
43   * This class provides a HTTP utility for the
44   * <code>com.liferay.portlet.shopping.service.ShoppingItemServiceUtil</code> service
45   * utility. The static methods of this class calls the same methods of the
46   * service utility. However, the signatures are different because it requires an
47   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
48   * parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for
53   * tunneling without the cost of serializing to text. The drawback is that it
54   * only works with Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
59   * portal.properties to configure security.
60   * </p>
61   *
62   * <p>
63   * The HTTP utility is only generated for remote services.
64   * </p>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   * @see com.liferay.portal.security.auth.HttpPrincipal
69   * @see com.liferay.portlet.shopping.service.ShoppingItemServiceUtil
70   * @see com.liferay.portlet.shopping.service.http.ShoppingItemServiceSoap
71   *
72   */
73  public class ShoppingItemServiceHttp {
74      public static void addBookItems(HttpPrincipal httpPrincipal,
75          long categoryId, java.lang.String[] isbns)
76          throws com.liferay.portal.PortalException,
77              com.liferay.portal.SystemException {
78          try {
79              Object paramObj0 = new LongWrapper(categoryId);
80  
81              Object paramObj1 = isbns;
82  
83              if (isbns == null) {
84                  paramObj1 = new NullWrapper("[Ljava.lang.String;");
85              }
86  
87              MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
88                      "addBookItems", new Object[] { paramObj0, paramObj1 });
89  
90              try {
91                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
92              }
93              catch (Exception e) {
94                  if (e instanceof com.liferay.portal.PortalException) {
95                      throw (com.liferay.portal.PortalException)e;
96                  }
97  
98                  if (e instanceof com.liferay.portal.SystemException) {
99                      throw (com.liferay.portal.SystemException)e;
100                 }
101 
102                 throw new com.liferay.portal.SystemException(e);
103             }
104         }
105         catch (com.liferay.portal.SystemException se) {
106             _log.error(se, se);
107 
108             throw se;
109         }
110     }
111 
112     public static com.liferay.portlet.shopping.model.ShoppingItem addItem(
113         HttpPrincipal httpPrincipal, long categoryId, java.lang.String sku,
114         java.lang.String name, java.lang.String description,
115         java.lang.String properties, java.lang.String fieldsQuantities,
116         boolean requiresShipping, int stockQuantity, boolean featured,
117         java.lang.Boolean sale, boolean smallImage,
118         java.lang.String smallImageURL, java.io.File smallFile,
119         boolean mediumImage, java.lang.String mediumImageURL,
120         java.io.File mediumFile, boolean largeImage,
121         java.lang.String largeImageURL, java.io.File largeFile,
122         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
123         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices,
124         boolean addCommunityPermissions, boolean addGuestPermissions)
125         throws com.liferay.portal.PortalException,
126             com.liferay.portal.SystemException {
127         try {
128             Object paramObj0 = new LongWrapper(categoryId);
129 
130             Object paramObj1 = sku;
131 
132             if (sku == null) {
133                 paramObj1 = new NullWrapper("java.lang.String");
134             }
135 
136             Object paramObj2 = name;
137 
138             if (name == null) {
139                 paramObj2 = new NullWrapper("java.lang.String");
140             }
141 
142             Object paramObj3 = description;
143 
144             if (description == null) {
145                 paramObj3 = new NullWrapper("java.lang.String");
146             }
147 
148             Object paramObj4 = properties;
149 
150             if (properties == null) {
151                 paramObj4 = new NullWrapper("java.lang.String");
152             }
153 
154             Object paramObj5 = fieldsQuantities;
155 
156             if (fieldsQuantities == null) {
157                 paramObj5 = new NullWrapper("java.lang.String");
158             }
159 
160             Object paramObj6 = new BooleanWrapper(requiresShipping);
161 
162             Object paramObj7 = new IntegerWrapper(stockQuantity);
163 
164             Object paramObj8 = new BooleanWrapper(featured);
165 
166             Object paramObj9 = sale;
167 
168             if (sale == null) {
169                 paramObj9 = new NullWrapper("java.lang.Boolean");
170             }
171 
172             Object paramObj10 = new BooleanWrapper(smallImage);
173 
174             Object paramObj11 = smallImageURL;
175 
176             if (smallImageURL == null) {
177                 paramObj11 = new NullWrapper("java.lang.String");
178             }
179 
180             Object paramObj12 = smallFile;
181 
182             if (smallFile == null) {
183                 paramObj12 = new NullWrapper("java.io.File");
184             }
185 
186             Object paramObj13 = new BooleanWrapper(mediumImage);
187 
188             Object paramObj14 = mediumImageURL;
189 
190             if (mediumImageURL == null) {
191                 paramObj14 = new NullWrapper("java.lang.String");
192             }
193 
194             Object paramObj15 = mediumFile;
195 
196             if (mediumFile == null) {
197                 paramObj15 = new NullWrapper("java.io.File");
198             }
199 
200             Object paramObj16 = new BooleanWrapper(largeImage);
201 
202             Object paramObj17 = largeImageURL;
203 
204             if (largeImageURL == null) {
205                 paramObj17 = new NullWrapper("java.lang.String");
206             }
207 
208             Object paramObj18 = largeFile;
209 
210             if (largeFile == null) {
211                 paramObj18 = new NullWrapper("java.io.File");
212             }
213 
214             Object paramObj19 = itemFields;
215 
216             if (itemFields == null) {
217                 paramObj19 = new NullWrapper("java.util.List");
218             }
219 
220             Object paramObj20 = itemPrices;
221 
222             if (itemPrices == null) {
223                 paramObj20 = new NullWrapper("java.util.List");
224             }
225 
226             Object paramObj21 = new BooleanWrapper(addCommunityPermissions);
227 
228             Object paramObj22 = new BooleanWrapper(addGuestPermissions);
229 
230             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
231                     "addItem",
232                     new Object[] {
233                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
234                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
235                         paramObj10, paramObj11, paramObj12, paramObj13,
236                         paramObj14, paramObj15, paramObj16, paramObj17,
237                         paramObj18, paramObj19, paramObj20, paramObj21,
238                         paramObj22
239                     });
240 
241             Object returnObj = null;
242 
243             try {
244                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
245             }
246             catch (Exception e) {
247                 if (e instanceof com.liferay.portal.PortalException) {
248                     throw (com.liferay.portal.PortalException)e;
249                 }
250 
251                 if (e instanceof com.liferay.portal.SystemException) {
252                     throw (com.liferay.portal.SystemException)e;
253                 }
254 
255                 throw new com.liferay.portal.SystemException(e);
256             }
257 
258             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
259         }
260         catch (com.liferay.portal.SystemException se) {
261             _log.error(se, se);
262 
263             throw se;
264         }
265     }
266 
267     public static com.liferay.portlet.shopping.model.ShoppingItem addItem(
268         HttpPrincipal httpPrincipal, long categoryId, java.lang.String sku,
269         java.lang.String name, java.lang.String description,
270         java.lang.String properties, java.lang.String fieldsQuantities,
271         boolean requiresShipping, int stockQuantity, boolean featured,
272         java.lang.Boolean sale, boolean smallImage,
273         java.lang.String smallImageURL, java.io.File smallFile,
274         boolean mediumImage, java.lang.String mediumImageURL,
275         java.io.File mediumFile, boolean largeImage,
276         java.lang.String largeImageURL, java.io.File largeFile,
277         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
278         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices,
279         java.lang.String[] communityPermissions,
280         java.lang.String[] guestPermissions)
281         throws com.liferay.portal.PortalException,
282             com.liferay.portal.SystemException {
283         try {
284             Object paramObj0 = new LongWrapper(categoryId);
285 
286             Object paramObj1 = sku;
287 
288             if (sku == null) {
289                 paramObj1 = new NullWrapper("java.lang.String");
290             }
291 
292             Object paramObj2 = name;
293 
294             if (name == null) {
295                 paramObj2 = new NullWrapper("java.lang.String");
296             }
297 
298             Object paramObj3 = description;
299 
300             if (description == null) {
301                 paramObj3 = new NullWrapper("java.lang.String");
302             }
303 
304             Object paramObj4 = properties;
305 
306             if (properties == null) {
307                 paramObj4 = new NullWrapper("java.lang.String");
308             }
309 
310             Object paramObj5 = fieldsQuantities;
311 
312             if (fieldsQuantities == null) {
313                 paramObj5 = new NullWrapper("java.lang.String");
314             }
315 
316             Object paramObj6 = new BooleanWrapper(requiresShipping);
317 
318             Object paramObj7 = new IntegerWrapper(stockQuantity);
319 
320             Object paramObj8 = new BooleanWrapper(featured);
321 
322             Object paramObj9 = sale;
323 
324             if (sale == null) {
325                 paramObj9 = new NullWrapper("java.lang.Boolean");
326             }
327 
328             Object paramObj10 = new BooleanWrapper(smallImage);
329 
330             Object paramObj11 = smallImageURL;
331 
332             if (smallImageURL == null) {
333                 paramObj11 = new NullWrapper("java.lang.String");
334             }
335 
336             Object paramObj12 = smallFile;
337 
338             if (smallFile == null) {
339                 paramObj12 = new NullWrapper("java.io.File");
340             }
341 
342             Object paramObj13 = new BooleanWrapper(mediumImage);
343 
344             Object paramObj14 = mediumImageURL;
345 
346             if (mediumImageURL == null) {
347                 paramObj14 = new NullWrapper("java.lang.String");
348             }
349 
350             Object paramObj15 = mediumFile;
351 
352             if (mediumFile == null) {
353                 paramObj15 = new NullWrapper("java.io.File");
354             }
355 
356             Object paramObj16 = new BooleanWrapper(largeImage);
357 
358             Object paramObj17 = largeImageURL;
359 
360             if (largeImageURL == null) {
361                 paramObj17 = new NullWrapper("java.lang.String");
362             }
363 
364             Object paramObj18 = largeFile;
365 
366             if (largeFile == null) {
367                 paramObj18 = new NullWrapper("java.io.File");
368             }
369 
370             Object paramObj19 = itemFields;
371 
372             if (itemFields == null) {
373                 paramObj19 = new NullWrapper("java.util.List");
374             }
375 
376             Object paramObj20 = itemPrices;
377 
378             if (itemPrices == null) {
379                 paramObj20 = new NullWrapper("java.util.List");
380             }
381 
382             Object paramObj21 = communityPermissions;
383 
384             if (communityPermissions == null) {
385                 paramObj21 = new NullWrapper("[Ljava.lang.String;");
386             }
387 
388             Object paramObj22 = guestPermissions;
389 
390             if (guestPermissions == null) {
391                 paramObj22 = new NullWrapper("[Ljava.lang.String;");
392             }
393 
394             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
395                     "addItem",
396                     new Object[] {
397                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
398                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
399                         paramObj10, paramObj11, paramObj12, paramObj13,
400                         paramObj14, paramObj15, paramObj16, paramObj17,
401                         paramObj18, paramObj19, paramObj20, paramObj21,
402                         paramObj22
403                     });
404 
405             Object returnObj = null;
406 
407             try {
408                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
409             }
410             catch (Exception e) {
411                 if (e instanceof com.liferay.portal.PortalException) {
412                     throw (com.liferay.portal.PortalException)e;
413                 }
414 
415                 if (e instanceof com.liferay.portal.SystemException) {
416                     throw (com.liferay.portal.SystemException)e;
417                 }
418 
419                 throw new com.liferay.portal.SystemException(e);
420             }
421 
422             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
423         }
424         catch (com.liferay.portal.SystemException se) {
425             _log.error(se, se);
426 
427             throw se;
428         }
429     }
430 
431     public static void deleteItem(HttpPrincipal httpPrincipal, long itemId)
432         throws com.liferay.portal.PortalException,
433             com.liferay.portal.SystemException {
434         try {
435             Object paramObj0 = new LongWrapper(itemId);
436 
437             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
438                     "deleteItem", new Object[] { paramObj0 });
439 
440             try {
441                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
442             }
443             catch (Exception e) {
444                 if (e instanceof com.liferay.portal.PortalException) {
445                     throw (com.liferay.portal.PortalException)e;
446                 }
447 
448                 if (e instanceof com.liferay.portal.SystemException) {
449                     throw (com.liferay.portal.SystemException)e;
450                 }
451 
452                 throw new com.liferay.portal.SystemException(e);
453             }
454         }
455         catch (com.liferay.portal.SystemException se) {
456             _log.error(se, se);
457 
458             throw se;
459         }
460     }
461 
462     public static com.liferay.portlet.shopping.model.ShoppingItem getItem(
463         HttpPrincipal httpPrincipal, long itemId)
464         throws com.liferay.portal.PortalException,
465             com.liferay.portal.SystemException {
466         try {
467             Object paramObj0 = new LongWrapper(itemId);
468 
469             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
470                     "getItem", new Object[] { paramObj0 });
471 
472             Object returnObj = null;
473 
474             try {
475                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
476             }
477             catch (Exception e) {
478                 if (e instanceof com.liferay.portal.PortalException) {
479                     throw (com.liferay.portal.PortalException)e;
480                 }
481 
482                 if (e instanceof com.liferay.portal.SystemException) {
483                     throw (com.liferay.portal.SystemException)e;
484                 }
485 
486                 throw new com.liferay.portal.SystemException(e);
487             }
488 
489             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
490         }
491         catch (com.liferay.portal.SystemException se) {
492             _log.error(se, se);
493 
494             throw se;
495         }
496     }
497 
498     public static com.liferay.portlet.shopping.model.ShoppingItem updateItem(
499         HttpPrincipal httpPrincipal, long itemId, long categoryId,
500         java.lang.String sku, java.lang.String name,
501         java.lang.String description, java.lang.String properties,
502         java.lang.String fieldsQuantities, boolean requiresShipping,
503         int stockQuantity, boolean featured, java.lang.Boolean sale,
504         boolean smallImage, java.lang.String smallImageURL,
505         java.io.File smallFile, boolean mediumImage,
506         java.lang.String mediumImageURL, java.io.File mediumFile,
507         boolean largeImage, java.lang.String largeImageURL,
508         java.io.File largeFile,
509         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
510         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices)
511         throws com.liferay.portal.PortalException,
512             com.liferay.portal.SystemException {
513         try {
514             Object paramObj0 = new LongWrapper(itemId);
515 
516             Object paramObj1 = new LongWrapper(categoryId);
517 
518             Object paramObj2 = sku;
519 
520             if (sku == null) {
521                 paramObj2 = new NullWrapper("java.lang.String");
522             }
523 
524             Object paramObj3 = name;
525 
526             if (name == null) {
527                 paramObj3 = new NullWrapper("java.lang.String");
528             }
529 
530             Object paramObj4 = description;
531 
532             if (description == null) {
533                 paramObj4 = new NullWrapper("java.lang.String");
534             }
535 
536             Object paramObj5 = properties;
537 
538             if (properties == null) {
539                 paramObj5 = new NullWrapper("java.lang.String");
540             }
541 
542             Object paramObj6 = fieldsQuantities;
543 
544             if (fieldsQuantities == null) {
545                 paramObj6 = new NullWrapper("java.lang.String");
546             }
547 
548             Object paramObj7 = new BooleanWrapper(requiresShipping);
549 
550             Object paramObj8 = new IntegerWrapper(stockQuantity);
551 
552             Object paramObj9 = new BooleanWrapper(featured);
553 
554             Object paramObj10 = sale;
555 
556             if (sale == null) {
557                 paramObj10 = new NullWrapper("java.lang.Boolean");
558             }
559 
560             Object paramObj11 = new BooleanWrapper(smallImage);
561 
562             Object paramObj12 = smallImageURL;
563 
564             if (smallImageURL == null) {
565                 paramObj12 = new NullWrapper("java.lang.String");
566             }
567 
568             Object paramObj13 = smallFile;
569 
570             if (smallFile == null) {
571                 paramObj13 = new NullWrapper("java.io.File");
572             }
573 
574             Object paramObj14 = new BooleanWrapper(mediumImage);
575 
576             Object paramObj15 = mediumImageURL;
577 
578             if (mediumImageURL == null) {
579                 paramObj15 = new NullWrapper("java.lang.String");
580             }
581 
582             Object paramObj16 = mediumFile;
583 
584             if (mediumFile == null) {
585                 paramObj16 = new NullWrapper("java.io.File");
586             }
587 
588             Object paramObj17 = new BooleanWrapper(largeImage);
589 
590             Object paramObj18 = largeImageURL;
591 
592             if (largeImageURL == null) {
593                 paramObj18 = new NullWrapper("java.lang.String");
594             }
595 
596             Object paramObj19 = largeFile;
597 
598             if (largeFile == null) {
599                 paramObj19 = new NullWrapper("java.io.File");
600             }
601 
602             Object paramObj20 = itemFields;
603 
604             if (itemFields == null) {
605                 paramObj20 = new NullWrapper("java.util.List");
606             }
607 
608             Object paramObj21 = itemPrices;
609 
610             if (itemPrices == null) {
611                 paramObj21 = new NullWrapper("java.util.List");
612             }
613 
614             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
615                     "updateItem",
616                     new Object[] {
617                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
618                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
619                         paramObj10, paramObj11, paramObj12, paramObj13,
620                         paramObj14, paramObj15, paramObj16, paramObj17,
621                         paramObj18, paramObj19, paramObj20, paramObj21
622                     });
623 
624             Object returnObj = null;
625 
626             try {
627                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
628             }
629             catch (Exception e) {
630                 if (e instanceof com.liferay.portal.PortalException) {
631                     throw (com.liferay.portal.PortalException)e;
632                 }
633 
634                 if (e instanceof com.liferay.portal.SystemException) {
635                     throw (com.liferay.portal.SystemException)e;
636                 }
637 
638                 throw new com.liferay.portal.SystemException(e);
639             }
640 
641             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
642         }
643         catch (com.liferay.portal.SystemException se) {
644             _log.error(se, se);
645 
646             throw se;
647         }
648     }
649 
650     private static Log _log = LogFactoryUtil.getLog(ShoppingItemServiceHttp.class);
651 }