1   /**
2    * Copyright (c) 2000-2009 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.PortalException,
80              com.liferay.portal.SystemException {
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.PortalException) {
98                      throw (com.liferay.portal.PortalException)e;
99                  }
100 
101                 if (e instanceof com.liferay.portal.SystemException) {
102                     throw (com.liferay.portal.SystemException)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         com.liferay.portal.service.ServiceContext serviceContext)
128         throws com.liferay.portal.PortalException,
129             com.liferay.portal.SystemException {
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 = serviceContext;
230 
231             if (serviceContext == null) {
232                 paramObj21 = new NullWrapper(
233                         "com.liferay.portal.service.ServiceContext");
234             }
235 
236             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
237                     "addItem",
238                     new Object[] {
239                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
240                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
241                         paramObj10, paramObj11, paramObj12, paramObj13,
242                         paramObj14, paramObj15, paramObj16, paramObj17,
243                         paramObj18, paramObj19, paramObj20, paramObj21
244                     });
245 
246             Object returnObj = null;
247 
248             try {
249                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
250             }
251             catch (Exception e) {
252                 if (e instanceof com.liferay.portal.PortalException) {
253                     throw (com.liferay.portal.PortalException)e;
254                 }
255 
256                 if (e instanceof com.liferay.portal.SystemException) {
257                     throw (com.liferay.portal.SystemException)e;
258                 }
259 
260                 throw new com.liferay.portal.SystemException(e);
261             }
262 
263             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
264         }
265         catch (com.liferay.portal.SystemException se) {
266             _log.error(se, se);
267 
268             throw se;
269         }
270     }
271 
272     public static void deleteItem(HttpPrincipal httpPrincipal, long itemId)
273         throws com.liferay.portal.PortalException,
274             com.liferay.portal.SystemException {
275         try {
276             Object paramObj0 = new LongWrapper(itemId);
277 
278             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
279                     "deleteItem", new Object[] { paramObj0 });
280 
281             try {
282                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
283             }
284             catch (Exception e) {
285                 if (e instanceof com.liferay.portal.PortalException) {
286                     throw (com.liferay.portal.PortalException)e;
287                 }
288 
289                 if (e instanceof com.liferay.portal.SystemException) {
290                     throw (com.liferay.portal.SystemException)e;
291                 }
292 
293                 throw new com.liferay.portal.SystemException(e);
294             }
295         }
296         catch (com.liferay.portal.SystemException se) {
297             _log.error(se, se);
298 
299             throw se;
300         }
301     }
302 
303     public static com.liferay.portlet.shopping.model.ShoppingItem getItem(
304         HttpPrincipal httpPrincipal, long itemId)
305         throws com.liferay.portal.PortalException,
306             com.liferay.portal.SystemException {
307         try {
308             Object paramObj0 = new LongWrapper(itemId);
309 
310             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
311                     "getItem", new Object[] { paramObj0 });
312 
313             Object returnObj = null;
314 
315             try {
316                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
317             }
318             catch (Exception e) {
319                 if (e instanceof com.liferay.portal.PortalException) {
320                     throw (com.liferay.portal.PortalException)e;
321                 }
322 
323                 if (e instanceof com.liferay.portal.SystemException) {
324                     throw (com.liferay.portal.SystemException)e;
325                 }
326 
327                 throw new com.liferay.portal.SystemException(e);
328             }
329 
330             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
331         }
332         catch (com.liferay.portal.SystemException se) {
333             _log.error(se, se);
334 
335             throw se;
336         }
337     }
338 
339     public static com.liferay.portlet.shopping.model.ShoppingItem updateItem(
340         HttpPrincipal httpPrincipal, long itemId, long categoryId,
341         java.lang.String sku, java.lang.String name,
342         java.lang.String description, java.lang.String properties,
343         java.lang.String fieldsQuantities, boolean requiresShipping,
344         int stockQuantity, boolean featured, java.lang.Boolean sale,
345         boolean smallImage, java.lang.String smallImageURL,
346         java.io.File smallFile, boolean mediumImage,
347         java.lang.String mediumImageURL, java.io.File mediumFile,
348         boolean largeImage, java.lang.String largeImageURL,
349         java.io.File largeFile,
350         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemField> itemFields,
351         java.util.List<com.liferay.portlet.shopping.model.ShoppingItemPrice> itemPrices,
352         com.liferay.portal.service.ServiceContext serviceContext)
353         throws com.liferay.portal.PortalException,
354             com.liferay.portal.SystemException {
355         try {
356             Object paramObj0 = new LongWrapper(itemId);
357 
358             Object paramObj1 = new LongWrapper(categoryId);
359 
360             Object paramObj2 = sku;
361 
362             if (sku == null) {
363                 paramObj2 = new NullWrapper("java.lang.String");
364             }
365 
366             Object paramObj3 = name;
367 
368             if (name == null) {
369                 paramObj3 = new NullWrapper("java.lang.String");
370             }
371 
372             Object paramObj4 = description;
373 
374             if (description == null) {
375                 paramObj4 = new NullWrapper("java.lang.String");
376             }
377 
378             Object paramObj5 = properties;
379 
380             if (properties == null) {
381                 paramObj5 = new NullWrapper("java.lang.String");
382             }
383 
384             Object paramObj6 = fieldsQuantities;
385 
386             if (fieldsQuantities == null) {
387                 paramObj6 = new NullWrapper("java.lang.String");
388             }
389 
390             Object paramObj7 = new BooleanWrapper(requiresShipping);
391 
392             Object paramObj8 = new IntegerWrapper(stockQuantity);
393 
394             Object paramObj9 = new BooleanWrapper(featured);
395 
396             Object paramObj10 = sale;
397 
398             if (sale == null) {
399                 paramObj10 = new NullWrapper("java.lang.Boolean");
400             }
401 
402             Object paramObj11 = new BooleanWrapper(smallImage);
403 
404             Object paramObj12 = smallImageURL;
405 
406             if (smallImageURL == null) {
407                 paramObj12 = new NullWrapper("java.lang.String");
408             }
409 
410             Object paramObj13 = smallFile;
411 
412             if (smallFile == null) {
413                 paramObj13 = new NullWrapper("java.io.File");
414             }
415 
416             Object paramObj14 = new BooleanWrapper(mediumImage);
417 
418             Object paramObj15 = mediumImageURL;
419 
420             if (mediumImageURL == null) {
421                 paramObj15 = new NullWrapper("java.lang.String");
422             }
423 
424             Object paramObj16 = mediumFile;
425 
426             if (mediumFile == null) {
427                 paramObj16 = new NullWrapper("java.io.File");
428             }
429 
430             Object paramObj17 = new BooleanWrapper(largeImage);
431 
432             Object paramObj18 = largeImageURL;
433 
434             if (largeImageURL == null) {
435                 paramObj18 = new NullWrapper("java.lang.String");
436             }
437 
438             Object paramObj19 = largeFile;
439 
440             if (largeFile == null) {
441                 paramObj19 = new NullWrapper("java.io.File");
442             }
443 
444             Object paramObj20 = itemFields;
445 
446             if (itemFields == null) {
447                 paramObj20 = new NullWrapper("java.util.List");
448             }
449 
450             Object paramObj21 = itemPrices;
451 
452             if (itemPrices == null) {
453                 paramObj21 = new NullWrapper("java.util.List");
454             }
455 
456             Object paramObj22 = serviceContext;
457 
458             if (serviceContext == null) {
459                 paramObj22 = new NullWrapper(
460                         "com.liferay.portal.service.ServiceContext");
461             }
462 
463             MethodWrapper methodWrapper = new MethodWrapper(ShoppingItemServiceUtil.class.getName(),
464                     "updateItem",
465                     new Object[] {
466                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
467                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
468                         paramObj10, paramObj11, paramObj12, paramObj13,
469                         paramObj14, paramObj15, paramObj16, paramObj17,
470                         paramObj18, paramObj19, paramObj20, paramObj21,
471                         paramObj22
472                     });
473 
474             Object returnObj = null;
475 
476             try {
477                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
478             }
479             catch (Exception e) {
480                 if (e instanceof com.liferay.portal.PortalException) {
481                     throw (com.liferay.portal.PortalException)e;
482                 }
483 
484                 if (e instanceof com.liferay.portal.SystemException) {
485                     throw (com.liferay.portal.SystemException)e;
486                 }
487 
488                 throw new com.liferay.portal.SystemException(e);
489             }
490 
491             return (com.liferay.portlet.shopping.model.ShoppingItem)returnObj;
492         }
493         catch (com.liferay.portal.SystemException se) {
494             _log.error(se, se);
495 
496             throw se;
497         }
498     }
499 
500     private static Log _log = LogFactoryUtil.getLog(ShoppingItemServiceHttp.class);
501 }