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