1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.wiki.service.http;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  import com.liferay.portal.kernel.util.BooleanWrapper;
25  import com.liferay.portal.kernel.util.LongWrapper;
26  import com.liferay.portal.kernel.util.MethodWrapper;
27  import com.liferay.portal.kernel.util.NullWrapper;
28  import com.liferay.portal.security.auth.HttpPrincipal;
29  import com.liferay.portal.service.http.TunnelUtil;
30  
31  import com.liferay.portlet.wiki.service.WikiNodeServiceUtil;
32  
33  /**
34   * <a href="WikiNodeServiceHttp.java.html"><b><i>View Source</i></b></a>
35   *
36   * <p>
37   * ServiceBuilder generated this class. Modifications in this class will be
38   * overwritten the next time is generated.
39   * </p>
40   *
41   * <p>
42   * This class provides a HTTP utility for the
43   * <code>com.liferay.portlet.wiki.service.WikiNodeServiceUtil</code> service
44   * utility. The static methods of this class calls the same methods of the
45   * service utility. However, the signatures are different because it requires an
46   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
47   * parameter.
48   * </p>
49   *
50   * <p>
51   * The benefits of using the HTTP utility is that it is fast and allows for
52   * tunneling without the cost of serializing to text. The drawback is that it
53   * only works with Java.
54   * </p>
55   *
56   * <p>
57   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
58   * portal.properties to configure security.
59   * </p>
60   *
61   * <p>
62   * The HTTP utility is only generated for remote services.
63   * </p>
64   *
65   * @author Brian Wing Shun Chan
66   *
67   * @see com.liferay.portal.security.auth.HttpPrincipal
68   * @see com.liferay.portlet.wiki.service.WikiNodeServiceUtil
69   * @see com.liferay.portlet.wiki.service.http.WikiNodeServiceSoap
70   *
71   */
72  public class WikiNodeServiceHttp {
73      public static com.liferay.portlet.wiki.model.WikiNode addNode(
74          HttpPrincipal httpPrincipal, long plid, java.lang.String name,
75          java.lang.String description, boolean addCommunityPermissions,
76          boolean addGuestPermissions)
77          throws com.liferay.portal.PortalException,
78              com.liferay.portal.SystemException {
79          try {
80              Object paramObj0 = new LongWrapper(plid);
81  
82              Object paramObj1 = name;
83  
84              if (name == null) {
85                  paramObj1 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj2 = description;
89  
90              if (description == null) {
91                  paramObj2 = new NullWrapper("java.lang.String");
92              }
93  
94              Object paramObj3 = new BooleanWrapper(addCommunityPermissions);
95  
96              Object paramObj4 = new BooleanWrapper(addGuestPermissions);
97  
98              MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
99                      "addNode",
100                     new Object[] {
101                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
102                     });
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 com.liferay.portlet.wiki.model.WikiNode addNode(
131         HttpPrincipal httpPrincipal, long plid, java.lang.String name,
132         java.lang.String description, java.lang.String[] communityPermissions,
133         java.lang.String[] guestPermissions)
134         throws com.liferay.portal.PortalException,
135             com.liferay.portal.SystemException {
136         try {
137             Object paramObj0 = new LongWrapper(plid);
138 
139             Object paramObj1 = name;
140 
141             if (name == null) {
142                 paramObj1 = new NullWrapper("java.lang.String");
143             }
144 
145             Object paramObj2 = description;
146 
147             if (description == null) {
148                 paramObj2 = new NullWrapper("java.lang.String");
149             }
150 
151             Object paramObj3 = communityPermissions;
152 
153             if (communityPermissions == null) {
154                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
155             }
156 
157             Object paramObj4 = guestPermissions;
158 
159             if (guestPermissions == null) {
160                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
161             }
162 
163             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
164                     "addNode",
165                     new Object[] {
166                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
167                     });
168 
169             Object returnObj = null;
170 
171             try {
172                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
173             }
174             catch (Exception e) {
175                 if (e instanceof com.liferay.portal.PortalException) {
176                     throw (com.liferay.portal.PortalException)e;
177                 }
178 
179                 if (e instanceof com.liferay.portal.SystemException) {
180                     throw (com.liferay.portal.SystemException)e;
181                 }
182 
183                 throw new com.liferay.portal.SystemException(e);
184             }
185 
186             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
187         }
188         catch (com.liferay.portal.SystemException se) {
189             _log.error(se, se);
190 
191             throw se;
192         }
193     }
194 
195     public static void deleteNode(HttpPrincipal httpPrincipal, long nodeId)
196         throws com.liferay.portal.PortalException,
197             com.liferay.portal.SystemException {
198         try {
199             Object paramObj0 = new LongWrapper(nodeId);
200 
201             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
202                     "deleteNode", new Object[] { paramObj0 });
203 
204             try {
205                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
206             }
207             catch (Exception e) {
208                 if (e instanceof com.liferay.portal.PortalException) {
209                     throw (com.liferay.portal.PortalException)e;
210                 }
211 
212                 if (e instanceof com.liferay.portal.SystemException) {
213                     throw (com.liferay.portal.SystemException)e;
214                 }
215 
216                 throw new com.liferay.portal.SystemException(e);
217             }
218         }
219         catch (com.liferay.portal.SystemException se) {
220             _log.error(se, se);
221 
222             throw se;
223         }
224     }
225 
226     public static com.liferay.portlet.wiki.model.WikiNode getNode(
227         HttpPrincipal httpPrincipal, long nodeId)
228         throws com.liferay.portal.PortalException,
229             com.liferay.portal.SystemException {
230         try {
231             Object paramObj0 = new LongWrapper(nodeId);
232 
233             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
234                     "getNode", new Object[] { paramObj0 });
235 
236             Object returnObj = null;
237 
238             try {
239                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
240             }
241             catch (Exception e) {
242                 if (e instanceof com.liferay.portal.PortalException) {
243                     throw (com.liferay.portal.PortalException)e;
244                 }
245 
246                 if (e instanceof com.liferay.portal.SystemException) {
247                     throw (com.liferay.portal.SystemException)e;
248                 }
249 
250                 throw new com.liferay.portal.SystemException(e);
251             }
252 
253             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
254         }
255         catch (com.liferay.portal.SystemException se) {
256             _log.error(se, se);
257 
258             throw se;
259         }
260     }
261 
262     public static com.liferay.portlet.wiki.model.WikiNode getNode(
263         HttpPrincipal httpPrincipal, long groupId, java.lang.String name)
264         throws com.liferay.portal.PortalException,
265             com.liferay.portal.SystemException {
266         try {
267             Object paramObj0 = new LongWrapper(groupId);
268 
269             Object paramObj1 = name;
270 
271             if (name == null) {
272                 paramObj1 = new NullWrapper("java.lang.String");
273             }
274 
275             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
276                     "getNode", new Object[] { paramObj0, paramObj1 });
277 
278             Object returnObj = null;
279 
280             try {
281                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
282             }
283             catch (Exception e) {
284                 if (e instanceof com.liferay.portal.PortalException) {
285                     throw (com.liferay.portal.PortalException)e;
286                 }
287 
288                 if (e instanceof com.liferay.portal.SystemException) {
289                     throw (com.liferay.portal.SystemException)e;
290                 }
291 
292                 throw new com.liferay.portal.SystemException(e);
293             }
294 
295             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
296         }
297         catch (com.liferay.portal.SystemException se) {
298             _log.error(se, se);
299 
300             throw se;
301         }
302     }
303 
304     public static void importPages(HttpPrincipal httpPrincipal, long nodeId,
305         java.lang.String importer, java.io.File[] files,
306         java.util.Map<String, String[]> options)
307         throws com.liferay.portal.PortalException,
308             com.liferay.portal.SystemException {
309         try {
310             Object paramObj0 = new LongWrapper(nodeId);
311 
312             Object paramObj1 = importer;
313 
314             if (importer == null) {
315                 paramObj1 = new NullWrapper("java.lang.String");
316             }
317 
318             Object paramObj2 = files;
319 
320             if (files == null) {
321                 paramObj2 = new NullWrapper("[Ljava.io.File;");
322             }
323 
324             Object paramObj3 = options;
325 
326             if (options == null) {
327                 paramObj3 = new NullWrapper("java.util.Map");
328             }
329 
330             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
331                     "importPages",
332                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
333 
334             try {
335                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
336             }
337             catch (Exception e) {
338                 if (e instanceof com.liferay.portal.PortalException) {
339                     throw (com.liferay.portal.PortalException)e;
340                 }
341 
342                 if (e instanceof com.liferay.portal.SystemException) {
343                     throw (com.liferay.portal.SystemException)e;
344                 }
345 
346                 throw new com.liferay.portal.SystemException(e);
347             }
348         }
349         catch (com.liferay.portal.SystemException se) {
350             _log.error(se, se);
351 
352             throw se;
353         }
354     }
355 
356     public static void subscribeNode(HttpPrincipal httpPrincipal, long nodeId)
357         throws com.liferay.portal.PortalException,
358             com.liferay.portal.SystemException {
359         try {
360             Object paramObj0 = new LongWrapper(nodeId);
361 
362             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
363                     "subscribeNode", new Object[] { paramObj0 });
364 
365             try {
366                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
367             }
368             catch (Exception e) {
369                 if (e instanceof com.liferay.portal.PortalException) {
370                     throw (com.liferay.portal.PortalException)e;
371                 }
372 
373                 if (e instanceof com.liferay.portal.SystemException) {
374                     throw (com.liferay.portal.SystemException)e;
375                 }
376 
377                 throw new com.liferay.portal.SystemException(e);
378             }
379         }
380         catch (com.liferay.portal.SystemException se) {
381             _log.error(se, se);
382 
383             throw se;
384         }
385     }
386 
387     public static void unsubscribeNode(HttpPrincipal httpPrincipal, long nodeId)
388         throws com.liferay.portal.PortalException,
389             com.liferay.portal.SystemException {
390         try {
391             Object paramObj0 = new LongWrapper(nodeId);
392 
393             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
394                     "unsubscribeNode", new Object[] { paramObj0 });
395 
396             try {
397                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
398             }
399             catch (Exception e) {
400                 if (e instanceof com.liferay.portal.PortalException) {
401                     throw (com.liferay.portal.PortalException)e;
402                 }
403 
404                 if (e instanceof com.liferay.portal.SystemException) {
405                     throw (com.liferay.portal.SystemException)e;
406                 }
407 
408                 throw new com.liferay.portal.SystemException(e);
409             }
410         }
411         catch (com.liferay.portal.SystemException se) {
412             _log.error(se, se);
413 
414             throw se;
415         }
416     }
417 
418     public static com.liferay.portlet.wiki.model.WikiNode updateNode(
419         HttpPrincipal httpPrincipal, long nodeId, java.lang.String name,
420         java.lang.String description)
421         throws com.liferay.portal.PortalException,
422             com.liferay.portal.SystemException {
423         try {
424             Object paramObj0 = new LongWrapper(nodeId);
425 
426             Object paramObj1 = name;
427 
428             if (name == null) {
429                 paramObj1 = new NullWrapper("java.lang.String");
430             }
431 
432             Object paramObj2 = description;
433 
434             if (description == null) {
435                 paramObj2 = new NullWrapper("java.lang.String");
436             }
437 
438             MethodWrapper methodWrapper = new MethodWrapper(WikiNodeServiceUtil.class.getName(),
439                     "updateNode",
440                     new Object[] { paramObj0, paramObj1, paramObj2 });
441 
442             Object returnObj = null;
443 
444             try {
445                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
446             }
447             catch (Exception e) {
448                 if (e instanceof com.liferay.portal.PortalException) {
449                     throw (com.liferay.portal.PortalException)e;
450                 }
451 
452                 if (e instanceof com.liferay.portal.SystemException) {
453                     throw (com.liferay.portal.SystemException)e;
454                 }
455 
456                 throw new com.liferay.portal.SystemException(e);
457             }
458 
459             return (com.liferay.portlet.wiki.model.WikiNode)returnObj;
460         }
461         catch (com.liferay.portal.SystemException se) {
462             _log.error(se, se);
463 
464             throw se;
465         }
466     }
467 
468     private static Log _log = LogFactoryUtil.getLog(WikiNodeServiceHttp.class);
469 }