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.BooleanWrapper;
20  import com.liferay.portal.kernel.util.IntegerWrapper;
21  import com.liferay.portal.kernel.util.LongWrapper;
22  import com.liferay.portal.kernel.util.MethodWrapper;
23  import com.liferay.portal.kernel.util.NullWrapper;
24  import com.liferay.portal.security.auth.HttpPrincipal;
25  import com.liferay.portal.service.AddressServiceUtil;
26  
27  /**
28   * <a href="AddressServiceHttp.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * ServiceBuilder generated this class. Modifications in this class will be
32   * overwritten the next time is generated.
33   * </p>
34   *
35   * <p>
36   * This class provides a HTTP utility for the
37   * {@link com.liferay.portal.service.AddressServiceUtil} service utility. The
38   * static methods of this class calls the same methods of the service utility.
39   * However, the signatures are different because it requires an additional
40   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
41   * </p>
42   *
43   * <p>
44   * The benefits of using the HTTP utility is that it is fast and allows for
45   * tunneling without the cost of serializing to text. The drawback is that it
46   * only works with Java.
47   * </p>
48   *
49   * <p>
50   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
51   * configure security.
52   * </p>
53   *
54   * <p>
55   * The HTTP utility is only generated for remote services.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       AddressServiceSoap
60   * @see       com.liferay.portal.security.auth.HttpPrincipal
61   * @see       com.liferay.portal.service.AddressServiceUtil
62   * @generated
63   */
64  public class AddressServiceHttp {
65      public static com.liferay.portal.model.Address addAddress(
66          HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
67          java.lang.String street1, java.lang.String street2,
68          java.lang.String street3, java.lang.String city, java.lang.String zip,
69          long regionId, long countryId, int typeId, boolean mailing,
70          boolean primary)
71          throws com.liferay.portal.kernel.exception.PortalException,
72              com.liferay.portal.kernel.exception.SystemException {
73          try {
74              Object paramObj0 = className;
75  
76              if (className == null) {
77                  paramObj0 = new NullWrapper("java.lang.String");
78              }
79  
80              Object paramObj1 = new LongWrapper(classPK);
81  
82              Object paramObj2 = street1;
83  
84              if (street1 == null) {
85                  paramObj2 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj3 = street2;
89  
90              if (street2 == null) {
91                  paramObj3 = new NullWrapper("java.lang.String");
92              }
93  
94              Object paramObj4 = street3;
95  
96              if (street3 == null) {
97                  paramObj4 = new NullWrapper("java.lang.String");
98              }
99  
100             Object paramObj5 = city;
101 
102             if (city == null) {
103                 paramObj5 = new NullWrapper("java.lang.String");
104             }
105 
106             Object paramObj6 = zip;
107 
108             if (zip == null) {
109                 paramObj6 = new NullWrapper("java.lang.String");
110             }
111 
112             Object paramObj7 = new LongWrapper(regionId);
113 
114             Object paramObj8 = new LongWrapper(countryId);
115 
116             Object paramObj9 = new IntegerWrapper(typeId);
117 
118             Object paramObj10 = new BooleanWrapper(mailing);
119 
120             Object paramObj11 = new BooleanWrapper(primary);
121 
122             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
123                     "addAddress",
124                     new Object[] {
125                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
126                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
127                         paramObj10, paramObj11
128                     });
129 
130             Object returnObj = null;
131 
132             try {
133                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
134             }
135             catch (Exception e) {
136                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
137                     throw (com.liferay.portal.kernel.exception.PortalException)e;
138                 }
139 
140                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
141                     throw (com.liferay.portal.kernel.exception.SystemException)e;
142                 }
143 
144                 throw new com.liferay.portal.kernel.exception.SystemException(e);
145             }
146 
147             return (com.liferay.portal.model.Address)returnObj;
148         }
149         catch (com.liferay.portal.kernel.exception.SystemException se) {
150             _log.error(se, se);
151 
152             throw se;
153         }
154     }
155 
156     public static void deleteAddress(HttpPrincipal httpPrincipal, long addressId)
157         throws com.liferay.portal.kernel.exception.PortalException,
158             com.liferay.portal.kernel.exception.SystemException {
159         try {
160             Object paramObj0 = new LongWrapper(addressId);
161 
162             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
163                     "deleteAddress", new Object[] { paramObj0 });
164 
165             try {
166                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
167             }
168             catch (Exception e) {
169                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
170                     throw (com.liferay.portal.kernel.exception.PortalException)e;
171                 }
172 
173                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
174                     throw (com.liferay.portal.kernel.exception.SystemException)e;
175                 }
176 
177                 throw new com.liferay.portal.kernel.exception.SystemException(e);
178             }
179         }
180         catch (com.liferay.portal.kernel.exception.SystemException se) {
181             _log.error(se, se);
182 
183             throw se;
184         }
185     }
186 
187     public static com.liferay.portal.model.Address getAddress(
188         HttpPrincipal httpPrincipal, long addressId)
189         throws com.liferay.portal.kernel.exception.PortalException,
190             com.liferay.portal.kernel.exception.SystemException {
191         try {
192             Object paramObj0 = new LongWrapper(addressId);
193 
194             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
195                     "getAddress", new Object[] { paramObj0 });
196 
197             Object returnObj = null;
198 
199             try {
200                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
201             }
202             catch (Exception e) {
203                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
204                     throw (com.liferay.portal.kernel.exception.PortalException)e;
205                 }
206 
207                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
208                     throw (com.liferay.portal.kernel.exception.SystemException)e;
209                 }
210 
211                 throw new com.liferay.portal.kernel.exception.SystemException(e);
212             }
213 
214             return (com.liferay.portal.model.Address)returnObj;
215         }
216         catch (com.liferay.portal.kernel.exception.SystemException se) {
217             _log.error(se, se);
218 
219             throw se;
220         }
221     }
222 
223     public static java.util.List<com.liferay.portal.model.Address> getAddresses(
224         HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
225         throws com.liferay.portal.kernel.exception.PortalException,
226             com.liferay.portal.kernel.exception.SystemException {
227         try {
228             Object paramObj0 = className;
229 
230             if (className == null) {
231                 paramObj0 = new NullWrapper("java.lang.String");
232             }
233 
234             Object paramObj1 = new LongWrapper(classPK);
235 
236             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
237                     "getAddresses", new Object[] { paramObj0, paramObj1 });
238 
239             Object returnObj = null;
240 
241             try {
242                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
243             }
244             catch (Exception e) {
245                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
246                     throw (com.liferay.portal.kernel.exception.PortalException)e;
247                 }
248 
249                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
250                     throw (com.liferay.portal.kernel.exception.SystemException)e;
251                 }
252 
253                 throw new com.liferay.portal.kernel.exception.SystemException(e);
254             }
255 
256             return (java.util.List<com.liferay.portal.model.Address>)returnObj;
257         }
258         catch (com.liferay.portal.kernel.exception.SystemException se) {
259             _log.error(se, se);
260 
261             throw se;
262         }
263     }
264 
265     public static com.liferay.portal.model.Address updateAddress(
266         HttpPrincipal httpPrincipal, long addressId, java.lang.String street1,
267         java.lang.String street2, java.lang.String street3,
268         java.lang.String city, java.lang.String zip, long regionId,
269         long countryId, int typeId, boolean mailing, boolean primary)
270         throws com.liferay.portal.kernel.exception.PortalException,
271             com.liferay.portal.kernel.exception.SystemException {
272         try {
273             Object paramObj0 = new LongWrapper(addressId);
274 
275             Object paramObj1 = street1;
276 
277             if (street1 == null) {
278                 paramObj1 = new NullWrapper("java.lang.String");
279             }
280 
281             Object paramObj2 = street2;
282 
283             if (street2 == null) {
284                 paramObj2 = new NullWrapper("java.lang.String");
285             }
286 
287             Object paramObj3 = street3;
288 
289             if (street3 == null) {
290                 paramObj3 = new NullWrapper("java.lang.String");
291             }
292 
293             Object paramObj4 = city;
294 
295             if (city == null) {
296                 paramObj4 = new NullWrapper("java.lang.String");
297             }
298 
299             Object paramObj5 = zip;
300 
301             if (zip == null) {
302                 paramObj5 = new NullWrapper("java.lang.String");
303             }
304 
305             Object paramObj6 = new LongWrapper(regionId);
306 
307             Object paramObj7 = new LongWrapper(countryId);
308 
309             Object paramObj8 = new IntegerWrapper(typeId);
310 
311             Object paramObj9 = new BooleanWrapper(mailing);
312 
313             Object paramObj10 = new BooleanWrapper(primary);
314 
315             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
316                     "updateAddress",
317                     new Object[] {
318                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
319                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
320                         paramObj10
321                     });
322 
323             Object returnObj = null;
324 
325             try {
326                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
327             }
328             catch (Exception e) {
329                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
330                     throw (com.liferay.portal.kernel.exception.PortalException)e;
331                 }
332 
333                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
334                     throw (com.liferay.portal.kernel.exception.SystemException)e;
335                 }
336 
337                 throw new com.liferay.portal.kernel.exception.SystemException(e);
338             }
339 
340             return (com.liferay.portal.model.Address)returnObj;
341         }
342         catch (com.liferay.portal.kernel.exception.SystemException se) {
343             _log.error(se, se);
344 
345             throw se;
346         }
347     }
348 
349     private static Log _log = LogFactoryUtil.getLog(AddressServiceHttp.class);
350 }