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<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
126         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices,
127         boolean addCommunityPermissions, boolean addGuestPermissions)
128         throws com.liferay.portal.SystemException,
129             com.liferay.portal.PortalException {
130         try {
131             Object paramObj0 = new LongWrapper(categoryId);
132 
133             Object paramObj1 = sku;
134 
135             if (sku == null) {
136                 paramObj1 = new NullWrapper("java.lang.String");
137             }
138 
139             Object paramObj2 = name;
140 
141             if (name == null) {
142                 paramObj2 = new NullWrapper("java.lang.String");
143             }
144 
145             Object paramObj3 = description;
146 
147             if (description == null) {
148                 paramObj3 = new NullWrapper("java.lang.String");
149             }
150 
151             Object paramObj4 = properties;
152 
153             if (properties == null) {
154                 paramObj4 = new NullWrapper("java.lang.String");
155             }
156 
157             Object paramObj5 = fieldsQuantities;
158 
159             if (fieldsQuantities == null) {
160                 paramObj5 = new NullWrapper("java.lang.String");
161             }
162 
163             Object paramObj6 = new BooleanWrapper(requiresShipping);
164 
165             Object paramObj7 = new IntegerWrapper(stockQuantity);
166 
167             Object paramObj8 = new BooleanWrapper(featured);
168 
169             Object paramObj9 = sale;
170 
171             if (sale == null) {
172                 paramObj9 = new NullWrapper("java.lang.Boolean");
173             }
174 
175             Object paramObj10 = new BooleanWrapper(smallImage);
176 
177             Object paramObj11 = smallImageURL;
178 
179             if (smallImageURL == null) {
180                 paramObj11 = new NullWrapper("java.lang.String");
181             }
182 
183             Object paramObj12 = smallFile;
184 
185             if (smallFile == null) {
186                 paramObj12 = new NullWrapper("java.io.File");
187             }
188 
189             Object paramObj13 = new BooleanWrapper(mediumImage);
190 
191             Object paramObj14 = mediumImageURL;
192 
193             if (mediumImageURL == null) {
194                 paramObj14 = new NullWrapper("java.lang.String");
195             }
196 
197             Object paramObj15 = mediumFile;
198 
199             if (mediumFile == null) {
200                 paramObj15 = new NullWrapper("java.io.File");
201             }
202 
203             Object paramObj16 = new BooleanWrapper(largeImage);
204 
205             Object paramObj17 = largeImageURL;
206 
207             if (largeImageURL == null) {
208                 paramObj17 = new NullWrapper("java.lang.String");
209             }
210 
211             Object paramObj18 = largeFile;
212 
213             if (largeFile == null) {
214                 paramObj18 = new NullWrapper("java.io.File");
215             }
216 
217             Object paramObj19 = itemFields;
218 
219             if (itemFields == null) {
220                 paramObj19 = new NullWrapper("java.util.List");
221             }
222 
223             Object paramObj20 = itemPrices;
224 
225             if (itemPrices == null) {
226                 paramObj20 = new NullWrapper("java.util.List");
227             }
228 
229             Object paramObj21 = new BooleanWrapper(addCommunityPermissions);
230 
231             Object paramObj22 = new BooleanWrapper(addGuestPermissions);
232 
233             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
234                     "addItem",
235                     new Object[] {
236                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
237                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
238                         paramObj10, paramObj11, paramObj12, paramObj13,
239                         paramObj14, paramObj15, paramObj16, paramObj17,
240                         paramObj18, paramObj19, paramObj20, paramObj21,
241                         paramObj22
242                     });
243 
244             Object returnObj = null;
245 
246             try {
247                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
248             }
249             catch (Exception e) {
250                 if (e instanceof com.liferay.portal.SystemException) {
251                     throw (com.liferay.portal.SystemException)e;
252                 }
253 
254                 if (e instanceof com.liferay.portal.PortalException) {
255                     throw (com.liferay.portal.PortalException)e;
256                 }
257 
258                 throw new com.liferay.portal.SystemException(e);
259             }
260 
261             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
262         }
263         catch (com.liferay.portal.SystemException se) {
264             _log.error(se, se);
265 
266             throw se;
267         }
268     }
269 
270     public static com.liferay.portlet.shopping.model.ShoppingItem addItem(
271         HttpPrincipal httpPrincipal, long categoryId, java.lang.String sku,
272         java.lang.String name, java.lang.String description,
273         java.lang.String properties, java.lang.String fieldsQuantities,
274         boolean requiresShipping, int stockQuantity, boolean featured,
275         java.lang.Boolean sale, boolean smallImage,
276         java.lang.String smallImageURL, java.io.File smallFile,
277         boolean mediumImage, java.lang.String mediumImageURL,
278         java.io.File mediumFile, boolean largeImage,
279         java.lang.String largeImageURL, java.io.File largeFile,
280         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
281         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices,
282         java.lang.String[] communityPermissions,
283         java.lang.String[] guestPermissions)
284         throws com.liferay.portal.SystemException,
285             com.liferay.portal.PortalException {
286         try {
287             Object paramObj0 = new LongWrapper(categoryId);
288 
289             Object paramObj1 = sku;
290 
291             if (sku == null) {
292                 paramObj1 = new NullWrapper("java.lang.String");
293             }
294 
295             Object paramObj2 = name;
296 
297             if (name == null) {
298                 paramObj2 = new NullWrapper("java.lang.String");
299             }
300 
301             Object paramObj3 = description;
302 
303             if (description == null) {
304                 paramObj3 = new NullWrapper("java.lang.String");
305             }
306 
307             Object paramObj4 = properties;
308 
309             if (properties == null) {
310                 paramObj4 = new NullWrapper("java.lang.String");
311             }
312 
313             Object paramObj5 = fieldsQuantities;
314 
315             if (fieldsQuantities == null) {
316                 paramObj5 = new NullWrapper("java.lang.String");
317             }
318 
319             Object paramObj6 = new BooleanWrapper(requiresShipping);
320 
321             Object paramObj7 = new IntegerWrapper(stockQuantity);
322 
323             Object paramObj8 = new BooleanWrapper(featured);
324 
325             Object paramObj9 = sale;
326 
327             if (sale == null) {
328                 paramObj9 = new NullWrapper("java.lang.Boolean");
329             }
330 
331             Object paramObj10 = new BooleanWrapper(smallImage);
332 
333             Object paramObj11 = smallImageURL;
334 
335             if (smallImageURL == null) {
336                 paramObj11 = new NullWrapper("java.lang.String");
337             }
338 
339             Object paramObj12 = smallFile;
340 
341             if (smallFile == null) {
342                 paramObj12 = new NullWrapper("java.io.File");
343             }
344 
345             Object paramObj13 = new BooleanWrapper(mediumImage);
346 
347             Object paramObj14 = mediumImageURL;
348 
349             if (mediumImageURL == null) {
350                 paramObj14 = new NullWrapper("java.lang.String");
351             }
352 
353             Object paramObj15 = mediumFile;
354 
355             if (mediumFile == null) {
356                 paramObj15 = new NullWrapper("java.io.File");
357             }
358 
359             Object paramObj16 = new BooleanWrapper(largeImage);
360 
361             Object paramObj17 = largeImageURL;
362 
363             if (largeImageURL == null) {
364                 paramObj17 = new NullWrapper("java.lang.String");
365             }
366 
367             Object paramObj18 = largeFile;
368 
369             if (largeFile == null) {
370                 paramObj18 = new NullWrapper("java.io.File");
371             }
372 
373             Object paramObj19 = itemFields;
374 
375             if (itemFields == null) {
376                 paramObj19 = new NullWrapper("java.util.List");
377             }
378 
379             Object paramObj20 = itemPrices;
380 
381             if (itemPrices == null) {
382                 paramObj20 = new NullWrapper("java.util.List");
383             }
384 
385             Object paramObj21 = communityPermissions;
386 
387             if (communityPermissions == null) {
388                 paramObj21 = new NullWrapper("[Ljava.lang.String;");
389             }
390 
391             Object paramObj22 = guestPermissions;
392 
393             if (guestPermissions == null) {
394                 paramObj22 = new NullWrapper("[Ljava.lang.String;");
395             }
396 
397             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
398                     "addItem",
399                     new Object[] {
400                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
401                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
402                         paramObj10, paramObj11, paramObj12, paramObj13,
403                         paramObj14, paramObj15, paramObj16, paramObj17,
404                         paramObj18, paramObj19, paramObj20, paramObj21,
405                         paramObj22
406                     });
407 
408             Object returnObj = null;
409 
410             try {
411                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
412             }
413             catch (Exception e) {
414                 if (e instanceof com.liferay.portal.SystemException) {
415                     throw (com.liferay.portal.SystemException)e;
416                 }
417 
418                 if (e instanceof com.liferay.portal.PortalException) {
419                     throw (com.liferay.portal.PortalException)e;
420                 }
421 
422                 throw new com.liferay.portal.SystemException(e);
423             }
424 
425             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
426         }
427         catch (com.liferay.portal.SystemException se) {
428             _log.error(se, se);
429 
430             throw se;
431         }
432     }
433 
434     public static void deleteItem(HttpPrincipal httpPrincipal, long itemId)
435         throws com.liferay.portal.SystemException,
436             com.liferay.portal.PortalException {
437         try {
438             Object paramObj0 = new LongWrapper(itemId);
439 
440             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
441                     "deleteItem", new Object[] { paramObj0 });
442 
443             try {
444                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
445             }
446             catch (Exception e) {
447                 if (e instanceof com.liferay.portal.SystemException) {
448                     throw (com.liferay.portal.SystemException)e;
449                 }
450 
451                 if (e instanceof com.liferay.portal.PortalException) {
452                     throw (com.liferay.portal.PortalException)e;
453                 }
454 
455                 throw new com.liferay.portal.SystemException(e);
456             }
457         }
458         catch (com.liferay.portal.SystemException se) {
459             _log.error(se, se);
460 
461             throw se;
462         }
463     }
464 
465     public static com.liferay.portlet.shopping.model.ShoppingItem getItem(
466         HttpPrincipal httpPrincipal, long itemId)
467         throws com.liferay.portal.SystemException,
468             com.liferay.portal.PortalException {
469         try {
470             Object paramObj0 = new LongWrapper(itemId);
471 
472             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
473                     "getItem", new Object[] { paramObj0 });
474 
475             Object returnObj = null;
476 
477             try {
478                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
479             }
480             catch (Exception e) {
481                 if (e instanceof com.liferay.portal.SystemException) {
482                     throw (com.liferay.portal.SystemException)e;
483                 }
484 
485                 if (e instanceof com.liferay.portal.PortalException) {
486                     throw (com.liferay.portal.PortalException)e;
487                 }
488 
489                 throw new com.liferay.portal.SystemException(e);
490             }
491 
492             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
493         }
494         catch (com.liferay.portal.SystemException se) {
495             _log.error(se, se);
496 
497             throw se;
498         }
499     }
500 
501     public static com.liferay.portlet.shopping.model.ShoppingItem updateItem(
502         HttpPrincipal httpPrincipal, long itemId, long categoryId,
503         java.lang.String sku, java.lang.String name,
504         java.lang.String description, java.lang.String properties,
505         java.lang.String fieldsQuantities, boolean requiresShipping,
506         int stockQuantity, boolean featured, java.lang.Boolean sale,
507         boolean smallImage, java.lang.String smallImageURL,
508         java.io.File smallFile, boolean mediumImage,
509         java.lang.String mediumImageURL, java.io.File mediumFile,
510         boolean largeImage, java.lang.String largeImageURL,
511         java.io.File largeFile,
512         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
513         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices)
514         throws com.liferay.portal.SystemException,
515             com.liferay.portal.PortalException {
516         try {
517             Object paramObj0 = new LongWrapper(itemId);
518 
519             Object paramObj1 = new LongWrapper(categoryId);
520 
521             Object paramObj2 = sku;
522 
523             if (sku == null) {
524                 paramObj2 = new NullWrapper("java.lang.String");
525             }
526 
527             Object paramObj3 = name;
528 
529             if (name == null) {
530                 paramObj3 = new NullWrapper("java.lang.String");
531             }
532 
533             Object paramObj4 = description;
534 
535             if (description == null) {
536                 paramObj4 = new NullWrapper("java.lang.String");
537             }
538 
539             Object paramObj5 = properties;
540 
541             if (properties == null) {
542                 paramObj5 = new NullWrapper("java.lang.String");
543             }
544 
545             Object paramObj6 = fieldsQuantities;
546 
547             if (fieldsQuantities == null) {
548                 paramObj6 = new NullWrapper("java.lang.String");
549             }
550 
551             Object paramObj7 = new BooleanWrapper(requiresShipping);
552 
553             Object paramObj8 = new IntegerWrapper(stockQuantity);
554 
555             Object paramObj9 = new BooleanWrapper(featured);
556 
557             Object paramObj10 = sale;
558 
559             if (sale == null) {
560                 paramObj10 = new NullWrapper("java.lang.Boolean");
561             }
562 
563             Object paramObj11 = new BooleanWrapper(smallImage);
564 
565             Object paramObj12 = smallImageURL;
566 
567             if (smallImageURL == null) {
568                 paramObj12 = new NullWrapper("java.lang.String");
569             }
570 
571             Object paramObj13 = smallFile;
572 
573             if (smallFile == null) {
574                 paramObj13 = new NullWrapper("java.io.File");
575             }
576 
577             Object paramObj14 = new BooleanWrapper(mediumImage);
578 
579             Object paramObj15 = mediumImageURL;
580 
581             if (mediumImageURL == null) {
582                 paramObj15 = new NullWrapper("java.lang.String");
583             }
584 
585             Object paramObj16 = mediumFile;
586 
587             if (mediumFile == null) {
588                 paramObj16 = new NullWrapper("java.io.File");
589             }
590 
591             Object paramObj17 = new BooleanWrapper(largeImage);
592 
593             Object paramObj18 = largeImageURL;
594 
595             if (largeImageURL == null) {
596                 paramObj18 = new NullWrapper("java.lang.String");
597             }
598 
599             Object paramObj19 = largeFile;
600 
601             if (largeFile == null) {
602                 paramObj19 = new NullWrapper("java.io.File");
603             }
604 
605             Object paramObj20 = itemFields;
606 
607             if (itemFields == null) {
608                 paramObj20 = new NullWrapper("java.util.List");
609             }
610 
611             Object paramObj21 = itemPrices;
612 
613             if (itemPrices == null) {
614                 paramObj21 = new NullWrapper("java.util.List");
615             }
616 
617             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
618                     "updateItem",
619                     new Object[] {
620                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
621                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
622                         paramObj10, paramObj11, paramObj12, paramObj13,
623                         paramObj14, paramObj15, paramObj16, paramObj17,
624                         paramObj18, paramObj19, paramObj20, paramObj21
625                     });
626 
627             Object returnObj = null;
628 
629             try {
630                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
631             }
632             catch (Exception e) {
633                 if (e instanceof com.liferay.portal.SystemException) {
634                     throw (com.liferay.portal.SystemException)e;
635                 }
636 
637                 if (e instanceof com.liferay.portal.PortalException) {
638                     throw (com.liferay.portal.PortalException)e;
639                 }
640 
641                 throw new com.liferay.portal.SystemException(e);
642             }
643 
644             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
645         }
646         catch (com.liferay.portal.SystemException se) {
647             _log.error(se, se);
648 
649             throw se;
650         }
651     }
652 
653     private static Log _log = LogFactoryUtil.getLog(ShoppingItemServiceHttp.class);
654 }