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