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.bookmarks.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.bookmarks.service.BookmarksFolderServiceUtil;
32  
33  /**
34   * <a href="BookmarksFolderServiceHttp.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.bookmarks.service.BookmarksFolderServiceUtil</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.bookmarks.service.BookmarksFolderServiceUtil
69   * @see com.liferay.portlet.bookmarks.service.http.BookmarksFolderServiceSoap
70   *
71   */
72  public class BookmarksFolderServiceHttp {
73      public static com.liferay.portlet.bookmarks.model.BookmarksFolder addFolder(
74          HttpPrincipal httpPrincipal, long plid, long parentFolderId,
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(parentFolderId);
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(BookmarksFolderServiceUtil.class.getName(),
101                     "addFolder",
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.bookmarks.model.BookmarksFolder)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.bookmarks.model.BookmarksFolder addFolder(
134         HttpPrincipal httpPrincipal, long plid, long parentFolderId,
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(parentFolderId);
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(BookmarksFolderServiceUtil.class.getName(),
170                     "addFolder",
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.bookmarks.model.BookmarksFolder)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 deleteFolder(HttpPrincipal httpPrincipal, long folderId)
203         throws com.liferay.portal.PortalException,
204             com.liferay.portal.SystemException {
205         try {
206             Object paramObj0 = new LongWrapper(folderId);
207 
208             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
209                     "deleteFolder", new Object[] { paramObj0 });
210 
211             try {
212                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
213             }
214             catch (Exception e) {
215                 if (e instanceof com.liferay.portal.PortalException) {
216                     throw (com.liferay.portal.PortalException)e;
217                 }
218 
219                 if (e instanceof com.liferay.portal.SystemException) {
220                     throw (com.liferay.portal.SystemException)e;
221                 }
222 
223                 throw new com.liferay.portal.SystemException(e);
224             }
225         }
226         catch (com.liferay.portal.SystemException se) {
227             _log.error(se, se);
228 
229             throw se;
230         }
231     }
232 
233     public static com.liferay.portlet.bookmarks.model.BookmarksFolder getFolder(
234         HttpPrincipal httpPrincipal, long folderId)
235         throws com.liferay.portal.PortalException,
236             com.liferay.portal.SystemException {
237         try {
238             Object paramObj0 = new LongWrapper(folderId);
239 
240             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
241                     "getFolder", new Object[] { paramObj0 });
242 
243             Object returnObj = null;
244 
245             try {
246                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
247             }
248             catch (Exception e) {
249                 if (e instanceof com.liferay.portal.PortalException) {
250                     throw (com.liferay.portal.PortalException)e;
251                 }
252 
253                 if (e instanceof com.liferay.portal.SystemException) {
254                     throw (com.liferay.portal.SystemException)e;
255                 }
256 
257                 throw new com.liferay.portal.SystemException(e);
258             }
259 
260             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
261         }
262         catch (com.liferay.portal.SystemException se) {
263             _log.error(se, se);
264 
265             throw se;
266         }
267     }
268 
269     public static com.liferay.portlet.bookmarks.model.BookmarksFolder updateFolder(
270         HttpPrincipal httpPrincipal, long folderId, long parentFolderId,
271         java.lang.String name, java.lang.String description,
272         boolean mergeWithParentFolder)
273         throws com.liferay.portal.PortalException,
274             com.liferay.portal.SystemException {
275         try {
276             Object paramObj0 = new LongWrapper(folderId);
277 
278             Object paramObj1 = new LongWrapper(parentFolderId);
279 
280             Object paramObj2 = name;
281 
282             if (name == null) {
283                 paramObj2 = new NullWrapper("java.lang.String");
284             }
285 
286             Object paramObj3 = description;
287 
288             if (description == null) {
289                 paramObj3 = new NullWrapper("java.lang.String");
290             }
291 
292             Object paramObj4 = new BooleanWrapper(mergeWithParentFolder);
293 
294             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
295                     "updateFolder",
296                     new Object[] {
297                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
298                     });
299 
300             Object returnObj = null;
301 
302             try {
303                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
304             }
305             catch (Exception e) {
306                 if (e instanceof com.liferay.portal.PortalException) {
307                     throw (com.liferay.portal.PortalException)e;
308                 }
309 
310                 if (e instanceof com.liferay.portal.SystemException) {
311                     throw (com.liferay.portal.SystemException)e;
312                 }
313 
314                 throw new com.liferay.portal.SystemException(e);
315             }
316 
317             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
318         }
319         catch (com.liferay.portal.SystemException se) {
320             _log.error(se, se);
321 
322             throw se;
323         }
324     }
325 
326     private static Log _log = LogFactoryUtil.getLog(BookmarksFolderServiceHttp.class);
327 }