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 parentFolderId,
75          java.lang.String name, java.lang.String description,
76          com.liferay.portal.service.ServiceContext serviceContext)
77          throws com.liferay.portal.PortalException,
78              com.liferay.portal.SystemException {
79          try {
80              Object paramObj0 = new LongWrapper(parentFolderId);
81  
82              Object paramObj1 = name;
83  
84              if (name == null) {
85                  paramObj1 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj2 = description;
89  
90              if (description == null) {
91                  paramObj2 = new NullWrapper("java.lang.String");
92              }
93  
94              Object paramObj3 = serviceContext;
95  
96              if (serviceContext == null) {
97                  paramObj3 = new NullWrapper(
98                          "com.liferay.portal.service.ServiceContext");
99              }
100 
101             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
102                     "addFolder",
103                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
104 
105             Object returnObj = null;
106 
107             try {
108                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
109             }
110             catch (Exception e) {
111                 if (e instanceof com.liferay.portal.PortalException) {
112                     throw (com.liferay.portal.PortalException)e;
113                 }
114 
115                 if (e instanceof com.liferay.portal.SystemException) {
116                     throw (com.liferay.portal.SystemException)e;
117                 }
118 
119                 throw new com.liferay.portal.SystemException(e);
120             }
121 
122             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
123         }
124         catch (com.liferay.portal.SystemException se) {
125             _log.error(se, se);
126 
127             throw se;
128         }
129     }
130 
131     public static void deleteFolder(HttpPrincipal httpPrincipal, long folderId)
132         throws com.liferay.portal.PortalException,
133             com.liferay.portal.SystemException {
134         try {
135             Object paramObj0 = new LongWrapper(folderId);
136 
137             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
138                     "deleteFolder", new Object[] { paramObj0 });
139 
140             try {
141                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
142             }
143             catch (Exception e) {
144                 if (e instanceof com.liferay.portal.PortalException) {
145                     throw (com.liferay.portal.PortalException)e;
146                 }
147 
148                 if (e instanceof com.liferay.portal.SystemException) {
149                     throw (com.liferay.portal.SystemException)e;
150                 }
151 
152                 throw new com.liferay.portal.SystemException(e);
153             }
154         }
155         catch (com.liferay.portal.SystemException se) {
156             _log.error(se, se);
157 
158             throw se;
159         }
160     }
161 
162     public static com.liferay.portlet.bookmarks.model.BookmarksFolder getFolder(
163         HttpPrincipal httpPrincipal, long folderId)
164         throws com.liferay.portal.PortalException,
165             com.liferay.portal.SystemException {
166         try {
167             Object paramObj0 = new LongWrapper(folderId);
168 
169             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
170                     "getFolder", new Object[] { paramObj0 });
171 
172             Object returnObj = null;
173 
174             try {
175                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
176             }
177             catch (Exception e) {
178                 if (e instanceof com.liferay.portal.PortalException) {
179                     throw (com.liferay.portal.PortalException)e;
180                 }
181 
182                 if (e instanceof com.liferay.portal.SystemException) {
183                     throw (com.liferay.portal.SystemException)e;
184                 }
185 
186                 throw new com.liferay.portal.SystemException(e);
187             }
188 
189             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
190         }
191         catch (com.liferay.portal.SystemException se) {
192             _log.error(se, se);
193 
194             throw se;
195         }
196     }
197 
198     public static com.liferay.portlet.bookmarks.model.BookmarksFolder updateFolder(
199         HttpPrincipal httpPrincipal, long folderId, long parentFolderId,
200         java.lang.String name, java.lang.String description,
201         boolean mergeWithParentFolder,
202         com.liferay.portal.service.ServiceContext serviceContext)
203         throws com.liferay.portal.PortalException,
204             com.liferay.portal.SystemException {
205         try {
206             Object paramObj0 = new LongWrapper(folderId);
207 
208             Object paramObj1 = new LongWrapper(parentFolderId);
209 
210             Object paramObj2 = name;
211 
212             if (name == null) {
213                 paramObj2 = new NullWrapper("java.lang.String");
214             }
215 
216             Object paramObj3 = description;
217 
218             if (description == null) {
219                 paramObj3 = new NullWrapper("java.lang.String");
220             }
221 
222             Object paramObj4 = new BooleanWrapper(mergeWithParentFolder);
223 
224             Object paramObj5 = serviceContext;
225 
226             if (serviceContext == null) {
227                 paramObj5 = new NullWrapper(
228                         "com.liferay.portal.service.ServiceContext");
229             }
230 
231             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
232                     "updateFolder",
233                     new Object[] {
234                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
235                         paramObj5
236                     });
237 
238             Object returnObj = null;
239 
240             try {
241                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
242             }
243             catch (Exception e) {
244                 if (e instanceof com.liferay.portal.PortalException) {
245                     throw (com.liferay.portal.PortalException)e;
246                 }
247 
248                 if (e instanceof com.liferay.portal.SystemException) {
249                     throw (com.liferay.portal.SystemException)e;
250                 }
251 
252                 throw new com.liferay.portal.SystemException(e);
253             }
254 
255             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
256         }
257         catch (com.liferay.portal.SystemException se) {
258             _log.error(se, se);
259 
260             throw se;
261         }
262     }
263 
264     private static Log _log = LogFactoryUtil.getLog(BookmarksFolderServiceHttp.class);
265 }