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