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