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