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.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.LongWrapper;
28  import com.liferay.portal.kernel.util.MethodWrapper;
29  import com.liferay.portal.kernel.util.NullWrapper;
30  import com.liferay.portal.security.auth.HttpPrincipal;
31  import com.liferay.portal.service.http.TunnelUtil;
32  
33  import com.liferay.portlet.wiki.service.WikiNodeServiceUtil;
34  
35  /**
36   * <a href="WikiNodeServiceHttp.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be
40   * overwritten the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class provides a HTTP utility for the
45   * <code>com.liferay.portlet.wiki.service.WikiNodeServiceUtil</code> service
46   * 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>
49   * parameter.
50   * </p>
51   *
52   * <p>
53   * The benefits of using the HTTP utility is that it is fast and allows for
54   * tunneling without the cost of serializing to text. The drawback is that it
55   * only works with Java.
56   * </p>
57   *
58   * <p>
59   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
60   * portal.properties to configure security.
61   * </p>
62   *
63   * <p>
64   * The HTTP utility is only generated for remote services.
65   * </p>
66   *
67   * @author Brian Wing Shun Chan
68   *
69   * @see com.liferay.portal.security.auth.HttpPrincipal
70   * @see com.liferay.portlet.wiki.service.WikiNodeServiceUtil
71   * @see com.liferay.portlet.wiki.service.http.WikiNodeServiceSoap
72   *
73   */
74  public class WikiNodeServiceHttp {
75      public static com.liferay.portlet.wiki.model.WikiNode addNode(
76          HttpPrincipal httpPrincipal, java.lang.String name,
77          java.lang.String description,
78          com.liferay.portal.service.ServiceContext serviceContext)
79          throws com.liferay.portal.PortalException,
80              com.liferay.portal.SystemException {
81          try {
82              Object paramObj0 = name;
83  
84              if (name == null) {
85                  paramObj0 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj1 = description;
89  
90              if (description == null) {
91                  paramObj1 = new NullWrapper("java.lang.String");
92              }
93  
94              Object paramObj2 = serviceContext;
95  
96              if (serviceContext == null) {
97                  paramObj2 = new NullWrapper(
98                          "com.liferay.portal.service.ServiceContext");
99              }
100 
101             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
102                     "addNode", new Object[] { paramObj0, paramObj1, paramObj2 });
103 
104             Object returnObj = null;
105 
106             try {
107                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
108             }
109             catch (Exception e) {
110                 if (e instanceof com.liferay.portal.PortalException) {
111                     throw (com.liferay.portal.PortalException)e;
112                 }
113 
114                 if (e instanceof com.liferay.portal.SystemException) {
115                     throw (com.liferay.portal.SystemException)e;
116                 }
117 
118                 throw new com.liferay.portal.SystemException(e);
119             }
120 
121             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
122         }
123         catch (com.liferay.portal.SystemException se) {
124             _log.error(se, se);
125 
126             throw se;
127         }
128     }
129 
130     public static void deleteNode(HttpPrincipal httpPrincipal, long nodeId)
131         throws com.liferay.portal.PortalException,
132             com.liferay.portal.SystemException {
133         try {
134             Object paramObj0 = new LongWrapper(nodeId);
135 
136             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
137                     "deleteNode", new Object[] { paramObj0 });
138 
139             try {
140                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
141             }
142             catch (Exception e) {
143                 if (e instanceof com.liferay.portal.PortalException) {
144                     throw (com.liferay.portal.PortalException)e;
145                 }
146 
147                 if (e instanceof com.liferay.portal.SystemException) {
148                     throw (com.liferay.portal.SystemException)e;
149                 }
150 
151                 throw new com.liferay.portal.SystemException(e);
152             }
153         }
154         catch (com.liferay.portal.SystemException se) {
155             _log.error(se, se);
156 
157             throw se;
158         }
159     }
160 
161     public static com.liferay.portlet.wiki.model.WikiNode getNode(
162         HttpPrincipal httpPrincipal, long nodeId)
163         throws com.liferay.portal.PortalException,
164             com.liferay.portal.SystemException {
165         try {
166             Object paramObj0 = new LongWrapper(nodeId);
167 
168             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
169                     "getNode", new Object[] { paramObj0 });
170 
171             Object returnObj = null;
172 
173             try {
174                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
175             }
176             catch (Exception e) {
177                 if (e instanceof com.liferay.portal.PortalException) {
178                     throw (com.liferay.portal.PortalException)e;
179                 }
180 
181                 if (e instanceof com.liferay.portal.SystemException) {
182                     throw (com.liferay.portal.SystemException)e;
183                 }
184 
185                 throw new com.liferay.portal.SystemException(e);
186             }
187 
188             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
189         }
190         catch (com.liferay.portal.SystemException se) {
191             _log.error(se, se);
192 
193             throw se;
194         }
195     }
196 
197     public static com.liferay.portlet.wiki.model.WikiNode getNode(
198         HttpPrincipal httpPrincipal, long groupId, java.lang.String name)
199         throws com.liferay.portal.PortalException,
200             com.liferay.portal.SystemException {
201         try {
202             Object paramObj0 = new LongWrapper(groupId);
203 
204             Object paramObj1 = name;
205 
206             if (name == null) {
207                 paramObj1 = new NullWrapper("java.lang.String");
208             }
209 
210             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
211                     "getNode", new Object[] { paramObj0, paramObj1 });
212 
213             Object returnObj = null;
214 
215             try {
216                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
217             }
218             catch (Exception e) {
219                 if (e instanceof com.liferay.portal.PortalException) {
220                     throw (com.liferay.portal.PortalException)e;
221                 }
222 
223                 if (e instanceof com.liferay.portal.SystemException) {
224                     throw (com.liferay.portal.SystemException)e;
225                 }
226 
227                 throw new com.liferay.portal.SystemException(e);
228             }
229 
230             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
231         }
232         catch (com.liferay.portal.SystemException se) {
233             _log.error(se, se);
234 
235             throw se;
236         }
237     }
238 
239     public static void importPages(HttpPrincipal httpPrincipal, long nodeId,
240         java.lang.String importer, java.io.File[] files,
241         java.util.Map<String, String[]> options)
242         throws com.liferay.portal.PortalException,
243             com.liferay.portal.SystemException {
244         try {
245             Object paramObj0 = new LongWrapper(nodeId);
246 
247             Object paramObj1 = importer;
248 
249             if (importer == null) {
250                 paramObj1 = new NullWrapper("java.lang.String");
251             }
252 
253             Object paramObj2 = files;
254 
255             if (files == null) {
256                 paramObj2 = new NullWrapper("[Ljava.io.File;");
257             }
258 
259             Object paramObj3 = options;
260 
261             if (options == null) {
262                 paramObj3 = new NullWrapper("java.util.Map");
263             }
264 
265             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
266                     "importPages",
267                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
268 
269             try {
270                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
271             }
272             catch (Exception e) {
273                 if (e instanceof com.liferay.portal.PortalException) {
274                     throw (com.liferay.portal.PortalException)e;
275                 }
276 
277                 if (e instanceof com.liferay.portal.SystemException) {
278                     throw (com.liferay.portal.SystemException)e;
279                 }
280 
281                 throw new com.liferay.portal.SystemException(e);
282             }
283         }
284         catch (com.liferay.portal.SystemException se) {
285             _log.error(se, se);
286 
287             throw se;
288         }
289     }
290 
291     public static void subscribeNode(HttpPrincipal httpPrincipal, long nodeId)
292         throws com.liferay.portal.PortalException,
293             com.liferay.portal.SystemException {
294         try {
295             Object paramObj0 = new LongWrapper(nodeId);
296 
297             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
298                     "subscribeNode", new Object[] { paramObj0 });
299 
300             try {
301                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
302             }
303             catch (Exception e) {
304                 if (e instanceof com.liferay.portal.PortalException) {
305                     throw (com.liferay.portal.PortalException)e;
306                 }
307 
308                 if (e instanceof com.liferay.portal.SystemException) {
309                     throw (com.liferay.portal.SystemException)e;
310                 }
311 
312                 throw new com.liferay.portal.SystemException(e);
313             }
314         }
315         catch (com.liferay.portal.SystemException se) {
316             _log.error(se, se);
317 
318             throw se;
319         }
320     }
321 
322     public static void unsubscribeNode(HttpPrincipal httpPrincipal, long nodeId)
323         throws com.liferay.portal.PortalException,
324             com.liferay.portal.SystemException {
325         try {
326             Object paramObj0 = new LongWrapper(nodeId);
327 
328             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
329                     "unsubscribeNode", new Object[] { paramObj0 });
330 
331             try {
332                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
333             }
334             catch (Exception e) {
335                 if (e instanceof com.liferay.portal.PortalException) {
336                     throw (com.liferay.portal.PortalException)e;
337                 }
338 
339                 if (e instanceof com.liferay.portal.SystemException) {
340                     throw (com.liferay.portal.SystemException)e;
341                 }
342 
343                 throw new com.liferay.portal.SystemException(e);
344             }
345         }
346         catch (com.liferay.portal.SystemException se) {
347             _log.error(se, se);
348 
349             throw se;
350         }
351     }
352 
353     public static com.liferay.portlet.wiki.model.WikiNode updateNode(
354         HttpPrincipal httpPrincipal, long nodeId, java.lang.String name,
355         java.lang.String description)
356         throws com.liferay.portal.PortalException,
357             com.liferay.portal.SystemException {
358         try {
359             Object paramObj0 = new LongWrapper(nodeId);
360 
361             Object paramObj1 = name;
362 
363             if (name == null) {
364                 paramObj1 = new NullWrapper("java.lang.String");
365             }
366 
367             Object paramObj2 = description;
368 
369             if (description == null) {
370                 paramObj2 = new NullWrapper("java.lang.String");
371             }
372 
373             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
374                     "updateNode",
375                     new Object[] { paramObj0, paramObj1, paramObj2 });
376 
377             Object returnObj = null;
378 
379             try {
380                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
381             }
382             catch (Exception e) {
383                 if (e instanceof com.liferay.portal.PortalException) {
384                     throw (com.liferay.portal.PortalException)e;
385                 }
386 
387                 if (e instanceof com.liferay.portal.SystemException) {
388                     throw (com.liferay.portal.SystemException)e;
389                 }
390 
391                 throw new com.liferay.portal.SystemException(e);
392             }
393 
394             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
395         }
396         catch (com.liferay.portal.SystemException se) {
397             _log.error(se, se);
398 
399             throw se;
400         }
401     }
402 
403     private static Log _log = LogFactoryUtil.getLog(WikiNodeServiceHttp.class);
404 }