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