1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
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.MethodHandler;
20  import com.liferay.portal.kernel.util.MethodKey;
21  import com.liferay.portal.security.auth.HttpPrincipal;
22  import com.liferay.portal.service.AddressServiceUtil;
23  
24  /**
25   * <a href="AddressServiceHttp.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.AddressServiceUtil} 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       AddressServiceSoap
57   * @see       com.liferay.portal.security.auth.HttpPrincipal
58   * @see       com.liferay.portal.service.AddressServiceUtil
59   * @generated
60   */
61  public class AddressServiceHttp {
62      public static com.liferay.portal.model.Address addAddress(
63          HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
64          java.lang.String street1, java.lang.String street2,
65          java.lang.String street3, java.lang.String city, java.lang.String zip,
66          long regionId, long countryId, int typeId, boolean mailing,
67          boolean primary)
68          throws com.liferay.portal.PortalException,
69              com.liferay.portal.SystemException {
70          try {
71              MethodKey methodKey = new MethodKey(AddressServiceUtil.class.getName(),
72                      "addAddress", _addAddressParameterTypes0);
73  
74              MethodHandler methodHandler = new MethodHandler(methodKey,
75                      className, classPK, street1, street2, street3, city, zip,
76                      regionId, countryId, typeId, mailing, primary);
77  
78              Object returnObj = null;
79  
80              try {
81                  returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
82              }
83              catch (Exception e) {
84                  if (e instanceof com.liferay.portal.PortalException) {
85                      throw (com.liferay.portal.PortalException)e;
86                  }
87  
88                  if (e instanceof com.liferay.portal.SystemException) {
89                      throw (com.liferay.portal.SystemException)e;
90                  }
91  
92                  throw new com.liferay.portal.SystemException(e);
93              }
94  
95              return (com.liferay.portal.model.Address)returnObj;
96          }
97          catch (com.liferay.portal.SystemException se) {
98              _log.error(se, se);
99  
100             throw se;
101         }
102     }
103 
104     public static void deleteAddress(HttpPrincipal httpPrincipal, long addressId)
105         throws com.liferay.portal.PortalException,
106             com.liferay.portal.SystemException {
107         try {
108             MethodKey methodKey = new MethodKey(AddressServiceUtil.class.getName(),
109                     "deleteAddress", _deleteAddressParameterTypes1);
110 
111             MethodHandler methodHandler = new MethodHandler(methodKey, addressId);
112 
113             try {
114                 TunnelUtil.invoke(httpPrincipal, methodHandler);
115             }
116             catch (Exception e) {
117                 if (e instanceof com.liferay.portal.PortalException) {
118                     throw (com.liferay.portal.PortalException)e;
119                 }
120 
121                 if (e instanceof com.liferay.portal.SystemException) {
122                     throw (com.liferay.portal.SystemException)e;
123                 }
124 
125                 throw new com.liferay.portal.SystemException(e);
126             }
127         }
128         catch (com.liferay.portal.SystemException se) {
129             _log.error(se, se);
130 
131             throw se;
132         }
133     }
134 
135     public static com.liferay.portal.model.Address getAddress(
136         HttpPrincipal httpPrincipal, long addressId)
137         throws com.liferay.portal.PortalException,
138             com.liferay.portal.SystemException {
139         try {
140             MethodKey methodKey = new MethodKey(AddressServiceUtil.class.getName(),
141                     "getAddress", _getAddressParameterTypes2);
142 
143             MethodHandler methodHandler = new MethodHandler(methodKey, addressId);
144 
145             Object returnObj = null;
146 
147             try {
148                 returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
149             }
150             catch (Exception e) {
151                 if (e instanceof com.liferay.portal.PortalException) {
152                     throw (com.liferay.portal.PortalException)e;
153                 }
154 
155                 if (e instanceof com.liferay.portal.SystemException) {
156                     throw (com.liferay.portal.SystemException)e;
157                 }
158 
159                 throw new com.liferay.portal.SystemException(e);
160             }
161 
162             return (com.liferay.portal.model.Address)returnObj;
163         }
164         catch (com.liferay.portal.SystemException se) {
165             _log.error(se, se);
166 
167             throw se;
168         }
169     }
170 
171     public static java.util.List<com.liferay.portal.model.Address> getAddresses(
172         HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
173         throws com.liferay.portal.PortalException,
174             com.liferay.portal.SystemException {
175         try {
176             MethodKey methodKey = new MethodKey(AddressServiceUtil.class.getName(),
177                     "getAddresses", _getAddressesParameterTypes3);
178 
179             MethodHandler methodHandler = new MethodHandler(methodKey,
180                     className, classPK);
181 
182             Object returnObj = null;
183 
184             try {
185                 returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
186             }
187             catch (Exception e) {
188                 if (e instanceof com.liferay.portal.PortalException) {
189                     throw (com.liferay.portal.PortalException)e;
190                 }
191 
192                 if (e instanceof com.liferay.portal.SystemException) {
193                     throw (com.liferay.portal.SystemException)e;
194                 }
195 
196                 throw new com.liferay.portal.SystemException(e);
197             }
198 
199             return (java.util.List<com.liferay.portal.model.Address>)returnObj;
200         }
201         catch (com.liferay.portal.SystemException se) {
202             _log.error(se, se);
203 
204             throw se;
205         }
206     }
207 
208     public static com.liferay.portal.model.Address updateAddress(
209         HttpPrincipal httpPrincipal, long addressId, java.lang.String street1,
210         java.lang.String street2, java.lang.String street3,
211         java.lang.String city, java.lang.String zip, long regionId,
212         long countryId, int typeId, boolean mailing, boolean primary)
213         throws com.liferay.portal.PortalException,
214             com.liferay.portal.SystemException {
215         try {
216             MethodKey methodKey = new MethodKey(AddressServiceUtil.class.getName(),
217                     "updateAddress", _updateAddressParameterTypes4);
218 
219             MethodHandler methodHandler = new MethodHandler(methodKey,
220                     addressId, street1, street2, street3, city, zip, regionId,
221                     countryId, typeId, mailing, primary);
222 
223             Object returnObj = null;
224 
225             try {
226                 returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
227             }
228             catch (Exception e) {
229                 if (e instanceof com.liferay.portal.PortalException) {
230                     throw (com.liferay.portal.PortalException)e;
231                 }
232 
233                 if (e instanceof com.liferay.portal.SystemException) {
234                     throw (com.liferay.portal.SystemException)e;
235                 }
236 
237                 throw new com.liferay.portal.SystemException(e);
238             }
239 
240             return (com.liferay.portal.model.Address)returnObj;
241         }
242         catch (com.liferay.portal.SystemException se) {
243             _log.error(se, se);
244 
245             throw se;
246         }
247     }
248 
249     private static Log _log = LogFactoryUtil.getLog(AddressServiceHttp.class);
250     private static final Class<?>[] _addAddressParameterTypes0 = new Class[] {
251             java.lang.String.class, long.class, java.lang.String.class,
252             java.lang.String.class, java.lang.String.class,
253             java.lang.String.class, java.lang.String.class, long.class,
254             long.class, int.class, boolean.class, boolean.class
255         };
256     private static final Class<?>[] _deleteAddressParameterTypes1 = new Class[] {
257             long.class
258         };
259     private static final Class<?>[] _getAddressParameterTypes2 = new Class[] {
260             long.class
261         };
262     private static final Class<?>[] _getAddressesParameterTypes3 = new Class[] {
263             java.lang.String.class, long.class
264         };
265     private static final Class<?>[] _updateAddressParameterTypes4 = new Class[] {
266             long.class, java.lang.String.class, java.lang.String.class,
267             java.lang.String.class, java.lang.String.class,
268             java.lang.String.class, long.class, long.class, int.class,
269             boolean.class, boolean.class
270         };
271 }