1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.shopping.service.http;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  import com.liferay.portal.kernel.util.BooleanWrapper;
25  import com.liferay.portal.kernel.util.LongWrapper;
26  import com.liferay.portal.kernel.util.MethodWrapper;
27  import com.liferay.portal.kernel.util.NullWrapper;
28  import com.liferay.portal.security.auth.HttpPrincipal;
29  import com.liferay.portal.service.http.TunnelUtil;
30  
31  import com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil;
32  
33  /**
34   * <a href="ShoppingCategoryServiceHttp.java.html"><b><i>View Source</i></b></a>
35   *
36   * <p>
37   * ServiceBuilder generated this class. Modifications in this class will be
38   * overwritten the next time is generated.
39   * </p>
40   *
41   * <p>
42   * This class provides a HTTP utility for the
43   * <code>com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil</code> service
44   * utility. The static methods of this class calls the same methods of the
45   * service utility. However, the signatures are different because it requires an
46   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
47   * parameter.
48   * </p>
49   *
50   * <p>
51   * The benefits of using the HTTP utility is that it is fast and allows for
52   * tunneling without the cost of serializing to text. The drawback is that it
53   * only works with Java.
54   * </p>
55   *
56   * <p>
57   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
58   * portal.properties to configure security.
59   * </p>
60   *
61   * <p>
62   * The HTTP utility is only generated for remote services.
63   * </p>
64   *
65   * @author Brian Wing Shun Chan
66   *
67   * @see com.liferay.portal.security.auth.HttpPrincipal
68   * @see com.liferay.portlet.shopping.service.ShoppingCategoryServiceUtil
69   * @see com.liferay.portlet.shopping.service.http.ShoppingCategoryServiceSoap
70   *
71   */
72  public class ShoppingCategoryServiceHttp {
73      public static com.liferay.portlet.shopping.model.ShoppingCategory addCategory(
74          HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
75          java.lang.String name, java.lang.String description,
76          boolean addCommunityPermissions, boolean addGuestPermissions)
77          throws com.liferay.portal.PortalException,
78              com.liferay.portal.SystemException {
79          try {
80              Object paramObj0 = new LongWrapper(plid);
81  
82              Object paramObj1 = new LongWrapper(parentCategoryId);
83  
84              Object paramObj2 = name;
85  
86              if (name == null) {
87                  paramObj2 = new NullWrapper("java.lang.String");
88              }
89  
90              Object paramObj3 = description;
91  
92              if (description == null) {
93                  paramObj3 = new NullWrapper("java.lang.String");
94              }
95  
96              Object paramObj4 = new BooleanWrapper(addCommunityPermissions);
97  
98              Object paramObj5 = new BooleanWrapper(addGuestPermissions);
99  
100             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
101                     "addCategory",
102                     new Object[] {
103                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
104                         paramObj5
105                     });
106 
107             Object returnObj = null;
108 
109             try {
110                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
111             }
112             catch (Exception e) {
113                 if (e instanceof com.liferay.portal.PortalException) {
114                     throw (com.liferay.portal.PortalException)e;
115                 }
116 
117                 if (e instanceof com.liferay.portal.SystemException) {
118                     throw (com.liferay.portal.SystemException)e;
119                 }
120 
121                 throw new com.liferay.portal.SystemException(e);
122             }
123 
124             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
125         }
126         catch (com.liferay.portal.SystemException se) {
127             _log.error(se, se);
128 
129             throw se;
130         }
131     }
132 
133     public static com.liferay.portlet.shopping.model.ShoppingCategory addCategory(
134         HttpPrincipal httpPrincipal, long plid, long parentCategoryId,
135         java.lang.String name, java.lang.String description,
136         java.lang.String[] communityPermissions,
137         java.lang.String[] guestPermissions)
138         throws com.liferay.portal.PortalException,
139             com.liferay.portal.SystemException {
140         try {
141             Object paramObj0 = new LongWrapper(plid);
142 
143             Object paramObj1 = new LongWrapper(parentCategoryId);
144 
145             Object paramObj2 = name;
146 
147             if (name == null) {
148                 paramObj2 = new NullWrapper("java.lang.String");
149             }
150 
151             Object paramObj3 = description;
152 
153             if (description == null) {
154                 paramObj3 = new NullWrapper("java.lang.String");
155             }
156 
157             Object paramObj4 = communityPermissions;
158 
159             if (communityPermissions == null) {
160                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
161             }
162 
163             Object paramObj5 = guestPermissions;
164 
165             if (guestPermissions == null) {
166                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
167             }
168 
169             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
170                     "addCategory",
171                     new Object[] {
172                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
173                         paramObj5
174                     });
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 void deleteCategory(HttpPrincipal httpPrincipal,
203         long categoryId)
204         throws com.liferay.portal.PortalException,
205             com.liferay.portal.SystemException {
206         try {
207             Object paramObj0 = new LongWrapper(categoryId);
208 
209             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
210                     "deleteCategory", new Object[] { paramObj0 });
211 
212             try {
213                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
214             }
215             catch (Exception e) {
216                 if (e instanceof com.liferay.portal.PortalException) {
217                     throw (com.liferay.portal.PortalException)e;
218                 }
219 
220                 if (e instanceof com.liferay.portal.SystemException) {
221                     throw (com.liferay.portal.SystemException)e;
222                 }
223 
224                 throw new com.liferay.portal.SystemException(e);
225             }
226         }
227         catch (com.liferay.portal.SystemException se) {
228             _log.error(se, se);
229 
230             throw se;
231         }
232     }
233 
234     public static com.liferay.portlet.shopping.model.ShoppingCategory getCategory(
235         HttpPrincipal httpPrincipal, long categoryId)
236         throws com.liferay.portal.PortalException,
237             com.liferay.portal.SystemException {
238         try {
239             Object paramObj0 = new LongWrapper(categoryId);
240 
241             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
242                     "getCategory", new Object[] { paramObj0 });
243 
244             Object returnObj = null;
245 
246             try {
247                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
248             }
249             catch (Exception e) {
250                 if (e instanceof com.liferay.portal.PortalException) {
251                     throw (com.liferay.portal.PortalException)e;
252                 }
253 
254                 if (e instanceof com.liferay.portal.SystemException) {
255                     throw (com.liferay.portal.SystemException)e;
256                 }
257 
258                 throw new com.liferay.portal.SystemException(e);
259             }
260 
261             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
262         }
263         catch (com.liferay.portal.SystemException se) {
264             _log.error(se, se);
265 
266             throw se;
267         }
268     }
269 
270     public static com.liferay.portlet.shopping.model.ShoppingCategory updateCategory(
271         HttpPrincipal httpPrincipal, long categoryId, long parentCategoryId,
272         java.lang.String name, java.lang.String description,
273         boolean mergeWithParentCategory)
274         throws com.liferay.portal.PortalException,
275             com.liferay.portal.SystemException {
276         try {
277             Object paramObj0 = new LongWrapper(categoryId);
278 
279             Object paramObj1 = new LongWrapper(parentCategoryId);
280 
281             Object paramObj2 = name;
282 
283             if (name == null) {
284                 paramObj2 = new NullWrapper("java.lang.String");
285             }
286 
287             Object paramObj3 = description;
288 
289             if (description == null) {
290                 paramObj3 = new NullWrapper("java.lang.String");
291             }
292 
293             Object paramObj4 = new BooleanWrapper(mergeWithParentCategory);
294 
295             MethodWrapper methodWrapper = new MethodWrapper(ShoppingCategoryServiceUtil.class.getName(),
296                     "updateCategory",
297                     new Object[] {
298                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
299                     });
300 
301             Object returnObj = null;
302 
303             try {
304                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
305             }
306             catch (Exception e) {
307                 if (e instanceof com.liferay.portal.PortalException) {
308                     throw (com.liferay.portal.PortalException)e;
309                 }
310 
311                 if (e instanceof com.liferay.portal.SystemException) {
312                     throw (com.liferay.portal.SystemException)e;
313                 }
314 
315                 throw new com.liferay.portal.SystemException(e);
316             }
317 
318             return (com.liferay.portlet.shopping.model.ShoppingCategory)returnObj;
319         }
320         catch (com.liferay.portal.SystemException se) {
321             _log.error(se, se);
322 
323             throw se;
324         }
325     }
326 
327     private static Log _log = LogFactoryUtil.getLog(ShoppingCategoryServiceHttp.class);
328 }