1   /**
2    * Copyright (c) 2000-2009 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  
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   * <code>com.liferay.portal.service.PhoneServiceUtil</code> service
46   * 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>
49   * parameter.
50   * </p>
51   *
52   * <p>
53   * The benefits of using the HTTP utility is that it is fast and allows for
54   * tunneling without the cost of serializing to text. The drawback is that it
55   * only works with Java.
56   * </p>
57   *
58   * <p>
59   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
60   * portal.properties to configure security.
61   * </p>
62   *
63   * <p>
64   * The HTTP utility is only generated for remote services.
65   * </p>
66   *
67   * @author Brian Wing Shun Chan
68   *
69   * @see com.liferay.portal.security.auth.HttpPrincipal
70   * @see com.liferay.portal.service.PhoneServiceUtil
71   * @see com.liferay.portal.service.http.PhoneServiceSoap
72   *
73   */
74  public class PhoneServiceHttp {
75      public static com.liferay.portal.model.Phone addPhone(
76          HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
77          java.lang.String number, java.lang.String extension, int typeId,
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 = number;
91  
92              if (number == null) {
93                  paramObj2 = new NullWrapper("java.lang.String");
94              }
95  
96              Object paramObj3 = extension;
97  
98              if (extension == null) {
99                  paramObj3 = new NullWrapper("java.lang.String");
100             }
101 
102             Object paramObj4 = new IntegerWrapper(typeId);
103 
104             Object paramObj5 = new BooleanWrapper(primary);
105 
106             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
107                     "addPhone",
108                     new Object[] {
109                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
110                         paramObj5
111                     });
112 
113             Object returnObj = null;
114 
115             try {
116                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
117             }
118             catch (Exception e) {
119                 if (e instanceof com.liferay.portal.PortalException) {
120                     throw (com.liferay.portal.PortalException)e;
121                 }
122 
123                 if (e instanceof com.liferay.portal.SystemException) {
124                     throw (com.liferay.portal.SystemException)e;
125                 }
126 
127                 throw new com.liferay.portal.SystemException(e);
128             }
129 
130             return (com.liferay.portal.model.Phone)returnObj;
131         }
132         catch (com.liferay.portal.SystemException se) {
133             _log.error(se, se);
134 
135             throw se;
136         }
137     }
138 
139     public static void deletePhone(HttpPrincipal httpPrincipal, long phoneId)
140         throws com.liferay.portal.PortalException,
141             com.liferay.portal.SystemException {
142         try {
143             Object paramObj0 = new LongWrapper(phoneId);
144 
145             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
146                     "deletePhone", new Object[] { paramObj0 });
147 
148             try {
149                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
150             }
151             catch (Exception e) {
152                 if (e instanceof com.liferay.portal.PortalException) {
153                     throw (com.liferay.portal.PortalException)e;
154                 }
155 
156                 if (e instanceof com.liferay.portal.SystemException) {
157                     throw (com.liferay.portal.SystemException)e;
158                 }
159 
160                 throw new com.liferay.portal.SystemException(e);
161             }
162         }
163         catch (com.liferay.portal.SystemException se) {
164             _log.error(se, se);
165 
166             throw se;
167         }
168     }
169 
170     public static com.liferay.portal.model.Phone getPhone(
171         HttpPrincipal httpPrincipal, long phoneId)
172         throws com.liferay.portal.PortalException,
173             com.liferay.portal.SystemException {
174         try {
175             Object paramObj0 = new LongWrapper(phoneId);
176 
177             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
178                     "getPhone", new Object[] { paramObj0 });
179 
180             Object returnObj = null;
181 
182             try {
183                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
184             }
185             catch (Exception e) {
186                 if (e instanceof com.liferay.portal.PortalException) {
187                     throw (com.liferay.portal.PortalException)e;
188                 }
189 
190                 if (e instanceof com.liferay.portal.SystemException) {
191                     throw (com.liferay.portal.SystemException)e;
192                 }
193 
194                 throw new com.liferay.portal.SystemException(e);
195             }
196 
197             return (com.liferay.portal.model.Phone)returnObj;
198         }
199         catch (com.liferay.portal.SystemException se) {
200             _log.error(se, se);
201 
202             throw se;
203         }
204     }
205 
206     public static java.util.List<com.liferay.portal.model.Phone> getPhones(
207         HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
208         throws com.liferay.portal.PortalException,
209             com.liferay.portal.SystemException {
210         try {
211             Object paramObj0 = className;
212 
213             if (className == null) {
214                 paramObj0 = new NullWrapper("java.lang.String");
215             }
216 
217             Object paramObj1 = new LongWrapper(classPK);
218 
219             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
220                     "getPhones", new Object[] { paramObj0, paramObj1 });
221 
222             Object returnObj = null;
223 
224             try {
225                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
226             }
227             catch (Exception e) {
228                 if (e instanceof com.liferay.portal.PortalException) {
229                     throw (com.liferay.portal.PortalException)e;
230                 }
231 
232                 if (e instanceof com.liferay.portal.SystemException) {
233                     throw (com.liferay.portal.SystemException)e;
234                 }
235 
236                 throw new com.liferay.portal.SystemException(e);
237             }
238 
239             return (java.util.List<com.liferay.portal.model.Phone>)returnObj;
240         }
241         catch (com.liferay.portal.SystemException se) {
242             _log.error(se, se);
243 
244             throw se;
245         }
246     }
247 
248     public static com.liferay.portal.model.Phone updatePhone(
249         HttpPrincipal httpPrincipal, long phoneId, java.lang.String number,
250         java.lang.String extension, int typeId, boolean primary)
251         throws com.liferay.portal.PortalException,
252             com.liferay.portal.SystemException {
253         try {
254             Object paramObj0 = new LongWrapper(phoneId);
255 
256             Object paramObj1 = number;
257 
258             if (number == null) {
259                 paramObj1 = new NullWrapper("java.lang.String");
260             }
261 
262             Object paramObj2 = extension;
263 
264             if (extension == null) {
265                 paramObj2 = new NullWrapper("java.lang.String");
266             }
267 
268             Object paramObj3 = new IntegerWrapper(typeId);
269 
270             Object paramObj4 = new BooleanWrapper(primary);
271 
272             MethodWrapper methodWrapper = new MethodWrapper(PhoneServiceUtil.class.getName(),
273                     "updatePhone",
274                     new Object[] {
275                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
276                     });
277 
278             Object returnObj = null;
279 
280             try {
281                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
282             }
283             catch (Exception e) {
284                 if (e instanceof com.liferay.portal.PortalException) {
285                     throw (com.liferay.portal.PortalException)e;
286                 }
287 
288                 if (e instanceof com.liferay.portal.SystemException) {
289                     throw (com.liferay.portal.SystemException)e;
290                 }
291 
292                 throw new com.liferay.portal.SystemException(e);
293             }
294 
295             return (com.liferay.portal.model.Phone)returnObj;
296         }
297         catch (com.liferay.portal.SystemException se) {
298             _log.error(se, se);
299 
300             throw se;
301         }
302     }
303 
304     private static Log _log = LogFactoryUtil.getLog(PhoneServiceHttp.class);
305 }