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.bookmarks.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.LongWrapper;
28  import com.liferay.portal.kernel.util.MethodWrapper;
29  import com.liferay.portal.kernel.util.NullWrapper;
30  import com.liferay.portal.security.auth.HttpPrincipal;
31  import com.liferay.portal.service.http.TunnelUtil;
32  
33  import com.liferay.portlet.bookmarks.service.BookmarksEntryServiceUtil;
34  
35  /**
36   * <a href="BookmarksEntryServiceHttp.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be
40   * overwritten the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class provides a HTTP utility for the
45   * <code>com.liferay.portlet.bookmarks.service.BookmarksEntryServiceUtil</code> service
46   * 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>
49   * 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 <code>tunnel.servlet.hosts.allowed</code> in
60   * portal.properties to 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   *
69   * @see com.liferay.portal.security.auth.HttpPrincipal
70   * @see com.liferay.portlet.bookmarks.service.BookmarksEntryServiceUtil
71   * @see com.liferay.portlet.bookmarks.service.http.BookmarksEntryServiceSoap
72   *
73   */
74  public class BookmarksEntryServiceHttp {
75      public static com.liferay.portlet.bookmarks.model.BookmarksEntry addEntry(
76          HttpPrincipal httpPrincipal, long folderId, java.lang.String name,
77          java.lang.String url, java.lang.String comments,
78          com.liferay.portal.service.ServiceContext serviceContext)
79          throws com.liferay.portal.PortalException,
80              com.liferay.portal.SystemException {
81          try {
82              Object paramObj0 = new LongWrapper(folderId);
83  
84              Object paramObj1 = name;
85  
86              if (name == null) {
87                  paramObj1 = new NullWrapper("java.lang.String");
88              }
89  
90              Object paramObj2 = url;
91  
92              if (url == null) {
93                  paramObj2 = new NullWrapper("java.lang.String");
94              }
95  
96              Object paramObj3 = comments;
97  
98              if (comments == null) {
99                  paramObj3 = new NullWrapper("java.lang.String");
100             }
101 
102             Object paramObj4 = serviceContext;
103 
104             if (serviceContext == null) {
105                 paramObj4 = new NullWrapper(
106                         "com.liferay.portal.service.ServiceContext");
107             }
108 
109             MethodWrapper methodWrapper = new MethodWrapper(BookmarksEntryServiceUtil.class.getName(),
110                     "addEntry",
111                     new Object[] {
112                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
113                     });
114 
115             Object returnObj = null;
116 
117             try {
118                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
119             }
120             catch (Exception e) {
121                 if (e instanceof com.liferay.portal.PortalException) {
122                     throw (com.liferay.portal.PortalException)e;
123                 }
124 
125                 if (e instanceof com.liferay.portal.SystemException) {
126                     throw (com.liferay.portal.SystemException)e;
127                 }
128 
129                 throw new com.liferay.portal.SystemException(e);
130             }
131 
132             return (com.liferay.portlet.bookmarks.model.BookmarksEntry)returnObj;
133         }
134         catch (com.liferay.portal.SystemException se) {
135             _log.error(se, se);
136 
137             throw se;
138         }
139     }
140 
141     public static void deleteEntry(HttpPrincipal httpPrincipal, long entryId)
142         throws com.liferay.portal.PortalException,
143             com.liferay.portal.SystemException {
144         try {
145             Object paramObj0 = new LongWrapper(entryId);
146 
147             MethodWrapper methodWrapper = new MethodWrapper(BookmarksEntryServiceUtil.class.getName(),
148                     "deleteEntry", new Object[] { paramObj0 });
149 
150             try {
151                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
152             }
153             catch (Exception e) {
154                 if (e instanceof com.liferay.portal.PortalException) {
155                     throw (com.liferay.portal.PortalException)e;
156                 }
157 
158                 if (e instanceof com.liferay.portal.SystemException) {
159                     throw (com.liferay.portal.SystemException)e;
160                 }
161 
162                 throw new com.liferay.portal.SystemException(e);
163             }
164         }
165         catch (com.liferay.portal.SystemException se) {
166             _log.error(se, se);
167 
168             throw se;
169         }
170     }
171 
172     public static com.liferay.portlet.bookmarks.model.BookmarksEntry getEntry(
173         HttpPrincipal httpPrincipal, long entryId)
174         throws com.liferay.portal.PortalException,
175             com.liferay.portal.SystemException {
176         try {
177             Object paramObj0 = new LongWrapper(entryId);
178 
179             MethodWrapper methodWrapper = new MethodWrapper(BookmarksEntryServiceUtil.class.getName(),
180                     "getEntry", new Object[] { paramObj0 });
181 
182             Object returnObj = null;
183 
184             try {
185                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
186             }
187             catch (Exception e) {
188                 if (e instanceof com.liferay.portal.PortalException) {
189                     throw (com.liferay.portal.PortalException)e;
190                 }
191 
192                 if (e instanceof com.liferay.portal.SystemException) {
193                     throw (com.liferay.portal.SystemException)e;
194                 }
195 
196                 throw new com.liferay.portal.SystemException(e);
197             }
198 
199             return (com.liferay.portlet.bookmarks.model.BookmarksEntry)returnObj;
200         }
201         catch (com.liferay.portal.SystemException se) {
202             _log.error(se, se);
203 
204             throw se;
205         }
206     }
207 
208     public static com.liferay.portlet.bookmarks.model.BookmarksEntry openEntry(
209         HttpPrincipal httpPrincipal, long entryId)
210         throws com.liferay.portal.PortalException,
211             com.liferay.portal.SystemException {
212         try {
213             Object paramObj0 = new LongWrapper(entryId);
214 
215             MethodWrapper methodWrapper = new MethodWrapper(BookmarksEntryServiceUtil.class.getName(),
216                     "openEntry", new Object[] { paramObj0 });
217 
218             Object returnObj = null;
219 
220             try {
221                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
222             }
223             catch (Exception e) {
224                 if (e instanceof com.liferay.portal.PortalException) {
225                     throw (com.liferay.portal.PortalException)e;
226                 }
227 
228                 if (e instanceof com.liferay.portal.SystemException) {
229                     throw (com.liferay.portal.SystemException)e;
230                 }
231 
232                 throw new com.liferay.portal.SystemException(e);
233             }
234 
235             return (com.liferay.portlet.bookmarks.model.BookmarksEntry)returnObj;
236         }
237         catch (com.liferay.portal.SystemException se) {
238             _log.error(se, se);
239 
240             throw se;
241         }
242     }
243 
244     public static com.liferay.portlet.bookmarks.model.BookmarksEntry updateEntry(
245         HttpPrincipal httpPrincipal, long entryId, long folderId,
246         java.lang.String name, java.lang.String url, java.lang.String comments,
247         com.liferay.portal.service.ServiceContext serviceContext)
248         throws com.liferay.portal.PortalException,
249             com.liferay.portal.SystemException {
250         try {
251             Object paramObj0 = new LongWrapper(entryId);
252 
253             Object paramObj1 = new LongWrapper(folderId);
254 
255             Object paramObj2 = name;
256 
257             if (name == null) {
258                 paramObj2 = new NullWrapper("java.lang.String");
259             }
260 
261             Object paramObj3 = url;
262 
263             if (url == null) {
264                 paramObj3 = new NullWrapper("java.lang.String");
265             }
266 
267             Object paramObj4 = comments;
268 
269             if (comments == null) {
270                 paramObj4 = new NullWrapper("java.lang.String");
271             }
272 
273             Object paramObj5 = serviceContext;
274 
275             if (serviceContext == null) {
276                 paramObj5 = new NullWrapper(
277                         "com.liferay.portal.service.ServiceContext");
278             }
279 
280             MethodWrapper methodWrapper = new MethodWrapper(BookmarksEntryServiceUtil.class.getName(),
281                     "updateEntry",
282                     new Object[] {
283                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
284                         paramObj5
285                     });
286 
287             Object returnObj = null;
288 
289             try {
290                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
291             }
292             catch (Exception e) {
293                 if (e instanceof com.liferay.portal.PortalException) {
294                     throw (com.liferay.portal.PortalException)e;
295                 }
296 
297                 if (e instanceof com.liferay.portal.SystemException) {
298                     throw (com.liferay.portal.SystemException)e;
299                 }
300 
301                 throw new com.liferay.portal.SystemException(e);
302             }
303 
304             return (com.liferay.portlet.bookmarks.model.BookmarksEntry)returnObj;
305         }
306         catch (com.liferay.portal.SystemException se) {
307             _log.error(se, se);
308 
309             throw se;
310         }
311     }
312 
313     private static Log _log = LogFactoryUtil.getLog(BookmarksEntryServiceHttp.class);
314 }