1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.http;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.LongWrapper;
20  import com.liferay.portal.kernel.util.MethodWrapper;
21  import com.liferay.portal.security.auth.HttpPrincipal;
22  import com.liferay.portal.service.ImageServiceUtil;
23  
24  /**
25   * <a href="ImageServiceHttp.java.html"><b><i>View Source</i></b></a>
26   *
27   * <p>
28   * ServiceBuilder generated this class. Modifications in this class will be
29   * overwritten the next time is generated.
30   * </p>
31   *
32   * <p>
33   * This class provides a HTTP utility for the
34   * {@link com.liferay.portal.service.ImageServiceUtil} service utility. The
35   * static methods of this class calls the same methods of the service utility.
36   * However, the signatures are different because it requires an additional
37   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
38   * </p>
39   *
40   * <p>
41   * The benefits of using the HTTP utility is that it is fast and allows for
42   * tunneling without the cost of serializing to text. The drawback is that it
43   * only works with Java.
44   * </p>
45   *
46   * <p>
47   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
48   * configure security.
49   * </p>
50   *
51   * <p>
52   * The HTTP utility is only generated for remote services.
53   * </p>
54   *
55   * @author    Brian Wing Shun Chan
56   * @see       ImageServiceSoap
57   * @see       com.liferay.portal.security.auth.HttpPrincipal
58   * @see       com.liferay.portal.service.ImageServiceUtil
59   * @generated
60   */
61  public class ImageServiceHttp {
62      public static com.liferay.portal.model.Image getImage(
63          HttpPrincipal httpPrincipal, long imageId)
64          throws com.liferay.portal.kernel.exception.PortalException,
65              com.liferay.portal.kernel.exception.SystemException {
66          try {
67              Object paramObj0 = new LongWrapper(imageId);
68  
69              MethodWrapper methodWrapper = new MethodWrapper(ImageServiceUtil.class.getName(),
70                      "getImage", new Object[] { paramObj0 });
71  
72              Object returnObj = null;
73  
74              try {
75                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
76              }
77              catch (Exception e) {
78                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
79                      throw (com.liferay.portal.kernel.exception.PortalException)e;
80                  }
81  
82                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
83                      throw (com.liferay.portal.kernel.exception.SystemException)e;
84                  }
85  
86                  throw new com.liferay.portal.kernel.exception.SystemException(e);
87              }
88  
89              return (com.liferay.portal.model.Image)returnObj;
90          }
91          catch (com.liferay.portal.kernel.exception.SystemException se) {
92              _log.error(se, se);
93  
94              throw se;
95          }
96      }
97  
98      private static Log _log = LogFactoryUtil.getLog(ImageServiceHttp.class);
99  }