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.portal.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.IntegerWrapper;
29  import com.liferay.portal.kernel.util.LongWrapper;
30  import com.liferay.portal.kernel.util.MethodWrapper;
31  import com.liferay.portal.kernel.util.NullWrapper;
32  import com.liferay.portal.security.auth.HttpPrincipal;
33  import com.liferay.portal.service.AddressServiceUtil;
34  
35  /**
36   * <a href="AddressServiceHttp.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.portal.service.AddressServiceUtil</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.portal.service.AddressServiceUtil
71   * @see com.liferay.portal.service.http.AddressServiceSoap
72   *
73   */
74  public class AddressServiceHttp {
75      public static com.liferay.portal.model.Address addAddress(
76          HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
77          java.lang.String street1, java.lang.String street2,
78          java.lang.String street3, java.lang.String city, java.lang.String zip,
79          long regionId, long countryId, int typeId, boolean mailing,
80          boolean primary)
81          throws com.liferay.portal.PortalException,
82              com.liferay.portal.SystemException {
83          try {
84              Object paramObj0 = className;
85  
86              if (className == null) {
87                  paramObj0 = new NullWrapper("java.lang.String");
88              }
89  
90              Object paramObj1 = new LongWrapper(classPK);
91  
92              Object paramObj2 = street1;
93  
94              if (street1 == null) {
95                  paramObj2 = new NullWrapper("java.lang.String");
96              }
97  
98              Object paramObj3 = street2;
99  
100             if (street2 == null) {
101                 paramObj3 = new NullWrapper("java.lang.String");
102             }
103 
104             Object paramObj4 = street3;
105 
106             if (street3 == null) {
107                 paramObj4 = new NullWrapper("java.lang.String");
108             }
109 
110             Object paramObj5 = city;
111 
112             if (city == null) {
113                 paramObj5 = new NullWrapper("java.lang.String");
114             }
115 
116             Object paramObj6 = zip;
117 
118             if (zip == null) {
119                 paramObj6 = new NullWrapper("java.lang.String");
120             }
121 
122             Object paramObj7 = new LongWrapper(regionId);
123 
124             Object paramObj8 = new LongWrapper(countryId);
125 
126             Object paramObj9 = new IntegerWrapper(typeId);
127 
128             Object paramObj10 = new BooleanWrapper(mailing);
129 
130             Object paramObj11 = new BooleanWrapper(primary);
131 
132             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
133                     "addAddress",
134                     new Object[] {
135                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
136                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
137                         paramObj10, paramObj11
138                     });
139 
140             Object returnObj = null;
141 
142             try {
143                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
144             }
145             catch (Exception e) {
146                 if (e instanceof com.liferay.portal.PortalException) {
147                     throw (com.liferay.portal.PortalException)e;
148                 }
149 
150                 if (e instanceof com.liferay.portal.SystemException) {
151                     throw (com.liferay.portal.SystemException)e;
152                 }
153 
154                 throw new com.liferay.portal.SystemException(e);
155             }
156 
157             return (com.liferay.portal.model.Address)returnObj;
158         }
159         catch (com.liferay.portal.SystemException se) {
160             _log.error(se, se);
161 
162             throw se;
163         }
164     }
165 
166     public static void deleteAddress(HttpPrincipal httpPrincipal, long addressId)
167         throws com.liferay.portal.PortalException,
168             com.liferay.portal.SystemException {
169         try {
170             Object paramObj0 = new LongWrapper(addressId);
171 
172             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
173                     "deleteAddress", new Object[] { paramObj0 });
174 
175             try {
176                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
177             }
178             catch (Exception e) {
179                 if (e instanceof com.liferay.portal.PortalException) {
180                     throw (com.liferay.portal.PortalException)e;
181                 }
182 
183                 if (e instanceof com.liferay.portal.SystemException) {
184                     throw (com.liferay.portal.SystemException)e;
185                 }
186 
187                 throw new com.liferay.portal.SystemException(e);
188             }
189         }
190         catch (com.liferay.portal.SystemException se) {
191             _log.error(se, se);
192 
193             throw se;
194         }
195     }
196 
197     public static com.liferay.portal.model.Address getAddress(
198         HttpPrincipal httpPrincipal, long addressId)
199         throws com.liferay.portal.PortalException,
200             com.liferay.portal.SystemException {
201         try {
202             Object paramObj0 = new LongWrapper(addressId);
203 
204             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
205                     "getAddress", new Object[] { paramObj0 });
206 
207             Object returnObj = null;
208 
209             try {
210                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
211             }
212             catch (Exception e) {
213                 if (e instanceof com.liferay.portal.PortalException) {
214                     throw (com.liferay.portal.PortalException)e;
215                 }
216 
217                 if (e instanceof com.liferay.portal.SystemException) {
218                     throw (com.liferay.portal.SystemException)e;
219                 }
220 
221                 throw new com.liferay.portal.SystemException(e);
222             }
223 
224             return (com.liferay.portal.model.Address)returnObj;
225         }
226         catch (com.liferay.portal.SystemException se) {
227             _log.error(se, se);
228 
229             throw se;
230         }
231     }
232 
233     public static java.util.List<com.liferay.portal.model.Address> getAddresses(
234         HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
235         throws com.liferay.portal.PortalException,
236             com.liferay.portal.SystemException {
237         try {
238             Object paramObj0 = className;
239 
240             if (className == null) {
241                 paramObj0 = new NullWrapper("java.lang.String");
242             }
243 
244             Object paramObj1 = new LongWrapper(classPK);
245 
246             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
247                     "getAddresses", new Object[] { paramObj0, paramObj1 });
248 
249             Object returnObj = null;
250 
251             try {
252                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
253             }
254             catch (Exception e) {
255                 if (e instanceof com.liferay.portal.PortalException) {
256                     throw (com.liferay.portal.PortalException)e;
257                 }
258 
259                 if (e instanceof com.liferay.portal.SystemException) {
260                     throw (com.liferay.portal.SystemException)e;
261                 }
262 
263                 throw new com.liferay.portal.SystemException(e);
264             }
265 
266             return (java.util.List<com.liferay.portal.model.Address>)returnObj;
267         }
268         catch (com.liferay.portal.SystemException se) {
269             _log.error(se, se);
270 
271             throw se;
272         }
273     }
274 
275     public static com.liferay.portal.model.Address updateAddress(
276         HttpPrincipal httpPrincipal, long addressId, java.lang.String street1,
277         java.lang.String street2, java.lang.String street3,
278         java.lang.String city, java.lang.String zip, long regionId,
279         long countryId, int typeId, boolean mailing, boolean primary)
280         throws com.liferay.portal.PortalException,
281             com.liferay.portal.SystemException {
282         try {
283             Object paramObj0 = new LongWrapper(addressId);
284 
285             Object paramObj1 = street1;
286 
287             if (street1 == null) {
288                 paramObj1 = new NullWrapper("java.lang.String");
289             }
290 
291             Object paramObj2 = street2;
292 
293             if (street2 == null) {
294                 paramObj2 = new NullWrapper("java.lang.String");
295             }
296 
297             Object paramObj3 = street3;
298 
299             if (street3 == null) {
300                 paramObj3 = new NullWrapper("java.lang.String");
301             }
302 
303             Object paramObj4 = city;
304 
305             if (city == null) {
306                 paramObj4 = new NullWrapper("java.lang.String");
307             }
308 
309             Object paramObj5 = zip;
310 
311             if (zip == null) {
312                 paramObj5 = new NullWrapper("java.lang.String");
313             }
314 
315             Object paramObj6 = new LongWrapper(regionId);
316 
317             Object paramObj7 = new LongWrapper(countryId);
318 
319             Object paramObj8 = new IntegerWrapper(typeId);
320 
321             Object paramObj9 = new BooleanWrapper(mailing);
322 
323             Object paramObj10 = new BooleanWrapper(primary);
324 
325             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
326                     "updateAddress",
327                     new Object[] {
328                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
329                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
330                         paramObj10
331                     });
332 
333             Object returnObj = null;
334 
335             try {
336                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
337             }
338             catch (Exception e) {
339                 if (e instanceof com.liferay.portal.PortalException) {
340                     throw (com.liferay.portal.PortalException)e;
341                 }
342 
343                 if (e instanceof com.liferay.portal.SystemException) {
344                     throw (com.liferay.portal.SystemException)e;
345                 }
346 
347                 throw new com.liferay.portal.SystemException(e);
348             }
349 
350             return (com.liferay.portal.model.Address)returnObj;
351         }
352         catch (com.liferay.portal.SystemException se) {
353             _log.error(se, se);
354 
355             throw se;
356         }
357     }
358 
359     private static Log _log = LogFactoryUtil.getLog(AddressServiceHttp.class);
360 }