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.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
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class provides a HTTP utility for the
47   * <code>com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil</code> service
48   * utility. The static methods of this class calls the same methods of the
49   * service utility. However, the signatures are different because it requires an
50   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
51   * parameter.
52   * </p>
53   *
54   * <p>
55   * The benefits of using the HTTP utility is that it is fast and allows for
56   * tunneling without the cost of serializing to text. The drawback is that it
57   * only works with Java.
58   * </p>
59   *
60   * <p>
61   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
62   * portal.properties to configure security.
63   * </p>
64   *
65   * <p>
66   * The HTTP utility is only generated for remote services.
67   * </p>
68   *
69   * @author Brian Wing Shun Chan
70   *
71   * @see com.liferay.portal.security.auth.HttpPrincipal
72   * @see com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil
73   * @see com.liferay.portlet.documentlibrary.service.http.DLFileEntryServiceSoap
74   *
75   */
76  public class DLFileEntryServiceHttp {
77      public static com.liferay.portlet.documentlibrary.model.DLFileEntry addFileEntry(
78          HttpPrincipal httpPrincipal, long folderId, java.lang.String name,
79          java.lang.String title, java.lang.String description,
80          java.lang.String[] tagsEntries, java.lang.String extraSettings,
81          byte[] byteArray, boolean addCommunityPermissions,
82          boolean addGuestPermissions)
83          throws com.liferay.portal.SystemException, 
84              com.liferay.portal.PortalException {
85          try {
86              Object paramObj0 = new LongWrapper(folderId);
87  
88              Object paramObj1 = name;
89  
90              if (name == null) {
91                  paramObj1 = new NullWrapper("java.lang.String");
92              }
93  
94              Object paramObj2 = title;
95  
96              if (title == null) {
97                  paramObj2 = new NullWrapper("java.lang.String");
98              }
99  
100             Object paramObj3 = description;
101 
102             if (description == null) {
103                 paramObj3 = new NullWrapper("java.lang.String");
104             }
105 
106             Object paramObj4 = tagsEntries;
107 
108             if (tagsEntries == null) {
109                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
110             }
111 
112             Object paramObj5 = extraSettings;
113 
114             if (extraSettings == null) {
115                 paramObj5 = new NullWrapper("java.lang.String");
116             }
117 
118             Object paramObj6 = byteArray;
119 
120             if (byteArray == null) {
121                 paramObj6 = new NullWrapper("[B");
122             }
123 
124             Object paramObj7 = new BooleanWrapper(addCommunityPermissions);
125 
126             Object paramObj8 = new BooleanWrapper(addGuestPermissions);
127 
128             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
129                     "addFileEntry",
130                     new Object[] {
131                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
132                         paramObj5, paramObj6, paramObj7, paramObj8
133                     });
134 
135             Object returnObj = null;
136 
137             try {
138                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
139             }
140             catch (Exception e) {
141                 if (e instanceof com.liferay.portal.SystemException) {
142                     throw (com.liferay.portal.SystemException)e;
143                 }
144 
145                 if (e instanceof com.liferay.portal.PortalException) {
146                     throw (com.liferay.portal.PortalException)e;
147                 }
148 
149                 throw new com.liferay.portal.SystemException(e);
150             }
151 
152             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
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.documentlibrary.model.DLFileEntry addFileEntry(
162         HttpPrincipal httpPrincipal, long folderId, java.lang.String name,
163         java.lang.String title, java.lang.String description,
164         java.lang.String[] tagsEntries, java.lang.String extraSettings,
165         byte[] byteArray, java.lang.String[] communityPermissions,
166         java.lang.String[] guestPermissions)
167         throws com.liferay.portal.SystemException, 
168             com.liferay.portal.PortalException {
169         try {
170             Object paramObj0 = new LongWrapper(folderId);
171 
172             Object paramObj1 = name;
173 
174             if (name == null) {
175                 paramObj1 = new NullWrapper("java.lang.String");
176             }
177 
178             Object paramObj2 = title;
179 
180             if (title == null) {
181                 paramObj2 = new NullWrapper("java.lang.String");
182             }
183 
184             Object paramObj3 = description;
185 
186             if (description == null) {
187                 paramObj3 = new NullWrapper("java.lang.String");
188             }
189 
190             Object paramObj4 = tagsEntries;
191 
192             if (tagsEntries == null) {
193                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
194             }
195 
196             Object paramObj5 = extraSettings;
197 
198             if (extraSettings == null) {
199                 paramObj5 = new NullWrapper("java.lang.String");
200             }
201 
202             Object paramObj6 = byteArray;
203 
204             if (byteArray == null) {
205                 paramObj6 = new NullWrapper("[B");
206             }
207 
208             Object paramObj7 = communityPermissions;
209 
210             if (communityPermissions == null) {
211                 paramObj7 = new NullWrapper("[Ljava.lang.String;");
212             }
213 
214             Object paramObj8 = guestPermissions;
215 
216             if (guestPermissions == null) {
217                 paramObj8 = new NullWrapper("[Ljava.lang.String;");
218             }
219 
220             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
221                     "addFileEntry",
222                     new Object[] {
223                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
224                         paramObj5, paramObj6, paramObj7, paramObj8
225                     });
226 
227             Object returnObj = null;
228 
229             try {
230                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
231             }
232             catch (Exception e) {
233                 if (e instanceof com.liferay.portal.SystemException) {
234                     throw (com.liferay.portal.SystemException)e;
235                 }
236 
237                 if (e instanceof com.liferay.portal.PortalException) {
238                     throw (com.liferay.portal.PortalException)e;
239                 }
240 
241                 throw new com.liferay.portal.SystemException(e);
242             }
243 
244             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
245         }
246         catch (com.liferay.portal.SystemException se) {
247             _log.error(se, se);
248 
249             throw se;
250         }
251     }
252 
253     public static void deleteFileEntry(HttpPrincipal httpPrincipal,
254         long folderId, java.lang.String name)
255         throws com.liferay.portal.SystemException, 
256             com.liferay.portal.PortalException, java.rmi.RemoteException {
257         try {
258             Object paramObj0 = new LongWrapper(folderId);
259 
260             Object paramObj1 = name;
261 
262             if (name == null) {
263                 paramObj1 = new NullWrapper("java.lang.String");
264             }
265 
266             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
267                     "deleteFileEntry", new Object[] { paramObj0, paramObj1 });
268 
269             try {
270                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
271             }
272             catch (Exception e) {
273                 if (e instanceof com.liferay.portal.SystemException) {
274                     throw (com.liferay.portal.SystemException)e;
275                 }
276 
277                 if (e instanceof com.liferay.portal.PortalException) {
278                     throw (com.liferay.portal.PortalException)e;
279                 }
280 
281                 if (e instanceof java.rmi.RemoteException) {
282                     throw (java.rmi.RemoteException)e;
283                 }
284 
285                 throw new com.liferay.portal.SystemException(e);
286             }
287         }
288         catch (com.liferay.portal.SystemException se) {
289             _log.error(se, se);
290 
291             throw se;
292         }
293     }
294 
295     public static void deleteFileEntry(HttpPrincipal httpPrincipal,
296         long folderId, java.lang.String name, double version)
297         throws com.liferay.portal.SystemException, 
298             com.liferay.portal.PortalException, java.rmi.RemoteException {
299         try {
300             Object paramObj0 = new LongWrapper(folderId);
301 
302             Object paramObj1 = name;
303 
304             if (name == null) {
305                 paramObj1 = new NullWrapper("java.lang.String");
306             }
307 
308             Object paramObj2 = new DoubleWrapper(version);
309 
310             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
311                     "deleteFileEntry",
312                     new Object[] { paramObj0, paramObj1, paramObj2 });
313 
314             try {
315                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
316             }
317             catch (Exception e) {
318                 if (e instanceof com.liferay.portal.SystemException) {
319                     throw (com.liferay.portal.SystemException)e;
320                 }
321 
322                 if (e instanceof com.liferay.portal.PortalException) {
323                     throw (com.liferay.portal.PortalException)e;
324                 }
325 
326                 if (e instanceof java.rmi.RemoteException) {
327                     throw (java.rmi.RemoteException)e;
328                 }
329 
330                 throw new com.liferay.portal.SystemException(e);
331             }
332         }
333         catch (com.liferay.portal.SystemException se) {
334             _log.error(se, se);
335 
336             throw se;
337         }
338     }
339 
340     public static void deleteFileEntryByTitle(HttpPrincipal httpPrincipal,
341         long folderId, java.lang.String titleWithExtension)
342         throws com.liferay.portal.SystemException, 
343             com.liferay.portal.PortalException, java.rmi.RemoteException {
344         try {
345             Object paramObj0 = new LongWrapper(folderId);
346 
347             Object paramObj1 = titleWithExtension;
348 
349             if (titleWithExtension == null) {
350                 paramObj1 = new NullWrapper("java.lang.String");
351             }
352 
353             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
354                     "deleteFileEntryByTitle",
355                     new Object[] { paramObj0, paramObj1 });
356 
357             try {
358                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
359             }
360             catch (Exception e) {
361                 if (e instanceof com.liferay.portal.SystemException) {
362                     throw (com.liferay.portal.SystemException)e;
363                 }
364 
365                 if (e instanceof com.liferay.portal.PortalException) {
366                     throw (com.liferay.portal.PortalException)e;
367                 }
368 
369                 if (e instanceof java.rmi.RemoteException) {
370                     throw (java.rmi.RemoteException)e;
371                 }
372 
373                 throw new com.liferay.portal.SystemException(e);
374             }
375         }
376         catch (com.liferay.portal.SystemException se) {
377             _log.error(se, se);
378 
379             throw se;
380         }
381     }
382 
383     public static com.liferay.portlet.documentlibrary.model.DLFileEntry getFileEntry(
384         HttpPrincipal httpPrincipal, long folderId, java.lang.String name)
385         throws com.liferay.portal.SystemException, 
386             com.liferay.portal.PortalException {
387         try {
388             Object paramObj0 = new LongWrapper(folderId);
389 
390             Object paramObj1 = name;
391 
392             if (name == null) {
393                 paramObj1 = new NullWrapper("java.lang.String");
394             }
395 
396             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
397                     "getFileEntry", new Object[] { paramObj0, paramObj1 });
398 
399             Object returnObj = null;
400 
401             try {
402                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
403             }
404             catch (Exception e) {
405                 if (e instanceof com.liferay.portal.SystemException) {
406                     throw (com.liferay.portal.SystemException)e;
407                 }
408 
409                 if (e instanceof com.liferay.portal.PortalException) {
410                     throw (com.liferay.portal.PortalException)e;
411                 }
412 
413                 throw new com.liferay.portal.SystemException(e);
414             }
415 
416             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
417         }
418         catch (com.liferay.portal.SystemException se) {
419             _log.error(se, se);
420 
421             throw se;
422         }
423     }
424 
425     public static com.liferay.portlet.documentlibrary.model.DLFileEntry getFileEntryByTitle(
426         HttpPrincipal httpPrincipal, long folderId,
427         java.lang.String titleWithExtension)
428         throws com.liferay.portal.SystemException, 
429             com.liferay.portal.PortalException {
430         try {
431             Object paramObj0 = new LongWrapper(folderId);
432 
433             Object paramObj1 = titleWithExtension;
434 
435             if (titleWithExtension == null) {
436                 paramObj1 = new NullWrapper("java.lang.String");
437             }
438 
439             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
440                     "getFileEntryByTitle", new Object[] { paramObj0, paramObj1 });
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.SystemException) {
449                     throw (com.liferay.portal.SystemException)e;
450                 }
451 
452                 if (e instanceof com.liferay.portal.PortalException) {
453                     throw (com.liferay.portal.PortalException)e;
454                 }
455 
456                 throw new com.liferay.portal.SystemException(e);
457             }
458 
459             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
460         }
461         catch (com.liferay.portal.SystemException se) {
462             _log.error(se, se);
463 
464             throw se;
465         }
466     }
467 
468     public static void lockFileEntry(HttpPrincipal httpPrincipal,
469         long folderId, java.lang.String name)
470         throws com.liferay.portal.SystemException, 
471             com.liferay.portal.PortalException, java.rmi.RemoteException {
472         try {
473             Object paramObj0 = new LongWrapper(folderId);
474 
475             Object paramObj1 = name;
476 
477             if (name == null) {
478                 paramObj1 = new NullWrapper("java.lang.String");
479             }
480 
481             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
482                     "lockFileEntry", new Object[] { paramObj0, paramObj1 });
483 
484             try {
485                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
486             }
487             catch (Exception e) {
488                 if (e instanceof com.liferay.portal.SystemException) {
489                     throw (com.liferay.portal.SystemException)e;
490                 }
491 
492                 if (e instanceof com.liferay.portal.PortalException) {
493                     throw (com.liferay.portal.PortalException)e;
494                 }
495 
496                 if (e instanceof java.rmi.RemoteException) {
497                     throw (java.rmi.RemoteException)e;
498                 }
499 
500                 throw new com.liferay.portal.SystemException(e);
501             }
502         }
503         catch (com.liferay.portal.SystemException se) {
504             _log.error(se, se);
505 
506             throw se;
507         }
508     }
509 
510     public static void unlockFileEntry(HttpPrincipal httpPrincipal,
511         long folderId, java.lang.String name)
512         throws com.liferay.portal.SystemException, 
513             com.liferay.portal.PortalException, java.rmi.RemoteException {
514         try {
515             Object paramObj0 = new LongWrapper(folderId);
516 
517             Object paramObj1 = name;
518 
519             if (name == null) {
520                 paramObj1 = new NullWrapper("java.lang.String");
521             }
522 
523             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
524                     "unlockFileEntry", new Object[] { paramObj0, paramObj1 });
525 
526             try {
527                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
528             }
529             catch (Exception e) {
530                 if (e instanceof com.liferay.portal.SystemException) {
531                     throw (com.liferay.portal.SystemException)e;
532                 }
533 
534                 if (e instanceof com.liferay.portal.PortalException) {
535                     throw (com.liferay.portal.PortalException)e;
536                 }
537 
538                 if (e instanceof java.rmi.RemoteException) {
539                     throw (java.rmi.RemoteException)e;
540                 }
541 
542                 throw new com.liferay.portal.SystemException(e);
543             }
544         }
545         catch (com.liferay.portal.SystemException se) {
546             _log.error(se, se);
547 
548             throw se;
549         }
550     }
551 
552     public static com.liferay.portlet.documentlibrary.model.DLFileEntry updateFileEntry(
553         HttpPrincipal httpPrincipal, long folderId, long newFolderId,
554         java.lang.String name, java.lang.String sourceFileName,
555         java.lang.String title, java.lang.String description,
556         java.lang.String[] tagsEntries, java.lang.String extraSettings,
557         byte[] byteArray)
558         throws com.liferay.portal.SystemException, 
559             com.liferay.portal.PortalException, java.rmi.RemoteException {
560         try {
561             Object paramObj0 = new LongWrapper(folderId);
562 
563             Object paramObj1 = new LongWrapper(newFolderId);
564 
565             Object paramObj2 = name;
566 
567             if (name == null) {
568                 paramObj2 = new NullWrapper("java.lang.String");
569             }
570 
571             Object paramObj3 = sourceFileName;
572 
573             if (sourceFileName == null) {
574                 paramObj3 = new NullWrapper("java.lang.String");
575             }
576 
577             Object paramObj4 = title;
578 
579             if (title == null) {
580                 paramObj4 = new NullWrapper("java.lang.String");
581             }
582 
583             Object paramObj5 = description;
584 
585             if (description == null) {
586                 paramObj5 = new NullWrapper("java.lang.String");
587             }
588 
589             Object paramObj6 = tagsEntries;
590 
591             if (tagsEntries == null) {
592                 paramObj6 = new NullWrapper("[Ljava.lang.String;");
593             }
594 
595             Object paramObj7 = extraSettings;
596 
597             if (extraSettings == null) {
598                 paramObj7 = new NullWrapper("java.lang.String");
599             }
600 
601             Object paramObj8 = byteArray;
602 
603             if (byteArray == null) {
604                 paramObj8 = new NullWrapper("[B");
605             }
606 
607             MethodWrapper methodWrapper = new MethodWrapper(DLFileEntryServiceUtil.class.getName(),
608                     "updateFileEntry",
609                     new Object[] {
610                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
611                         paramObj5, paramObj6, paramObj7, paramObj8
612                     });
613 
614             Object returnObj = null;
615 
616             try {
617                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
618             }
619             catch (Exception e) {
620                 if (e instanceof com.liferay.portal.SystemException) {
621                     throw (com.liferay.portal.SystemException)e;
622                 }
623 
624                 if (e instanceof com.liferay.portal.PortalException) {
625                     throw (com.liferay.portal.PortalException)e;
626                 }
627 
628                 if (e instanceof java.rmi.RemoteException) {
629                     throw (java.rmi.RemoteException)e;
630                 }
631 
632                 throw new com.liferay.portal.SystemException(e);
633             }
634 
635             return (com.liferay.portlet.documentlibrary.model.DLFileEntry)returnObj;
636         }
637         catch (com.liferay.portal.SystemException se) {
638             _log.error(se, se);
639 
640             throw se;
641         }
642     }
643 
644     private static Log _log = LogFactoryUtil.getLog(DLFileEntryServiceHttp.class);
645 }