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.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
41   * overwritten the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This class provides a HTTP utility for the
46   * <code>com.liferay.portlet.bookmarks.service.BookmarksFolderServiceUtil</code> service
47   * utility. The static methods of this class calls the same methods of the
48   * service utility. However, the signatures are different because it requires an
49   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
50   * parameter.
51   * </p>
52   *
53   * <p>
54   * The benefits of using the HTTP utility is that it is fast and allows for
55   * tunneling without the cost of serializing to text. The drawback is that it
56   * only works with Java.
57   * </p>
58   *
59   * <p>
60   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
61   * portal.properties to configure security.
62   * </p>
63   *
64   * <p>
65   * The HTTP utility is only generated for remote services.
66   * </p>
67   *
68   * @author Brian Wing Shun Chan
69   *
70   * @see com.liferay.portal.security.auth.HttpPrincipal
71   * @see com.liferay.portlet.bookmarks.service.BookmarksFolderServiceUtil
72   * @see com.liferay.portlet.bookmarks.service.http.BookmarksFolderServiceSoap
73   *
74   */
75  public class BookmarksFolderServiceHttp {
76      public static com.liferay.portlet.bookmarks.model.BookmarksFolder addFolder(
77          HttpPrincipal httpPrincipal, long parentFolderId,
78          java.lang.String name, java.lang.String description,
79          com.liferay.portal.service.ServiceContext serviceContext)
80          throws com.liferay.portal.PortalException,
81              com.liferay.portal.SystemException {
82          try {
83              Object paramObj0 = new LongWrapper(parentFolderId);
84  
85              Object paramObj1 = name;
86  
87              if (name == null) {
88                  paramObj1 = new NullWrapper("java.lang.String");
89              }
90  
91              Object paramObj2 = description;
92  
93              if (description == null) {
94                  paramObj2 = new NullWrapper("java.lang.String");
95              }
96  
97              Object paramObj3 = serviceContext;
98  
99              if (serviceContext == null) {
100                 paramObj3 = new NullWrapper(
101                         "com.liferay.portal.service.ServiceContext");
102             }
103 
104             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
105                     "addFolder",
106                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
107 
108             Object returnObj = null;
109 
110             try {
111                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
112             }
113             catch (Exception e) {
114                 if (e instanceof com.liferay.portal.PortalException) {
115                     throw (com.liferay.portal.PortalException)e;
116                 }
117 
118                 if (e instanceof com.liferay.portal.SystemException) {
119                     throw (com.liferay.portal.SystemException)e;
120                 }
121 
122                 throw new com.liferay.portal.SystemException(e);
123             }
124 
125             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
126         }
127         catch (com.liferay.portal.SystemException se) {
128             _log.error(se, se);
129 
130             throw se;
131         }
132     }
133 
134     public static void deleteFolder(HttpPrincipal httpPrincipal, long folderId)
135         throws com.liferay.portal.PortalException,
136             com.liferay.portal.SystemException {
137         try {
138             Object paramObj0 = new LongWrapper(folderId);
139 
140             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
141                     "deleteFolder", new Object[] { paramObj0 });
142 
143             try {
144                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
145             }
146             catch (Exception e) {
147                 if (e instanceof com.liferay.portal.PortalException) {
148                     throw (com.liferay.portal.PortalException)e;
149                 }
150 
151                 if (e instanceof com.liferay.portal.SystemException) {
152                     throw (com.liferay.portal.SystemException)e;
153                 }
154 
155                 throw new com.liferay.portal.SystemException(e);
156             }
157         }
158         catch (com.liferay.portal.SystemException se) {
159             _log.error(se, se);
160 
161             throw se;
162         }
163     }
164 
165     public static com.liferay.portlet.bookmarks.model.BookmarksFolder getFolder(
166         HttpPrincipal httpPrincipal, long folderId)
167         throws com.liferay.portal.PortalException,
168             com.liferay.portal.SystemException {
169         try {
170             Object paramObj0 = new LongWrapper(folderId);
171 
172             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
173                     "getFolder", new Object[] { paramObj0 });
174 
175             Object returnObj = null;
176 
177             try {
178                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
179             }
180             catch (Exception e) {
181                 if (e instanceof com.liferay.portal.PortalException) {
182                     throw (com.liferay.portal.PortalException)e;
183                 }
184 
185                 if (e instanceof com.liferay.portal.SystemException) {
186                     throw (com.liferay.portal.SystemException)e;
187                 }
188 
189                 throw new com.liferay.portal.SystemException(e);
190             }
191 
192             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
193         }
194         catch (com.liferay.portal.SystemException se) {
195             _log.error(se, se);
196 
197             throw se;
198         }
199     }
200 
201     public static com.liferay.portlet.bookmarks.model.BookmarksFolder updateFolder(
202         HttpPrincipal httpPrincipal, long folderId, long parentFolderId,
203         java.lang.String name, java.lang.String description,
204         boolean mergeWithParentFolder)
205         throws com.liferay.portal.PortalException,
206             com.liferay.portal.SystemException {
207         try {
208             Object paramObj0 = new LongWrapper(folderId);
209 
210             Object paramObj1 = new LongWrapper(parentFolderId);
211 
212             Object paramObj2 = name;
213 
214             if (name == null) {
215                 paramObj2 = new NullWrapper("java.lang.String");
216             }
217 
218             Object paramObj3 = description;
219 
220             if (description == null) {
221                 paramObj3 = new NullWrapper("java.lang.String");
222             }
223 
224             Object paramObj4 = new BooleanWrapper(mergeWithParentFolder);
225 
226             MethodWrapper methodWrapper = new MethodWrapper(BookmarksFolderServiceUtil.class.getName(),
227                     "updateFolder",
228                     new Object[] {
229                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
230                     });
231 
232             Object returnObj = null;
233 
234             try {
235                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
236             }
237             catch (Exception e) {
238                 if (e instanceof com.liferay.portal.PortalException) {
239                     throw (com.liferay.portal.PortalException)e;
240                 }
241 
242                 if (e instanceof com.liferay.portal.SystemException) {
243                     throw (com.liferay.portal.SystemException)e;
244                 }
245 
246                 throw new com.liferay.portal.SystemException(e);
247             }
248 
249             return (com.liferay.portlet.bookmarks.model.BookmarksFolder)returnObj;
250         }
251         catch (com.liferay.portal.SystemException se) {
252             _log.error(se, se);
253 
254             throw se;
255         }
256     }
257 
258     private static Log _log = LogFactoryUtil.getLog(BookmarksFolderServiceHttp.class);
259 }