1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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   * {@link com.liferay.portal.service.AddressServiceUtil} service utility. The
46   * static methods of this class calls the same methods of the service utility.
47   * However, the signatures are different because it requires an additional
48   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for
53   * tunneling without the cost of serializing to text. The drawback is that it
54   * only works with Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
59   * 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   * @see       AddressServiceSoap
68   * @see       com.liferay.portal.security.auth.HttpPrincipal
69   * @see       com.liferay.portal.service.AddressServiceUtil
70   * @generated
71   */
72  public class AddressServiceHttp {
73      public static com.liferay.portal.model.Address addAddress(
74          HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
75          java.lang.String street1, java.lang.String street2,
76          java.lang.String street3, java.lang.String city, java.lang.String zip,
77          long regionId, long countryId, int typeId, boolean mailing,
78          boolean primary)
79          throws com.liferay.portal.PortalException,
80              com.liferay.portal.SystemException {
81          try {
82              Object paramObj0 = className;
83  
84              if (className == null) {
85                  paramObj0 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj1 = new LongWrapper(classPK);
89  
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 
122             Object paramObj8 = new LongWrapper(countryId);
123 
124             Object paramObj9 = new IntegerWrapper(typeId);
125 
126             Object paramObj10 = new BooleanWrapper(mailing);
127 
128             Object paramObj11 = new BooleanWrapper(primary);
129 
130             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
131                     "addAddress",
132                     new Object[] {
133                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
134                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
135                         paramObj10, paramObj11
136                     });
137 
138             Object returnObj = null;
139 
140             try {
141                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
142             }
143             catch (Exception e) {
144                 if (e instanceof com.liferay.portal.PortalException) {
145                     throw (com.liferay.portal.PortalException)e;
146                 }
147 
148                 if (e instanceof com.liferay.portal.SystemException) {
149                     throw (com.liferay.portal.SystemException)e;
150                 }
151 
152                 throw new com.liferay.portal.SystemException(e);
153             }
154 
155             return (com.liferay.portal.model.Address)returnObj;
156         }
157         catch (com.liferay.portal.SystemException se) {
158             _log.error(se, se);
159 
160             throw se;
161         }
162     }
163 
164     public static void deleteAddress(HttpPrincipal httpPrincipal, long addressId)
165         throws com.liferay.portal.PortalException,
166             com.liferay.portal.SystemException {
167         try {
168             Object paramObj0 = new LongWrapper(addressId);
169 
170             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
171                     "deleteAddress", new Object[] { paramObj0 });
172 
173             try {
174                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
175             }
176             catch (Exception e) {
177                 if (e instanceof com.liferay.portal.PortalException) {
178                     throw (com.liferay.portal.PortalException)e;
179                 }
180 
181                 if (e instanceof com.liferay.portal.SystemException) {
182                     throw (com.liferay.portal.SystemException)e;
183                 }
184 
185                 throw new com.liferay.portal.SystemException(e);
186             }
187         }
188         catch (com.liferay.portal.SystemException se) {
189             _log.error(se, se);
190 
191             throw se;
192         }
193     }
194 
195     public static com.liferay.portal.model.Address getAddress(
196         HttpPrincipal httpPrincipal, long addressId)
197         throws com.liferay.portal.PortalException,
198             com.liferay.portal.SystemException {
199         try {
200             Object paramObj0 = new LongWrapper(addressId);
201 
202             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
203                     "getAddress", new Object[] { paramObj0 });
204 
205             Object returnObj = null;
206 
207             try {
208                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
209             }
210             catch (Exception e) {
211                 if (e instanceof com.liferay.portal.PortalException) {
212                     throw (com.liferay.portal.PortalException)e;
213                 }
214 
215                 if (e instanceof com.liferay.portal.SystemException) {
216                     throw (com.liferay.portal.SystemException)e;
217                 }
218 
219                 throw new com.liferay.portal.SystemException(e);
220             }
221 
222             return (com.liferay.portal.model.Address)returnObj;
223         }
224         catch (com.liferay.portal.SystemException se) {
225             _log.error(se, se);
226 
227             throw se;
228         }
229     }
230 
231     public static java.util.List<com.liferay.portal.model.Address> getAddresses(
232         HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
233         throws com.liferay.portal.PortalException,
234             com.liferay.portal.SystemException {
235         try {
236             Object paramObj0 = className;
237 
238             if (className == null) {
239                 paramObj0 = new NullWrapper("java.lang.String");
240             }
241 
242             Object paramObj1 = new LongWrapper(classPK);
243 
244             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
245                     "getAddresses", new Object[] { paramObj0, paramObj1 });
246 
247             Object returnObj = null;
248 
249             try {
250                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
251             }
252             catch (Exception e) {
253                 if (e instanceof com.liferay.portal.PortalException) {
254                     throw (com.liferay.portal.PortalException)e;
255                 }
256 
257                 if (e instanceof com.liferay.portal.SystemException) {
258                     throw (com.liferay.portal.SystemException)e;
259                 }
260 
261                 throw new com.liferay.portal.SystemException(e);
262             }
263 
264             return (java.util.List<com.liferay.portal.model.Address>)returnObj;
265         }
266         catch (com.liferay.portal.SystemException se) {
267             _log.error(se, se);
268 
269             throw se;
270         }
271     }
272 
273     public static com.liferay.portal.model.Address updateAddress(
274         HttpPrincipal httpPrincipal, long addressId, java.lang.String street1,
275         java.lang.String street2, java.lang.String street3,
276         java.lang.String city, java.lang.String zip, long regionId,
277         long countryId, int typeId, boolean mailing, boolean primary)
278         throws com.liferay.portal.PortalException,
279             com.liferay.portal.SystemException {
280         try {
281             Object paramObj0 = new LongWrapper(addressId);
282 
283             Object paramObj1 = street1;
284 
285             if (street1 == null) {
286                 paramObj1 = new NullWrapper("java.lang.String");
287             }
288 
289             Object paramObj2 = street2;
290 
291             if (street2 == null) {
292                 paramObj2 = new NullWrapper("java.lang.String");
293             }
294 
295             Object paramObj3 = street3;
296 
297             if (street3 == null) {
298                 paramObj3 = new NullWrapper("java.lang.String");
299             }
300 
301             Object paramObj4 = city;
302 
303             if (city == null) {
304                 paramObj4 = new NullWrapper("java.lang.String");
305             }
306 
307             Object paramObj5 = zip;
308 
309             if (zip == null) {
310                 paramObj5 = new NullWrapper("java.lang.String");
311             }
312 
313             Object paramObj6 = new LongWrapper(regionId);
314 
315             Object paramObj7 = new LongWrapper(countryId);
316 
317             Object paramObj8 = new IntegerWrapper(typeId);
318 
319             Object paramObj9 = new BooleanWrapper(mailing);
320 
321             Object paramObj10 = new BooleanWrapper(primary);
322 
323             MethodWrapper methodWrapper = new MethodWrapper(AddressServiceUtil.class.getName(),
324                     "updateAddress",
325                     new Object[] {
326                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
327                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
328                         paramObj10
329                     });
330 
331             Object returnObj = null;
332 
333             try {
334                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
335             }
336             catch (Exception e) {
337                 if (e instanceof com.liferay.portal.PortalException) {
338                     throw (com.liferay.portal.PortalException)e;
339                 }
340 
341                 if (e instanceof com.liferay.portal.SystemException) {
342                     throw (com.liferay.portal.SystemException)e;
343                 }
344 
345                 throw new com.liferay.portal.SystemException(e);
346             }
347 
348             return (com.liferay.portal.model.Address)returnObj;
349         }
350         catch (com.liferay.portal.SystemException se) {
351             _log.error(se, se);
352 
353             throw se;
354         }
355     }
356 
357     private static Log _log = LogFactoryUtil.getLog(AddressServiceHttp.class);
358 }