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