1   /**
2    * Copyright (c) 2000-2008 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 plid, long parentCategoryId,
78          java.lang.String name, java.lang.String description,
79          boolean addCommunityPermissions, boolean addGuestPermissions)
80          throws com.liferay.portal.SystemException,
81              com.liferay.portal.PortalException {
82          try {
83              Object paramObj0 = new LongWrapper(plid);
84  
85              Object paramObj1 = new LongWrapper(parentCategoryId);
86  
87              Object paramObj2 = name;
88  
89              if (name == null) {
90                  paramObj2 = new NullWrapper("java.lang.String");
91              }
92  
93              Object paramObj3 = description;
94  
95              if (description == null) {
96                  paramObj3 = new NullWrapper("java.lang.String");
97              }
98  
99              Object paramObj4 = new BooleanWrapper(addCommunityPermissions);
100 
101             Object paramObj5 = new BooleanWrapper(addGuestPermissions);
102 
103             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
104                     "addCategory",
105                     new Object[] {
106                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
107                         paramObj5
108                     });
109 
110             Object returnObj = null;
111 
112             try {
113                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
114             }
115             catch (Exception e) {
116                 if (e instanceof com.liferay.portal.SystemException) {
117                     throw (com.liferay.portal.SystemException)e;
118                 }
119 
120                 if (e instanceof com.liferay.portal.PortalException) {
121                     throw (com.liferay.portal.PortalException)e;
122                 }
123 
124                 throw new com.liferay.portal.SystemException(e);
125             }
126 
127             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
128         }
129         catch (com.liferay.portal.SystemException se) {
130             _log.error(se, se);
131 
132             throw se;
133         }
134     }
135 
136     public static com.liferay.portlet.shopping.model.ShoppingCategory addCategory(
137         HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
138         java.lang.String name, java.lang.String description,
139         java.lang.String[] communityPermissions,
140         java.lang.String[] guestPermissions)
141         throws com.liferay.portal.SystemException,
142             com.liferay.portal.PortalException {
143         try {
144             Object paramObj0 = new LongWrapper(plid);
145 
146             Object paramObj1 = new LongWrapper(parentCategoryId);
147 
148             Object paramObj2 = name;
149 
150             if (name == null) {
151                 paramObj2 = new NullWrapper("java.lang.String");
152             }
153 
154             Object paramObj3 = description;
155 
156             if (description == null) {
157                 paramObj3 = new NullWrapper("java.lang.String");
158             }
159 
160             Object paramObj4 = communityPermissions;
161 
162             if (communityPermissions == null) {
163                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
164             }
165 
166             Object paramObj5 = guestPermissions;
167 
168             if (guestPermissions == null) {
169                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
170             }
171 
172             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
173                     "addCategory",
174                     new Object[] {
175                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
176                         paramObj5
177                     });
178 
179             Object returnObj = null;
180 
181             try {
182                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
183             }
184             catch (Exception e) {
185                 if (e instanceof com.liferay.portal.SystemException) {
186                     throw (com.liferay.portal.SystemException)e;
187                 }
188 
189                 if (e instanceof com.liferay.portal.PortalException) {
190                     throw (com.liferay.portal.PortalException)e;
191                 }
192 
193                 throw new com.liferay.portal.SystemException(e);
194             }
195 
196             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
197         }
198         catch (com.liferay.portal.SystemException se) {
199             _log.error(se, se);
200 
201             throw se;
202         }
203     }
204 
205     public static void deleteCategory(HttpPrincipal httpPrincipal,
206         long categoryId)
207         throws com.liferay.portal.SystemException,
208             com.liferay.portal.PortalException {
209         try {
210             Object paramObj0 = new LongWrapper(categoryId);
211 
212             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
213                     "deleteCategory", new Object[] { paramObj0 });
214 
215             try {
216                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
217             }
218             catch (Exception e) {
219                 if (e instanceof com.liferay.portal.SystemException) {
220                     throw (com.liferay.portal.SystemException)e;
221                 }
222 
223                 if (e instanceof com.liferay.portal.PortalException) {
224                     throw (com.liferay.portal.PortalException)e;
225                 }
226 
227                 throw new com.liferay.portal.SystemException(e);
228             }
229         }
230         catch (com.liferay.portal.SystemException se) {
231             _log.error(se, se);
232 
233             throw se;
234         }
235     }
236 
237     public static com.liferay.portlet.shopping.model.ShoppingCategory getCategory(
238         HttpPrincipal httpPrincipal, long categoryId)
239         throws com.liferay.portal.SystemException,
240             com.liferay.portal.PortalException {
241         try {
242             Object paramObj0 = new LongWrapper(categoryId);
243 
244             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
245                     "getCategory", new Object[] { paramObj0 });
246 
247             Object returnObj = null;
248 
249             try {
250                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
251             }
252             catch (Exception e) {
253                 if (e instanceof com.liferay.portal.SystemException) {
254                     throw (com.liferay.portal.SystemException)e;
255                 }
256 
257                 if (e instanceof com.liferay.portal.PortalException) {
258                     throw (com.liferay.portal.PortalException)e;
259                 }
260 
261                 throw new com.liferay.portal.SystemException(e);
262             }
263 
264             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
265         }
266         catch (com.liferay.portal.SystemException se) {
267             _log.error(se, se);
268 
269             throw se;
270         }
271     }
272 
273     public static com.liferay.portlet.shopping.model.ShoppingCategory updateCategory(
274         HttpPrincipal httpPrincipal, long categoryId, long parentCategoryId,
275         java.lang.String name, java.lang.String description,
276         boolean mergeWithParentCategory)
277         throws com.liferay.portal.SystemException,
278             com.liferay.portal.PortalException {
279         try {
280             Object paramObj0 = new LongWrapper(categoryId);
281 
282             Object paramObj1 = new LongWrapper(parentCategoryId);
283 
284             Object paramObj2 = name;
285 
286             if (name == null) {
287                 paramObj2 = new NullWrapper("java.lang.String");
288             }
289 
290             Object paramObj3 = description;
291 
292             if (description == null) {
293                 paramObj3 = new NullWrapper("java.lang.String");
294             }
295 
296             Object paramObj4 = new BooleanWrapper(mergeWithParentCategory);
297 
298             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
299                     "updateCategory",
300                     new Object[] {
301                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
302                     });
303 
304             Object returnObj = null;
305 
306             try {
307                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
308             }
309             catch (Exception e) {
310                 if (e instanceof com.liferay.portal.SystemException) {
311                     throw (com.liferay.portal.SystemException)e;
312                 }
313 
314                 if (e instanceof com.liferay.portal.PortalException) {
315                     throw (com.liferay.portal.PortalException)e;
316                 }
317 
318                 throw new com.liferay.portal.SystemException(e);
319             }
320 
321             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
322         }
323         catch (com.liferay.portal.SystemException se) {
324             _log.error(se, se);
325 
326             throw se;
327         }
328     }
329 
330     private static Log _log = LogFactoryUtil.getLog(ShoppingCategoryServiceHttp.class);
331 }