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