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.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.wiki.service.WikiNodeServiceUtil;
35  
36  /**
37   * <a href="WikiNodeServiceHttp.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.WikiNodeServiceUtil</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.WikiNodeServiceUtil
72   * @see com.liferay.portlet.wiki.service.http.WikiNodeServiceSoap
73   *
74   */
75  public class WikiNodeServiceHttp {
76      public static com.liferay.portlet.wiki.model.WikiNode addNode(
77          HttpPrincipal httpPrincipal, long plid, java.lang.String name,
78          java.lang.String description, boolean addCommunityPermissions,
79          boolean addGuestPermissions)
80          throws com.liferay.portal.SystemException,
81              com.liferay.portal.PortalException {
82          try {
83              Object paramObj0 = new LongWrapper(plid);
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 = new BooleanWrapper(addCommunityPermissions);
98  
99              Object paramObj4 = new BooleanWrapper(addGuestPermissions);
100 
101             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
102                     "addNode",
103                     new Object[] {
104                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
105                     });
106 
107             Object returnObj = null;
108 
109             try {
110                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
111             }
112             catch (Exception e) {
113                 if (e instanceof com.liferay.portal.SystemException) {
114                     throw (com.liferay.portal.SystemException)e;
115                 }
116 
117                 if (e instanceof com.liferay.portal.PortalException) {
118                     throw (com.liferay.portal.PortalException)e;
119                 }
120 
121                 throw new com.liferay.portal.SystemException(e);
122             }
123 
124             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
125         }
126         catch (com.liferay.portal.SystemException se) {
127             _log.error(se, se);
128 
129             throw se;
130         }
131     }
132 
133     public static com.liferay.portlet.wiki.model.WikiNode addNode(
134         HttpPrincipal httpPrincipal, long plid, java.lang.String name,
135         java.lang.String description, java.lang.String[] communityPermissions,
136         java.lang.String[] guestPermissions)
137         throws com.liferay.portal.SystemException,
138             com.liferay.portal.PortalException {
139         try {
140             Object paramObj0 = new LongWrapper(plid);
141 
142             Object paramObj1 = name;
143 
144             if (name == null) {
145                 paramObj1 = new NullWrapper("java.lang.String");
146             }
147 
148             Object paramObj2 = description;
149 
150             if (description == null) {
151                 paramObj2 = new NullWrapper("java.lang.String");
152             }
153 
154             Object paramObj3 = communityPermissions;
155 
156             if (communityPermissions == null) {
157                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
158             }
159 
160             Object paramObj4 = guestPermissions;
161 
162             if (guestPermissions == null) {
163                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
164             }
165 
166             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
167                     "addNode",
168                     new Object[] {
169                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
170                     });
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.WikiNode)returnObj;
190         }
191         catch (com.liferay.portal.SystemException se) {
192             _log.error(se, se);
193 
194             throw se;
195         }
196     }
197 
198     public static void deleteNode(HttpPrincipal httpPrincipal, long nodeId)
199         throws com.liferay.portal.SystemException,
200             com.liferay.portal.PortalException {
201         try {
202             Object paramObj0 = new LongWrapper(nodeId);
203 
204             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
205                     "deleteNode", new Object[] { paramObj0 });
206 
207             try {
208                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
209             }
210             catch (Exception e) {
211                 if (e instanceof com.liferay.portal.SystemException) {
212                     throw (com.liferay.portal.SystemException)e;
213                 }
214 
215                 if (e instanceof com.liferay.portal.PortalException) {
216                     throw (com.liferay.portal.PortalException)e;
217                 }
218 
219                 throw new com.liferay.portal.SystemException(e);
220             }
221         }
222         catch (com.liferay.portal.SystemException se) {
223             _log.error(se, se);
224 
225             throw se;
226         }
227     }
228 
229     public static com.liferay.portlet.wiki.model.WikiNode getNode(
230         HttpPrincipal httpPrincipal, long nodeId)
231         throws com.liferay.portal.SystemException,
232             com.liferay.portal.PortalException {
233         try {
234             Object paramObj0 = new LongWrapper(nodeId);
235 
236             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
237                     "getNode", new Object[] { paramObj0 });
238 
239             Object returnObj = null;
240 
241             try {
242                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
243             }
244             catch (Exception e) {
245                 if (e instanceof com.liferay.portal.SystemException) {
246                     throw (com.liferay.portal.SystemException)e;
247                 }
248 
249                 if (e instanceof com.liferay.portal.PortalException) {
250                     throw (com.liferay.portal.PortalException)e;
251                 }
252 
253                 throw new com.liferay.portal.SystemException(e);
254             }
255 
256             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
257         }
258         catch (com.liferay.portal.SystemException se) {
259             _log.error(se, se);
260 
261             throw se;
262         }
263     }
264 
265     public static com.liferay.portlet.wiki.model.WikiNode getNode(
266         HttpPrincipal httpPrincipal, long groupId, java.lang.String name)
267         throws com.liferay.portal.SystemException,
268             com.liferay.portal.PortalException {
269         try {
270             Object paramObj0 = new LongWrapper(groupId);
271 
272             Object paramObj1 = name;
273 
274             if (name == null) {
275                 paramObj1 = new NullWrapper("java.lang.String");
276             }
277 
278             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
279                     "getNode", new Object[] { paramObj0, paramObj1 });
280 
281             Object returnObj = null;
282 
283             try {
284                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
285             }
286             catch (Exception e) {
287                 if (e instanceof com.liferay.portal.SystemException) {
288                     throw (com.liferay.portal.SystemException)e;
289                 }
290 
291                 if (e instanceof com.liferay.portal.PortalException) {
292                     throw (com.liferay.portal.PortalException)e;
293                 }
294 
295                 throw new com.liferay.portal.SystemException(e);
296             }
297 
298             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
299         }
300         catch (com.liferay.portal.SystemException se) {
301             _log.error(se, se);
302 
303             throw se;
304         }
305     }
306 
307     public static void subscribeNode(HttpPrincipal httpPrincipal, long nodeId)
308         throws com.liferay.portal.SystemException,
309             com.liferay.portal.PortalException {
310         try {
311             Object paramObj0 = new LongWrapper(nodeId);
312 
313             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
314                     "subscribeNode", new Object[] { paramObj0 });
315 
316             try {
317                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
318             }
319             catch (Exception e) {
320                 if (e instanceof com.liferay.portal.SystemException) {
321                     throw (com.liferay.portal.SystemException)e;
322                 }
323 
324                 if (e instanceof com.liferay.portal.PortalException) {
325                     throw (com.liferay.portal.PortalException)e;
326                 }
327 
328                 throw new com.liferay.portal.SystemException(e);
329             }
330         }
331         catch (com.liferay.portal.SystemException se) {
332             _log.error(se, se);
333 
334             throw se;
335         }
336     }
337 
338     public static void unsubscribeNode(HttpPrincipal httpPrincipal, long nodeId)
339         throws com.liferay.portal.SystemException,
340             com.liferay.portal.PortalException {
341         try {
342             Object paramObj0 = new LongWrapper(nodeId);
343 
344             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
345                     "unsubscribeNode", new Object[] { paramObj0 });
346 
347             try {
348                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
349             }
350             catch (Exception e) {
351                 if (e instanceof com.liferay.portal.SystemException) {
352                     throw (com.liferay.portal.SystemException)e;
353                 }
354 
355                 if (e instanceof com.liferay.portal.PortalException) {
356                     throw (com.liferay.portal.PortalException)e;
357                 }
358 
359                 throw new com.liferay.portal.SystemException(e);
360             }
361         }
362         catch (com.liferay.portal.SystemException se) {
363             _log.error(se, se);
364 
365             throw se;
366         }
367     }
368 
369     public static com.liferay.portlet.wiki.model.WikiNode updateNode(
370         HttpPrincipal httpPrincipal, long nodeId, java.lang.String name,
371         java.lang.String description)
372         throws com.liferay.portal.SystemException,
373             com.liferay.portal.PortalException {
374         try {
375             Object paramObj0 = new LongWrapper(nodeId);
376 
377             Object paramObj1 = name;
378 
379             if (name == null) {
380                 paramObj1 = new NullWrapper("java.lang.String");
381             }
382 
383             Object paramObj2 = description;
384 
385             if (description == null) {
386                 paramObj2 = new NullWrapper("java.lang.String");
387             }
388 
389             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
390                     "updateNode",
391                     new Object[] { paramObj0, paramObj1, paramObj2 });
392 
393             Object returnObj = null;
394 
395             try {
396                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
397             }
398             catch (Exception e) {
399                 if (e instanceof com.liferay.portal.SystemException) {
400                     throw (com.liferay.portal.SystemException)e;
401                 }
402 
403                 if (e instanceof com.liferay.portal.PortalException) {
404                     throw (com.liferay.portal.PortalException)e;
405                 }
406 
407                 throw new com.liferay.portal.SystemException(e);
408             }
409 
410             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
411         }
412         catch (com.liferay.portal.SystemException se) {
413             _log.error(se, se);
414 
415             throw se;
416         }
417     }
418 
419     private static Log _log = LogFactoryUtil.getLog(WikiNodeServiceHttp.class);
420 }