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