1   /**
2    * Copyright (c) 2000-2008 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.wiki.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.DoubleWrapper;
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.wiki.service.WikiPageServiceUtil;
35  
36  /**
37   * <a href="WikiPageServiceHttp.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.wiki.service.WikiPageServiceUtil</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.wiki.service.WikiPageServiceUtil
72   * @see com.liferay.portlet.wiki.service.http.WikiPageServiceSoap
73   *
74   */
75  public class WikiPageServiceHttp {
76      public static com.liferay.portlet.wiki.model.WikiPage addPage(
77          HttpPrincipal httpPrincipal, long nodeId, java.lang.String title)
78          throws com.liferay.portal.SystemException, 
79              com.liferay.portal.PortalException {
80          try {
81              Object paramObj0 = new LongWrapper(nodeId);
82  
83              Object paramObj1 = title;
84  
85              if (title == null) {
86                  paramObj1 = new NullWrapper("java.lang.String");
87              }
88  
89              MethodWrapper methodWrapper = new MethodWrapper(WikiPageServiceUtil.class.getName(),
90                      "addPage", new Object[] { paramObj0, paramObj1 });
91  
92              Object returnObj = null;
93  
94              try {
95                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
96              }
97              catch (Exception e) {
98                  if (e instanceof com.liferay.portal.SystemException) {
99                      throw (com.liferay.portal.SystemException)e;
100                 }
101 
102                 if (e instanceof com.liferay.portal.PortalException) {
103                     throw (com.liferay.portal.PortalException)e;
104                 }
105 
106                 throw new com.liferay.portal.SystemException(e);
107             }
108 
109             return (com.liferay.portlet.wiki.model.WikiPage)returnObj;
110         }
111         catch (com.liferay.portal.SystemException se) {
112             _log.error(se, se);
113 
114             throw se;
115         }
116     }
117 
118     public static void deletePage(HttpPrincipal httpPrincipal, long nodeId,
119         java.lang.String title)
120         throws com.liferay.portal.SystemException, 
121             com.liferay.portal.PortalException {
122         try {
123             Object paramObj0 = new LongWrapper(nodeId);
124 
125             Object paramObj1 = title;
126 
127             if (title == null) {
128                 paramObj1 = new NullWrapper("java.lang.String");
129             }
130 
131             MethodWrapper methodWrapper = new MethodWrapper(WikiPageServiceUtil.class.getName(),
132                     "deletePage", new Object[] { paramObj0, paramObj1 });
133 
134             try {
135                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
136             }
137             catch (Exception e) {
138                 if (e instanceof com.liferay.portal.SystemException) {
139                     throw (com.liferay.portal.SystemException)e;
140                 }
141 
142                 if (e instanceof com.liferay.portal.PortalException) {
143                     throw (com.liferay.portal.PortalException)e;
144                 }
145 
146                 throw new com.liferay.portal.SystemException(e);
147             }
148         }
149         catch (com.liferay.portal.SystemException se) {
150             _log.error(se, se);
151 
152             throw se;
153         }
154     }
155 
156     public static com.liferay.portlet.wiki.model.WikiPage getPage(
157         HttpPrincipal httpPrincipal, long nodeId, java.lang.String title)
158         throws com.liferay.portal.SystemException, 
159             com.liferay.portal.PortalException {
160         try {
161             Object paramObj0 = new LongWrapper(nodeId);
162 
163             Object paramObj1 = title;
164 
165             if (title == null) {
166                 paramObj1 = new NullWrapper("java.lang.String");
167             }
168 
169             MethodWrapper methodWrapper = new MethodWrapper(WikiPageServiceUtil.class.getName(),
170                     "getPage", new Object[] { paramObj0, paramObj1 });
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.SystemException) {
179                     throw (com.liferay.portal.SystemException)e;
180                 }
181 
182                 if (e instanceof com.liferay.portal.PortalException) {
183                     throw (com.liferay.portal.PortalException)e;
184                 }
185 
186                 throw new com.liferay.portal.SystemException(e);
187             }
188 
189             return (com.liferay.portlet.wiki.model.WikiPage)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.wiki.model.WikiPage getPage(
199         HttpPrincipal httpPrincipal, long nodeId, java.lang.String title,
200         double version)
201         throws com.liferay.portal.SystemException, 
202             com.liferay.portal.PortalException {
203         try {
204             Object paramObj0 = new LongWrapper(nodeId);
205 
206             Object paramObj1 = title;
207 
208             if (title == null) {
209                 paramObj1 = new NullWrapper("java.lang.String");
210             }
211 
212             Object paramObj2 = new DoubleWrapper(version);
213 
214             MethodWrapper methodWrapper = new MethodWrapper(WikiPageServiceUtil.class.getName(),
215                     "getPage", new Object[] { paramObj0, paramObj1, paramObj2 });
216 
217             Object returnObj = null;
218 
219             try {
220                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
221             }
222             catch (Exception e) {
223                 if (e instanceof com.liferay.portal.SystemException) {
224                     throw (com.liferay.portal.SystemException)e;
225                 }
226 
227                 if (e instanceof com.liferay.portal.PortalException) {
228                     throw (com.liferay.portal.PortalException)e;
229                 }
230 
231                 throw new com.liferay.portal.SystemException(e);
232             }
233 
234             return (com.liferay.portlet.wiki.model.WikiPage)returnObj;
235         }
236         catch (com.liferay.portal.SystemException se) {
237             _log.error(se, se);
238 
239             throw se;
240         }
241     }
242 
243     public static com.liferay.portlet.wiki.model.WikiPage revertPage(
244         HttpPrincipal httpPrincipal, long nodeId, java.lang.String title,
245         double version)
246         throws com.liferay.portal.SystemException, 
247             com.liferay.portal.PortalException {
248         try {
249             Object paramObj0 = new LongWrapper(nodeId);
250 
251             Object paramObj1 = title;
252 
253             if (title == null) {
254                 paramObj1 = new NullWrapper("java.lang.String");
255             }
256 
257             Object paramObj2 = new DoubleWrapper(version);
258 
259             MethodWrapper methodWrapper = new MethodWrapper(WikiPageServiceUtil.class.getName(),
260                     "revertPage",
261                     new Object[] { paramObj0, paramObj1, paramObj2 });
262 
263             Object returnObj = null;
264 
265             try {
266                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
267             }
268             catch (Exception e) {
269                 if (e instanceof com.liferay.portal.SystemException) {
270                     throw (com.liferay.portal.SystemException)e;
271                 }
272 
273                 if (e instanceof com.liferay.portal.PortalException) {
274                     throw (com.liferay.portal.PortalException)e;
275                 }
276 
277                 throw new com.liferay.portal.SystemException(e);
278             }
279 
280             return (com.liferay.portlet.wiki.model.WikiPage)returnObj;
281         }
282         catch (com.liferay.portal.SystemException se) {
283             _log.error(se, se);
284 
285             throw se;
286         }
287     }
288 
289     public static com.liferay.portlet.wiki.model.WikiPage updatePage(
290         HttpPrincipal httpPrincipal, long nodeId, java.lang.String title,
291         java.lang.String content, java.lang.String format,
292         java.lang.String[] tagsEntries)
293         throws com.liferay.portal.SystemException, 
294             com.liferay.portal.PortalException {
295         try {
296             Object paramObj0 = new LongWrapper(nodeId);
297 
298             Object paramObj1 = title;
299 
300             if (title == null) {
301                 paramObj1 = new NullWrapper("java.lang.String");
302             }
303 
304             Object paramObj2 = content;
305 
306             if (content == null) {
307                 paramObj2 = new NullWrapper("java.lang.String");
308             }
309 
310             Object paramObj3 = format;
311 
312             if (format == null) {
313                 paramObj3 = new NullWrapper("java.lang.String");
314             }
315 
316             Object paramObj4 = tagsEntries;
317 
318             if (tagsEntries == null) {
319                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
320             }
321 
322             MethodWrapper methodWrapper = new MethodWrapper(WikiPageServiceUtil.class.getName(),
323                     "updatePage",
324                     new Object[] {
325                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
326                     });
327 
328             Object returnObj = null;
329 
330             try {
331                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
332             }
333             catch (Exception e) {
334                 if (e instanceof com.liferay.portal.SystemException) {
335                     throw (com.liferay.portal.SystemException)e;
336                 }
337 
338                 if (e instanceof com.liferay.portal.PortalException) {
339                     throw (com.liferay.portal.PortalException)e;
340                 }
341 
342                 throw new com.liferay.portal.SystemException(e);
343             }
344 
345             return (com.liferay.portlet.wiki.model.WikiPage)returnObj;
346         }
347         catch (com.liferay.portal.SystemException se) {
348             _log.error(se, se);
349 
350             throw se;
351         }
352     }
353 
354     private static Log _log = LogFactoryUtil.getLog(WikiPageServiceHttp.class);
355 }