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