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