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