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