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.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.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.bookmarks.service.BookmarksFolderServiceUtil;
35  
36  /**
37   * <a href="BookmarksFolderServiceHttp.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.bookmarks.service.BookmarksFolderServiceUtil</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.bookmarks.service.BookmarksFolderServiceUtil
70   * @see com.liferay.portlet.bookmarks.service.http.BookmarksFolderServiceSoap
71   *
72   */
73  public class BookmarksFolderServiceHttp {
74      public static com.liferay.portlet.bookmarks.model.BookmarksFolder addFolder(
75          HttpPrincipal httpPrincipal, long plid, long parentFolderId,
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(parentFolderId);
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(BookmarksFolderServiceUtil.class.getName(),
98                      "addFolder",
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.bookmarks.model.BookmarksFolder)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.bookmarks.model.BookmarksFolder addFolder(
129         HttpPrincipal httpPrincipal, long plid, long parentFolderId,
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(parentFolderId);
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(BookmarksFolderServiceUtil.class.getName(),
163                     "addFolder",
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.bookmarks.model.BookmarksFolder)returnObj;
186         }
187         catch (com.liferay.portal.SystemException se) {
188             _log.error(se, se);
189             throw se;
190         }
191     }
192 
193     public static void deleteFolder(HttpPrincipal httpPrincipal, long folderId)
194         throws com.liferay.portal.SystemException, 
195             com.liferay.portal.PortalException {
196         try {
197             Object paramObj0 = new LongWrapper(folderId);
198             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
199                     "deleteFolder", new Object[] { paramObj0 });
200 
201             try {
202                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
203             }
204             catch (Exception e) {
205                 if (e instanceof com.liferay.portal.SystemException) {
206                     throw (com.liferay.portal.SystemException)e;
207                 }
208 
209                 if (e instanceof com.liferay.portal.PortalException) {
210                     throw (com.liferay.portal.PortalException)e;
211                 }
212 
213                 throw new com.liferay.portal.SystemException(e);
214             }
215         }
216         catch (com.liferay.portal.SystemException se) {
217             _log.error(se, se);
218             throw se;
219         }
220     }
221 
222     public static com.liferay.portlet.bookmarks.model.BookmarksFolder getFolder(
223         HttpPrincipal httpPrincipal, long folderId)
224         throws com.liferay.portal.SystemException, 
225             com.liferay.portal.PortalException {
226         try {
227             Object paramObj0 = new LongWrapper(folderId);
228             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
229                     "getFolder", new Object[] { paramObj0 });
230             Object returnObj = null;
231 
232             try {
233                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
234             }
235             catch (Exception e) {
236                 if (e instanceof com.liferay.portal.SystemException) {
237                     throw (com.liferay.portal.SystemException)e;
238                 }
239 
240                 if (e instanceof com.liferay.portal.PortalException) {
241                     throw (com.liferay.portal.PortalException)e;
242                 }
243 
244                 throw new com.liferay.portal.SystemException(e);
245             }
246 
247             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
248         }
249         catch (com.liferay.portal.SystemException se) {
250             _log.error(se, se);
251             throw se;
252         }
253     }
254 
255     public static com.liferay.portlet.bookmarks.model.BookmarksFolder updateFolder(
256         HttpPrincipal httpPrincipal, long folderId, long parentFolderId,
257         java.lang.String name, java.lang.String description,
258         boolean mergeWithParentFolder)
259         throws com.liferay.portal.SystemException, 
260             com.liferay.portal.PortalException {
261         try {
262             Object paramObj0 = new LongWrapper(folderId);
263             Object paramObj1 = new LongWrapper(parentFolderId);
264             Object paramObj2 = name;
265 
266             if (name == null) {
267                 paramObj2 = new NullWrapper("java.lang.String");
268             }
269 
270             Object paramObj3 = description;
271 
272             if (description == null) {
273                 paramObj3 = new NullWrapper("java.lang.String");
274             }
275 
276             Object paramObj4 = new BooleanWrapper(mergeWithParentFolder);
277             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
278                     "updateFolder",
279                     new Object[] {
280                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
281                     });
282             Object returnObj = null;
283 
284             try {
285                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
286             }
287             catch (Exception e) {
288                 if (e instanceof com.liferay.portal.SystemException) {
289                     throw (com.liferay.portal.SystemException)e;
290                 }
291 
292                 if (e instanceof com.liferay.portal.PortalException) {
293                     throw (com.liferay.portal.PortalException)e;
294                 }
295 
296                 throw new com.liferay.portal.SystemException(e);
297             }
298 
299             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
300         }
301         catch (com.liferay.portal.SystemException se) {
302             _log.error(se, se);
303             throw se;
304         }
305     }
306 
307     private static Log _log = LogFactoryUtil.getLog(BookmarksFolderServiceHttp.class);
308 }