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