1   /**
2    * Copyright (c) 2000-2007 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 overwritten
41   * the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This class provides a HTTP utility for the <code>com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil</code>
46   * service utility. The static methods of this class calls the same methods of the
47   * service utility. However, the signatures are different because it requires an
48   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code> parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for tunneling
53   * without the cost of serializing to text. The drawback is that it only works with
54   * Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in portal.properties
59   * to configure security.
60   * </p>
61   *
62   * <p>
63   * The HTTP utility is only generated for remote services.
64   * </p>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   * @see com.liferay.portal.security.auth.HttpPrincipal
69   * @see com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil
70   * @see com.liferay.portlet.shopping.service.http.ShoppingCategoryServiceSoap
71   *
72   */
73  public class ShoppingCategoryServiceHttp {
74      public static com.liferay.portlet.shopping.model.ShoppingCategory addCategory(
75          HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
76          java.lang.String name, java.lang.String description,
77          boolean addCommunityPermissions, boolean addGuestPermissions)
78          throws com.liferay.portal.SystemException, 
79              com.liferay.portal.PortalException {
80          try {
81              Object paramObj0 = new LongWrapper(plid);
82              Object paramObj1 = new LongWrapper(parentCategoryId);
83              Object paramObj2 = name;
84  
85              if (name == null) {
86                  paramObj2 = new NullWrapper("java.lang.String");
87              }
88  
89              Object paramObj3 = description;
90  
91              if (description == null) {
92                  paramObj3 = new NullWrapper("java.lang.String");
93              }
94  
95              Object paramObj4 = new BooleanWrapper(addCommunityPermissions);
96              Object paramObj5 = new BooleanWrapper(addGuestPermissions);
97              MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
98                      "addCategory",
99                      new Object[] {
100                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
101                         paramObj5
102                     });
103             Object returnObj = null;
104 
105             try {
106                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
107             }
108             catch (Exception e) {
109                 if (e instanceof com.liferay.portal.SystemException) {
110                     throw (com.liferay.portal.SystemException)e;
111                 }
112 
113                 if (e instanceof com.liferay.portal.PortalException) {
114                     throw (com.liferay.portal.PortalException)e;
115                 }
116 
117                 throw new com.liferay.portal.SystemException(e);
118             }
119 
120             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
121         }
122         catch (com.liferay.portal.SystemException se) {
123             _log.error(se, se);
124             throw se;
125         }
126     }
127 
128     public static com.liferay.portlet.shopping.model.ShoppingCategory addCategory(
129         HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
130         java.lang.String name, java.lang.String description,
131         java.lang.String[] communityPermissions,
132         java.lang.String[] guestPermissions)
133         throws com.liferay.portal.SystemException, 
134             com.liferay.portal.PortalException {
135         try {
136             Object paramObj0 = new LongWrapper(plid);
137             Object paramObj1 = new LongWrapper(parentCategoryId);
138             Object paramObj2 = name;
139 
140             if (name == null) {
141                 paramObj2 = new NullWrapper("java.lang.String");
142             }
143 
144             Object paramObj3 = description;
145 
146             if (description == null) {
147                 paramObj3 = new NullWrapper("java.lang.String");
148             }
149 
150             Object paramObj4 = communityPermissions;
151 
152             if (communityPermissions == null) {
153                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
154             }
155 
156             Object paramObj5 = guestPermissions;
157 
158             if (guestPermissions == null) {
159                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
160             }
161 
162             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
163                     "addCategory",
164                     new Object[] {
165                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
166                         paramObj5
167                     });
168             Object returnObj = null;
169 
170             try {
171                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
172             }
173             catch (Exception e) {
174                 if (e instanceof com.liferay.portal.SystemException) {
175                     throw (com.liferay.portal.SystemException)e;
176                 }
177 
178                 if (e instanceof com.liferay.portal.PortalException) {
179                     throw (com.liferay.portal.PortalException)e;
180                 }
181 
182                 throw new com.liferay.portal.SystemException(e);
183             }
184 
185             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
186         }
187         catch (com.liferay.portal.SystemException se) {
188             _log.error(se, se);
189             throw se;
190         }
191     }
192 
193     public static void deleteCategory(HttpPrincipal httpPrincipal,
194         long categoryId)
195         throws com.liferay.portal.SystemException, 
196             com.liferay.portal.PortalException {
197         try {
198             Object paramObj0 = new LongWrapper(categoryId);
199             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
200                     "deleteCategory", new Object[] { paramObj0 });
201 
202             try {
203                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
204             }
205             catch (Exception e) {
206                 if (e instanceof com.liferay.portal.SystemException) {
207                     throw (com.liferay.portal.SystemException)e;
208                 }
209 
210                 if (e instanceof com.liferay.portal.PortalException) {
211                     throw (com.liferay.portal.PortalException)e;
212                 }
213 
214                 throw new com.liferay.portal.SystemException(e);
215             }
216         }
217         catch (com.liferay.portal.SystemException se) {
218             _log.error(se, se);
219             throw se;
220         }
221     }
222 
223     public static com.liferay.portlet.shopping.model.ShoppingCategory getCategory(
224         HttpPrincipal httpPrincipal, long categoryId)
225         throws com.liferay.portal.SystemException, 
226             com.liferay.portal.PortalException {
227         try {
228             Object paramObj0 = new LongWrapper(categoryId);
229             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
230                     "getCategory", new Object[] { paramObj0 });
231             Object returnObj = null;
232 
233             try {
234                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
235             }
236             catch (Exception e) {
237                 if (e instanceof com.liferay.portal.SystemException) {
238                     throw (com.liferay.portal.SystemException)e;
239                 }
240 
241                 if (e instanceof com.liferay.portal.PortalException) {
242                     throw (com.liferay.portal.PortalException)e;
243                 }
244 
245                 throw new com.liferay.portal.SystemException(e);
246             }
247 
248             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
249         }
250         catch (com.liferay.portal.SystemException se) {
251             _log.error(se, se);
252             throw se;
253         }
254     }
255 
256     public static com.liferay.portlet.shopping.model.ShoppingCategory updateCategory(
257         HttpPrincipal httpPrincipal, long categoryId, long parentCategoryId,
258         java.lang.String name, java.lang.String description,
259         boolean mergeWithParentCategory)
260         throws com.liferay.portal.SystemException, 
261             com.liferay.portal.PortalException {
262         try {
263             Object paramObj0 = new LongWrapper(categoryId);
264             Object paramObj1 = new LongWrapper(parentCategoryId);
265             Object paramObj2 = name;
266 
267             if (name == null) {
268                 paramObj2 = new NullWrapper("java.lang.String");
269             }
270 
271             Object paramObj3 = description;
272 
273             if (description == null) {
274                 paramObj3 = new NullWrapper("java.lang.String");
275             }
276 
277             Object paramObj4 = new BooleanWrapper(mergeWithParentCategory);
278             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
279                     "updateCategory",
280                     new Object[] {
281                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
282                     });
283             Object returnObj = null;
284 
285             try {
286                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
287             }
288             catch (Exception e) {
289                 if (e instanceof com.liferay.portal.SystemException) {
290                     throw (com.liferay.portal.SystemException)e;
291                 }
292 
293                 if (e instanceof com.liferay.portal.PortalException) {
294                     throw (com.liferay.portal.PortalException)e;
295                 }
296 
297                 throw new com.liferay.portal.SystemException(e);
298             }
299 
300             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
301         }
302         catch (com.liferay.portal.SystemException se) {
303             _log.error(se, se);
304             throw se;
305         }
306     }
307 
308     private static Log _log = LogFactoryUtil.getLog(ShoppingCategoryServiceHttp.class);
309 }