1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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.LongWrapper;
21  import com.liferay.portal.kernel.util.MethodWrapper;
22  import com.liferay.portal.kernel.util.NullWrapper;
23  import com.liferay.portal.security.auth.HttpPrincipal;
24  import com.liferay.portal.service.http.TunnelUtil;
25  
26  import com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil;
27  
28  /**
29   * <a href="ShoppingCategoryServiceHttp.java.html"><b><i>View Source</i></b></a>
30   *
31   * <p>
32   * ServiceBuilder generated this class. Modifications in this class will be
33   * overwritten the next time is generated.
34   * </p>
35   *
36   * <p>
37   * This class provides a HTTP utility for the
38   * {@link com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil} service utility. The
39   * static methods of this class calls the same methods of the service utility.
40   * However, the signatures are different because it requires an additional
41   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
42   * </p>
43   *
44   * <p>
45   * The benefits of using the HTTP utility is that it is fast and allows for
46   * tunneling without the cost of serializing to text. The drawback is that it
47   * only works with Java.
48   * </p>
49   *
50   * <p>
51   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
52   * configure security.
53   * </p>
54   *
55   * <p>
56   * The HTTP utility is only generated for remote services.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       ShoppingCategoryServiceSoap
61   * @see       com.liferay.portal.security.auth.HttpPrincipal
62   * @see       com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil
63   * @generated
64   */
65  public class ShoppingCategoryServiceHttp {
66      public static com.liferay.portlet.shopping.model.ShoppingCategory addCategory(
67          HttpPrincipal httpPrincipal, long parentCategoryId,
68          java.lang.String name, java.lang.String description,
69          com.liferay.portal.service.ServiceContext serviceContext)
70          throws com.liferay.portal.kernel.exception.PortalException,
71              com.liferay.portal.kernel.exception.SystemException {
72          try {
73              Object paramObj0 = new LongWrapper(parentCategoryId);
74  
75              Object paramObj1 = name;
76  
77              if (name == null) {
78                  paramObj1 = new NullWrapper("java.lang.String");
79              }
80  
81              Object paramObj2 = description;
82  
83              if (description == null) {
84                  paramObj2 = new NullWrapper("java.lang.String");
85              }
86  
87              Object paramObj3 = serviceContext;
88  
89              if (serviceContext == null) {
90                  paramObj3 = new NullWrapper(
91                          "com.liferay.portal.service.ServiceContext");
92              }
93  
94              MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
95                      "addCategory",
96                      new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
97  
98              Object returnObj = null;
99  
100             try {
101                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
102             }
103             catch (Exception e) {
104                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
105                     throw (com.liferay.portal.kernel.exception.PortalException)e;
106                 }
107 
108                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
109                     throw (com.liferay.portal.kernel.exception.SystemException)e;
110                 }
111 
112                 throw new com.liferay.portal.kernel.exception.SystemException(e);
113             }
114 
115             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
116         }
117         catch (com.liferay.portal.kernel.exception.SystemException se) {
118             _log.error(se, se);
119 
120             throw se;
121         }
122     }
123 
124     public static void deleteCategory(HttpPrincipal httpPrincipal,
125         long categoryId)
126         throws com.liferay.portal.kernel.exception.PortalException,
127             com.liferay.portal.kernel.exception.SystemException {
128         try {
129             Object paramObj0 = new LongWrapper(categoryId);
130 
131             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
132                     "deleteCategory", new Object[] { paramObj0 });
133 
134             try {
135                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
136             }
137             catch (Exception e) {
138                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
139                     throw (com.liferay.portal.kernel.exception.PortalException)e;
140                 }
141 
142                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
143                     throw (com.liferay.portal.kernel.exception.SystemException)e;
144                 }
145 
146                 throw new com.liferay.portal.kernel.exception.SystemException(e);
147             }
148         }
149         catch (com.liferay.portal.kernel.exception.SystemException se) {
150             _log.error(se, se);
151 
152             throw se;
153         }
154     }
155 
156     public static com.liferay.portlet.shopping.model.ShoppingCategory getCategory(
157         HttpPrincipal httpPrincipal, long categoryId)
158         throws com.liferay.portal.kernel.exception.PortalException,
159             com.liferay.portal.kernel.exception.SystemException {
160         try {
161             Object paramObj0 = new LongWrapper(categoryId);
162 
163             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
164                     "getCategory", new Object[] { paramObj0 });
165 
166             Object returnObj = null;
167 
168             try {
169                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
170             }
171             catch (Exception e) {
172                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
173                     throw (com.liferay.portal.kernel.exception.PortalException)e;
174                 }
175 
176                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
177                     throw (com.liferay.portal.kernel.exception.SystemException)e;
178                 }
179 
180                 throw new com.liferay.portal.kernel.exception.SystemException(e);
181             }
182 
183             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
184         }
185         catch (com.liferay.portal.kernel.exception.SystemException se) {
186             _log.error(se, se);
187 
188             throw se;
189         }
190     }
191 
192     public static com.liferay.portlet.shopping.model.ShoppingCategory updateCategory(
193         HttpPrincipal httpPrincipal, long categoryId, long parentCategoryId,
194         java.lang.String name, java.lang.String description,
195         boolean mergeWithParentCategory,
196         com.liferay.portal.service.ServiceContext serviceContext)
197         throws com.liferay.portal.kernel.exception.PortalException,
198             com.liferay.portal.kernel.exception.SystemException {
199         try {
200             Object paramObj0 = new LongWrapper(categoryId);
201 
202             Object paramObj1 = new LongWrapper(parentCategoryId);
203 
204             Object paramObj2 = name;
205 
206             if (name == null) {
207                 paramObj2 = new NullWrapper("java.lang.String");
208             }
209 
210             Object paramObj3 = description;
211 
212             if (description == null) {
213                 paramObj3 = new NullWrapper("java.lang.String");
214             }
215 
216             Object paramObj4 = new BooleanWrapper(mergeWithParentCategory);
217 
218             Object paramObj5 = serviceContext;
219 
220             if (serviceContext == null) {
221                 paramObj5 = new NullWrapper(
222                         "com.liferay.portal.service.ServiceContext");
223             }
224 
225             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
226                     "updateCategory",
227                     new Object[] {
228                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
229                         paramObj5
230                     });
231 
232             Object returnObj = null;
233 
234             try {
235                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
236             }
237             catch (Exception e) {
238                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
239                     throw (com.liferay.portal.kernel.exception.PortalException)e;
240                 }
241 
242                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
243                     throw (com.liferay.portal.kernel.exception.SystemException)e;
244                 }
245 
246                 throw new com.liferay.portal.kernel.exception.SystemException(e);
247             }
248 
249             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
250         }
251         catch (com.liferay.portal.kernel.exception.SystemException se) {
252             _log.error(se, se);
253 
254             throw se;
255         }
256     }
257 
258     private static Log _log = LogFactoryUtil.getLog(ShoppingCategoryServiceHttp.class);
259 }