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.IntegerWrapper;
29  import com.liferay.portal.kernel.util.LongWrapper;
30  import com.liferay.portal.kernel.util.MethodWrapper;
31  import com.liferay.portal.kernel.util.NullWrapper;
32  import com.liferay.portal.security.auth.HttpPrincipal;
33  import com.liferay.portal.service.http.TunnelUtil;
34  
35  import com.liferay.portlet.shopping.service.ShoppingItemServiceUtil;
36  
37  /**
38   * <a href="ShoppingItemServiceHttp.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class provides a HTTP utility for the
47   * <code>com.liferay.portlet.shopping.service.ShoppingItemServiceUtil</code> service
48   * utility. The static methods of this class calls the same methods of the
49   * service utility. However, the signatures are different because it requires an
50   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
51   * parameter.
52   * </p>
53   *
54   * <p>
55   * The benefits of using the HTTP utility is that it is fast and allows for
56   * tunneling without the cost of serializing to text. The drawback is that it
57   * only works with Java.
58   * </p>
59   *
60   * <p>
61   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
62   * portal.properties to configure security.
63   * </p>
64   *
65   * <p>
66   * The HTTP utility is only generated for remote services.
67   * </p>
68   *
69   * @author Brian Wing Shun Chan
70   *
71   * @see com.liferay.portal.security.auth.HttpPrincipal
72   * @see com.liferay.portlet.shopping.service.ShoppingItemServiceUtil
73   * @see com.liferay.portlet.shopping.service.http.ShoppingItemServiceSoap
74   *
75   */
76  public class ShoppingItemServiceHttp {
77      public static void addBookItems(HttpPrincipal httpPrincipal,
78          long categoryId, java.lang.String[] isbns)
79          throws com.liferay.portal.SystemException, 
80              com.liferay.portal.PortalException {
81          try {
82              Object paramObj0 = new LongWrapper(categoryId);
83  
84              Object paramObj1 = isbns;
85  
86              if (isbns == null) {
87                  paramObj1 = new NullWrapper("[Ljava.lang.String;");
88              }
89  
90              MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
91                      "addBookItems", new Object[] { paramObj0, paramObj1 });
92  
93              try {
94                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
95              }
96              catch (Exception e) {
97                  if (e instanceof com.liferay.portal.SystemException) {
98                      throw (com.liferay.portal.SystemException)e;
99                  }
100 
101                 if (e instanceof com.liferay.portal.PortalException) {
102                     throw (com.liferay.portal.PortalException)e;
103                 }
104 
105                 throw new com.liferay.portal.SystemException(e);
106             }
107         }
108         catch (com.liferay.portal.SystemException se) {
109             _log.error(se, se);
110 
111             throw se;
112         }
113     }
114 
115     public static com.liferay.portlet.shopping.model.ShoppingItem addItem(
116         HttpPrincipal httpPrincipal, long categoryId, java.lang.String sku,
117         java.lang.String name, java.lang.String description,
118         java.lang.String properties, java.lang.String fieldsQuantities,
119         boolean requiresShipping, int stockQuantity, boolean featured,
120         java.lang.Boolean sale, boolean smallImage,
121         java.lang.String smallImageURL, java.io.File smallFile,
122         boolean mediumImage, java.lang.String mediumImageURL,
123         java.io.File mediumFile, boolean largeImage,
124         java.lang.String largeImageURL, java.io.File largeFile,
125         java.util.List itemFields, java.util.List itemPrices,
126         boolean addCommunityPermissions, boolean addGuestPermissions)
127         throws com.liferay.portal.SystemException, 
128             com.liferay.portal.PortalException {
129         try {
130             Object paramObj0 = new LongWrapper(categoryId);
131 
132             Object paramObj1 = sku;
133 
134             if (sku == null) {
135                 paramObj1 = new NullWrapper("java.lang.String");
136             }
137 
138             Object paramObj2 = name;
139 
140             if (name == null) {
141                 paramObj2 = new NullWrapper("java.lang.String");
142             }
143 
144             Object paramObj3 = description;
145 
146             if (description == null) {
147                 paramObj3 = new NullWrapper("java.lang.String");
148             }
149 
150             Object paramObj4 = properties;
151 
152             if (properties == null) {
153                 paramObj4 = new NullWrapper("java.lang.String");
154             }
155 
156             Object paramObj5 = fieldsQuantities;
157 
158             if (fieldsQuantities == null) {
159                 paramObj5 = new NullWrapper("java.lang.String");
160             }
161 
162             Object paramObj6 = new BooleanWrapper(requiresShipping);
163 
164             Object paramObj7 = new IntegerWrapper(stockQuantity);
165 
166             Object paramObj8 = new BooleanWrapper(featured);
167 
168             Object paramObj9 = sale;
169 
170             if (sale == null) {
171                 paramObj9 = new NullWrapper("java.lang.Boolean");
172             }
173 
174             Object paramObj10 = new BooleanWrapper(smallImage);
175 
176             Object paramObj11 = smallImageURL;
177 
178             if (smallImageURL == null) {
179                 paramObj11 = new NullWrapper("java.lang.String");
180             }
181 
182             Object paramObj12 = smallFile;
183 
184             if (smallFile == null) {
185                 paramObj12 = new NullWrapper("java.io.File");
186             }
187 
188             Object paramObj13 = new BooleanWrapper(mediumImage);
189 
190             Object paramObj14 = mediumImageURL;
191 
192             if (mediumImageURL == null) {
193                 paramObj14 = new NullWrapper("java.lang.String");
194             }
195 
196             Object paramObj15 = mediumFile;
197 
198             if (mediumFile == null) {
199                 paramObj15 = new NullWrapper("java.io.File");
200             }
201 
202             Object paramObj16 = new BooleanWrapper(largeImage);
203 
204             Object paramObj17 = largeImageURL;
205 
206             if (largeImageURL == null) {
207                 paramObj17 = new NullWrapper("java.lang.String");
208             }
209 
210             Object paramObj18 = largeFile;
211 
212             if (largeFile == null) {
213                 paramObj18 = new NullWrapper("java.io.File");
214             }
215 
216             Object paramObj19 = itemFields;
217 
218             if (itemFields == null) {
219                 paramObj19 = new NullWrapper("java.util.List");
220             }
221 
222             Object paramObj20 = itemPrices;
223 
224             if (itemPrices == null) {
225                 paramObj20 = new NullWrapper("java.util.List");
226             }
227 
228             Object paramObj21 = new BooleanWrapper(addCommunityPermissions);
229 
230             Object paramObj22 = new BooleanWrapper(addGuestPermissions);
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.SystemException) {
250                     throw (com.liferay.portal.SystemException)e;
251                 }
252 
253                 if (e instanceof com.liferay.portal.PortalException) {
254                     throw (com.liferay.portal.PortalException)e;
255                 }
256 
257                 throw new com.liferay.portal.SystemException(e);
258             }
259 
260             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
261         }
262         catch (com.liferay.portal.SystemException se) {
263             _log.error(se, se);
264 
265             throw se;
266         }
267     }
268 
269     public static com.liferay.portlet.shopping.model.ShoppingItem addItem(
270         HttpPrincipal httpPrincipal, long categoryId, java.lang.String sku,
271         java.lang.String name, java.lang.String description,
272         java.lang.String properties, java.lang.String fieldsQuantities,
273         boolean requiresShipping, int stockQuantity, boolean featured,
274         java.lang.Boolean sale, boolean smallImage,
275         java.lang.String smallImageURL, java.io.File smallFile,
276         boolean mediumImage, java.lang.String mediumImageURL,
277         java.io.File mediumFile, boolean largeImage,
278         java.lang.String largeImageURL, java.io.File largeFile,
279         java.util.List itemFields, java.util.List itemPrices,
280         java.lang.String[] communityPermissions,
281         java.lang.String[] guestPermissions)
282         throws com.liferay.portal.SystemException, 
283             com.liferay.portal.PortalException {
284         try {
285             Object paramObj0 = new LongWrapper(categoryId);
286 
287             Object paramObj1 = sku;
288 
289             if (sku == null) {
290                 paramObj1 = new NullWrapper("java.lang.String");
291             }
292 
293             Object paramObj2 = name;
294 
295             if (name == null) {
296                 paramObj2 = new NullWrapper("java.lang.String");
297             }
298 
299             Object paramObj3 = description;
300 
301             if (description == null) {
302                 paramObj3 = new NullWrapper("java.lang.String");
303             }
304 
305             Object paramObj4 = properties;
306 
307             if (properties == null) {
308                 paramObj4 = new NullWrapper("java.lang.String");
309             }
310 
311             Object paramObj5 = fieldsQuantities;
312 
313             if (fieldsQuantities == null) {
314                 paramObj5 = new NullWrapper("java.lang.String");
315             }
316 
317             Object paramObj6 = new BooleanWrapper(requiresShipping);
318 
319             Object paramObj7 = new IntegerWrapper(stockQuantity);
320 
321             Object paramObj8 = new BooleanWrapper(featured);
322 
323             Object paramObj9 = sale;
324 
325             if (sale == null) {
326                 paramObj9 = new NullWrapper("java.lang.Boolean");
327             }
328 
329             Object paramObj10 = new BooleanWrapper(smallImage);
330 
331             Object paramObj11 = smallImageURL;
332 
333             if (smallImageURL == null) {
334                 paramObj11 = new NullWrapper("java.lang.String");
335             }
336 
337             Object paramObj12 = smallFile;
338 
339             if (smallFile == null) {
340                 paramObj12 = new NullWrapper("java.io.File");
341             }
342 
343             Object paramObj13 = new BooleanWrapper(mediumImage);
344 
345             Object paramObj14 = mediumImageURL;
346 
347             if (mediumImageURL == null) {
348                 paramObj14 = new NullWrapper("java.lang.String");
349             }
350 
351             Object paramObj15 = mediumFile;
352 
353             if (mediumFile == null) {
354                 paramObj15 = new NullWrapper("java.io.File");
355             }
356 
357             Object paramObj16 = new BooleanWrapper(largeImage);
358 
359             Object paramObj17 = largeImageURL;
360 
361             if (largeImageURL == null) {
362                 paramObj17 = new NullWrapper("java.lang.String");
363             }
364 
365             Object paramObj18 = largeFile;
366 
367             if (largeFile == null) {
368                 paramObj18 = new NullWrapper("java.io.File");
369             }
370 
371             Object paramObj19 = itemFields;
372 
373             if (itemFields == null) {
374                 paramObj19 = new NullWrapper("java.util.List");
375             }
376 
377             Object paramObj20 = itemPrices;
378 
379             if (itemPrices == null) {
380                 paramObj20 = new NullWrapper("java.util.List");
381             }
382 
383             Object paramObj21 = communityPermissions;
384 
385             if (communityPermissions == null) {
386                 paramObj21 = new NullWrapper("[Ljava.lang.String;");
387             }
388 
389             Object paramObj22 = guestPermissions;
390 
391             if (guestPermissions == null) {
392                 paramObj22 = new NullWrapper("[Ljava.lang.String;");
393             }
394 
395             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
396                     "addItem",
397                     new Object[] {
398                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
399                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
400                         paramObj10, paramObj11, paramObj12, paramObj13,
401                         paramObj14, paramObj15, paramObj16, paramObj17,
402                         paramObj18, paramObj19, paramObj20, paramObj21,
403                         paramObj22
404                     });
405 
406             Object returnObj = null;
407 
408             try {
409                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
410             }
411             catch (Exception e) {
412                 if (e instanceof com.liferay.portal.SystemException) {
413                     throw (com.liferay.portal.SystemException)e;
414                 }
415 
416                 if (e instanceof com.liferay.portal.PortalException) {
417                     throw (com.liferay.portal.PortalException)e;
418                 }
419 
420                 throw new com.liferay.portal.SystemException(e);
421             }
422 
423             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
424         }
425         catch (com.liferay.portal.SystemException se) {
426             _log.error(se, se);
427 
428             throw se;
429         }
430     }
431 
432     public static void deleteItem(HttpPrincipal httpPrincipal, long itemId)
433         throws com.liferay.portal.SystemException, 
434             com.liferay.portal.PortalException {
435         try {
436             Object paramObj0 = new LongWrapper(itemId);
437 
438             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
439                     "deleteItem", new Object[] { paramObj0 });
440 
441             try {
442                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
443             }
444             catch (Exception e) {
445                 if (e instanceof com.liferay.portal.SystemException) {
446                     throw (com.liferay.portal.SystemException)e;
447                 }
448 
449                 if (e instanceof com.liferay.portal.PortalException) {
450                     throw (com.liferay.portal.PortalException)e;
451                 }
452 
453                 throw new com.liferay.portal.SystemException(e);
454             }
455         }
456         catch (com.liferay.portal.SystemException se) {
457             _log.error(se, se);
458 
459             throw se;
460         }
461     }
462 
463     public static com.liferay.portlet.shopping.model.ShoppingItem getItem(
464         HttpPrincipal httpPrincipal, long itemId)
465         throws com.liferay.portal.SystemException, 
466             com.liferay.portal.PortalException {
467         try {
468             Object paramObj0 = new LongWrapper(itemId);
469 
470             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
471                     "getItem", new Object[] { paramObj0 });
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.SystemException) {
480                     throw (com.liferay.portal.SystemException)e;
481                 }
482 
483                 if (e instanceof com.liferay.portal.PortalException) {
484                     throw (com.liferay.portal.PortalException)e;
485                 }
486 
487                 throw new com.liferay.portal.SystemException(e);
488             }
489 
490             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
491         }
492         catch (com.liferay.portal.SystemException se) {
493             _log.error(se, se);
494 
495             throw se;
496         }
497     }
498 
499     public static com.liferay.portlet.shopping.model.ShoppingItem updateItem(
500         HttpPrincipal httpPrincipal, long itemId, long categoryId,
501         java.lang.String sku, java.lang.String name,
502         java.lang.String description, java.lang.String properties,
503         java.lang.String fieldsQuantities, boolean requiresShipping,
504         int stockQuantity, boolean featured, java.lang.Boolean sale,
505         boolean smallImage, java.lang.String smallImageURL,
506         java.io.File smallFile, boolean mediumImage,
507         java.lang.String mediumImageURL, java.io.File mediumFile,
508         boolean largeImage, java.lang.String largeImageURL,
509         java.io.File largeFile, java.util.List itemFields,
510         java.util.List itemPrices)
511         throws com.liferay.portal.SystemException, 
512             com.liferay.portal.PortalException {
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.SystemException) {
631                     throw (com.liferay.portal.SystemException)e;
632                 }
633 
634                 if (e instanceof com.liferay.portal.PortalException) {
635                     throw (com.liferay.portal.PortalException)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 }