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.LongWrapper;
29  import com.liferay.portal.kernel.util.MethodWrapper;
30  import com.liferay.portal.kernel.util.NullWrapper;
31  import com.liferay.portal.security.auth.HttpPrincipal;
32  import com.liferay.portal.service.http.TunnelUtil;
33  
34  import com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil;
35  
36  /**
37   * <a href="ShoppingCategoryServiceHttp.java.html"><b><i>View Source</i></b></a>
38   *
39   * <p>
40   * ServiceBuilder generated this class. Modifications in this class will be
41   * overwritten the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This class provides a HTTP utility for the
46   * {@link com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil} service utility. The
47   * static methods of this class calls the same methods of the service utility.
48   * However, the signatures are different because it requires an additional
49   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
50   * </p>
51   *
52   * <p>
53   * The benefits of using the HTTP utility is that it is fast and allows for
54   * tunneling without the cost of serializing to text. The drawback is that it
55   * only works with Java.
56   * </p>
57   *
58   * <p>
59   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
60   * 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   * @see       ShoppingCategoryServiceSoap
69   * @see       com.liferay.portal.security.auth.HttpPrincipal
70   * @see       com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil
71   * @generated
72   */
73  public class ShoppingCategoryServiceHttp {
74      public static com.liferay.portlet.shopping.model.ShoppingCategory addCategory(
75          HttpPrincipal httpPrincipal, long parentCategoryId,
76          java.lang.String name, java.lang.String description,
77          com.liferay.portal.service.ServiceContext serviceContext)
78          throws com.liferay.portal.PortalException,
79              com.liferay.portal.SystemException {
80          try {
81              Object paramObj0 = new LongWrapper(parentCategoryId);
82  
83              Object paramObj1 = name;
84  
85              if (name == null) {
86                  paramObj1 = new NullWrapper("java.lang.String");
87              }
88  
89              Object paramObj2 = description;
90  
91              if (description == null) {
92                  paramObj2 = new NullWrapper("java.lang.String");
93              }
94  
95              Object paramObj3 = serviceContext;
96  
97              if (serviceContext == null) {
98                  paramObj3 = new NullWrapper(
99                          "com.liferay.portal.service.ServiceContext");
100             }
101 
102             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
103                     "addCategory",
104                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
105 
106             Object returnObj = null;
107 
108             try {
109                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
110             }
111             catch (Exception e) {
112                 if (e instanceof com.liferay.portal.PortalException) {
113                     throw (com.liferay.portal.PortalException)e;
114                 }
115 
116                 if (e instanceof com.liferay.portal.SystemException) {
117                     throw (com.liferay.portal.SystemException)e;
118                 }
119 
120                 throw new com.liferay.portal.SystemException(e);
121             }
122 
123             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
124         }
125         catch (com.liferay.portal.SystemException se) {
126             _log.error(se, se);
127 
128             throw se;
129         }
130     }
131 
132     public static void deleteCategory(HttpPrincipal httpPrincipal,
133         long categoryId)
134         throws com.liferay.portal.PortalException,
135             com.liferay.portal.SystemException {
136         try {
137             Object paramObj0 = new LongWrapper(categoryId);
138 
139             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
140                     "deleteCategory", new Object[] { paramObj0 });
141 
142             try {
143                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
144             }
145             catch (Exception e) {
146                 if (e instanceof com.liferay.portal.PortalException) {
147                     throw (com.liferay.portal.PortalException)e;
148                 }
149 
150                 if (e instanceof com.liferay.portal.SystemException) {
151                     throw (com.liferay.portal.SystemException)e;
152                 }
153 
154                 throw new com.liferay.portal.SystemException(e);
155             }
156         }
157         catch (com.liferay.portal.SystemException se) {
158             _log.error(se, se);
159 
160             throw se;
161         }
162     }
163 
164     public static com.liferay.portlet.shopping.model.ShoppingCategory getCategory(
165         HttpPrincipal httpPrincipal, long categoryId)
166         throws com.liferay.portal.PortalException,
167             com.liferay.portal.SystemException {
168         try {
169             Object paramObj0 = new LongWrapper(categoryId);
170 
171             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
172                     "getCategory", new Object[] { paramObj0 });
173 
174             Object returnObj = null;
175 
176             try {
177                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
178             }
179             catch (Exception e) {
180                 if (e instanceof com.liferay.portal.PortalException) {
181                     throw (com.liferay.portal.PortalException)e;
182                 }
183 
184                 if (e instanceof com.liferay.portal.SystemException) {
185                     throw (com.liferay.portal.SystemException)e;
186                 }
187 
188                 throw new com.liferay.portal.SystemException(e);
189             }
190 
191             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
192         }
193         catch (com.liferay.portal.SystemException se) {
194             _log.error(se, se);
195 
196             throw se;
197         }
198     }
199 
200     public static com.liferay.portlet.shopping.model.ShoppingCategory updateCategory(
201         HttpPrincipal httpPrincipal, long categoryId, long parentCategoryId,
202         java.lang.String name, java.lang.String description,
203         boolean mergeWithParentCategory,
204         com.liferay.portal.service.ServiceContext serviceContext)
205         throws com.liferay.portal.PortalException,
206             com.liferay.portal.SystemException {
207         try {
208             Object paramObj0 = new LongWrapper(categoryId);
209 
210             Object paramObj1 = new LongWrapper(parentCategoryId);
211 
212             Object paramObj2 = name;
213 
214             if (name == null) {
215                 paramObj2 = new NullWrapper("java.lang.String");
216             }
217 
218             Object paramObj3 = description;
219 
220             if (description == null) {
221                 paramObj3 = new NullWrapper("java.lang.String");
222             }
223 
224             Object paramObj4 = new BooleanWrapper(mergeWithParentCategory);
225 
226             Object paramObj5 = serviceContext;
227 
228             if (serviceContext == null) {
229                 paramObj5 = new NullWrapper(
230                         "com.liferay.portal.service.ServiceContext");
231             }
232 
233             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
234                     "updateCategory",
235                     new Object[] {
236                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
237                         paramObj5
238                     });
239 
240             Object returnObj = null;
241 
242             try {
243                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
244             }
245             catch (Exception e) {
246                 if (e instanceof com.liferay.portal.PortalException) {
247                     throw (com.liferay.portal.PortalException)e;
248                 }
249 
250                 if (e instanceof com.liferay.portal.SystemException) {
251                     throw (com.liferay.portal.SystemException)e;
252                 }
253 
254                 throw new com.liferay.portal.SystemException(e);
255             }
256 
257             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
258         }
259         catch (com.liferay.portal.SystemException se) {
260             _log.error(se, se);
261 
262             throw se;
263         }
264     }
265 
266     private static Log _log = LogFactoryUtil.getLog(ShoppingCategoryServiceHttp.class);
267 }