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.imagegallery.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.imagegallery.service.IGImageServiceUtil;
32  
33  /**
34   * <a href="IGImageServiceHttp.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.imagegallery.service.IGImageServiceUtil</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.imagegallery.service.IGImageServiceUtil
69   * @see com.liferay.portlet.imagegallery.service.http.IGImageServiceSoap
70   *
71   */
72  public class IGImageServiceHttp {
73      public static com.liferay.portlet.imagegallery.model.IGImage addImage(
74          HttpPrincipal httpPrincipal, long folderId, java.lang.String name,
75          java.lang.String description, java.io.File file,
76          java.lang.String contentType, java.lang.String[] tagsEntries,
77          boolean addCommunityPermissions, boolean addGuestPermissions)
78          throws com.liferay.portal.PortalException,
79              com.liferay.portal.SystemException {
80          try {
81              Object paramObj0 = new LongWrapper(folderId);
82  
83              Object paramObj1 = name;
84  
85              if (name == null) {
86                  paramObj1 = new NullWrapper("java.lang.String");
87              }
88  
89              Object paramObj2 = description;
90  
91              if (description == null) {
92                  paramObj2 = new NullWrapper("java.lang.String");
93              }
94  
95              Object paramObj3 = file;
96  
97              if (file == null) {
98                  paramObj3 = new NullWrapper("java.io.File");
99              }
100 
101             Object paramObj4 = contentType;
102 
103             if (contentType == null) {
104                 paramObj4 = new NullWrapper("java.lang.String");
105             }
106 
107             Object paramObj5 = tagsEntries;
108 
109             if (tagsEntries == null) {
110                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
111             }
112 
113             Object paramObj6 = new BooleanWrapper(addCommunityPermissions);
114 
115             Object paramObj7 = new BooleanWrapper(addGuestPermissions);
116 
117             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
118                     "addImage",
119                     new Object[] {
120                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
121                         paramObj5, paramObj6, paramObj7
122                     });
123 
124             Object returnObj = null;
125 
126             try {
127                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
128             }
129             catch (Exception e) {
130                 if (e instanceof com.liferay.portal.PortalException) {
131                     throw (com.liferay.portal.PortalException)e;
132                 }
133 
134                 if (e instanceof com.liferay.portal.SystemException) {
135                     throw (com.liferay.portal.SystemException)e;
136                 }
137 
138                 throw new com.liferay.portal.SystemException(e);
139             }
140 
141             return (com.liferay.portlet.imagegallery.model.IGImage)returnObj;
142         }
143         catch (com.liferay.portal.SystemException se) {
144             _log.error(se, se);
145 
146             throw se;
147         }
148     }
149 
150     public static com.liferay.portlet.imagegallery.model.IGImage addImage(
151         HttpPrincipal httpPrincipal, long folderId, java.lang.String name,
152         java.lang.String description, java.io.File file,
153         java.lang.String contentType, java.lang.String[] tagsEntries,
154         java.lang.String[] communityPermissions,
155         java.lang.String[] guestPermissions)
156         throws com.liferay.portal.PortalException,
157             com.liferay.portal.SystemException {
158         try {
159             Object paramObj0 = new LongWrapper(folderId);
160 
161             Object paramObj1 = name;
162 
163             if (name == null) {
164                 paramObj1 = new NullWrapper("java.lang.String");
165             }
166 
167             Object paramObj2 = description;
168 
169             if (description == null) {
170                 paramObj2 = new NullWrapper("java.lang.String");
171             }
172 
173             Object paramObj3 = file;
174 
175             if (file == null) {
176                 paramObj3 = new NullWrapper("java.io.File");
177             }
178 
179             Object paramObj4 = contentType;
180 
181             if (contentType == null) {
182                 paramObj4 = new NullWrapper("java.lang.String");
183             }
184 
185             Object paramObj5 = tagsEntries;
186 
187             if (tagsEntries == null) {
188                 paramObj5 = new NullWrapper("[Ljava.lang.String;");
189             }
190 
191             Object paramObj6 = communityPermissions;
192 
193             if (communityPermissions == null) {
194                 paramObj6 = new NullWrapper("[Ljava.lang.String;");
195             }
196 
197             Object paramObj7 = guestPermissions;
198 
199             if (guestPermissions == null) {
200                 paramObj7 = new NullWrapper("[Ljava.lang.String;");
201             }
202 
203             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
204                     "addImage",
205                     new Object[] {
206                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
207                         paramObj5, paramObj6, paramObj7
208                     });
209 
210             Object returnObj = null;
211 
212             try {
213                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
214             }
215             catch (Exception e) {
216                 if (e instanceof com.liferay.portal.PortalException) {
217                     throw (com.liferay.portal.PortalException)e;
218                 }
219 
220                 if (e instanceof com.liferay.portal.SystemException) {
221                     throw (com.liferay.portal.SystemException)e;
222                 }
223 
224                 throw new com.liferay.portal.SystemException(e);
225             }
226 
227             return (com.liferay.portlet.imagegallery.model.IGImage)returnObj;
228         }
229         catch (com.liferay.portal.SystemException se) {
230             _log.error(se, se);
231 
232             throw se;
233         }
234     }
235 
236     public static void deleteImage(HttpPrincipal httpPrincipal, long imageId)
237         throws com.liferay.portal.PortalException,
238             com.liferay.portal.SystemException {
239         try {
240             Object paramObj0 = new LongWrapper(imageId);
241 
242             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
243                     "deleteImage", new Object[] { paramObj0 });
244 
245             try {
246                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
247             }
248             catch (Exception e) {
249                 if (e instanceof com.liferay.portal.PortalException) {
250                     throw (com.liferay.portal.PortalException)e;
251                 }
252 
253                 if (e instanceof com.liferay.portal.SystemException) {
254                     throw (com.liferay.portal.SystemException)e;
255                 }
256 
257                 throw new com.liferay.portal.SystemException(e);
258             }
259         }
260         catch (com.liferay.portal.SystemException se) {
261             _log.error(se, se);
262 
263             throw se;
264         }
265     }
266 
267     public static void deleteImageByFolderIdAndNameWithExtension(
268         HttpPrincipal httpPrincipal, long folderId,
269         java.lang.String nameWithExtension)
270         throws com.liferay.portal.PortalException,
271             com.liferay.portal.SystemException {
272         try {
273             Object paramObj0 = new LongWrapper(folderId);
274 
275             Object paramObj1 = nameWithExtension;
276 
277             if (nameWithExtension == null) {
278                 paramObj1 = new NullWrapper("java.lang.String");
279             }
280 
281             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
282                     "deleteImageByFolderIdAndNameWithExtension",
283                     new Object[] { paramObj0, paramObj1 });
284 
285             try {
286                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
287             }
288             catch (Exception e) {
289                 if (e instanceof com.liferay.portal.PortalException) {
290                     throw (com.liferay.portal.PortalException)e;
291                 }
292 
293                 if (e instanceof com.liferay.portal.SystemException) {
294                     throw (com.liferay.portal.SystemException)e;
295                 }
296 
297                 throw new com.liferay.portal.SystemException(e);
298             }
299         }
300         catch (com.liferay.portal.SystemException se) {
301             _log.error(se, se);
302 
303             throw se;
304         }
305     }
306 
307     public static com.liferay.portlet.imagegallery.model.IGImage getImage(
308         HttpPrincipal httpPrincipal, long imageId)
309         throws com.liferay.portal.PortalException,
310             com.liferay.portal.SystemException {
311         try {
312             Object paramObj0 = new LongWrapper(imageId);
313 
314             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
315                     "getImage", new Object[] { paramObj0 });
316 
317             Object returnObj = null;
318 
319             try {
320                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
321             }
322             catch (Exception e) {
323                 if (e instanceof com.liferay.portal.PortalException) {
324                     throw (com.liferay.portal.PortalException)e;
325                 }
326 
327                 if (e instanceof com.liferay.portal.SystemException) {
328                     throw (com.liferay.portal.SystemException)e;
329                 }
330 
331                 throw new com.liferay.portal.SystemException(e);
332             }
333 
334             return (com.liferay.portlet.imagegallery.model.IGImage)returnObj;
335         }
336         catch (com.liferay.portal.SystemException se) {
337             _log.error(se, se);
338 
339             throw se;
340         }
341     }
342 
343     public static com.liferay.portlet.imagegallery.model.IGImage getImageByFolderIdAndNameWithExtension(
344         HttpPrincipal httpPrincipal, long folderId,
345         java.lang.String nameWithExtension)
346         throws com.liferay.portal.PortalException,
347             com.liferay.portal.SystemException {
348         try {
349             Object paramObj0 = new LongWrapper(folderId);
350 
351             Object paramObj1 = nameWithExtension;
352 
353             if (nameWithExtension == null) {
354                 paramObj1 = new NullWrapper("java.lang.String");
355             }
356 
357             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
358                     "getImageByFolderIdAndNameWithExtension",
359                     new Object[] { paramObj0, paramObj1 });
360 
361             Object returnObj = null;
362 
363             try {
364                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
365             }
366             catch (Exception e) {
367                 if (e instanceof com.liferay.portal.PortalException) {
368                     throw (com.liferay.portal.PortalException)e;
369                 }
370 
371                 if (e instanceof com.liferay.portal.SystemException) {
372                     throw (com.liferay.portal.SystemException)e;
373                 }
374 
375                 throw new com.liferay.portal.SystemException(e);
376             }
377 
378             return (com.liferay.portlet.imagegallery.model.IGImage)returnObj;
379         }
380         catch (com.liferay.portal.SystemException se) {
381             _log.error(se, se);
382 
383             throw se;
384         }
385     }
386 
387     public static com.liferay.portlet.imagegallery.model.IGImage getImageByLargeImageId(
388         HttpPrincipal httpPrincipal, long largeImageId)
389         throws com.liferay.portal.PortalException,
390             com.liferay.portal.SystemException {
391         try {
392             Object paramObj0 = new LongWrapper(largeImageId);
393 
394             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
395                     "getImageByLargeImageId", new Object[] { paramObj0 });
396 
397             Object returnObj = null;
398 
399             try {
400                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
401             }
402             catch (Exception e) {
403                 if (e instanceof com.liferay.portal.PortalException) {
404                     throw (com.liferay.portal.PortalException)e;
405                 }
406 
407                 if (e instanceof com.liferay.portal.SystemException) {
408                     throw (com.liferay.portal.SystemException)e;
409                 }
410 
411                 throw new com.liferay.portal.SystemException(e);
412             }
413 
414             return (com.liferay.portlet.imagegallery.model.IGImage)returnObj;
415         }
416         catch (com.liferay.portal.SystemException se) {
417             _log.error(se, se);
418 
419             throw se;
420         }
421     }
422 
423     public static com.liferay.portlet.imagegallery.model.IGImage getImageBySmallImageId(
424         HttpPrincipal httpPrincipal, long smallImageId)
425         throws com.liferay.portal.PortalException,
426             com.liferay.portal.SystemException {
427         try {
428             Object paramObj0 = new LongWrapper(smallImageId);
429 
430             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
431                     "getImageBySmallImageId", new Object[] { paramObj0 });
432 
433             Object returnObj = null;
434 
435             try {
436                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
437             }
438             catch (Exception e) {
439                 if (e instanceof com.liferay.portal.PortalException) {
440                     throw (com.liferay.portal.PortalException)e;
441                 }
442 
443                 if (e instanceof com.liferay.portal.SystemException) {
444                     throw (com.liferay.portal.SystemException)e;
445                 }
446 
447                 throw new com.liferay.portal.SystemException(e);
448             }
449 
450             return (com.liferay.portlet.imagegallery.model.IGImage)returnObj;
451         }
452         catch (com.liferay.portal.SystemException se) {
453             _log.error(se, se);
454 
455             throw se;
456         }
457     }
458 
459     public static java.util.List<com.liferay.portlet.imagegallery.model.IGImage> getImages(
460         HttpPrincipal httpPrincipal, long folderId)
461         throws com.liferay.portal.PortalException,
462             com.liferay.portal.SystemException {
463         try {
464             Object paramObj0 = new LongWrapper(folderId);
465 
466             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
467                     "getImages", new Object[] { paramObj0 });
468 
469             Object returnObj = null;
470 
471             try {
472                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
473             }
474             catch (Exception e) {
475                 if (e instanceof com.liferay.portal.PortalException) {
476                     throw (com.liferay.portal.PortalException)e;
477                 }
478 
479                 if (e instanceof com.liferay.portal.SystemException) {
480                     throw (com.liferay.portal.SystemException)e;
481                 }
482 
483                 throw new com.liferay.portal.SystemException(e);
484             }
485 
486             return (java.util.List<com.liferay.portlet.imagegallery.model.IGImage>)returnObj;
487         }
488         catch (com.liferay.portal.SystemException se) {
489             _log.error(se, se);
490 
491             throw se;
492         }
493     }
494 
495     public static com.liferay.portlet.imagegallery.model.IGImage updateImage(
496         HttpPrincipal httpPrincipal, long imageId, long folderId,
497         java.lang.String name, java.lang.String description, java.io.File file,
498         java.lang.String contentType, java.lang.String[] tagsEntries)
499         throws com.liferay.portal.PortalException,
500             com.liferay.portal.SystemException {
501         try {
502             Object paramObj0 = new LongWrapper(imageId);
503 
504             Object paramObj1 = new LongWrapper(folderId);
505 
506             Object paramObj2 = name;
507 
508             if (name == null) {
509                 paramObj2 = new NullWrapper("java.lang.String");
510             }
511 
512             Object paramObj3 = description;
513 
514             if (description == null) {
515                 paramObj3 = new NullWrapper("java.lang.String");
516             }
517 
518             Object paramObj4 = file;
519 
520             if (file == null) {
521                 paramObj4 = new NullWrapper("java.io.File");
522             }
523 
524             Object paramObj5 = contentType;
525 
526             if (contentType == null) {
527                 paramObj5 = new NullWrapper("java.lang.String");
528             }
529 
530             Object paramObj6 = tagsEntries;
531 
532             if (tagsEntries == null) {
533                 paramObj6 = new NullWrapper("[Ljava.lang.String;");
534             }
535 
536             MethodWrapper methodWrapper = new MethodWrapper(IGImageServiceUtil.class.getName(),
537                     "updateImage",
538                     new Object[] {
539                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
540                         paramObj5, paramObj6
541                     });
542 
543             Object returnObj = null;
544 
545             try {
546                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
547             }
548             catch (Exception e) {
549                 if (e instanceof com.liferay.portal.PortalException) {
550                     throw (com.liferay.portal.PortalException)e;
551                 }
552 
553                 if (e instanceof com.liferay.portal.SystemException) {
554                     throw (com.liferay.portal.SystemException)e;
555                 }
556 
557                 throw new com.liferay.portal.SystemException(e);
558             }
559 
560             return (com.liferay.portlet.imagegallery.model.IGImage)returnObj;
561         }
562         catch (com.liferay.portal.SystemException se) {
563             _log.error(se, se);
564 
565             throw se;
566         }
567     }
568 
569     private static Log _log = LogFactoryUtil.getLog(IGImageServiceHttp.class);
570 }