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.PhoneServiceUtil;
26  
27  /**
28   * <a href="PhoneServiceHttp.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.PhoneServiceUtil} 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       PhoneServiceSoap
60   * @see       com.liferay.portal.security.auth.HttpPrincipal
61   * @see       com.liferay.portal.service.PhoneServiceUtil
62   * @generated
63   */
64  public class PhoneServiceHttp {
65      public static com.liferay.portal.model.Phone addPhone(
66          HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
67          java.lang.String number, java.lang.String extension, int typeId,
68          boolean primary)
69          throws com.liferay.portal.kernel.exception.PortalException,
70              com.liferay.portal.kernel.exception.SystemException {
71          try {
72              Object paramObj0 = className;
73  
74              if (className == null) {
75                  paramObj0 = new NullWrapper("java.lang.String");
76              }
77  
78              Object paramObj1 = new LongWrapper(classPK);
79  
80              Object paramObj2 = number;
81  
82              if (number == null) {
83                  paramObj2 = new NullWrapper("java.lang.String");
84              }
85  
86              Object paramObj3 = extension;
87  
88              if (extension == null) {
89                  paramObj3 = new NullWrapper("java.lang.String");
90              }
91  
92              Object paramObj4 = new IntegerWrapper(typeId);
93  
94              Object paramObj5 = new BooleanWrapper(primary);
95  
96              MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
97                      "addPhone",
98                      new Object[] {
99                          paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
100                         paramObj5
101                     });
102 
103             Object returnObj = null;
104 
105             try {
106                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
107             }
108             catch (Exception e) {
109                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
110                     throw (com.liferay.portal.kernel.exception.PortalException)e;
111                 }
112 
113                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
114                     throw (com.liferay.portal.kernel.exception.SystemException)e;
115                 }
116 
117                 throw new com.liferay.portal.kernel.exception.SystemException(e);
118             }
119 
120             return (com.liferay.portal.model.Phone)returnObj;
121         }
122         catch (com.liferay.portal.kernel.exception.SystemException se) {
123             _log.error(se, se);
124 
125             throw se;
126         }
127     }
128 
129     public static void deletePhone(HttpPrincipal httpPrincipal, long phoneId)
130         throws com.liferay.portal.kernel.exception.PortalException,
131             com.liferay.portal.kernel.exception.SystemException {
132         try {
133             Object paramObj0 = new LongWrapper(phoneId);
134 
135             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
136                     "deletePhone", new Object[] { paramObj0 });
137 
138             try {
139                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
140             }
141             catch (Exception e) {
142                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
143                     throw (com.liferay.portal.kernel.exception.PortalException)e;
144                 }
145 
146                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
147                     throw (com.liferay.portal.kernel.exception.SystemException)e;
148                 }
149 
150                 throw new com.liferay.portal.kernel.exception.SystemException(e);
151             }
152         }
153         catch (com.liferay.portal.kernel.exception.SystemException se) {
154             _log.error(se, se);
155 
156             throw se;
157         }
158     }
159 
160     public static com.liferay.portal.model.Phone getPhone(
161         HttpPrincipal httpPrincipal, long phoneId)
162         throws com.liferay.portal.kernel.exception.PortalException,
163             com.liferay.portal.kernel.exception.SystemException {
164         try {
165             Object paramObj0 = new LongWrapper(phoneId);
166 
167             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
168                     "getPhone", new Object[] { paramObj0 });
169 
170             Object returnObj = null;
171 
172             try {
173                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
174             }
175             catch (Exception e) {
176                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
177                     throw (com.liferay.portal.kernel.exception.PortalException)e;
178                 }
179 
180                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
181                     throw (com.liferay.portal.kernel.exception.SystemException)e;
182                 }
183 
184                 throw new com.liferay.portal.kernel.exception.SystemException(e);
185             }
186 
187             return (com.liferay.portal.model.Phone)returnObj;
188         }
189         catch (com.liferay.portal.kernel.exception.SystemException se) {
190             _log.error(se, se);
191 
192             throw se;
193         }
194     }
195 
196     public static java.util.List<com.liferay.portal.model.Phone> getPhones(
197         HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
198         throws com.liferay.portal.kernel.exception.PortalException,
199             com.liferay.portal.kernel.exception.SystemException {
200         try {
201             Object paramObj0 = className;
202 
203             if (className == null) {
204                 paramObj0 = new NullWrapper("java.lang.String");
205             }
206 
207             Object paramObj1 = new LongWrapper(classPK);
208 
209             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
210                     "getPhones", new Object[] { paramObj0, paramObj1 });
211 
212             Object returnObj = null;
213 
214             try {
215                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
216             }
217             catch (Exception e) {
218                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
219                     throw (com.liferay.portal.kernel.exception.PortalException)e;
220                 }
221 
222                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
223                     throw (com.liferay.portal.kernel.exception.SystemException)e;
224                 }
225 
226                 throw new com.liferay.portal.kernel.exception.SystemException(e);
227             }
228 
229             return (java.util.List<com.liferay.portal.model.Phone>)returnObj;
230         }
231         catch (com.liferay.portal.kernel.exception.SystemException se) {
232             _log.error(se, se);
233 
234             throw se;
235         }
236     }
237 
238     public static com.liferay.portal.model.Phone updatePhone(
239         HttpPrincipal httpPrincipal, long phoneId, java.lang.String number,
240         java.lang.String extension, int typeId, boolean primary)
241         throws com.liferay.portal.kernel.exception.PortalException,
242             com.liferay.portal.kernel.exception.SystemException {
243         try {
244             Object paramObj0 = new LongWrapper(phoneId);
245 
246             Object paramObj1 = number;
247 
248             if (number == null) {
249                 paramObj1 = new NullWrapper("java.lang.String");
250             }
251 
252             Object paramObj2 = extension;
253 
254             if (extension == null) {
255                 paramObj2 = new NullWrapper("java.lang.String");
256             }
257 
258             Object paramObj3 = new IntegerWrapper(typeId);
259 
260             Object paramObj4 = new BooleanWrapper(primary);
261 
262             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
263                     "updatePhone",
264                     new Object[] {
265                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
266                     });
267 
268             Object returnObj = null;
269 
270             try {
271                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
272             }
273             catch (Exception e) {
274                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
275                     throw (com.liferay.portal.kernel.exception.PortalException)e;
276                 }
277 
278                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
279                     throw (com.liferay.portal.kernel.exception.SystemException)e;
280                 }
281 
282                 throw new com.liferay.portal.kernel.exception.SystemException(e);
283             }
284 
285             return (com.liferay.portal.model.Phone)returnObj;
286         }
287         catch (com.liferay.portal.kernel.exception.SystemException se) {
288             _log.error(se, se);
289 
290             throw se;
291         }
292     }
293 
294     private static Log _log = LogFactoryUtil.getLog(PhoneServiceHttp.class);
295 }