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.documentlibrary.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.DoubleWrapper;
29  import com.liferay.portal.kernel.util.LongWrapper;
30  import com.liferay.portal.kernel.util.MethodWrapper;
31  import com.liferay.portal.kernel.util.NullWrapper;
32  import com.liferay.portal.security.auth.HttpPrincipal;
33  import com.liferay.portal.service.http.TunnelUtil;
34  
35  import com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil;
36  
37  /**
38   * <a href="DLFileEntryServiceHttp.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be overwritten
42   * the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class provides a HTTP utility for the <code>com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil</code>
47   * service 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> parameter.
50   * </p>
51   *
52   * <p>
53   * The benefits of using the HTTP utility is that it is fast and allows for tunneling
54   * without the cost of serializing to text. The drawback is that it only works with
55   * Java.
56   * </p>
57   *
58   * <p>
59   * Set the property <code>tunnel.servlet.hosts.allowed</code> in portal.properties
60   * 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.documentlibrary.service.DLFileEntryServiceUtil
71   * @see com.liferay.portlet.documentlibrary.service.http.DLFileEntryServiceSoap
72   *
73   */
74  public class DLFileEntryServiceHttp {
75      public static com.liferay.portlet.documentlibrary.model.DLFileEntry addFileEntry(
76          HttpPrincipal httpPrincipal, long folderId, java.lang.String name,
77          java.lang.String title, java.lang.String description,
78          java.lang.String[] tagsEntries, java.lang.String extraSettings,
79          byte[] byteArray, boolean addCommunityPermissions,
80          boolean addGuestPermissions)
81          throws com.liferay.portal.SystemException, 
82              com.liferay.portal.PortalException {
83          try {
84              Object paramObj0 = new LongWrapper(folderId);
85              Object paramObj1 = name;
86  
87              if (name == null) {
88                  paramObj1 = new NullWrapper("java.lang.String");
89              }
90  
91              Object paramObj2 = title;
92  
93              if (title == null) {
94                  paramObj2 = new NullWrapper("java.lang.String");
95              }
96  
97              Object paramObj3 = description;
98  
99              if (description == null) {
100                 paramObj3 = new NullWrapper("java.lang.String");
101             }
102 
103             Object paramObj4 = tagsEntries;
104 
105             if (tagsEntries == null) {
106                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
107             }
108 
109             Object paramObj5 = extraSettings;
110 
111             if (extraSettings == null) {
112                 paramObj5 = new NullWrapper("java.lang.String");
113             }
114 
115             Object paramObj6 = byteArray;
116 
117             if (byteArray == null) {
118                 paramObj6 = new NullWrapper("[B");
119             }
120 
121             Object paramObj7 = new BooleanWrapper(addCommunityPermissions);
122             Object paramObj8 = new BooleanWrapper(addGuestPermissions);
123             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
124                     "addFileEntry",
125                     new Object[] {
126                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
127                         paramObj5, paramObj6, paramObj7, paramObj8
128                     });
129             Object returnObj = null;
130 
131             try {
132                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
133             }
134             catch (Exception e) {
135                 if (e instanceof com.liferay.portal.SystemException) {
136                     throw (com.liferay.portal.SystemException)e;
137                 }
138 
139                 if (e instanceof com.liferay.portal.PortalException) {
140                     throw (com.liferay.portal.PortalException)e;
141                 }
142 
143                 throw new com.liferay.portal.SystemException(e);
144             }
145 
146             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
147         }
148         catch (com.liferay.portal.SystemException se) {
149             _log.error(se, se);
150             throw se;
151         }
152     }
153 
154     public static com.liferay.portlet.documentlibrary.model.DLFileEntry addFileEntry(
155         HttpPrincipal httpPrincipal, long folderId, java.lang.String name,
156         java.lang.String title, java.lang.String description,
157         java.lang.String[] tagsEntries, java.lang.String extraSettings,
158         byte[] byteArray, java.lang.String[] communityPermissions,
159         java.lang.String[] guestPermissions)
160         throws com.liferay.portal.SystemException, 
161             com.liferay.portal.PortalException {
162         try {
163             Object paramObj0 = new LongWrapper(folderId);
164             Object paramObj1 = name;
165 
166             if (name == null) {
167                 paramObj1 = new NullWrapper("java.lang.String");
168             }
169 
170             Object paramObj2 = title;
171 
172             if (title == null) {
173                 paramObj2 = new NullWrapper("java.lang.String");
174             }
175 
176             Object paramObj3 = description;
177 
178             if (description == null) {
179                 paramObj3 = new NullWrapper("java.lang.String");
180             }
181 
182             Object paramObj4 = tagsEntries;
183 
184             if (tagsEntries == null) {
185                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
186             }
187 
188             Object paramObj5 = extraSettings;
189 
190             if (extraSettings == null) {
191                 paramObj5 = new NullWrapper("java.lang.String");
192             }
193 
194             Object paramObj6 = byteArray;
195 
196             if (byteArray == null) {
197                 paramObj6 = new NullWrapper("[B");
198             }
199 
200             Object paramObj7 = communityPermissions;
201 
202             if (communityPermissions == null) {
203                 paramObj7 = new NullWrapper("[Ljava.lang.String;");
204             }
205 
206             Object paramObj8 = guestPermissions;
207 
208             if (guestPermissions == null) {
209                 paramObj8 = new NullWrapper("[Ljava.lang.String;");
210             }
211 
212             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
213                     "addFileEntry",
214                     new Object[] {
215                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
216                         paramObj5, paramObj6, paramObj7, paramObj8
217                     });
218             Object returnObj = null;
219 
220             try {
221                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
222             }
223             catch (Exception e) {
224                 if (e instanceof com.liferay.portal.SystemException) {
225                     throw (com.liferay.portal.SystemException)e;
226                 }
227 
228                 if (e instanceof com.liferay.portal.PortalException) {
229                     throw (com.liferay.portal.PortalException)e;
230                 }
231 
232                 throw new com.liferay.portal.SystemException(e);
233             }
234 
235             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
236         }
237         catch (com.liferay.portal.SystemException se) {
238             _log.error(se, se);
239             throw se;
240         }
241     }
242 
243     public static void deleteFileEntry(HttpPrincipal httpPrincipal,
244         long folderId, java.lang.String name)
245         throws com.liferay.portal.SystemException, 
246             com.liferay.portal.PortalException, java.rmi.RemoteException {
247         try {
248             Object paramObj0 = new LongWrapper(folderId);
249             Object paramObj1 = name;
250 
251             if (name == null) {
252                 paramObj1 = new NullWrapper("java.lang.String");
253             }
254 
255             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
256                     "deleteFileEntry", new Object[] { paramObj0, paramObj1 });
257 
258             try {
259                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
260             }
261             catch (Exception e) {
262                 if (e instanceof com.liferay.portal.SystemException) {
263                     throw (com.liferay.portal.SystemException)e;
264                 }
265 
266                 if (e instanceof com.liferay.portal.PortalException) {
267                     throw (com.liferay.portal.PortalException)e;
268                 }
269 
270                 if (e instanceof java.rmi.RemoteException) {
271                     throw (java.rmi.RemoteException)e;
272                 }
273 
274                 throw new com.liferay.portal.SystemException(e);
275             }
276         }
277         catch (com.liferay.portal.SystemException se) {
278             _log.error(se, se);
279             throw se;
280         }
281     }
282 
283     public static void deleteFileEntry(HttpPrincipal httpPrincipal,
284         long folderId, java.lang.String name, double version)
285         throws com.liferay.portal.SystemException, 
286             com.liferay.portal.PortalException, java.rmi.RemoteException {
287         try {
288             Object paramObj0 = new LongWrapper(folderId);
289             Object paramObj1 = name;
290 
291             if (name == null) {
292                 paramObj1 = new NullWrapper("java.lang.String");
293             }
294 
295             Object paramObj2 = new DoubleWrapper(version);
296             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
297                     "deleteFileEntry",
298                     new Object[] { paramObj0, paramObj1, paramObj2 });
299 
300             try {
301                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
302             }
303             catch (Exception e) {
304                 if (e instanceof com.liferay.portal.SystemException) {
305                     throw (com.liferay.portal.SystemException)e;
306                 }
307 
308                 if (e instanceof com.liferay.portal.PortalException) {
309                     throw (com.liferay.portal.PortalException)e;
310                 }
311 
312                 if (e instanceof java.rmi.RemoteException) {
313                     throw (java.rmi.RemoteException)e;
314                 }
315 
316                 throw new com.liferay.portal.SystemException(e);
317             }
318         }
319         catch (com.liferay.portal.SystemException se) {
320             _log.error(se, se);
321             throw se;
322         }
323     }
324 
325     public static com.liferay.portlet.documentlibrary.model.DLFileEntry getFileEntry(
326         HttpPrincipal httpPrincipal, long folderId, java.lang.String name)
327         throws com.liferay.portal.SystemException, 
328             com.liferay.portal.PortalException {
329         try {
330             Object paramObj0 = new LongWrapper(folderId);
331             Object paramObj1 = name;
332 
333             if (name == null) {
334                 paramObj1 = new NullWrapper("java.lang.String");
335             }
336 
337             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
338                     "getFileEntry", new Object[] { paramObj0, paramObj1 });
339             Object returnObj = null;
340 
341             try {
342                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
343             }
344             catch (Exception e) {
345                 if (e instanceof com.liferay.portal.SystemException) {
346                     throw (com.liferay.portal.SystemException)e;
347                 }
348 
349                 if (e instanceof com.liferay.portal.PortalException) {
350                     throw (com.liferay.portal.PortalException)e;
351                 }
352 
353                 throw new com.liferay.portal.SystemException(e);
354             }
355 
356             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
357         }
358         catch (com.liferay.portal.SystemException se) {
359             _log.error(se, se);
360             throw se;
361         }
362     }
363 
364     public static void lockFileEntry(HttpPrincipal httpPrincipal,
365         long folderId, java.lang.String name)
366         throws com.liferay.portal.SystemException, 
367             com.liferay.portal.PortalException, java.rmi.RemoteException {
368         try {
369             Object paramObj0 = new LongWrapper(folderId);
370             Object paramObj1 = name;
371 
372             if (name == null) {
373                 paramObj1 = new NullWrapper("java.lang.String");
374             }
375 
376             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
377                     "lockFileEntry", new Object[] { paramObj0, paramObj1 });
378 
379             try {
380                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
381             }
382             catch (Exception e) {
383                 if (e instanceof com.liferay.portal.SystemException) {
384                     throw (com.liferay.portal.SystemException)e;
385                 }
386 
387                 if (e instanceof com.liferay.portal.PortalException) {
388                     throw (com.liferay.portal.PortalException)e;
389                 }
390 
391                 if (e instanceof java.rmi.RemoteException) {
392                     throw (java.rmi.RemoteException)e;
393                 }
394 
395                 throw new com.liferay.portal.SystemException(e);
396             }
397         }
398         catch (com.liferay.portal.SystemException se) {
399             _log.error(se, se);
400             throw se;
401         }
402     }
403 
404     public static void unlockFileEntry(HttpPrincipal httpPrincipal,
405         long folderId, java.lang.String name)
406         throws com.liferay.portal.SystemException, 
407             com.liferay.portal.PortalException, java.rmi.RemoteException {
408         try {
409             Object paramObj0 = new LongWrapper(folderId);
410             Object paramObj1 = name;
411 
412             if (name == null) {
413                 paramObj1 = new NullWrapper("java.lang.String");
414             }
415 
416             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
417                     "unlockFileEntry", new Object[] { paramObj0, paramObj1 });
418 
419             try {
420                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
421             }
422             catch (Exception e) {
423                 if (e instanceof com.liferay.portal.SystemException) {
424                     throw (com.liferay.portal.SystemException)e;
425                 }
426 
427                 if (e instanceof com.liferay.portal.PortalException) {
428                     throw (com.liferay.portal.PortalException)e;
429                 }
430 
431                 if (e instanceof java.rmi.RemoteException) {
432                     throw (java.rmi.RemoteException)e;
433                 }
434 
435                 throw new com.liferay.portal.SystemException(e);
436             }
437         }
438         catch (com.liferay.portal.SystemException se) {
439             _log.error(se, se);
440             throw se;
441         }
442     }
443 
444     public static com.liferay.portlet.documentlibrary.model.DLFileEntry updateFileEntry(
445         HttpPrincipal httpPrincipal, long folderId, long newFolderId,
446         java.lang.String name, java.lang.String sourceFileName,
447         java.lang.String title, java.lang.String description,
448         java.lang.String[] tagsEntries, java.lang.String extraSettings,
449         byte[] byteArray)
450         throws com.liferay.portal.SystemException, 
451             com.liferay.portal.PortalException, java.rmi.RemoteException {
452         try {
453             Object paramObj0 = new LongWrapper(folderId);
454             Object paramObj1 = new LongWrapper(newFolderId);
455             Object paramObj2 = name;
456 
457             if (name == null) {
458                 paramObj2 = new NullWrapper("java.lang.String");
459             }
460 
461             Object paramObj3 = sourceFileName;
462 
463             if (sourceFileName == null) {
464                 paramObj3 = new NullWrapper("java.lang.String");
465             }
466 
467             Object paramObj4 = title;
468 
469             if (title == null) {
470                 paramObj4 = new NullWrapper("java.lang.String");
471             }
472 
473             Object paramObj5 = description;
474 
475             if (description == null) {
476                 paramObj5 = new NullWrapper("java.lang.String");
477             }
478 
479             Object paramObj6 = tagsEntries;
480 
481             if (tagsEntries == null) {
482                 paramObj6 = new NullWrapper("[Ljava.lang.String;");
483             }
484 
485             Object paramObj7 = extraSettings;
486 
487             if (extraSettings == null) {
488                 paramObj7 = new NullWrapper("java.lang.String");
489             }
490 
491             Object paramObj8 = byteArray;
492 
493             if (byteArray == null) {
494                 paramObj8 = new NullWrapper("[B");
495             }
496 
497             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
498                     "updateFileEntry",
499                     new Object[] {
500                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
501                         paramObj5, paramObj6, paramObj7, paramObj8
502                     });
503             Object returnObj = null;
504 
505             try {
506                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
507             }
508             catch (Exception e) {
509                 if (e instanceof com.liferay.portal.SystemException) {
510                     throw (com.liferay.portal.SystemException)e;
511                 }
512 
513                 if (e instanceof com.liferay.portal.PortalException) {
514                     throw (com.liferay.portal.PortalException)e;
515                 }
516 
517                 if (e instanceof java.rmi.RemoteException) {
518                     throw (java.rmi.RemoteException)e;
519                 }
520 
521                 throw new com.liferay.portal.SystemException(e);
522             }
523 
524             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
525         }
526         catch (com.liferay.portal.SystemException se) {
527             _log.error(se, se);
528             throw se;
529         }
530     }
531 
532     private static Log _log = LogFactoryUtil.getLog(DLFileEntryServiceHttp.class);
533 }